lock
This commit is contained in:
@@ -91,15 +91,18 @@ class SendWechatTemp implements Consumer
|
|||||||
Log::info('模版消息用户列表' . json_encode($user_list));
|
Log::info('模版消息用户列表' . json_encode($user_list));
|
||||||
if($user_list) {
|
if($user_list) {
|
||||||
foreach ($user_list as $k => $user) {
|
foreach ($user_list as $k => $user) {
|
||||||
|
// 发送模版消息(公众号和小程序都发送)
|
||||||
if(!empty($user['wechat_ac_open_id'])) {
|
if(!empty($user['wechat_ac_open_id'])) {
|
||||||
$config = [
|
$config = [
|
||||||
'app_id' => config('cons.app_id'),
|
'app_id' => config('cons.app_id'),
|
||||||
'secret' => config('cons.secret'),
|
'secret' => config('cons.secret'),
|
||||||
'response_type' => 'array',
|
'response_type' => 'array',
|
||||||
];
|
];
|
||||||
$app = Factory::officialAccount($config);
|
// 公众号存放 AccessToken
|
||||||
$acc_token = Redis::get('wx:ac:AccessToken');
|
$acc_token = Redis::get('wx:ac:AccessToken');
|
||||||
if($acc_token) {
|
// 公众号发送模版消息通知
|
||||||
|
$app = Factory::officialAccount($config);
|
||||||
|
if ($acc_token) {
|
||||||
$app['access_token']->setToken($acc_token);
|
$app['access_token']->setToken($acc_token);
|
||||||
}
|
}
|
||||||
$wechat_res = $app->template_message->send([
|
$wechat_res = $app->template_message->send([
|
||||||
@@ -116,16 +119,53 @@ class SendWechatTemp implements Consumer
|
|||||||
'thing16' => $record['address'],
|
'thing16' => $record['address'],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
Log::info('公众号模版发送结果' . json_encode($wechat_res));
|
||||||
|
}else {
|
||||||
|
Log::info('用户' . $user['u_user_id'] . 'wechat_ac_open_id为空。不发送');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($user['wechat_open_id'])) {
|
||||||
|
$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($acc_token);
|
||||||
|
}
|
||||||
|
// 小程序发送模版消息通知
|
||||||
|
$mini_wechat_res = $mini_app->subscribe_message->send([
|
||||||
|
'template_id' => 'JGPAGmqcPEgWB6mvAl0SC5cMqr5H5Qjcim8JCpHAZd0',
|
||||||
|
'touser' => $user['wechat_open_id'],
|
||||||
|
'page' => 'pages/index/index',
|
||||||
|
'data' => [
|
||||||
|
'thing1' => [
|
||||||
|
'value' => $record['shop_name'],
|
||||||
|
],
|
||||||
|
'thing2' => [
|
||||||
|
'value' => $record['activity_detail'],
|
||||||
|
],
|
||||||
|
'time3' => [
|
||||||
|
'value' => $record['activity_time'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
Log::info('小程序订阅消息发送结果' . json_encode($mini_wechat_res));
|
||||||
|
}else {
|
||||||
|
Log::info('用户' . $user['u_user_id'] . 'wechat_open_id为空。不发送');
|
||||||
|
}
|
||||||
|
if(!empty($user['wechat_open_id']) || !empty($user['wechat_ac_open_id'])) {
|
||||||
Db::table('ac_push_event')->where(['id' => $record['id']])->update([
|
Db::table('ac_push_event')->where(['id' => $record['id']])->update([
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'update_time' => date('Y-m-d H:i:s'),
|
'update_time' => date('Y-m-d H:i:s'),
|
||||||
'send_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') {
|
if((isset($wechat_res) && $wechat_res['errcode'] == 0 && $wechat_res['errmsg'] == 'ok') || (isset($mini_wechat_res) && $mini_wechat_res['errcode'] == 0 && $mini_wechat_res['errmsg'] == 'ok')) {
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
Log::info('OKKKKK了');
|
|
||||||
Db::table('sms_push_event_record')->insert([
|
Db::table('sms_push_event_record')->insert([
|
||||||
'type' => 'ac',
|
'type' => 'ac',
|
||||||
'shop_id' => $record['shop_id'],
|
'shop_id' => $record['shop_id'],
|
||||||
@@ -144,10 +184,6 @@ class SendWechatTemp implements Consumer
|
|||||||
]);
|
]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
Log::info('用户' . $user['u_user_id'] . 'open_id 为空。不发送');
|
|
||||||
}
|
|
||||||
sleep(1);
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
Log::info('【发送营销短信】无目标用户---》' . $record['user_id']);
|
Log::info('【发送营销短信】无目标用户---》' . $record['user_id']);
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'app_id' => 'wx1fb600d0f5ea6279', // 银收客czg
|
'app_id' => 'wx1fb600d0f5ea6279', // 银收客czg 公众号
|
||||||
'secret' => 'b4c0534c9b5e6c84a7fe5c2078dff876',
|
'secret' => 'b4c0534c9b5e6c84a7fe5c2078dff876', // 银收客czg 公众号
|
||||||
|
|
||||||
|
'mini_app_id' => 'wxd88fffa983758a30', // 零点八零
|
||||||
|
'mini_secret' => 'a34a61adc0602118b49400baa8812454', // 零点八零
|
||||||
|
|
||||||
'sms_price' => 0.055, // 短信发送价格
|
'sms_price' => 0.055, // 短信发送价格
|
||||||
'alibaba_sms' => [
|
'alibaba_sms' => [
|
||||||
'access_key_id' => 'LTAI5t9Wn4qu9UFcvy5LUH4y',
|
'access_key_id' => 'LTAI5t9Wn4qu9UFcvy5LUH4y',
|
||||||
|
|||||||
Reference in New Issue
Block a user