拼团
This commit is contained in:
@@ -27,13 +27,15 @@ class SendWechatTemp implements Consumer
|
|||||||
if(is_array($arr)) {
|
if(is_array($arr)) {
|
||||||
$shop_id = $arr[0];
|
$shop_id = $arr[0];
|
||||||
$sms_push_event_id = $arr[1];
|
$sms_push_event_id = $arr[1];
|
||||||
|
$type = $arr[2];
|
||||||
}else {
|
}else {
|
||||||
Log::info('send.wechat.temp数据格式错误');
|
Log::info('send.wechat.temp数据格式错误');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($data) {
|
if($data) {
|
||||||
|
|
||||||
|
if($type == 'sendWechatTemp') {
|
||||||
// 发送任务
|
// 发送任务
|
||||||
// $record = Db::table('sms_push_event')->where(['id' => $sms_push_event_id, 'push_type' => 2])->find();
|
|
||||||
$record = Db::table('ac_push_event')->where(['id' => $sms_push_event_id, 'status' => 0, 'is_del' => 0])->find();
|
$record = Db::table('ac_push_event')->where(['id' => $sms_push_event_id, 'status' => 0, 'is_del' => 0])->find();
|
||||||
if($record) {
|
if($record) {
|
||||||
// 查询是否是定时发送
|
// 查询是否是定时发送
|
||||||
@@ -134,7 +136,7 @@ class SendWechatTemp implements Consumer
|
|||||||
// 小程序存放 AccessToken
|
// 小程序存放 AccessToken
|
||||||
$mini_token = Redis::get('wx:mini:AccessToken');
|
$mini_token = Redis::get('wx:mini:AccessToken');
|
||||||
if($mini_token) {
|
if($mini_token) {
|
||||||
$mini_app['access_token']->setToken($acc_token);
|
$mini_app['access_token']->setToken($mini_token);
|
||||||
}
|
}
|
||||||
// 小程序发送模版消息通知
|
// 小程序发送模版消息通知
|
||||||
$mini_wechat_res = $mini_app->subscribe_message->send([
|
$mini_wechat_res = $mini_app->subscribe_message->send([
|
||||||
@@ -193,10 +195,63 @@ class SendWechatTemp implements Consumer
|
|||||||
}else {
|
}else {
|
||||||
Log::info('发送营销短信未查询到');
|
Log::info('发送营销短信未查询到');
|
||||||
}
|
}
|
||||||
|
}elseif ($type == 'groupBuyYes') {
|
||||||
|
$mini_config = [
|
||||||
|
'app_id' => config('cons.mini_app_id'),
|
||||||
|
'secret' => config('cons.mini_secret'),
|
||||||
|
'response_type' => 'array',
|
||||||
|
];
|
||||||
|
$mini_app = Factory::miniProgram($mini_config);
|
||||||
|
// 小程序存放 AccessToken
|
||||||
|
$mini_token = Redis::get('wx:mini:AccessToken');
|
||||||
|
if($mini_token) {
|
||||||
|
$mini_app['access_token']->setToken($mini_token);
|
||||||
|
}
|
||||||
|
$user_list = Db::name('gb_order_detail')
|
||||||
|
->alias('order_d')
|
||||||
|
->join('tb_user_info ui', 'order_d.user_id = ui.id')
|
||||||
|
->where('order_d.is_del', 0)
|
||||||
|
->where('order_d.status', '<>', '已退款')
|
||||||
|
->field('ui.wechat_open_id,ui.id,ui.phone,ui.id as u_user_id, order_d.create_time')
|
||||||
|
->select();
|
||||||
|
Log::info('需要发送拼团成功订阅消息' . json_encode($user_list));
|
||||||
|
$shop = Db::name('tb_shop_info')->where(['id' => $shop_id])->find();
|
||||||
|
if(!$shop) {
|
||||||
|
Log::info($shop . '店铺消息未找到');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($user_list as $k => $user) {
|
||||||
|
if(!empty($user['wechat_open_id'])) {
|
||||||
|
// 小程序发送模版消息通知
|
||||||
|
$mini_wechat_res = $mini_app->subscribe_message->send([
|
||||||
|
'template_id' => 'F4OyUhe_ZQ9BR731jlkaN2QXAUaA3HBZuUeVPfraSz0',
|
||||||
|
'touser' => $user['wechat_open_id'],
|
||||||
|
'page' => 'pages/index/index',
|
||||||
|
'data' => [
|
||||||
|
'thing1' => [
|
||||||
|
'value' => $shop['shop_name'],
|
||||||
|
],
|
||||||
|
'time3' => [
|
||||||
|
'value' => $user['create_time'],
|
||||||
|
],
|
||||||
|
'thing2' => [
|
||||||
|
'value' => $shop['address'],
|
||||||
|
],
|
||||||
|
'thing4' => [
|
||||||
|
'value' => '订单拼团成功,请至店内扫码核销',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
Log::info('小程序订阅消息发送结果' . $user['u_user_id'] . json_encode($mini_wechat_res));
|
||||||
|
}else {
|
||||||
|
Log::info('用户' . $user['u_user_id'] . 'wechat_open_id 为空不发送小程序订阅消息');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}catch (\Throwable $e) {
|
}catch (\Throwable $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getTraceAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ try {
|
|||||||
}elseif ($type == 'sendMarkSms') {
|
}elseif ($type == 'sendMarkSms') {
|
||||||
// 发给队列 营销短信发送
|
// 发给队列 营销短信发送
|
||||||
Redis::send('send.mark.sms', $data);
|
Redis::send('send.mark.sms', $data);
|
||||||
}elseif ($type == 'sendWechatTemp') {
|
}elseif ($type == 'sendWechatTemp' || $type == 'groupBuyYes') {
|
||||||
// 发给队列 发送微信模版消息
|
// 发给队列 发送微信模版消息 和小程序消息 groupBuyYes为拼团成功通知
|
||||||
Redis::send('send.wechat.temp', $data);
|
Redis::send('send.wechat.temp', $data);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
Reference in New Issue
Block a user