WechatTemplateMessageService.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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 crmeb\services;
  12. use app\common\repositories\store\order\StoreGroupOrderRepository;
  13. use app\common\repositories\store\order\StoreOrderRepository;
  14. use app\common\repositories\store\order\StoreOrderStatusRepository;
  15. use app\common\repositories\store\order\StoreRefundOrderRepository;
  16. use app\common\repositories\store\product\ProductGroupBuyingRepository;
  17. use app\common\repositories\store\product\ProductGroupUserRepository;
  18. use app\common\repositories\store\product\ProductRepository;
  19. use app\common\repositories\store\product\ProductTakeRepository;
  20. use app\common\repositories\store\service\StoreServiceRepository;
  21. use app\common\repositories\user\UserBillRepository;
  22. use app\common\repositories\user\UserExtractRepository;
  23. use app\common\repositories\user\UserRechargeRepository;
  24. use app\common\repositories\wechat\WechatUserRepository;
  25. use crmeb\listens\pay\UserRechargeSuccessListen;
  26. use crmeb\services\template\Template;
  27. use app\common\repositories\user\UserRepository;
  28. use think\facade\Route;
  29. class WechatTemplateMessageService
  30. {
  31. /**
  32. * TODO
  33. * @param array $data
  34. * @param string|null $link
  35. * @param string|null $color
  36. * @return bool
  37. * @author Qinii
  38. * @day 2020-06-29
  39. */
  40. public function sendTemplate(array $data)
  41. {
  42. $res = $this->templateMessage($data['tempCode'],$data['id']);
  43. if(!$res || !is_array($res))
  44. return true;
  45. foreach($res as $item){
  46. if(is_array($item['uid'])){
  47. foreach ($item['uid'] as $value){
  48. $openid = $this->getUserOpenID($value['uid']);
  49. if (!$openid) return true;
  50. $this->send($openid,$item['tempCode'],$item['data'],'wechat',$item['link'],$item['color']);
  51. }
  52. }else{
  53. $openid = $this->getUserOpenID($item['uid']);
  54. if (!$openid) return true;
  55. $this->send($openid,$item['tempCode'],$item['data'],'wechat',$item['link'],$item['color']);
  56. }
  57. }
  58. }
  59. /**
  60. * TODO
  61. * @param $data
  62. * @param string|null $link
  63. * @param string|null $color
  64. * @return bool
  65. * @author Qinii
  66. * @day 2020-07-01
  67. */
  68. public function subscribeSendTemplate($data)
  69. {
  70. $res = $this->subscribeTemplateMessage($data['tempCode'],$data['id']);
  71. if(!$res || !is_array($res))return true;
  72. foreach($res as $item){
  73. if(is_array($item['uid'])){
  74. foreach ($item['uid'] as $value){
  75. $openid = $this->getUserOpenID($value,'min');
  76. if (!$openid) return true;
  77. $this->send($openid,$item['tempCode'],$item['data'],'subscribe',$item['link'],$item['color']);
  78. }
  79. }else{
  80. $openid = $this->getUserOpenID($item['uid'],'min');
  81. if (!$openid) return true;
  82. $this->send($openid,$item['tempCode'],$item['data'],'subscribe',$item['link'],$item['color']);
  83. }
  84. }
  85. }
  86. /**
  87. * TODO
  88. * @param $uid
  89. * @return mixed
  90. * @author Qinii
  91. * @day 2020-06-29
  92. */
  93. public function getUserOpenID($uid,$type = 'wechat')
  94. {
  95. $user = app()->make(UserRepository::class)->get($uid);
  96. $make = app()->make(WechatUserRepository::class);
  97. if($type == 'wechat') {
  98. return $make->idByOpenId((int)$user['wechat_user_id']);
  99. }else{
  100. return $make->idByRoutineId((int)$user['wechat_user_id']);
  101. }
  102. }
  103. /**
  104. * TODO
  105. * @param $openid
  106. * @param $tempCode
  107. * @param $data
  108. * @param $type
  109. * @param $link
  110. * @param $color
  111. * @return bool|mixed
  112. * @author Qinii
  113. * @day 2020-07-01
  114. */
  115. public function send($openid,$tempCode,$data,$type,$link,$color)
  116. {
  117. try{
  118. $template = new Template($type);
  119. $template->to($openid)->color($color);
  120. if ($link) $template->url($link);
  121. return $template->send($tempCode, $data);
  122. } catch (\Exception $e) {
  123. return false;
  124. }
  125. }
  126. /**
  127. * TODO 公众号
  128. * @param string $tempCode
  129. * @param $id
  130. * @return array|bool
  131. * @author Qinii
  132. * @day 2020-07-01
  133. */
  134. public function templateMessage(string $tempCode, $id)
  135. {
  136. $bill_make = app()->make(UserBillRepository::class);
  137. $order_make = app()->make(StoreOrderRepository::class);
  138. $refund_make = app()->make(StoreRefundOrderRepository::class);
  139. $order_status_make = app()->make(StoreOrderStatusRepository::class);
  140. switch ($tempCode)
  141. {
  142. case 'ORDER_CREATE': //订单生成通知
  143. $res = $order_make->selectWhere(['group_order_id' => $id]);
  144. if(!$res) return false;
  145. foreach ($res as $item){
  146. $order = $order_make->getWith($item['order_id'],'orderProduct');
  147. $data[] = [
  148. 'tempCode' => 'ORDER_CREATE',
  149. 'uid' => app()->make(StoreServiceRepository::class)->getNoticeServiceInfo($item->mer_id),
  150. 'data' => [
  151. 'first' => '您有新的生成订单请注意查看',
  152. 'keyword1' => $item->create_time,
  153. 'keyword2' => '「'.$order['orderProduct'][0]['cart_info']['product']['store_name'].'」等',
  154. 'keyword3' => $item->order_sn,
  155. 'remark' => '查看详情'
  156. ],
  157. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/admin/orderList/index?types=1',
  158. 'color' => null
  159. ];
  160. }
  161. break;
  162. case 'ORDER_PAY_SUCCESS': //支付成功
  163. $group_order = app()->make(StoreGroupOrderRepository::class)->get($id);
  164. if(!$group_order) return false;
  165. $data[] = [
  166. 'tempCode' => 'ORDER_PAY_SUCCESS',
  167. 'uid' => $group_order->uid,
  168. 'data' => [
  169. 'first' => '您的订单已支付',
  170. 'keyword1' => $group_order->group_order_sn,
  171. 'keyword2' => $group_order->pay_price,
  172. 'remark' => '我们会经快发货,请耐心等待'
  173. ],
  174. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/users/order_list/index?status=1',
  175. 'color' => null
  176. ];
  177. $res = $order_make->selectWhere(['group_order_id' => $id]);
  178. if(!$res) return false;
  179. foreach ($res as $item){
  180. $data[] = [
  181. 'tempCode' => 'ORDER_PAY_SUCCESS',
  182. 'uid' => app()->make(StoreServiceRepository::class)->getNoticeServiceInfo($item->mer_id),
  183. 'data' => [
  184. 'first' => '您有新的支付订单请注意查看。',
  185. 'keyword1' => $item->order_sn,
  186. 'keyword2' => $item->pay_price,
  187. 'remark' => '请尽快发货。'
  188. ],
  189. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/admin/orderList/index?types=2',
  190. 'color' => null
  191. ];
  192. }
  193. break;
  194. case 'ORDER_POSTAGE_SUCCESS'://订单发货提醒(快递)
  195. $res = $order_make->get($id);
  196. if(!$res) return false;
  197. $data[] = [
  198. 'tempCode' => 'ORDER_POSTAGE_SUCCESS',
  199. 'uid' => $res->uid ,
  200. 'data' => [
  201. 'first' => '亲,宝贝已经启程了,好想快点来到你身边',
  202. 'keyword1' => $res['order_sn'],
  203. 'keyword2' => $res['delivery_name'],
  204. 'keyword3' => $res['delivery_id'],
  205. 'remark' => '请耐心等待收货哦。'
  206. ],
  207. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/order_details/index?order_id='.$id,
  208. 'color' => null
  209. ];
  210. break;
  211. case 'ORDER_DELIVER_SUCCESS'://订单发货提醒(送货)
  212. $res = $order_make->getWith($id,'orderProduct');
  213. if(!$res) return false;
  214. $data[] = [
  215. 'tempCode' => 'ORDER_DELIVER_SUCCESS',
  216. 'uid' => $res->uid ,
  217. 'data' => [
  218. 'first' => '亲,宝贝已经启程了,好想快点来到你身边',
  219. 'keyword1' => '「'.$res['orderProduct'][0]['cart_info']['product']['store_name'].'」等',
  220. 'keyword2' => $res['create_time'],
  221. 'keyword3' => $res['user_address'],
  222. 'keyword4' => $res['delivery_name'],
  223. 'keyword5' => $res['delivery_id'],
  224. 'remark' => '请耐心等待收货哦。'
  225. ],
  226. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/order_details/index?order_id='.$id,
  227. 'color' => null
  228. ];
  229. break;
  230. case 'ORDER_TAKE_SUCCESS': //订单收货通知
  231. $res = $order_make->getWith($id,'orderProduct');
  232. if(!$res) return false;
  233. $status = $order_status_make->getWhere(['order_id' => $id,'change_type' => 'take']);
  234. $data[] = [
  235. 'tempCode' => 'ORDER_TAKE_SUCCESS',
  236. 'uid' => $res->uid,
  237. 'data' => [
  238. 'first' => '亲,宝贝已经签收',
  239. 'keyword1' => $res['order_sn'],
  240. 'keyword2' => '已收货',
  241. 'keyword3' => $status['change_time'],
  242. 'keyword4' => '「'.$res['orderProduct'][0]['cart_info']['product']['store_name'].'」等',
  243. 'remark' => '请确认。'
  244. ],
  245. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/order_details/index?order_id='.$id,
  246. 'color' => null
  247. ];
  248. break;
  249. case 'USER_BALANCE_CHANGE'://帐户资金变动提醒
  250. $res = $bill_make->get($id);
  251. if(!$res) return false;
  252. $data[] = [
  253. 'tempCode' => 'USER_BALANCE_CHANGE',
  254. 'uid' => $res->uid,
  255. 'data' => [
  256. 'first' => '资金变动提醒',
  257. 'keyword1' => '账户余额变动',
  258. 'keyword2' => $res['number'],
  259. 'keyword3' => $res['create_time'],
  260. 'keyword4' => $res['balance'],
  261. 'remark' => '请确认'
  262. ],
  263. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/users/user_money/index',
  264. 'color' => null
  265. ];
  266. break;
  267. case 'ORDER_REFUND_STATUS'://退款申请通知
  268. $res = $refund_make->get($id);
  269. if(!$res) return false;
  270. $data[] = [
  271. 'tempCode' => 'ORDER_REFUND_STATUS',
  272. 'uid' => app()->make(StoreServiceRepository::class)->getNoticeServiceInfo($res->mer_id),
  273. 'data' => [
  274. 'first' => '您有新的退款申请',
  275. 'keyword1' => $res['refund_order_sn'],
  276. 'keyword2' => $res['refund_price'],
  277. 'keyword3' => $res['refund_message'],
  278. 'remark' => '请及时处理'
  279. ],
  280. 'link' => null,
  281. 'color' => null
  282. ];
  283. break;
  284. case 'ORDER_REFUND_END'://退货确认提醒
  285. $res = $refund_make->getWith($id,['order']);
  286. if(!$res) return false;
  287. $order = $order_make->getWith($res['order_id'],'orderProduct');
  288. $data[] = [
  289. 'tempCode' => 'ORDER_REFUND_END',
  290. 'uid' => $res->uid,
  291. 'data' => [
  292. 'first' => '亲,您有一个订单已退款',
  293. 'keyword1' => $res['refund_order_sn'],
  294. 'keyword2' => $res['order']['order_sn'],
  295. 'keyword3' => $res['refund_price'],
  296. 'keyword4' => '「'.$order['orderProduct'][0]['cart_info']['product']['store_name'].'」等',
  297. 'remark' => $order['activity_type'] == 4 ? '拼团失败,系统自动退款' : '请查看详情'
  298. ],
  299. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/users/refund/detail?id='.$id,
  300. 'color' => null
  301. ];
  302. break;
  303. case 'ORDER_REFUND_NOTICE'://退款进度提醒
  304. $status = [-1=>'审核未通过' ,1 => '商家已同意退货,请尽快将商品退回,并填写快递单号',];
  305. $res = $refund_make->getWith($id,['order']);
  306. if(!$res || !in_array($res['status'],[-1,1])) return false;
  307. $order = $order_make->getWith($res['order_id'],'orderProduct');
  308. $data[] = [
  309. 'tempCode' => 'ORDER_REFUND_NOTICE',
  310. 'uid' => $res->uid,
  311. 'data' => [
  312. 'first' => '退款进度提醒',
  313. 'keyword1' => $res['refund_order_sn'],
  314. 'keyword2' => $status[$res['status']],
  315. 'keyword3' => '「'.$order['orderProduct'][0]['cart_info']['product']['store_name'].'」等',
  316. 'keyword4' => $res['refund_price'],
  317. 'remark' => ''
  318. ],
  319. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/users/refund/detail?id='.$id,
  320. 'color' => null
  321. ];
  322. break;
  323. case 'GROUP_BUYING_SUCCESS':
  324. /*
  325. {{first.DATA}}
  326. 商品名称:{{keyword1.DATA}}
  327. 订单号:{{keyword2.DATA}}
  328. 支付金额:{{keyword3.DATA}}
  329. 支付时间:{{keyword4.DATA}}
  330. {{remark.DATA}}
  331. */
  332. $res = app()->make(ProductGroupBuyingRepository::class)->get($id);
  333. if(!$res) return false;
  334. $buying_make = app()->make(ProductGroupUserRepository::class);
  335. $ret = $buying_make->getSearch(['group_buying_id' => $id])->where('uid','>',0)->select();
  336. foreach ($ret as $item){
  337. $data[] = [
  338. 'tempCode' => 'GROUP_BUYING_SUCCESS',
  339. 'uid' => $item->uid,
  340. 'data' => [
  341. 'first' => '恭喜您拼团成功!',
  342. 'keyword1' => '「'.$res->productGroup->product['store_name'].'」',
  343. 'keyword2' => $item->orderInfo['order_sn'],
  344. 'keyword3' => $item->orderInfo['pay_price'],
  345. 'keyword4' => $item->orderInfo['pay_time'],
  346. 'remark' => ''
  347. ],
  348. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/order_details/index?order_id='.$item['order_id'],
  349. 'color' => null
  350. ];
  351. }
  352. break;
  353. case'PRODUCT_INCREASE':
  354. /*
  355. {{first.DATA}}
  356. 预订商品:{{keyword1.DATA}}
  357. 到货数量:{{keyword2.DATA}}
  358. 到货时间:{{keyword3.DATA}}
  359. {{remark.DATA}}
  360. */
  361. $make = app()->make(ProductTakeRepository::class);
  362. $product = app()->make(ProductRepository::class)->getWhere(['product_id' => $id],'*',['attrValue']);
  363. if(!$product) return false;
  364. $unique[] = 1;
  365. foreach ($product['attrValue'] as $item) {
  366. if($item['stock'] > 0){
  367. $unique[] = $item['unique'];
  368. }
  369. }
  370. $query = $make->getSearch(['product_id' => $id,'status' =>0,'type' => 2])->where('unique','in',$unique);
  371. $uid = $query->column('uid,product_id');
  372. if(!$uid) return false;
  373. $tak_id = $query->column('product_take_id');
  374. app()->make(ProductTakeRepository::class)->updates($tak_id,['status' => 1]);
  375. $data[] = [
  376. 'tempCode' => 'PRODUCT_INCREASE',
  377. 'uid' => $uid,
  378. 'data' => [
  379. 'first' => '亲,你想要的商品已到货,可以购买啦~',
  380. 'keyword1' => '「'.$product->store_name.'」',
  381. 'keyword2' => $product->stock,
  382. 'keyword3' => date('Y-m-d H:i:s',time()),
  383. 'remark' => ''
  384. ],
  385. 'link' => rtrim(systemConfig('site_url'),'/').'/pages/goods_details/index?id='.$id,
  386. 'color' => null
  387. ];
  388. break;
  389. default:
  390. return false;
  391. break;
  392. }
  393. return $data;
  394. }
  395. /**
  396. * TODO 小程序模板
  397. * @param string $tempCode
  398. * @param $id
  399. * @return array|bool
  400. * @author Qinii
  401. * @day 2020-07-01
  402. */
  403. public function subscribeTemplateMessage(string $tempCode, $id)
  404. {
  405. $user_make = app()->make(UserRechargeRepository::class);
  406. $order_make = app()->make(StoreOrderRepository::class);
  407. $refund_make = app()->make(StoreRefundOrderRepository::class);
  408. $order_group_make = app()->make(StoreGroupOrderRepository::class);
  409. $extract_make = app()->make(UserExtractRepository::class);
  410. switch($tempCode)
  411. {
  412. case 'ORDER_PAY_SUCCESS': //订单支付成功
  413. $res = $order_group_make->get($id);
  414. if(!$res) return false;
  415. $data[] = [
  416. 'tempCode' => 'ORDER_PAY_SUCCESS',
  417. 'uid' => $res->uid,
  418. 'data' => [
  419. 'character_string1' => $res->group_order_sn,
  420. 'amount2' => $res->pay_price,
  421. 'date3' => $res->pay_time,
  422. 'amount5' => $res->total_price,
  423. ],
  424. 'link' => 'pages/users/order_list/index?status=1',
  425. 'color' => null
  426. ];
  427. break;
  428. case 'ORDER_DELIVER_SUCCESS': //订单发货提醒(送货)
  429. $res = $order_make->getWith($id,'orderProduct');
  430. if(!$res) return false;
  431. $name = substr($res['orderProduct'][0]['cart_info']['product']['store_name'],0,10);
  432. $data[] = [
  433. 'tempCode' => 'ORDER_DELIVER_SUCCESS',
  434. 'uid' => $res->uid,
  435. 'data' => [
  436. 'thing8' => '「'.$name.'」等',
  437. 'character_string1' => $res->order_sn,
  438. 'name4' => $res->delivery_name,
  439. 'phone_number10' => $res->delivery_id,
  440. ],
  441. 'link' => 'pages/order_details/index?order_id='.$id,
  442. 'color' => null
  443. ];
  444. break;
  445. case 'ORDER_POSTAGE_SUCCESS': //订单发货提醒(快递)
  446. $res = $order_make->getWith($id,'orderProduct');
  447. if(!$res) return false;
  448. $name = substr($res['orderProduct'][0]['cart_info']['product']['store_name'],0,10);
  449. $data[] = [
  450. 'tempCode' => 'ORDER_POSTAGE_SUCCESS',
  451. 'uid' => $res->uid,
  452. /**
  453. 快递单号{{character_string2.DATA}}
  454. 快递公司{{thing1.DATA}}
  455. 发货时间{{time3.DATA}}
  456. 订单商品{{thing5.DATA}}
  457. */
  458. 'data' => [
  459. 'character_string2' => $res->delivery_id,
  460. 'thing1' => $res->delivery_name,
  461. 'time3' => date('Y-m-d H:i:s',time()),
  462. 'thing5' => '「'.$name.'」等',
  463. ],
  464. 'link' => 'pages/order_details/index?order_id='.$id,
  465. 'color' => null
  466. ];
  467. break;
  468. case 'ORDER_REFUND_NOTICE': //退款通知
  469. $status = [-1=>'审核未通过' ,1 => '商家已同意退货,请尽快将商品退回',3 => '退款成功'];
  470. $res = $refund_make->getWith($id,['order']);
  471. if(!$res || !in_array($res['status'],[-1,1,3])) return false;
  472. $order = $order_make->getWith($res['order_id'],'orderProduct');
  473. $name = substr($order['orderProduct'][0]['cart_info']['product']['store_name'],0,10);
  474. $data[] = [
  475. 'tempCode' => 'ORDER_REFUND_NOTICE',
  476. 'uid' => $res->uid,
  477. 'data' => [
  478. 'thing1' => $status[$res->status],
  479. 'thing2' => '「'.$name.'」等',
  480. 'character_string6' => $res->refund_order_sn,
  481. 'amount3' => $res->refund_price,
  482. 'thing13' => $res->fail_message ?? '',
  483. ],
  484. 'link' => 'pages/users/refund/detail?id='.$id,
  485. 'color' => null
  486. ];
  487. break;
  488. case 'RECHARGE_SUCCESS': //充值成功
  489. $res = $user_make->get($id);
  490. if(!$res) return false;
  491. $data[] = [
  492. 'tempCode' => 'RECHARGE_SUCCESS',
  493. 'uid' => $res->uid,
  494. 'data' => [
  495. 'character_string1' => $res->order_id,
  496. 'amount3' => $res->price,
  497. 'amount6' => $res->give_price,
  498. 'date5' => $res->pay_time,
  499. ],
  500. 'link' => 'pages/users/user_money/index',
  501. 'color' => null
  502. ];
  503. break;
  504. case 'USER_EXTRACT': //提现结果通知
  505. $res = $extract_make->get($id);
  506. if(!$res) return false;
  507. $data[] = [
  508. 'tempCode' => 'USER_EXTRACT',
  509. 'uid' => $res->uid,
  510. 'data' => [
  511. 'thing1' => $res->status == -1 ? '未通过' : '已通过',
  512. 'amount2' => empty($res->bank_code)?(empty($res->alipay_code)?$res->wechat:$res->alipay_code):$res->bank_code,
  513. 'thing3' => $res->give_price,
  514. 'date4' => $res->create_time,
  515. ],
  516. 'link' => 'pages/users/user_spread_user/index',
  517. 'color' => null
  518. ];
  519. break;
  520. case'PRODUCT_INCREASE':
  521. /*
  522. 商品名称 {{thing1.DATA}}
  523. 商品价格:{{amount5.DATA}}
  524. 温馨提示:{{thing2.DATA}}
  525. */
  526. $make = app()->make(ProductTakeRepository::class);
  527. $product = app()->make(ProductRepository::class)->getWhere(['product_id' => $id],'*',['attrValue']);
  528. if(!$product) return false;
  529. $unique[] = 1;
  530. foreach ($product['attrValue'] as $item) {
  531. if($item['stock'] > 0){
  532. $unique[] = $item['unique'];
  533. }
  534. }
  535. $query = $make->getSearch(['product_id' => $id,'status' =>0,'type' => 3])->where('unique','in',$unique);
  536. $uid = $query->column('uid');
  537. if(!$uid) return false;
  538. $tak_id = $query->column('product_take_id');
  539. app()->make(ProductTakeRepository::class)->updates($tak_id,['status' => 1]);
  540. $data[] = [
  541. 'tempCode' => 'PRODUCT_INCREASE',
  542. 'uid' => $uid,
  543. 'data' => [
  544. 'thing1' => '「'.substr($product->store_name,0,10) .'」',
  545. 'amount5' => $product->price,
  546. 'thing2' => '亲!你想要的商品已到货,可以购买啦~',
  547. ],
  548. 'link' => 'pages/goods_details/index?id='.$id,
  549. 'color' => null
  550. ];
  551. break;
  552. default:
  553. return false;
  554. break;
  555. }
  556. return $data;
  557. }
  558. }