From cdb4ebdaca0949ae4e504838619ae3269dcb0bdf Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Tue, 14 Jun 2022 11:11:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=91=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/listener/notice/Notice.php | 193 ++++++--------------------- 1 file changed, 40 insertions(+), 153 deletions(-) diff --git a/crmeb/app/listener/notice/Notice.php b/crmeb/app/listener/notice/Notice.php index c38017392..1de2dd28d 100644 --- a/crmeb/app/listener/notice/Notice.php +++ b/crmeb/app/listener/notice/Notice.php @@ -56,7 +56,6 @@ class Notice implements ListenerInterface /** @var UserServices $UserServices */ $UserServices = app()->make(UserServices::class); - $userType = 'wechat'; if ($mark) { $WechatTemplateList->setEvent($mark); $SystemMsg->setEvent($mark); @@ -67,19 +66,13 @@ class Notice implements ListenerInterface //绑定推广关系 case 'bind_spread_uid': if (isset($data['spreadUid']) && $data['spreadUid']) { - $userType = strtolower($data['user_type'] ?? ''); $name = $data['nickname'] ?? ''; //站内信 $SystemMsg->sendMsg($data['spreadUid'], ['nickname' => $name]); - $userType = $UserServices->value(['uid' => $data['spreadUid']], 'user_type'); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendBindSpreadUidSuccess($data['spreadUid'], $name); - } + $WechatTemplateList->sendBindSpreadUidSuccess($data['spreadUid'], $name); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendBindSpreadUidSuccess($data['spreadUid'], $name); - } + $RoutineTemplateList->sendBindSpreadUidSuccess($data['spreadUid'], $name); } break; //支付成功给用户 @@ -90,18 +83,12 @@ class Notice implements ListenerInterface $NoticeSms->sendSms($data['user_phone'], compact('order_id', 'pay_price'), 'PAY_SUCCESS_CODE'); $data['is_channel'] = $data['is_channel'] ?? 2; $data['total_num'] = $data['total_num'] ?? 1; - if (in_array($data['is_channel'], [0, 2])) $userType = 'wechat'; - if (in_array($data['is_channel'], [1, 2])) $userType = 'routine'; //站内信 $SystemMsg->sendMsg($data['uid'], ['order_id' => $data['order_id'], 'total_num' => $data['total_num'], 'pay_price' => $data['pay_price']]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPaySuccess($data['uid'], $data); - } + $WechatTemplateList->sendOrderPaySuccess($data['uid'], $data); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderSuccess($data['uid'], $data['pay_price'], $data['order_id']); - } + $RoutineTemplateList->sendOrderSuccess($data['uid'], $data['pay_price'], $data['order_id']); //小票打印 if (isset($data['cart_id']) && $data['cart_id']) { $NoticeService->orderPrint($data); @@ -120,19 +107,13 @@ class Notice implements ListenerInterface $NoticeSms->sendSms($orderInfo->user_phone, compact('order_id', 'store_name', 'nickname'), 'DELIVER_GOODS_CODE'); //小程序公众号消息 $storeTitle = Str::substrUTf8($storeTitle, 20, 'UTF-8', ''); - if (in_array($orderInfo->is_channel, [0, 2])) $userType = 'wechat'; - if (in_array($orderInfo->is_channel, [1, 2])) $userType = 'routine'; $isGive = 0; //站内信 $SystemMsg->sendMsg($orderInfo['uid'], ['nickname' => $nickname, 'store_name' => $storeTitle, 'order_id' => $orderInfo['order_id'], 'delivery_name' => $orderInfo['delivery_name'], 'delivery_id' => $orderInfo['delivery_id'], 'user_address' => $orderInfo['user_address']]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderDeliver($orderInfo['uid'], $storeTitle, $orderInfo->toArray(), $datas); - } + $WechatTemplateList->sendOrderDeliver($orderInfo['uid'], $storeTitle, $orderInfo->toArray(), $datas); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo->toArray(), $storeTitle, $isGive); - } + $RoutineTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo->toArray(), $storeTitle, $isGive); break; //发货快递给用户 case 'order_postage_success': @@ -146,20 +127,14 @@ class Notice implements ListenerInterface $store_name = $storeTitle; $NoticeSms->sendSms($orderInfo->user_phone, compact('order_id', 'store_name', 'nickname'), 'DELIVER_GOODS_CODE'); $storeTitle = Str::substrUTf8($storeTitle, 20, 'UTF-8', ''); - if (in_array($orderInfo->is_channel, [0, 2])) $userType = 'wechat'; - if (in_array($orderInfo->is_channel, [1, 2])) $userType = 'routine'; $isGive = 1; //站内信 $smsdata = ['nickname' => $nickname, 'store_name' => $storeTitle, 'order_id' => $orderInfo['order_id'], 'delivery_name' => $orderInfo['delivery_name'], 'delivery_id' => $orderInfo['delivery_id'], 'user_address' => $orderInfo['user_address']]; $SystemMsg->sendMsg($orderInfo['uid'], $smsdata); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo->toArray(), $datas); - } + $WechatTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo->toArray(), $datas); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo->toArray(), $storeTitle, $isGive); - } + $RoutineTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo->toArray(), $storeTitle, $isGive); break; //确认收货给用户 case 'order_take': @@ -169,18 +144,12 @@ class Notice implements ListenerInterface $store_name = $storeTitle; $order_id = $order['order_id']; $NoticeSms->sendSms($order['user_phone'], compact('store_name', 'order_id'), 'TAKE_DELIVERY_CODE'); - if (in_array($order['is_channel'], [0, 2])) $userType = 'wechat'; - if (in_array($order['is_channel'], [1, 2])) $userType = 'routine'; //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'store_name' => $storeTitle]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderTakeSuccess($order['uid'], $order, $storeTitle); - } + $WechatTemplateList->sendOrderTakeSuccess($order['uid'], $order, $storeTitle); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderTakeOver($order['uid'], $order, $storeTitle); - } + $RoutineTemplateList->sendOrderTakeOver($order['uid'], $order, $storeTitle); break; //改价给用户 case 'price_revision': @@ -190,46 +159,32 @@ class Notice implements ListenerInterface $NoticeSms->sendSms($order['user_phone'], ['order_id' => $order['order_id'], 'pay_price' => $pay_price], 'PRICE_REVISION_CODE'); //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $pay_price]); - if ($userType == 'wechat') { - $WechatTemplateList->sendPriceRevision($order['uid'], $order); - } + $WechatTemplateList->sendPriceRevision($order['uid'], $order); break; //退款成功 case 'order_refund': $datas = $data['data']; $order = $data['order']; - if (in_array($order->is_channel, [0, 2])) $userType = 'wechat'; - if (in_array($order->is_channel, [1, 2])) $userType = 'routine'; $storeName = $orderInfoServices->getCarIdByProductTitle($order['id'], $order['cart_id']); $storeTitle = Str::substrUTf8($storeName, 20, 'UTF-8', ''); //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $order['pay_price'], 'refund_price' => $datas['refund_price']]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderRefundSuccess($order['uid'], $datas, $order); - } + $WechatTemplateList->sendOrderRefundSuccess($order['uid'], $datas, $order); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderRefundSuccess($order['uid'], $order, $storeTitle, $datas); - } + $RoutineTemplateList->sendOrderRefundSuccess($order['uid'], $order, $storeTitle, $datas); break; //退款未通过 case 'send_order_refund_no_status': $order = $data['orderInfo']; $order['pay_price'] = $order['refund_price']; - if (in_array($order->is_channel, [0, 2])) $userType = 'wechat'; - if (in_array($order->is_channel, [1, 2])) $userType = 'routine'; $storeTitle = Str::substrUTf8($order['cart_info'][0]['productInfo']['store_name'], 20, 'UTF-8', ''); //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $order['refund_price'], 'store_name' => $storeTitle]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderRefundNoStatus($order['uid'], $order); - } + $WechatTemplateList->sendOrderRefundNoStatus($order['uid'], $order); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderRefundFail($order['uid'], $order, $storeTitle); - } + $RoutineTemplateList->sendOrderRefundFail($order['uid'], $order, $storeTitle); break; //充值余额 case 'recharge_success': @@ -238,30 +193,21 @@ class Notice implements ListenerInterface //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'price' => $order['price'], 'now_money' => $now_money]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendRechargeSuccess($order['uid'], $order); - } + $WechatTemplateList->sendRechargeSuccess($order['uid'], $order); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendRechargeSuccess($order['uid'], $order, $now_money); - } + $RoutineTemplateList->sendRechargeSuccess($order['uid'], $order, $now_money); break; //充值退款 case 'recharge_order_refund_status': - $userType = $data['user_type']; $datas = $data['data']; $UserRecharge = $data['UserRecharge']; $now_money = $data['now_money']; //站内信 $SystemMsg->sendMsg($UserRecharge['uid'], ['refund_price' => $datas['refund_price'], 'order_id' => $UserRecharge['order_id'], 'price' => $UserRecharge['price']]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendRechargeRefundStatus($UserRecharge['uid'], $datas, $UserRecharge); - } + $WechatTemplateList->sendRechargeRefundStatus($UserRecharge['uid'], $datas, $UserRecharge); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendRechargeSuccess($UserRecharge['uid'], $UserRecharge, $now_money); - } + $RoutineTemplateList->sendRechargeSuccess($UserRecharge['uid'], $UserRecharge, $now_money); break; //积分 case 'integral_accout': @@ -269,13 +215,9 @@ class Notice implements ListenerInterface //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'store_name' => $data['storeTitle'], 'pay_price' => $order['pay_price'], 'gain_integral' => $data['give_integral'], 'integral' => $data['integral']]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendUserIntegral($order['uid'], $order); - } + $WechatTemplateList->sendUserIntegral($order['uid'], $order); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendUserIntegral($order['uid'], $data['order'], $data['storeTitle'], $data['give_integral'], $data['integral']); - } + $RoutineTemplateList->sendUserIntegral($order['uid'], $data['order'], $data['storeTitle'], $data['give_integral'], $data['integral']); break; //佣金 case 'order_brokerage': @@ -283,18 +225,13 @@ class Notice implements ListenerInterface $goodsName = $data['goodsName']; $goodsPrice = $data['goodsPrice']; $add_time = $data['add_time']; - $userType = $data['userType']; $spread_uid = $data['spread_uid']; //站内信 $SystemMsg->sendMsg($spread_uid, ['goods_name' => $goodsName, 'goods_price' => $goodsPrice, 'brokerage_price' => $brokeragePrice]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderBrokerageSuccess($spread_uid, $brokeragePrice, $goodsName, $goodsPrice, $add_time); - } + $WechatTemplateList->sendOrderBrokerageSuccess($spread_uid, $brokeragePrice, $goodsName, $goodsPrice, $add_time); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendOrderBrokerageSuccess($spread_uid, $brokeragePrice, $goodsName); - } + $RoutineTemplateList->sendOrderBrokerageSuccess($spread_uid, $brokeragePrice, $goodsName); break; //砍价成功 case 'bargain_success': @@ -304,68 +241,43 @@ class Notice implements ListenerInterface //站内信 $SystemMsg->sendMsg($uid, ['title' => $bargainInfo['title'], 'min_price' => $bargainInfo['min_price']]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendBargainSuccess($uid, $bargainInfo, $bargainUserInfo, $uid); - } + $WechatTemplateList->sendBargainSuccess($uid, $bargainInfo, $bargainUserInfo, $uid); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendBargainSuccess($uid, $bargainInfo, $bargainUserInfo, $uid); - } + $RoutineTemplateList->sendBargainSuccess($uid, $bargainInfo, $bargainUserInfo, $uid); break; //拼团成功 case 'order_user_groups_success': $list = $data['list']; $title = $data['title']; - $user_type = $data['user_type']; - if (in_array($user_type, [0, 2])) $userType = 'wechat'; - if (in_array($user_type, [1, 2])) $userType = 'routine'; $url = '/pages/users/order_details/index?order_id=' . $list['order_id']; //站内信 $SystemMsg->sendMsg($list['uid'], ['title' => $title, 'nickname' => $list['nickname'], 'count' => $list['people'], 'pink_time' => date('Y-m-d H:i:s', $list['add_time'])]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPinkSuccess($list['uid'], $list['order_id'], $list['id'], $title); - } + $WechatTemplateList->sendOrderPinkSuccess($list['uid'], $list['order_id'], $list['id'], $title); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendPinkSuccess($list['uid'], $title, $list['nickname'], $list['add_time'], $list['people'], $url); - } + $RoutineTemplateList->sendPinkSuccess($list['uid'], $title, $list['nickname'], $list['add_time'], $list['people'], $url); break; //取消拼团 case 'send_order_pink_clone': $uid = $data['uid']; $pink = $data['pink']; - $user_type = $data['user_type']; - if (in_array($user_type, [0, 2])) $userType = 'wechat'; - if (in_array($user_type, [1, 2])) $userType = 'routine'; //站内信 $SystemMsg->sendMsg($uid, ['title' => $pink->title, 'count' => $pink->people]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPinkClone($uid, $pink, $pink->title); - } + $WechatTemplateList->sendOrderPinkClone($uid, $pink, $pink->title); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendPinkFail($uid, $pink->title, $pink->people, '亲,您的拼团取消,点击查看订单详情', '/pages/order_details/index?order_id=' . $pink->order_id); - } + $RoutineTemplateList->sendPinkFail($uid, $pink->title, $pink->people, '亲,您的拼团取消,点击查看订单详情', '/pages/order_details/index?order_id=' . $pink->order_id); break; //拼团失败 case 'send_order_pink_fial': $uid = $data['uid']; $pink = $data['pink']; - $user_type = $data['user_type']; - if (in_array($user_type, [0, 2])) $userType = 'wechat'; - if (in_array($user_type, [1, 2])) $userType = 'routine'; //站内信 $SystemMsg->sendMsg($uid, ['title' => $pink->title, 'count' => $pink->people]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPinkFial($uid, $pink, $pink->title); - } + $WechatTemplateList->sendOrderPinkFial($uid, $pink, $pink->title); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendPinkFail($uid, $pink->title, $pink->people, '亲,您拼团失败,自动为您申请退款,退款金额为:' . $pink->price, '/pages/order_details/index?order_id=' . $pink->order_id); - } + $RoutineTemplateList->sendPinkFail($uid, $pink->title, $pink->people, '亲,您拼团失败,自动为您申请退款,退款金额为:' . $pink->price, '/pages/order_details/index?order_id=' . $pink->order_id); break; //参团成功 case 'can_pink_success': @@ -375,17 +287,10 @@ class Notice implements ListenerInterface $nickname = $UserServices->value(['uid' => $orderInfo['uid']], 'nickname'); //站内信 $SystemMsg->sendMsg($orderInfo['uid'], ['title' => $title, 'nickname' => $nickname, 'count' => $pink['people'], 'pink_time' => date('Y-m-d H:i:s', $pink['add_time'])]); - if (in_array($orderInfo['is_channel'], [0, 2])) $userType = 'wechat'; - if (in_array($orderInfo['is_channel'], [1, 2])) $userType = 'routine'; - //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPinkUseSuccess($orderInfo['uid'], $orderInfo['order_id'], $title, $orderInfo['pink_id']); - } + $WechatTemplateList->sendOrderPinkUseSuccess($orderInfo['uid'], $orderInfo['order_id'], $title, $orderInfo['pink_id']); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendPinkSuccess($orderInfo['uid'], $title, $nickname, $pink['add_time'], $pink['people'], '/pages/users/order_details/index?order_id=' . $pink['order_id']); - } + $RoutineTemplateList->sendPinkSuccess($orderInfo['uid'], $title, $nickname, $pink['add_time'], $pink['people'], '/pages/users/order_details/index?order_id=' . $pink['order_id']); break; //开团成功 case 'open_pink_success': @@ -395,37 +300,25 @@ class Notice implements ListenerInterface $nickname = $UserServices->value(['uid' => $orderInfo['uid']], 'nickname'); //站内信 $SystemMsg->sendMsg($orderInfo['uid'], ['title' => $title, 'nickname' => $nickname, 'count' => $pink['people'], 'pink_time' => date('Y-m-d H:i:s', $pink['add_time'])]); - if (in_array($orderInfo['is_channel'], [0, 2])) $userType = 'wechat'; - if (in_array($orderInfo['is_channel'], [1, 2])) $userType = 'routine'; //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPinkOpenSuccess($orderInfo['uid'], $pink, $title); - } + $WechatTemplateList->sendOrderPinkOpenSuccess($orderInfo['uid'], $pink, $title); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendPinkSuccess($orderInfo['uid'], $title, $nickname, $pink['add_time'], $pink['people'], '/pages/users/order_details/index?order_id=' . $pink['order_id']); - } + $RoutineTemplateList->sendPinkSuccess($orderInfo['uid'], $title, $nickname, $pink['add_time'], $pink['people'], '/pages/users/order_details/index?order_id=' . $pink['order_id']); break; //提现成功 case 'user_extract': - $userType = $data['userType']; $extractNumber = $data['extractNumber']; $nickname = $data['nickname']; $uid = $data['uid']; //站内信 $SystemMsg->sendMsg($uid, ['extract_number' => $extractNumber, 'nickname' => $nickname, 'date' => date('Y-m-d H:i:s', time())]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendUserExtract($uid, $extractNumber); - } + $WechatTemplateList->sendUserExtract($uid, $extractNumber); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendExtractSuccess($uid, $extractNumber, $nickname); - } + $RoutineTemplateList->sendExtractSuccess($uid, $extractNumber, $nickname); break; //提现失败 case 'user_balance_change': - $userType = $data['userType']; $extract_number = $data['extract_number']; $message = $data['message']; $uid = $data['uid']; @@ -433,13 +326,9 @@ class Notice implements ListenerInterface //站内信 $SystemMsg->sendMsg($uid, ['extract_number' => $extract_number, 'nickname' => $nickname, 'date' => date('Y-m-d H:i:s', time()), 'message' => $message]); //模板消息公众号模版消息 - if ($userType == 'wechat') { - $WechatTemplateList->sendExtractFail($uid, $extract_number, $message); - } + $WechatTemplateList->sendExtractFail($uid, $extract_number, $message); //模板消息小程序订阅消息 - if ($userType == 'routine') { - $RoutineTemplateList->sendExtractFail($uid, $message, $extract_number, $nickname); - } + $RoutineTemplateList->sendExtractFail($uid, $message, $extract_number, $nickname); break; //提醒付款给用户 case 'order_pay_false': @@ -449,9 +338,7 @@ class Notice implements ListenerInterface $NoticeSms->sendSms($order['user_phone'], compact('order_id'), 'ORDER_PAY_FALSE'); //站内信 $SystemMsg->sendMsg($order['uid'], ['order_id' => $order_id]); - if ($userType == 'wechat') { - $WechatTemplateList->sendOrderPayFalse($order['uid'], $order); - } + $WechatTemplateList->sendOrderPayFalse($order['uid'], $order); break; //申请退款给客服发消息 case 'send_order_apply_refund':