user_id 保存
This commit is contained in:
parent
5542963183
commit
1ddef4432a
|
|
@ -100,7 +100,7 @@ class SendMarkSms implements Consumer
|
|||
Db::table('sms_push_event_record')->insert([
|
||||
'shop_id' => $record['shop_id'],
|
||||
'event_id' => $record['id'],
|
||||
'user_id' => $v['user_id'],
|
||||
'user_id' => $v['u_user_id'],
|
||||
'type' => 'sms',
|
||||
'user_phone' => $v['phone'],
|
||||
'biz_id' => $res['BizId'],
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class SendWechatTemp implements Consumer
|
|||
if($k_user_params) {
|
||||
$user_list = ShopInfo::getUserList($k_user_params);
|
||||
if(!$user_list) {
|
||||
Log::info('范围用户列表为空');
|
||||
return false;
|
||||
}
|
||||
foreach ($user_list as $k => &$v) {
|
||||
|
|
@ -89,56 +90,60 @@ class SendWechatTemp implements Consumer
|
|||
Log::info('模版消息用户列表' . json_encode($user_list));
|
||||
if($user_list) {
|
||||
foreach ($user_list as $k => $user) {
|
||||
$config = [
|
||||
'app_id' => config('cons.app_id'),
|
||||
'secret' => config('cons.secret'),
|
||||
'response_type' => 'array',
|
||||
];
|
||||
$app = Factory::officialAccount($config);
|
||||
$acc_token = Redis::get('wx:ac:AccessToken');
|
||||
if($acc_token) {
|
||||
$app['access_token']->setToken($acc_token);
|
||||
}
|
||||
$wechat_res = $app->template_message->send([
|
||||
'touser' => $user['wechat_ac_open_id'],
|
||||
'template_id' => 'hGsUGZlWqWC9TMm4ZGZuz0OwE4gwSmvgbr5ecmTDvq4',
|
||||
'miniprogram' => [
|
||||
'appid' => 'wxd88fffa983758a30', // 零点八零
|
||||
],
|
||||
'data' => [
|
||||
'thing7' => $record['shop_name'],
|
||||
'thing14' => $record['activity_detail'],
|
||||
'time3' => $record['activity_time'],
|
||||
'thing16' => $record['address'],
|
||||
],
|
||||
]);
|
||||
|
||||
Db::startTrans();
|
||||
Db::table('ac_push_event')->where(['id' => $record['id']])->update([
|
||||
'status' => 1,
|
||||
'update_time' => date('Y-m-d H:i:s'),
|
||||
'send_time' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
Log::info('模版发送结果' . json_encode($wechat_res));
|
||||
if($wechat_res['errcode'] == 0 && $wechat_res['errmsg'] == 'ok') {
|
||||
Log::info('OKKKKK了');
|
||||
Db::table('sms_push_event_record')->insert([
|
||||
'shop_id' => $record['shop_id'],
|
||||
'event_id' => $record['id'],
|
||||
'user_id' => $user['id'],
|
||||
'user_phone' => $user['phone'],
|
||||
'biz_id' => '',
|
||||
'send_time' => date('Y-m-d H:i:s'),
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'status' => 2,
|
||||
if(!empty($user['wechat_ac_open_id'])) {
|
||||
$config = [
|
||||
'app_id' => config('cons.app_id'),
|
||||
'secret' => config('cons.secret'),
|
||||
'response_type' => 'array',
|
||||
];
|
||||
$app = Factory::officialAccount($config);
|
||||
$acc_token = Redis::get('wx:ac:AccessToken');
|
||||
if($acc_token) {
|
||||
$app['access_token']->setToken($acc_token);
|
||||
}
|
||||
$wechat_res = $app->template_message->send([
|
||||
'touser' => $user['wechat_ac_open_id'],
|
||||
'template_id' => 'hGsUGZlWqWC9TMm4ZGZuz0OwE4gwSmvgbr5ecmTDvq4',
|
||||
'miniprogram' => [
|
||||
'appid' => 'wxd88fffa983758a30', // 零点八零
|
||||
],
|
||||
'data' => [
|
||||
'thing7' => $record['shop_name'],
|
||||
'thing14' => $record['activity_detail'],
|
||||
'time3' => $record['activity_time'],
|
||||
'thing16' => $record['address'],
|
||||
],
|
||||
]);
|
||||
|
||||
Db::startTrans();
|
||||
Db::table('ac_push_event')->where(['id' => $record['id']])->update([
|
||||
'status' => 2,
|
||||
'status' => 1,
|
||||
'update_time' => date('Y-m-d H:i:s'),
|
||||
'send_time' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
Log::info('模版发送结果' . json_encode($wechat_res));
|
||||
if($wechat_res['errcode'] == 0 && $wechat_res['errmsg'] == 'ok') {
|
||||
Log::info('OKKKKK了');
|
||||
Db::table('sms_push_event_record')->insert([
|
||||
'shop_id' => $record['shop_id'],
|
||||
'event_id' => $record['id'],
|
||||
'user_id' => $user['u_user_id'],
|
||||
'user_phone' => $user['phone'],
|
||||
'biz_id' => '',
|
||||
'send_time' => date('Y-m-d H:i:s'),
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'status' => 2,
|
||||
]);
|
||||
Db::table('ac_push_event')->where(['id' => $record['id']])->update([
|
||||
'status' => 2,
|
||||
'update_time' => date('Y-m-d H:i:s'),
|
||||
'send_time' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
Db::commit();
|
||||
}else {
|
||||
Log::info('用户' . $user['u_user_id'] . 'open_id 为空。不发送');
|
||||
}
|
||||
Db::commit();
|
||||
sleep(1);
|
||||
}
|
||||
}else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue