进一步完成
This commit is contained in:
@@ -17,9 +17,53 @@ class BirthdayGiftSms implements Consumer
|
||||
public function consume($data)
|
||||
{
|
||||
Log::info('消息队列【生日有礼】接收到消息' . $data);
|
||||
if($data) {
|
||||
$record = Db::table('mk_birthday_gift_record')->where(['id' => $data])->find();
|
||||
if($record) {
|
||||
// 待发送
|
||||
if($record['push_status'] == 'wait_push') {
|
||||
$user = Db::table('tb_shop_user')->where(['id' => $record['user_id']])->find();
|
||||
if($user && !empty($user['phone'])) {
|
||||
// 检测余额
|
||||
$shop_money = Db::table('sms_shop_money')->where(['shop_id' => $record['main_shop_id']])->find();
|
||||
if($shop_money) {
|
||||
// 余额计算
|
||||
if($shop_money['money'] > config('cons.sms_price')) {
|
||||
$data = [
|
||||
'templateCode' => $record['template_code'],
|
||||
'templateParam' => $record['template_content'],
|
||||
'phoneNumbers' => $user['phone'],
|
||||
'signName' => config('cons.sms_sign'),
|
||||
];
|
||||
$res = AlibabaSms::main($data);
|
||||
if($res['Code'] == 'OK') {
|
||||
Db::table('mk_birthday_gift_record')->where(['id' => $record['id']])->update([
|
||||
'push_status' => 'await_push',
|
||||
'biz_id' => $res['BizId'],
|
||||
'push_time' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}else {
|
||||
Db::table('mk_birthday_gift_record')->where(['id' => $record['id']])->update([
|
||||
'push_status' => 'failed',
|
||||
'push_time' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}else {
|
||||
Log::info('商户【' . $record['main_shop_id'] . '】余额不足');
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
Log::info('商户【' . $record['main_shop_id'] . '】余额为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}else {
|
||||
Log::info('【生日有礼】时查询用户不存在---》' . $record['user_id']);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
Log::info('生日有礼记录未查询到');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user