<?php 

namespace crmeb\jobs;

use crmeb\services\WechatService;
use crmeb\basic\BaseJob;
use think\facade\Route;
use think\facade\Log;

/**
 * 统计报表发送队列
 */
class ReportJob extends BaseJob
{
	//业绩查询结果通知
	const REPORT = '2IcjJ4Rfge8dXDUTEl2YHRKW4Bfs2Jad6qYT5AhkyY8';

	public static function sendMerchantMessage($report, $value, $v){
		$firstWeChat = '昨日业绩汇总';
		$keyword1WeChat = $report['report_date'];
		$keyword2WeChat = '昨日订单量：' . $report['today_order'] . '单，昨日销售额：' . $report['today_order_money'] . '元，昨日注册量：' . $report['today_reg'] . '人，昨日访问量：'. $report['today_visit'] . '人';
		$remarkWeChat = '今天会比昨天更加努力，加油！！！';
		$urlWeChat = Route::buildUrl('/bind/report.html?mer_id=' . $v . '&date=' . date('Y-m-d', strtotime('-1day')))->suffix('')->domain(true)->build();
		$res = WechatService::sendTemplate($value, self::REPORT, [
			'first' => $firstWeChat,
			'keyword1' => $keyword1WeChat,
			'keyword2' => $keyword2WeChat,
			'remark' => $remarkWeChat
		], $urlWeChat);
		@file_put_contents('callback.txt', $res . PHP_EOL, FILE_APPEND);
	}
}