Notice.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\listener\notice;
  12. use app\jobs\notice\PrintJob;
  13. use app\services\message\SystemMessageServices;
  14. use app\services\order\StoreOrderRefundServices;
  15. use app\services\message\notice\{
  16. NoticeSmsService, RoutineTemplateListService, SystemMsgService, WechatTemplateListService
  17. };
  18. use app\services\message\NoticeService;
  19. use app\services\order\StoreOrderCartInfoServices;
  20. use app\services\user\UserServices;
  21. use crmeb\interfaces\ListenerInterface;
  22. use think\facade\Log;
  23. /**
  24. * 订单创建事件
  25. * Class Create
  26. * @package app\listener\order
  27. */
  28. class Notice implements ListenerInterface
  29. {
  30. /**
  31. * @var string[]
  32. */
  33. protected $userTypeArray = [
  34. '0' => 'wechat',
  35. '1' => 'routine',
  36. '2' => 'wechat',//收银订单 weixinh5
  37. '3' => 'wechat',//pc
  38. ];
  39. public function handle($event): void
  40. {
  41. try {
  42. [$data, $mark] = $event;
  43. /** @var NoticeService $NoticeService */
  44. $NoticeService = app()->make(NoticeService::class);
  45. /** @var WechatTemplateListService $WechatTemplateList */
  46. $WechatTemplateList = app()->make(WechatTemplateListService::class);
  47. /** @var RoutineTemplateListService $RoutineTemplateList */
  48. $RoutineTemplateList = app()->make(RoutineTemplateListService::class);
  49. /** @var SystemMsgService $SystemMsg */
  50. $SystemMsg = app()->make(SystemMsgService::class);
  51. /** @var NoticeSmsService $NoticeSms */
  52. $NoticeSms = app()->make(NoticeSmsService::class);
  53. /** @var StoreOrderCartInfoServices $orderInfoServices */
  54. $orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
  55. /** @var UserServices $UserServices */
  56. $UserServices = app()->make(UserServices::class);
  57. /** @var SystemMessageServices $SystemMessageServices */
  58. $SystemMessageServices = app()->make(SystemMessageServices::class);
  59. if ($mark) {
  60. $WechatTemplateList->setEvent($mark);
  61. $SystemMsg->setEvent($mark);
  62. $NoticeSms->setEvent($mark);
  63. $RoutineTemplateList->setEvent($mark);
  64. $NoticeService->setEvent($mark);
  65. switch ($mark) {
  66. //绑定推广关系
  67. case 'bind_spread_uid':
  68. if (isset($data['spreadUid']) && $data['spreadUid']) {
  69. $name = $data['nickname'] ?? '';
  70. //站内信
  71. $SystemMsg->sendMsg($data['spreadUid'], ['nickname' => $name]);
  72. //模板消息小程序订阅消息
  73. $RoutineTemplateList->sendBindSpreadUidSuccess($data['spreadUid'], $name);
  74. }
  75. break;
  76. //支付成功给用户
  77. case 'order_pay_success':
  78. $pay_price = $data['pay_price'] ?? 0.00;
  79. $order_id = $data['order_id'] ?? '';
  80. //小票打印 排除付费会员订单
  81. if (isset($data['cart_id']) && $data['cart_id']) {
  82. PrintJob::dispatch([(int)$data['id']]);
  83. }
  84. //短信
  85. $NoticeSms->sendSms($data['user_phone'], compact('order_id', 'pay_price'), 'PAY_SUCCESS_CODE');
  86. $data['total_num'] = isset($data['total_num']) ? $data['total_num'] : 1;
  87. //站内信
  88. $SystemMsg->sendMsg($data['uid'], ['order_id' => $data['order_id'], 'total_num' => $data['total_num'], 'pay_price' => $data['pay_price']]);
  89. $link = '/pages/goods/order_details/index?order_id=' . $order_id;
  90. if (isset($data['is_vip_order']) && $data['is_vip_order'] == 1) {
  91. $link = '/pages/annex/vip_paid/index';
  92. }
  93. //模板消息公众号模版消息
  94. $WechatTemplateList->sendOrderPaySuccess($data['uid'], $data, $link);
  95. //模板消息小程序订阅消息
  96. $RoutineTemplateList->sendOrderSuccess($data['uid'], $pay_price, $data['order_id']);
  97. break;
  98. //发货给用户
  99. case 'order_fictitious_success':
  100. $orderInfo = $data['orderInfo'];
  101. $store_name = $data['storeName'];
  102. $datas = $data['data'];
  103. $service = app()->make(UserServices::class);
  104. $nickname = $service->value(['uid' => $orderInfo['uid']], 'nickname');
  105. //短信
  106. $order_id = $orderInfo['order_id'];
  107. $NoticeSms->sendSms($orderInfo['user_phone'], compact('order_id', 'store_name', 'nickname'), 'DELIVER_GOODS_CODE');
  108. //站内信
  109. $SystemMsg->sendMsg($orderInfo['uid'], ['nickname' => $nickname, 'store_name' => $store_name, 'order_id' => $orderInfo['order_id'], 'delivery_name' => $datas['delivery_name'] ?? '', 'delivery_id' => $datas['delivery_id'] ?? '', 'user_address' => $orderInfo['user_address']]);
  110. break;
  111. //发货给用户
  112. case 'order_deliver_success':
  113. $orderInfo = $data['orderInfo'];
  114. $store_name = $data['storeName'];
  115. $datas = $data['data'];
  116. $service = app()->make(UserServices::class);
  117. $nickname = $service->value(['uid' => $orderInfo['uid']], 'nickname');
  118. //短信
  119. $order_id = $orderInfo['order_id'];
  120. $NoticeSms->sendSms($orderInfo['user_phone'], compact('order_id', 'store_name', 'nickname'), 'DELIVER_GOODS_CODE');
  121. $isGive = 0;
  122. //站内信
  123. $SystemMsg->sendMsg($orderInfo['uid'], ['nickname' => $nickname, 'store_name' => $store_name, 'order_id' => $orderInfo['order_id'], 'delivery_name' => $datas['delivery_name'] ?? '', 'delivery_id' => $datas['delivery_id'] ?? '', 'user_address' => $orderInfo['user_address']]);
  124. //模板消息公众号模版消息
  125. // $WechatTemplateList->sendOrderDeliver($orderInfo['uid'], $store_name, $orderInfo, $datas);
  126. //模板消息小程序订阅消息
  127. $RoutineTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo, $store_name, $datas, $isGive);
  128. break;
  129. //发货快递给用户
  130. case 'order_postage_success':
  131. $orderInfo = $data['orderInfo'];
  132. $store_name = $data['storeName'];
  133. $datas = $data['data'];
  134. $service = app()->make(UserServices::class);
  135. $nickname = $service->value(['uid' => $orderInfo['uid']], 'nickname');
  136. //短信
  137. $order_id = $orderInfo['order_id'];
  138. $NoticeSms->sendSms($orderInfo['user_phone'], compact('order_id', 'store_name', 'nickname'), 'DELIVER_GOODS_CODE');
  139. $isGive = 1;
  140. //站内信
  141. $smsdata = ['nickname' => $nickname, 'store_name' => $store_name, 'order_id' => $orderInfo['order_id'], 'delivery_name' => $datas['delivery_name'] ?? '', 'delivery_id' => $datas['delivery_id'] ?? '', 'user_address' => $orderInfo['user_address']];
  142. $SystemMsg->sendMsg($orderInfo['uid'], $smsdata);
  143. //模板消息公众号模版消息
  144. $WechatTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo, $datas, $store_name);
  145. //模板消息小程序订阅消息
  146. $RoutineTemplateList->sendOrderPostage($orderInfo['uid'], $orderInfo, $store_name, $datas, $isGive);
  147. break;
  148. //确认收货给用户
  149. case 'order_takever':
  150. $order = is_object($data['order']) ? $data['order']->toArray() : $data['order'];
  151. //模板变量
  152. $store_name = substrUTf8($data['storeTitle'], 20, 'UTF-8', '');
  153. $order_id = $order['order_id'];
  154. $NoticeSms->sendSms($order['user_phone'], compact('store_name', 'order_id'), 'TAKE_DELIVERY_CODE');
  155. //站内信
  156. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'store_name' => $store_name]);
  157. //模板消息公众号模版消息
  158. $WechatTemplateList->sendOrderTakeSuccess($order['uid'], $order, $store_name);
  159. //模板消息小程序订阅消息
  160. $RoutineTemplateList->sendOrderTakeOver($order['uid'], $order, $store_name);
  161. break;
  162. //改价给用户
  163. case 'price_revision':
  164. $order = $data['order'];
  165. $pay_price = $data['pay_price'];
  166. $order['storeName'] = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  167. //短信
  168. $NoticeSms->sendSms($order['user_phone'], ['order_id' => $order['order_id'], 'pay_price' => $pay_price], 'PRICE_REVISION_CODE');
  169. //站内信
  170. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $pay_price]);
  171. break;
  172. //退款成功
  173. case 'order_refund':
  174. $datas = $data['data'];
  175. $order = $data['order'];
  176. $storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  177. $storeTitle = substrUTf8($storeName, 20, 'UTF-8', '');
  178. //站内信
  179. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $order['pay_price'], 'refund_price' => $datas['refund_price']]);
  180. /** @var StoreOrderRefundServices $serviceRefun */
  181. $serviceRefun = app()->make(StoreOrderRefundServices::class);
  182. $order['order_id'] = $serviceRefun->value(['uid' => $order['uid'], 'store_order_id' => $order['id']], 'order_id');
  183. //短信
  184. $NoticeSms->sendSms($order['user_phone'], ['order_id' => $order['order_id'], 'refund_price' => $datas['refund_price']], 'ORDER_REFUND_STATUS');
  185. //模板消息公众号模版消息
  186. $WechatTemplateList->sendOrderRefundSuccess($order['uid'], $datas, $order);
  187. //模板消息小程序订阅消息
  188. $RoutineTemplateList->sendOrderRefundSuccess($order['uid'], $order, $storeTitle);
  189. break;
  190. //退款未通过
  191. case 'send_order_refund_no_status':
  192. $order = $data['orderInfo'];
  193. $storeName = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  194. $storeTitle = substrUTf8($storeName, 20, 'UTF-8', '');
  195. //站内信
  196. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'pay_price' => $order['pay_price'], 'store_name' => $storeTitle]);
  197. //短信
  198. $NoticeSms->sendSms($order['user_phone'], ['order_id' => $order['order_id']], 'SEND_ORDER_REFUND_NO_STATUS');
  199. //模板消息公众号模版消息
  200. $WechatTemplateList->sendOrderRefundNoStatus($order['uid'], $order);
  201. //模板消息小程序订阅消息
  202. $RoutineTemplateList->sendOrderRefundFail($order['uid'], $order, $storeTitle);
  203. break;
  204. //充值余额
  205. case 'recharge_success':
  206. $order = $data['order'];
  207. $now_money = $data['now_money'];
  208. //短信
  209. $NoticeSms->sendSms($order['phone'], ['price' => $order['price'], 'now_money' => $now_money], 'RECHARGE_SUCCESS');
  210. //站内信
  211. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'price' => $order['price'], 'now_money' => $now_money]);
  212. //模板消息公众号模版消息
  213. $WechatTemplateList->sendRechargeSuccess($order['uid'], $order);
  214. //模板消息小程序订阅消息
  215. $RoutineTemplateList->sendRechargeSuccess($order['uid'], $order, $now_money);
  216. break;
  217. //充值退款
  218. case 'recharge_order_refund_status':
  219. $datas = $data['data'];
  220. $UserRecharge = $data['UserRecharge'];
  221. //短信
  222. $phone = $UserServices->value(['uid' => $UserRecharge['uid']], 'phone');
  223. if ($phone) {
  224. $NoticeSms->sendSms($phone, ['refund_price' => $datas['refund_price']], 'RECHARGE_ORDER_REFUND_STATUS');
  225. }
  226. //站内信
  227. $SystemMsg->sendMsg($UserRecharge['uid'], ['refund_price' => $datas['refund_price'], 'order_id' => $UserRecharge['order_id'], 'price' => $UserRecharge['price']]);
  228. //模板消息公众号模版消息
  229. $WechatTemplateList->sendRechargeRefundStatus($UserRecharge['uid'], $datas, $UserRecharge);
  230. //模板消息小程序订阅消息
  231. $RoutineTemplateList->sendRechargeSuccess($UserRecharge['uid'], $UserRecharge, $UserRecharge['now_money']);
  232. break;
  233. //积分
  234. case 'integral_accout':
  235. $order = $data['order'];
  236. $order['gain_integral'] = $data['give_integral'];
  237. $storeTitle = substrUTf8($data['storeTitle'], 20, 'UTF-8', '');
  238. //站内信
  239. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order['order_id'], 'store_name' => $storeTitle, 'pay_price' => $order['pay_price'], 'gain_integral' => $data['give_integral'], 'integral' => $data['integral']]);
  240. //短信
  241. $NoticeSms->sendSms($order['user_phone'], ['gain_integral' => $data['give_integral'], 'integral' => $data['integral']], 'INTEGRAL_ACCOUT');
  242. //模板消息公众号模版消息
  243. // $WechatTemplateList->sendUserIntegral($order['uid'], $order, $data);
  244. //模板消息小程序订阅消息
  245. $RoutineTemplateList->sendUserIntegral($order['uid'], $data['order'], $storeTitle, $data['give_integral'], $data['integral']);
  246. break;
  247. //佣金
  248. case 'order_brokerage':
  249. $brokeragePrice = $data['brokeragePrice'];
  250. $goodsName = substrUTf8($data['goodsName'], 20, 'UTF-8', '');
  251. $goodsPrice = $data['goodsPrice'];
  252. $add_time = $data['add_time'];
  253. $spread_uid = $data['spread_uid'];
  254. $phone = $data['phone'];
  255. //站内信
  256. $SystemMsg->sendMsg($spread_uid, ['goods_name' => $goodsName, 'goods_price' => $goodsPrice, 'brokerage_price' => $brokeragePrice]);
  257. if ($phone) {
  258. //短信
  259. $NoticeSms->sendSms($phone, ['brokerage_price' => $brokeragePrice], 'ORDER_BROKERAGE');
  260. }
  261. //模板消息公众号模版消息
  262. // $WechatTemplateList->sendOrderBrokerageSuccess($spread_uid, $brokeragePrice, $goodsName, $goodsPrice, $add_time);
  263. //模板消息小程序订阅消息
  264. $RoutineTemplateList->sendOrderBrokerageSuccess($spread_uid, $brokeragePrice, $goodsName);
  265. break;
  266. //砍价成功
  267. case 'bargain_success':
  268. $uid = $data['uid'];
  269. $bargainInfo = $data['bargainInfo'];
  270. $bargainUserInfo = $data['bargainUserInfo'];
  271. //站内信
  272. $SystemMsg->sendMsg($uid, ['title' => substrUTf8($bargainInfo['title'], 20, 'UTF-8', ''), 'min_price' => $bargainInfo['min_price']]);
  273. //短信
  274. $phone = $UserServices->value(['uid' => $uid], 'phone');
  275. if ($phone) {
  276. $NoticeSms->sendSms($phone, ['title' => substrUTf8($bargainInfo['title'], 20, 'UTF-8', ''), 'min_price' => $bargainInfo['min_price']], 'BARGAIN_SUCCESS');
  277. }
  278. //模板消息公众号模版消息
  279. // $WechatTemplateList->sendBargainSuccess($uid, $bargainInfo, $bargainUserInfo, $uid);
  280. //模板消息小程序订阅消息
  281. $RoutineTemplateList->sendBargainSuccess($uid, $bargainInfo, $bargainUserInfo, $uid);
  282. break;
  283. //拼团成功
  284. case 'order_user_groups_success':
  285. $list = $data['list'];
  286. $title = substrUTf8($data['title'], 20, 'UTF-8', '');
  287. $nickname = $data['nickname'] ?? '';
  288. $url = '/pages/goods/order_details/index?order_id=' . $list['order_id'];
  289. //站内信
  290. $SystemMsg->sendMsg($list['uid'], ['title' => $title, 'nickname' => $nickname, 'count' => $list['people'], 'pink_time' => date('Y-m-d H:i:s', $list['add_time'])]);
  291. //短信
  292. $phone = $UserServices->value(['uid' => $list['uid']], 'phone');
  293. if ($phone) {
  294. $NoticeSms->sendSms($phone, ['title' => $title, 'nickname' => $nickname], 'ORDER_USER_GROUPS_SUCCESS');
  295. }
  296. //模板消息公众号模版消息
  297. // $WechatTemplateList->sendOrderPinkSuccess($list['uid'], $list, $title);
  298. //模板消息小程序订阅消息
  299. $RoutineTemplateList->sendPinkSuccess($list['uid'], $title, $nickname, $list['add_time'], $list['people'], $url);
  300. break;
  301. //取消拼团
  302. case 'send_order_pink_clone':
  303. $uid = $data['uid'];
  304. $pink = $data['pink'];
  305. $title = substrUTf8($pink['title'], 20, 'UTF-8', '');
  306. //站内信
  307. $SystemMsg->sendMsg($uid, ['title' => $title, 'count' => $pink->people]);
  308. $phone = $UserServices->value(['uid' => $uid], 'phone');
  309. if ($phone) {
  310. $NoticeSms->sendSms($phone, ['title' => $title], 'SEND_ORDER_PINK_CLONE');
  311. }
  312. //模板消息公众号模版消息
  313. // $WechatTemplateList->sendOrderPinkClone($uid, $pink, $pink->title);
  314. //模板消息小程序订阅消息
  315. $RoutineTemplateList->sendPinkFail($uid, $title, $pink->people, '亲,您的拼团取消,点击查看订单详情', '/pages/goods/order_details/index?order_id=' . $pink->order_id);
  316. break;
  317. //拼团失败
  318. case 'send_order_pink_fial':
  319. $uid = $data['uid'];
  320. $pink = $data['pink'];
  321. $title = substrUTf8($pink['title'], 20, 'UTF-8', '');
  322. //站内信
  323. $SystemMsg->sendMsg($uid, ['title' => $title, 'count' => $pink->people]);
  324. $phone = $UserServices->value(['uid' => $uid], 'phone');
  325. if ($phone) {
  326. $NoticeSms->sendSms($phone, ['title' => $title], 'SEND_ORDER_PINK_FIAL');
  327. }
  328. //模板消息公众号模版消息
  329. // $WechatTemplateList->sendOrderPinkFial($uid, $pink, $pink->title);
  330. //模板消息小程序订阅消息
  331. $RoutineTemplateList->sendPinkFail($uid, $title, $pink->people, '亲,您拼团失败,自动为您申请退款,退款金额为:' . $pink->price, '/pages/goods/order_details/index?order_id=' . $pink->order_id);
  332. break;
  333. //参团成功
  334. case 'can_pink_success':
  335. $orderInfo = $data['orderInfo'];
  336. $title = substrUTf8($data['title'], 20, 'UTF-8', '');
  337. $pink = $data['pink'];
  338. $nickname = $UserServices->value(['uid' => $orderInfo['uid']], 'nickname');
  339. //站内信
  340. $SystemMsg->sendMsg($orderInfo['uid'], ['title' => $title, 'nickname' => $nickname, 'count' => $pink['people'], 'pink_time' => date('Y-m-d H:i:s', $pink['add_time'])]);
  341. //短信
  342. $NoticeSms->sendSms($orderInfo['user_phone'], ['order_id' => $orderInfo['order_id'], 'title' => $title], 'CAN_PINK_SUCCESS');
  343. //模板消息公众号模版消息
  344. // $WechatTemplateList->sendOrderPinkUseSuccess($orderInfo['uid'], $orderInfo, $title);
  345. //模板消息小程序订阅消息
  346. $RoutineTemplateList->sendPinkSuccess($orderInfo['uid'], $title, $nickname, $pink['add_time'], $pink['people'], '/pages/goods/order_details/index?order_id=' . $pink['order_id']);
  347. break;
  348. //开团成功
  349. case 'open_pink_success':
  350. $orderInfo = $data['orderInfo'];
  351. $title = substrUTf8($data['title'], 20, 'UTF-8', '');
  352. $pink = $data['pink'];
  353. $nickname = $UserServices->value(['uid' => $orderInfo['uid']], 'nickname');
  354. //站内信
  355. $SystemMsg->sendMsg($orderInfo['uid'], ['title' => $title, 'nickname' => $nickname, 'count' => $pink['people'], 'pink_time' => date('Y-m-d H:i:s', $pink['add_time'])]);
  356. //短信
  357. $NoticeSms->sendSms($orderInfo['user_phone'], ['title' => $title], 'OPEN_PINK_SUCCESS');
  358. //模板消息公众号模版消息
  359. // $WechatTemplateList->sendOrderPinkOpenSuccess($orderInfo['uid'], $pink, $title);
  360. //模板消息小程序订阅消息
  361. //$RoutineTemplateList->sendPinkSuccess($orderInfo['uid'], $title, $nickname, $pink['add_time'], $pink['people'], '/pages/goods/order_details/index?order_id=' . $pink['order_id']);
  362. $RoutineTemplateList->sendPinkFail($orderInfo['uid'], $title, $pink['people'], '亲,您已开团成功,可以查看详情邀请好友一起参与拼团', '/pages/goods/order_details/index?order_id=' . $pink['order_id']);
  363. break;
  364. //提现成功
  365. case 'user_extract':
  366. $extractNumber = $data['extractNumber'];
  367. $nickname = $data['nickname'];
  368. $uid = $data['uid'];
  369. //站内信
  370. $SystemMsg->sendMsg($uid, ['extract_number' => $extractNumber, 'nickname' => $nickname, 'date' => date('Y-m-d H:i:s', time())]);
  371. //短信
  372. $phone = $UserServices->value(['uid' => $uid], 'phone');
  373. if ($phone) {
  374. $NoticeSms->sendSms($phone, ['extract_number' => $extractNumber], 'USER_EXTRACT');
  375. }
  376. //模板消息公众号模版消息
  377. $WechatTemplateList->sendUserExtract($uid, $extractNumber);
  378. //模板消息小程序订阅消息
  379. $RoutineTemplateList->sendExtractSuccess($uid, $extractNumber, $nickname);
  380. break;
  381. //提现失败
  382. case 'user_balance_change':
  383. $extract_number = $data['extract_number'];
  384. $message = $data['message'];
  385. $uid = $data['uid'];
  386. $nickname = $data['nickname'];
  387. //站内信
  388. $SystemMsg->sendMsg($uid, ['extract_number' => $extract_number, 'nickname' => $nickname, 'date' => date('Y-m-d H:i:s', time()), 'message' => $message]);
  389. //短信
  390. $phone = $UserServices->value(['uid' => $uid], 'phone');
  391. if ($phone) {
  392. $NoticeSms->sendSms($phone, ['extract_number' => $extract_number], 'USER_EXTRACT_FAIL');
  393. }
  394. //模板消息公众号模版消息
  395. // $WechatTemplateList->sendExtractFail($uid, $extract_number, $message);
  396. //模板消息小程序订阅消息
  397. $RoutineTemplateList->sendExtractFail($uid, $message, $extract_number, $nickname);
  398. break;
  399. //提醒付款给用户
  400. case 'order_pay_false':
  401. $order = $data['order'];
  402. $order_id = $order['order_id'];
  403. $order['storeName'] = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  404. //短信
  405. $NoticeSms->sendSms($order['user_phone'], compact('order_id'), 'ORDER_PAY_FALSE');
  406. //站内信
  407. $SystemMsg->sendMsg($order['uid'], ['order_id' => $order_id]);
  408. break;
  409. //申请退款给客服发消息
  410. case 'send_order_apply_refund':
  411. $order = $data['order'];
  412. $datas = [
  413. 'order_id' => $order['order_id'],
  414. 'status' => '申请退款',
  415. ];
  416. $store_id = 0;
  417. //给门店店员发送消息
  418. if ($order['store_id'] != 0 && $order['shipping_type'] != 4) {
  419. $store_id = $order['store_id'];
  420. }
  421. $order['storeName'] = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  422. //站内信
  423. $SystemMsg->kefuSystemSend(['order_id' => $order['order_id']], $store_id);
  424. //短信
  425. $NoticeSms->sendAdminRefund($order, $store_id);
  426. //公众号
  427. // $WechatTemplateList->sendAdminNewRefund($order, $store_id);
  428. //企业微信通知
  429. $NoticeService->EnterpriseWechatSend(['order_id' => $order['order_id']]);
  430. break;
  431. //新订单给客服
  432. case 'admin_pay_success_code':
  433. $order = $data;
  434. $store_id = 0;
  435. //给门店店员发送消息
  436. if ($order['store_id'] != 0 && $order['shipping_type'] != 4) {
  437. $store_id = $order['store_id'];
  438. }
  439. if (isset($order['member_type'])) {//付费会员订单
  440. $order['storeName'] = '付费会员SVIP';
  441. } else {
  442. $order['storeName'] = $orderInfoServices->getCarIdByProductTitle((int)$order['id']);
  443. }
  444. //站内信
  445. $SystemMsg->kefuSystemSend(['order_id' => $order['order_id']], $store_id);
  446. //短信
  447. $NoticeSms->sendAdminPaySuccess($order, $store_id);
  448. //公众号
  449. // $WechatTemplateList->sendAdminNewOrder($order, $store_id);
  450. //企业微信通知
  451. $NoticeService->EnterpriseWechatSend(['order_id' => $order['order_id']]);
  452. break;
  453. //提现申请给客服
  454. case 'kefu_send_extract_application':
  455. //站内信
  456. $SystemMsg->kefuSystemSend($data);
  457. //企业微信通知
  458. $NoticeService->EnterpriseWechatSend($data);
  459. break;
  460. //确认收货给客服
  461. case 'send_admin_confirm_take_over':
  462. $order = $data['order'];
  463. $storeTitle = $data['storeTitle'];
  464. //站内信
  465. $SystemMsg->kefuSystemSend(['storeTitle' => $storeTitle, 'order_id' => $order['order_id']]);
  466. //短信
  467. $NoticeSms->sendAdminConfirmTakeOver($order);
  468. //企业微信通知
  469. $NoticeService->EnterpriseWechatSend(['store_title' => $storeTitle, 'order_id' => $order['order_id']]);
  470. break;
  471. //异地登录通知
  472. case 'login_city_error':
  473. $phone = $data['phone'];
  474. unset($data['phone']);
  475. $NoticeSms->sendSms($phone, $data, 'LOGIN_CITY_ERROR');
  476. break;
  477. //虚拟商品发货通知
  478. case 'kami_deliver_goods_code':
  479. $order_id = $data['order_id'];
  480. $siteUrl = sys_config('site_url');
  481. $url = ' ' . $siteUrl . ' ';
  482. $value = $data['value'];
  483. $phone = $UserServices->value(['uid' => $data['uid']], 'phone');
  484. if ($phone) {
  485. //短信
  486. $NoticeSms->sendSms($phone, compact('order_id', 'value', 'url'), 'KAMI_DELIVER_GOODS_CODE');
  487. }
  488. // if ($data['is_integral']) {
  489. // $templateUrl = $siteUrl . '/pages/points_mall/integral_order_details?order_id=' . $order_id;
  490. // } else {
  491. // $templateUrl = $siteUrl . '/pages/goods/order_details/index?order_id=' . $order_id;
  492. // }
  493. //模板消息公众号模版消息
  494. // $WechatTemplateList->sendKamiDeliverGoods($data['uid'], $value, $templateUrl);
  495. //发送站内行
  496. $SystemMessageServices->systemSend($data['uid'], [
  497. 'mark' => 'virtual_info',
  498. 'title' => $data['title'],
  499. 'content' => $data['content']
  500. ]);
  501. break;
  502. //核销成功提醒 次卡
  503. case 'reminder_verification_status':
  504. $store_name = $data['store_name'];
  505. $phone = $data['phone'];
  506. $write_time = date('Y-m-d H:i', time());
  507. if ($phone) {
  508. //短信
  509. $NoticeSms->sendSms($phone, compact('store_name', 'write_time'), 'REMINDER_VERIFICATION_STATUS');
  510. }
  511. $SystemMsg->sendMsg((int)$data['uid'], compact('store_name', 'write_time'));
  512. break;
  513. //过期提醒 次卡
  514. case 'expiration_reminder':
  515. $store_name = $data['store_name'];
  516. $phone = $data['phone'];
  517. $end_time = $data['end_time'];
  518. if ($phone) {
  519. //短信
  520. $NoticeSms->sendSms($phone, compact('store_name', 'end_time'), 'EXPIRATION_REMINDER');
  521. }
  522. $SystemMsg->sendMsg((int)$data['uid'], compact('store_name', 'end_time'));
  523. break;
  524. //临期提醒 次卡
  525. case 'reminder_brink_death':
  526. $store_name = $data['store_name'];
  527. $phone = $data['phone'];
  528. $pay_time = $data['pay_time'];
  529. $end_time = $data['end_time'];
  530. if ($phone) {
  531. //短信
  532. $NoticeSms->sendSms($phone, compact('store_name', 'pay_time', 'end_time'), 'REMINDER_BRINK_DEATH');
  533. }
  534. $SystemMsg->sendMsg((int)$data['uid'], compact('store_name', 'pay_time', 'end_time'));
  535. break;
  536. //供应商入驻审核通过
  537. case 'supplier_verify_success':
  538. $supplier = $data['system_name'] ?? '';
  539. $phone = $data['phone'] ?? '';
  540. $date = isset($data['add_time']) && $data['add_time'] ? date('Y-m-d H:i', $data['add_time']) : '';
  541. $site_name = sys_config('site_name');
  542. if ($phone) {
  543. $pwd = substr($phone, -6);
  544. //短信
  545. $NoticeSms->sendSms($phone, compact('date', 'supplier', 'phone', 'pwd', 'site_name'), 'SUPPLIER_VERIFY_SUCCESS');
  546. }
  547. break;
  548. //供应商入驻审核未通过
  549. case 'supplier_verify_fail':
  550. $supplier = $data['system_name'] ?? '';
  551. $phone = $data['phone'] ?? '';
  552. $date = isset($data['add_time']) && $data['add_time'] ? date('Y-m-d H:i', $data['add_time']) : '';
  553. $site_name = sys_config('site_name');
  554. if ($phone) {
  555. //短信
  556. $NoticeSms->sendSms($phone, compact('date', 'supplier', 'site_name'), 'SUPPLIER_VERIFY_FAIL');
  557. }
  558. break;
  559. }
  560. }
  561. } catch (\Throwable $e) {
  562. Log::error('错误' . $e->getMessage());
  563. }
  564. }
  565. }