<?php
 
namespace App\Http\Controllers\Queue\Template;
 
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Jobs\SendNews;
use App\Http\Controllers\Controller;
use App\Http\Models\WechatTemplateSendInfo;
use Carbon\Carbon;
use App\Http\Controllers\Wechat\Staff\NewsWorksController;

class AddNewsTasksController extends Controller
{
	public function add_news_task(){
		$data = array();
		$data['openid'] = 'oAcqg1LRHNKN2jaEkJ5v56HOwPEQ';
		$data['appid'] = 'wxdbc486f1b4f6a8c3';
		$data['news_content'] = '[[{"title":"标题啊"},{"description":"描述哦"},{"url":"http://www.baidu.com"},{"image":"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=314110819,2721402218&fm=173&s=91B3C23586024F4D0235ECFB0300C036&w=550&h=550&img.JPEG"}],[{"title":"标题2啊"},{"description":"描述哦"},{"url":"http://www.baidu.com"},{"image":"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=314110819,2721402218&fm=173&s=91B3C23586024F4D0235ECFB0300C036&w=550&h=550&img.JPEG"}]]';
		$data['type'] = 'last_task';// last_task,one_task
		$data['task_id'] = 3;
		$data['send_time'] = date("Y-m-d H:i:s");
		$send_data=array(
			'send_time'=>date("Y-m-d H:i:s"),
			'data' => $data
		);
		
		v('add_news_task_data:');v($send_data);
		$delay = 0;

// 		v('delay:'.$delay);die();
		$job = (new SendNews($send_data))->onConnection('rabbitmq')->delay($delay)->onQueue('send_news_list');
		
		dispatch($job);

	}
	
	public function test_send_news(){
		$data = array();
		$data['openid'] = 'oAcqg1LRHNKN2jaEkJ5v56HOwPEQ';
		$data['appid'] = 'wxdbc486f1b4f6a8c3';
		$data['news_content'] = '[[{"title":"标题啊"},{"description":"描述哦"},{"url":"http://www.baidu.com"},{"image":"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=314110819,2721402218&fm=173&s=91B3C23586024F4D0235ECFB0300C036&w=550&h=550&img.JPEG"}],[{"title":"标题2啊"},{"description":"描述哦"},{"url":"http://www.baidu.com"},{"image":"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=314110819,2721402218&fm=173&s=91B3C23586024F4D0235ECFB0300C036&w=550&h=550&img.JPEG"}]]';
		$data['type'] = 'last_task';// last_task,one_task
		$data['task_id'] = 3;
		$data['send_time'] = date("Y-m-d H:i:s");

		v('test_send_template_data:');v($data);
		$TemplateWork = new NewsWorksController($data);
		$TemplateWork->do_work();
	}

}