From 9e90e73bb9ecc34b2b04ab8ead266c48e0f526e8 Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Thu, 16 Oct 2025 16:57:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E7=89=88=E6=8F=90=E4=BA=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/command/QuerySmsStatus.php | 27 ++++++++++++++------------- app/model/ShopInfo.php | 7 ++++--- app/queue/redis/BirthdayGiftSms.php | 8 +++----- app/queue/redis/SendMarkSms.php | 7 ++++++- config/process.php | 6 +++--- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/app/command/QuerySmsStatus.php b/app/command/QuerySmsStatus.php index a8c2ea4..7d40e5f 100644 --- a/app/command/QuerySmsStatus.php +++ b/app/command/QuerySmsStatus.php @@ -36,45 +36,46 @@ class QuerySmsStatus extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { + $push_resp = ''; // 生日有礼 $bir_list = Db::table('mk_birthday_gift_record')->where(['push_status' => 'await_push'])->select()->toArray(); if($bir_list) { Log::info('生日有礼短信发送状态查询开始->' . json_encode($bir_list)); foreach ($bir_list as $k => $value) { $data = [ - 'PhoneNumber' => $value['phone'], - 'BizId' => $value['biz_id'], - 'SendDate' => date('Ymd'), - 'PageSize' => 1, - 'CurrentPage' => 20, + 'phoneNumber' => $value['phone'], + 'bizId' => $value['biz_id'], + 'sendDate' => date('Ymd'), + 'pageSize' => 10, + 'currentPage' => 1, ]; $res = AlibabaSms::QuerySendDetails($data); try { Db::startTrans(); if($res['Code'] == 'OK') { - $push_resp = $res['ErrCode']; if($res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['SendStatus'] == 3) { $push_status = 'success'; // 扣掉余额 - ShopInfo::moeny(config('cons.sms_price'), $value['main_shop_id'], 2, ); + ShopInfo::moeny(config('cons.sms_price'), $value['main_shop_id'], '生日有礼短信发送,任务ID:' . $value['id'], 2); }elseif ($res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['SendStatus'] == 2) { + $push_resp = $res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['ErrCode']; $push_status = 'failed'; }elseif ($res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['SendStatus'] == 1) { $push_status = 'await_push'; } $update_data = [ - 'status' => $push_status, + 'update_time' => date('Y-m-d H:i:s'), + 'push_status' => $push_status, 'push_resp' => $push_resp, ]; $update_status = Db::table('mk_birthday_gift_record')->where(['id' => $value['id']])->update($update_data); Db::commit(); - Log::info('短信查询完毕数据库更新结果---》[ID]' . $value['id'] . '更新结果-->' . $update_status . '-->更新数据 . ' . json_encode($update_data)); + Log::info('生日有礼短信查询完毕数据库更新结果---》[ID]' . $value['id'] . '更新结果-->' . $update_status . '-->更新数据 . ' . json_encode($update_data)); } }catch (\Exception $e) { Db::rollback(); - Log::info('短信查询错误---》[ID]' . $e->getMessage()); + Log::info('生日有礼短信查询错误---》[ID]' . $e->getMessage()); } - sleep(1); } } @@ -97,12 +98,12 @@ class QuerySmsStatus extends Command try { Db::startTrans(); if($res['Code'] == 'OK') { - $push_resp = $res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['ErrCode']; if($res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['SendStatus'] == 3) { $push_status = 2; // 扣掉余额 - ShopInfo::moeny(config('cons.sms_price'), $value['main_shop_id'], 2); + ShopInfo::moeny(config('cons.sms_price'), $value['main_shop_id'], '营销短信发送,任务ID:' . $value['event_id'], 2); }elseif ($res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['SendStatus'] == 2) { + $push_resp = $res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['ErrCode']; $push_status = -1; }elseif ($res['SmsSendDetailDTOs']['SmsSendDetailDTO'][0]['SendStatus'] == 1) { $push_status = 1; diff --git a/app/model/ShopInfo.php b/app/model/ShopInfo.php index fba01f3..f4ade97 100644 --- a/app/model/ShopInfo.php +++ b/app/model/ShopInfo.php @@ -8,7 +8,7 @@ use support\think\Db; class ShopInfo { - public static function moeny($money, $shop_id, $type = 1) + public static function moeny($money, $shop_id, $reason, $type = 1) { $shop_money = Db::table('sms_shop_money')->where(['shop_id' => $shop_id])->find(); if($shop_money) { @@ -26,6 +26,7 @@ class ShopInfo 'shop_id' => $shop_id, 'type' => $type, 'expense' => $money, + 'reason' => $reason, 'balance' => $befor_money, ]); } @@ -64,7 +65,7 @@ class ShopInfo { $data_arr = self::javaGetUserList($k_user_params, $page, $size); $for_user_list = []; - if($data_arr['code'] == 0) { + if($data_arr['code'] == 200) { $user_list = self::evnuserlist($data_arr['data']['records']); if($data_arr['data']['totalPage'] > 1) { for ($i = 2; $i <= $data_arr['data']['totalPage']; $i++) { @@ -92,7 +93,7 @@ class ShopInfo $push_user[] = [ 'user_id' => $user['id'], 'phone' => $user['phone'], - 'nick_name' => $user['nick_name'], + 'nick_name' => isset($user['nick_name'])?$user['nick_name']:$user['nickName'], ]; } return $push_user; diff --git a/app/queue/redis/BirthdayGiftSms.php b/app/queue/redis/BirthdayGiftSms.php index 17eb991..e29c974 100644 --- a/app/queue/redis/BirthdayGiftSms.php +++ b/app/queue/redis/BirthdayGiftSms.php @@ -22,10 +22,9 @@ class BirthdayGiftSms implements Consumer if($record) { // 待发送 if($record['push_status'] == 'wait_push') { - $user = Db::table('tb_shop_user')->where(['id' => $record['user_id']])->find(); - // 张松 需要加主模版ID - $y_temp = Db::table('sms_shop_template')->where(['id' => $record['push_event_id']])->find(); - if($user && !empty($user['phone'])) { + $user = Db::table('tb_shop_user')->where(['id' => $record['shop_user_id']])->find(); + $y_temp = Db::table('sms_shop_template')->where(['id' => $record['template_id']])->find(); + if($user) { // 检测余额 $shop_money = Db::table('sms_shop_money')->where(['shop_id' => $record['main_shop_id']])->find(); if($shop_money) { @@ -61,7 +60,6 @@ class BirthdayGiftSms implements Consumer Log::info('商户【' . $record['main_shop_id'] . '】余额为空'); return false; } - }else { Log::info('【生日有礼】时查询用户不存在---》' . $record['user_id']); } diff --git a/app/queue/redis/SendMarkSms.php b/app/queue/redis/SendMarkSms.php index ac61b16..58c4672 100644 --- a/app/queue/redis/SendMarkSms.php +++ b/app/queue/redis/SendMarkSms.php @@ -36,7 +36,12 @@ class SendMarkSms implements Consumer // $record = Db::table('sms_push_event')->where(['id' => $sms_push_event_id, 'push_type' => 2])->find(); $record = Db::table('sms_push_event')->where(['id' => $sms_push_event_id])->find(); if($record) { - Log::info('$record'); + + // 查询是否是定时发送 + if($record['send_type'] == 2) { + + } + // 待发送 if($record['status'] == 0) { Log::info('待发送'); diff --git a/config/process.php b/config/process.php index 279bc6b..b3f4d9f 100644 --- a/config/process.php +++ b/config/process.php @@ -61,7 +61,7 @@ return [ ] ] ], - 'MessagePushTask' => [ - 'handler' => MessagePushTask::class, - ] +// 'MessagePushTask' => [ +// 'handler' => MessagePushTask::class, +// ] ];