Commit f233f8d6 authored by jianghaiming's avatar jianghaiming

Merge branch 'jielong' of https://gitlab.yidian-inc.com/bp/goods into jielong

parents c33d7377 e487e748
<?php
namespace Daemon;
use Api\PhpServices\Daemon\DaemonServiceInterface;
use Api\PhpUtils\Log\DaemonLog;
use App\Services\marketing\MarketingService;
use Api\PhpServices\Wechat\Msg;
class Pindan implements DaemonServiceInterface
{
public function run()
{
//只在16:40执行逻辑
if(date('H') != 16 || date('i')!= 40) {
sleep(5);
return false;
}
try{
//查询进行中的拼单活动
$params['marketing_type'] = 4;//1分销 2团购 3秒杀 4团餐
$params['online_status'] = 1;//状态 , 1启用,2关闭,3 到期
$params['activity_status'] = 2;//1 未开始,2进行中,3已结束
$params['page'] = 1;
$params['page_size'] = 1;
$list = MarketingService::marketingList($params);
if(empty($list['result'])) {
return false;
}
//给订阅用户发送消息
//http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=71667995
$app_id = 'wx4e0d92499185fb74';
$template_id = 'LqGgPLdQPh2CHAFN1B8UK7NVc4LQt2zpjOZoyNuwaEI';
$page_url = '/pages/home/index?messageNotify=1';
$type = 2; // 1 公众号 2 小程序
//活动信息
$params = [
$list['result'][0]['marketing_name'],
$list['result'][0]['create_time'],
$list['result'][0]['pindan_desc']
];
//发送消息
Msg::send(999, $app_id, $template_id, $page_url, $type, $params);
sleep(60);//保证16:40只执行一次
}catch (Exception $e) {
DaemonLog::info(
'DaemonServiceInterface_pindan',
'params:'.json_encode($params).' exception:'.$e->getMessage()
);
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment