WxMessageClass.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531
  1. <?php
  2. namespace biz\wx\classes;
  3. use biz\base\classes\BaseClass;
  4. use biz\ghs\classes\GhsClass;
  5. use biz\shop\classes\ShopAdminClass;
  6. use biz\shop\classes\ShopClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use bizGhs\order\classes\PurchaseOrderItemClass;
  9. use common\components\dict;
  10. use common\components\noticeUtil;
  11. use common\components\stringUtil;
  12. use common\components\util;
  13. use common\components\wxUtil;
  14. use Yii;
  15. class WxMessageClass extends BaseClass
  16. {
  17. public static $baseFile = '\biz\wx\models\WxMessage';
  18. public static function has()
  19. {
  20. return [
  21. //零售
  22. dict::getDict('ptStyle', 'hd') => [
  23. 'OPENTM417875155' => '新订单通知',
  24. 'OPENTM207430125' => '操作成功通知',
  25. 'OPENTM401915538' => '审核通知',
  26. 'OPENTM201205968' => '订单送达通知',
  27. 'OPENTM207777535' => '付款提醒',
  28. 'OPENTM207422813' => '收入提醒',
  29. 'OPENTM202297555' => '下单成功通知',
  30. 'OPENTM207327227' => '宝贝售出提醒',
  31. 'OPENTM207188526' => '付款成功',
  32. 'OPENTM411207151' => '提现成功通知',
  33. 'OPENTM416881153' => '发货通知',
  34. 'OPENTM407280253' => '退款成功通知',
  35. 'OPENTM411530050' => '充值成功提醒',
  36. 'OPENTM408238177' => '反馈进度通知',
  37. 'OPENTM203447669' => '新客户加入通知',
  38. 'ZHH202308150025' => '退款申请处理通知',
  39. 'ZHH202311282308' => '采购申请处理通知',
  40. 'ZHH202405111701' => '采购单已确认通知',
  41. 'ZHH202405111702' => '异常订单提醒',
  42. 'ZHH202405111703' => '账单已结清提醒',
  43. 'ZHH202405111704' => '充值成功通知',
  44. 'ZHH202405121036' => '采购商品入库成功通知',
  45. 'ZHH202407100108' => '取货提醒',
  46. ],
  47. //供货商
  48. dict::getDict('ptStyle', 'ghs') => [
  49. 'OPENTM417875155' => '新订单通知',
  50. 'OPENTM207430125' => '操作成功通知',
  51. 'OPENTM401915538' => '审核通知',
  52. 'OPENTM201205968' => '订单送达通知',
  53. 'OPENTM207777535' => '付款提醒',
  54. 'OPENTM207422813' => '收入提醒',
  55. 'OPENTM202297555' => '下单成功通知',
  56. 'OPENTM207327227' => '宝贝售出提醒',
  57. 'OPENTM207188526' => '付款成功',
  58. 'OPENTM411207151' => '提现成功通知',
  59. 'OPENTM416881153' => '发货通知',
  60. 'OPENTM407280253' => '退款成功通知',
  61. 'OPENTM206773265' => '库存预警通知',
  62. 'OPENTM203447669' => '新客户加入通知',
  63. 'OPENTM411530050' => '充值成功提醒',
  64. 'OPENTM408238177' => '反馈进度通知',
  65. 'ZHH202308150025' => '退款申请处理通知',
  66. 'ZHH202311282308' => '采购申请处理通知',
  67. 'ZHH202405111701' => '采购单已确认通知',
  68. 'ZHH202405111702' => '异常订单提醒',
  69. 'ZHH202405111703' => '账单已结清提醒',
  70. 'ZHH202405111704' => '充值成功通知',
  71. 'ZHH202405121036' => '采购商品入库成功通知',
  72. 'ZHH202407100108' => '取货提醒',
  73. ],
  74. //商城
  75. dict::getDict('ptStyle', 'mall') => [
  76. ],
  77. ];
  78. }
  79. /**
  80. * 跑腿配送异常通知 ssh 20250825
  81. * @param \yii\db\ActiveRecord $shop 对象
  82. * @param string $customName 客户名称
  83. * @param int $orderId 订单id
  84. * @param string $result 异常状态说明内容:配送异常、配送员撤单、配送方取消订单、商家取消订单,这四种情况,其它不是异常的不需要通知
  85. * @return false|void
  86. */
  87. public static function expressErrorInform($shop, $customName, $orderId, $result)
  88. {
  89. $ptStyle = $shop->ptStyle ?? 0;
  90. $wxBase = WxOpenClass::getWxBase();
  91. $wx = $wxBase[$ptStyle] ?? [];
  92. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  93. $shortTempId = 'OPENTM408238177';
  94. $tempId = $message[$shortTempId]['templateId'] ?? '';
  95. if (empty($tempId)) {
  96. return false;
  97. }
  98. $adminList = ShopAdminClass::getRemainAdmin($shop);
  99. if (empty($adminList)) {
  100. return false;
  101. }
  102. foreach ($adminList as $admin) {
  103. $openId = $admin['openId'] ?? '';
  104. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  105. $openId = $admin['ghsOpenId'] ?? '';
  106. }
  107. if (empty($openId)) {
  108. continue;
  109. }
  110. $data = [
  111. "touser" => $openId,
  112. "template_id" => $tempId,
  113. "url" => Yii::$app->params['ghsDomain'],
  114. "data" => [
  115. "first" => ["value" => $result, "color" => "#173177"],
  116. "keyword1" => ["value" => $result, "color" => "#173177"],
  117. "keyword2" => ["value" => $customName . '的订单', "color" => "#173177"],
  118. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  119. ]
  120. ];
  121. $data['miniprogram']['appid'] = $wx['miniAppId'];
  122. $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
  123. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  124. }
  125. }
  126. //客户发留言通知花店 ssh 20250906
  127. public static function newMessageInform($shop, $result)
  128. {
  129. $ptStyle = $shop->ptStyle ?? 0;
  130. $wxBase = WxOpenClass::getWxBase();
  131. $wx = $wxBase[$ptStyle] ?? [];
  132. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  133. $shortTempId = 'OPENTM408238177';
  134. $tempId = $message[$shortTempId]['templateId'] ?? '';
  135. if (empty($tempId)) {
  136. return false;
  137. }
  138. $adminList = ShopAdminClass::getRemainAdmin($shop);
  139. if (empty($adminList)) {
  140. return false;
  141. }
  142. foreach ($adminList as $admin) {
  143. $openId = $admin['openId'] ?? '';
  144. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  145. $openId = $admin['ghsOpenId'] ?? '';
  146. }
  147. if (empty($openId)) {
  148. continue;
  149. }
  150. $data = [
  151. "touser" => $openId,
  152. "template_id" => $tempId,
  153. "url" => Yii::$app->params['ghsDomain'],
  154. "data" => [
  155. "first" => ["value" => $result, "color" => "#173177"],
  156. "keyword1" => ["value" => $result, "color" => "#173177"],
  157. "keyword2" => ["value" => '请及时回复', "color" => "#173177"],
  158. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  159. ]
  160. ];
  161. $data['miniprogram']['appid'] = $wx['miniAppId'];
  162. $data['miniprogram']['pagepath'] = 'admin/chat/list';
  163. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  164. }
  165. }
  166. //初始化消息模板
  167. // ./yii.bat wx-message/init
  168. public static function init()
  169. {
  170. $wxBase = [
  171. dict::getDict('ptStyle', 'hd') => \bizHd\wx\classes\WxOpenClass::getWxInfo(),
  172. dict::getDict('ptStyle', 'ghs') => \bizHd\wx\classes\WxOpenClass::getGhsWxInfo(),
  173. dict::getDict('ptStyle', 'mall') => \bizHd\wx\classes\WxOpenClass::getMallWxInfo(),
  174. ];
  175. $message = self::getAllByCondition([], null, '*', null, true);
  176. if (!empty($message)) {
  177. foreach ($message as $item) {
  178. $ptStyle = $item->ptStyle;
  179. $wx = $wxBase[$ptStyle] ?? [];
  180. if (empty($wx)) {
  181. util::fail('没有找到微信平台信息');
  182. }
  183. $templateId = $item->templateId;
  184. $respond = wxUtil::delTMessage($wx, $templateId, $ptStyle);
  185. if (isset($respond['errcode']) && $respond['errcode'] == 0) {
  186. $item->delete();
  187. }
  188. }
  189. }
  190. $wxMessageList = self::has();
  191. foreach ($wxMessageList as $k => $message) {
  192. $ptStyle = $k;
  193. if (empty($message)) {
  194. continue;
  195. }
  196. $wx = $wxBase[$ptStyle] ?? [];
  197. foreach ($message as $shortId => $title) {
  198. $wxReturn = wxUtil::tMessageCreate($wx, $shortId, $ptStyle);
  199. echo json_encode($wxReturn) . "\n";
  200. if (isset($wxReturn['errcode']) && $wxReturn['errcode'] == 0) {
  201. $templateId = $wxReturn['template_id'];
  202. $data = [
  203. 'shortTemplateId' => $shortId,
  204. 'templateId' => $templateId,
  205. 'templateName' => $title,
  206. 'ptStyle' => $ptStyle,
  207. ];
  208. self::add($data);
  209. //Yii::warning("add tmessage:" . $title . " success\n");
  210. } else {
  211. Yii::warning("add tmessage error:" . json_encode($wxReturn) . " \n");
  212. noticeUtil::push("add wx message {$shortId} error:" . json_encode($wxReturn), '15280215347');
  213. }
  214. }
  215. }
  216. }
  217. //供货商有新的退款申请 ssh 20230815
  218. public static function ghsHasNewRefundApplyInform($shop, $refund)
  219. {
  220. $id = $refund->id;
  221. $refundSn = $refund->orderSn ?? '';
  222. $refundType = $refund->refundType ?? 1;
  223. $refundName = $refundType == 1 ? '退货退款' : '只退款';
  224. $addTime = $refund->addTime ?? '';
  225. $refundPrice = $refund->refundPrice ?? '';
  226. $refundPrice = floatval($refundPrice);
  227. $customId = $refund->customId ?? 0;
  228. $custom = CustomClass::getById($customId, true);
  229. $customName = $custom->name ?? '--';
  230. $ptStyle = $shop->ptStyle;
  231. $wxBase = WxOpenClass::getWxBase();
  232. $wx = $wxBase[$ptStyle] ?? [];
  233. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  234. $shortTempId = 'ZHH202308150025';
  235. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  236. if (empty($tempId)) {
  237. return false;
  238. }
  239. $adminList = ShopAdminClass::getRemainAdmin($shop);
  240. if (empty($adminList)) {
  241. return false;
  242. }
  243. foreach ($adminList as $admin) {
  244. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  245. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  246. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  247. }
  248. $data = [
  249. "touser" => $openId,
  250. "template_id" => $tempId,
  251. "url" => Yii::$app->params['ghsDomain'],
  252. "data" => [
  253. "amount1" => ["value" => $refundPrice . '元'],
  254. "thing7" => ["value" => $customName],
  255. "time10" => ["value" => $addTime],
  256. "thing2" => ["value" => $refundName],
  257. "character_string3" => ["value" => $refundSn],
  258. ]
  259. ];
  260. $data['miniprogram']['appid'] = $wx['miniAppId'];
  261. $data['miniprogram']['pagepath'] = 'pagesOrder/refundDetail?from=1&id=' . $id;
  262. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  263. }
  264. }
  265. //供货商采购确认通知相关人员 ssh 20240511
  266. public static function ghsCgInform($shop, $cg)
  267. {
  268. $orderSn = $cg->orderSn ?? '';
  269. $ptStyle = $shop->ptStyle;
  270. $ghsName = $cg->ghsName ?? '';
  271. $actPrice = $cg->actPrice ?? 0;
  272. $entryTime = $cg->entryTime ?? '';
  273. $staffName = $cg->shopAdminName ?? '';
  274. $wxBase = WxOpenClass::getWxBase();
  275. $wx = $wxBase[$ptStyle] ?? [];
  276. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  277. $shortTempId = 'ZHH202405111701';
  278. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  279. if (empty($tempId)) {
  280. return false;
  281. }
  282. $adminList = ShopAdminClass::getRemainAdmin($shop);
  283. if (empty($adminList)) {
  284. return false;
  285. }
  286. foreach ($adminList as $admin) {
  287. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  288. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  289. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  290. }
  291. if (!empty($openId)) {
  292. $data = [
  293. "touser" => $openId,
  294. "template_id" => $tempId,
  295. "url" => Yii::$app->params['ghsDomain'],
  296. "data" => [
  297. "thing4" => ["value" => $ghsName],
  298. "character_string1" => ["value" => $orderSn],
  299. "amount2" => ["value" => $actPrice],
  300. "time3" => ["value" => $entryTime],
  301. "thing5" => ["value" => $staffName],
  302. ]
  303. ];
  304. $data['miniprogram']['appid'] = $wx['miniAppId'];
  305. $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
  306. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  307. }
  308. }
  309. }
  310. //供货商采购入库成功通知相关人员 ssh 20240511
  311. public static function ghsCgEntryInform($shop, $cg)
  312. {
  313. return true;
  314. $orderSn = $cg->orderSn ?? '';
  315. $ptStyle = $shop->ptStyle;
  316. $ghsName = $cg->ghsName ?? '';
  317. $actPrice = $cg->actPrice ?? 0;
  318. $entryTime = $cg->entryTime ?? '';
  319. $wxBase = WxOpenClass::getWxBase();
  320. $wx = $wxBase[$ptStyle] ?? [];
  321. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  322. $shortTempId = 'ZHH202405121036';
  323. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  324. if (empty($tempId)) {
  325. return false;
  326. }
  327. $adminList = ShopAdminClass::getRemainAdmin($shop);
  328. if (empty($adminList)) {
  329. return false;
  330. }
  331. $title = '花材';
  332. $totalNum = 0;
  333. $itemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
  334. if (!empty($itemList)) {
  335. $title = '';
  336. foreach ($itemList as $item) {
  337. $name = $item->name ?? '';
  338. if (empty($title)) {
  339. $title = $name;
  340. } else {
  341. $title .= ',' . $name;
  342. }
  343. $itemNum = $item->itemNum ?? 0;
  344. $refundNum = $item->refundNum ?? 0;
  345. $num = bcsub($itemNum, $refundNum, 2);
  346. $totalNum = bcadd($totalNum, $num, 2);
  347. }
  348. $totalNum = floatval($totalNum);
  349. $title = stringUtil::subStringUtf8($title, 15, '...');
  350. }
  351. foreach ($adminList as $admin) {
  352. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  353. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  354. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  355. }
  356. if (!empty($openId)) {
  357. $data = [
  358. "touser" => $openId,
  359. "template_id" => $tempId,
  360. "url" => Yii::$app->params['ghsDomain'],
  361. "data" => [
  362. "thing5" => ["value" => $ghsName],
  363. "character_string4" => ["value" => $orderSn],
  364. "time3" => ["value" => $entryTime],
  365. "character_string2" => ["value" => $totalNum . ' ¥' . $actPrice],
  366. "thing1" => ["value" => $title],
  367. ]
  368. ];
  369. $data['miniprogram']['appid'] = $wx['miniAppId'];
  370. $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
  371. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  372. }
  373. }
  374. }
  375. //客户结清账单提醒 ssh 20240512
  376. public static function customHasClearToGhsInform($shop, $clearInfo, $custom)
  377. {
  378. //账单编号 合同金额 客户名称
  379. $ptStyle = $shop->ptStyle;
  380. $id = $clearInfo->id ?? 0;
  381. $actPrice = $clearInfo->actPrice ?? 0;
  382. $actPrice = bcadd($actPrice, 0, 2);
  383. $customName = isset($custom->name) && !empty($custom->name) ? $custom->name : '-';
  384. $customName = stringUtil::subStringUtf8($customName, 6, '...');
  385. $orderSn = $clearInfo->orderSn ?? '';
  386. $wxBase = WxOpenClass::getWxBase();
  387. $wx = $wxBase[$ptStyle] ?? [];
  388. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  389. $shortTempId = 'ZHH202405111703';
  390. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  391. if (empty($tempId)) {
  392. return false;
  393. }
  394. $adminList = ShopAdminClass::getRemainAdmin($shop);
  395. if (empty($adminList)) {
  396. return false;
  397. }
  398. foreach ($adminList as $admin) {
  399. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  400. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  401. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  402. }
  403. if (!empty($openId)) {
  404. $data = [
  405. "touser" => $openId,
  406. "template_id" => $tempId,
  407. "url" => Yii::$app->params['ghsDomain'],
  408. "data" => [
  409. "character_string1" => ["value" => $orderSn],
  410. "amount5" => ["value" => $actPrice],
  411. "thing3" => ["value" => $customName . ' 线上结账'],
  412. ]
  413. ];
  414. $data['miniprogram']['appid'] = $wx['miniAppId'];
  415. $data['miniprogram']['pagepath'] = 'admin/clear/customInfo?id=' . $id;
  416. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  417. }
  418. }
  419. }
  420. //客户充值清账通知 ssh 20240511
  421. public static function customRechargeClearInform($shop, $recharge)
  422. {
  423. //充值金额 商品名称 姓名 操作人 充值时间
  424. $ptStyle = $shop->ptStyle;
  425. $amount = $recharge->amount ?? 0;
  426. $amount = bcadd($amount, 0, 2);
  427. $staffName = isset($recharge->staffName) && !empty($recharge->staffName) ? $recharge->staffName : '-';
  428. $onlinePay = $recharge->onlinePay ?? 1;
  429. $onlineName = $onlinePay == 1 ? '线下' : '线上';
  430. $payWay = $recharge->payWay ?? 0;
  431. $nameMap = dict::getDict('payWayName');
  432. $payWayName = $nameMap[$payWay] ?? '微信';
  433. $payName = $onlineName . $payWayName;
  434. $title = $payName . ' 付款';
  435. $customName = isset($recharge->customName) && !empty($recharge->customName) ? $recharge->customName : '-';
  436. $customName = stringUtil::subStringUtf8($customName, 6, '...');
  437. $customId = $recharge->customId ?? 0;
  438. $payTime = $recharge->payTime ?? '';
  439. $wxBase = WxOpenClass::getWxBase();
  440. $wx = $wxBase[$ptStyle] ?? [];
  441. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  442. $shortTempId = 'ZHH202405111704';
  443. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  444. if (empty($tempId)) {
  445. return false;
  446. }
  447. $adminList = ShopAdminClass::getRemainAdmin($shop);
  448. if (empty($adminList)) {
  449. return false;
  450. }
  451. foreach ($adminList as $admin) {
  452. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  453. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  454. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  455. }
  456. if (!empty($openId)) {
  457. $data = [
  458. "touser" => $openId,
  459. "template_id" => $tempId,
  460. "url" => Yii::$app->params['ghsDomain'],
  461. "data" => [
  462. "amount1" => ["value" => $amount],
  463. "thing9" => ["value" => $title],
  464. "thing7" => ["value" => $customName . ' 充值销账'],
  465. "thing11" => ["value" => $staffName],
  466. "time3" => ["value" => $payTime],
  467. ]
  468. ];
  469. $data['miniprogram']['appid'] = $wx['miniAppId'];
  470. $data['miniprogram']['pagepath'] = 'admin/custom/balanceChange?customId=' . $customId;
  471. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  472. }
  473. }
  474. }
  475. //供货商重复打印通知 ssh 20240511
  476. public static function ghsCgRepeatPrintInform($cg)
  477. {
  478. $shopId = $cg->shopId ?? 0;
  479. $shop = ShopClass::getById($shopId, true);
  480. if (empty($shop)) {
  481. return false;
  482. }
  483. $orderSn = $cg->orderSn ?? '';
  484. $num = $cg->printNum ?? 0;
  485. $ptStyle = $shop->ptStyle;
  486. $ghsName = $cg->ghsName ?? '';
  487. $ghsName = stringUtil::subStringUtf8($ghsName, 6, '...');
  488. $staffName = $cg->shopAdminName ?? '';
  489. $wxBase = WxOpenClass::getWxBase();
  490. $wx = $wxBase[$ptStyle] ?? [];
  491. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  492. $shortTempId = 'ZHH202405111702';
  493. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  494. if (empty($tempId)) {
  495. return false;
  496. }
  497. $adminList = ShopAdminClass::getRemainAdmin($shop);
  498. if (empty($adminList)) {
  499. return false;
  500. }
  501. foreach ($adminList as $admin) {
  502. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  503. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  504. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  505. }
  506. if (!empty($openId)) {
  507. $data = [
  508. "touser" => $openId,
  509. "template_id" => $tempId,
  510. "url" => Yii::$app->params['ghsDomain'],
  511. "data" => [
  512. "character_string20" => ["value" => $orderSn],
  513. "thing13" => ["value" => $ghsName],
  514. "thing17" => ["value" => "采购单 打印了【{$num}】次"],
  515. "thing23" => ["value" => $staffName],
  516. ]
  517. ];
  518. $data['miniprogram']['appid'] = $wx['miniAppId'];
  519. $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
  520. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  521. }
  522. }
  523. }
  524. //供货商新订单通知 ssh 20210529
  525. public static function ghsHasNewOrderInform($shop, $order)
  526. {
  527. if ($order->payStatus != 1) {
  528. return false;
  529. }
  530. $ptStyle = $shop->ptStyle;
  531. $wxBase = WxOpenClass::getWxBase();
  532. $wx = $wxBase[$ptStyle] ?? [];
  533. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  534. $shortTempId = 'OPENTM417875155';//新订单通知
  535. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  536. if (empty($tempId)) {
  537. return false;
  538. }
  539. $title = '';
  540. if (isset($order->book) && $order->book == 1) {
  541. $title = '【预订】';
  542. }
  543. if (isset($order->presell) && $order->presell == 1) {
  544. $title = '【预售】';
  545. }
  546. $orderId = $order->id;
  547. $actPrice = $order->actPrice;
  548. $actPrice = floatval($actPrice);
  549. $shopName = $shop->shopName ?? '';
  550. $first = isset($order->shopAdminId) && !empty($order->shopAdminId) ? "【门店开单】" : "";
  551. $customName = $order->customName ?? '';
  552. $customName = stringUtil::subStringUtf8($customName, 5, '...');
  553. $adminList = ShopAdminClass::getRemainAdmin($shop);
  554. if (empty($adminList)) {
  555. return false;
  556. }
  557. foreach ($adminList as $admin) {
  558. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  559. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  560. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  561. }
  562. $orderSn = $shopName == '首店' ? $order->orderSn : $shopName;
  563. $data = [
  564. "touser" => $openId,
  565. "template_id" => $tempId,
  566. "url" => Yii::$app->params['ghsDomain'],
  567. "data" => [
  568. "first" => ["value" => '', "color" => "#173177"],
  569. "keyword1" => ["value" => $orderSn . $title, "color" => "#173177"],
  570. "keyword2" => ["value" => $customName . ' ¥' . $actPrice . $first, "color" => "#173177"],
  571. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  572. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  573. ]
  574. ];
  575. $data['miniprogram']['appid'] = $wx['miniAppId'];
  576. $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
  577. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  578. }
  579. }
  580. //预订增加减少通知 ssh 20240820
  581. public static function bookChangeInform($shop, $arr)
  582. {
  583. $orderId = $arr['orderId'] ?? 0;
  584. $ptStyle = $shop->ptStyle;
  585. $wxBase = WxOpenClass::getWxBase();
  586. $wx = $wxBase[$ptStyle] ?? [];
  587. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  588. $shortTempId = 'OPENTM417875155';
  589. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  590. if (empty($tempId)) {
  591. return false;
  592. }
  593. $itemName = $arr['itemName'] ?? '';
  594. $io = $arr['io'] ?? 0;
  595. $plus = $io == 1 ? '加' : '减';
  596. $num = $arr['num'] ?? 0;
  597. $title = $plus . $num . ' ' . $itemName;
  598. $customName = $arr['customName'] ?? '';
  599. $customName = stringUtil::subStringUtf8($customName, 5, '...');
  600. $adminList = ShopAdminClass::getRemainAdmin($shop);
  601. if (empty($adminList)) {
  602. return false;
  603. }
  604. foreach ($adminList as $admin) {
  605. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  606. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  607. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  608. }
  609. $data = [
  610. "touser" => $openId,
  611. "template_id" => $tempId,
  612. "url" => Yii::$app->params['ghsDomain'],
  613. "data" => [
  614. "first" => ["value" => '', "color" => "#173177"],
  615. "keyword1" => ["value" => $title, "color" => "#173177"],
  616. "keyword2" => ["value" => '客户-' . $customName, "color" => "#173177"],
  617. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  618. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  619. ]
  620. ];
  621. $data['miniprogram']['appid'] = $wx['miniAppId'];
  622. $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
  623. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  624. }
  625. }
  626. //花店新采购单通知 ssh 20231128
  627. public static function hdNewCgOrderInform($shop, $cg)
  628. {
  629. $ptStyle = $shop->ptStyle;
  630. $wxBase = WxOpenClass::getWxBase();
  631. $wx = $wxBase[$ptStyle] ?? [];
  632. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  633. //采购申请处理通知
  634. $shortTempId = 'ZHH202311282308';
  635. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  636. if (empty($tempId)) {
  637. return false;
  638. }
  639. $id = $cg->id;
  640. $ghsName = $cg->ghsName;
  641. $actPrice = $cg->actPrice;
  642. $book = $cg->book;
  643. $goods = '花材';
  644. $status = $cg->status;
  645. if ($status == 1) {
  646. $road = '待付款';
  647. } elseif ($status == 2) {
  648. $road = '待发货';
  649. if ($book == 0) {
  650. $goods = '请查阅';
  651. } else {
  652. $goods = '请查阅(预订)';
  653. }
  654. } elseif ($status == 3) {
  655. $road = '已发货';
  656. if ($book == 0) {
  657. $goods = '请查阅';
  658. } else {
  659. $goods = '请查阅(预订)';
  660. }
  661. } elseif ($status == 4) {
  662. $road = '已完成';
  663. } else {
  664. $road = '已取消';
  665. }
  666. $adminList = ShopAdminClass::getRemainAdmin($shop);
  667. if (empty($adminList)) {
  668. return false;
  669. }
  670. foreach ($adminList as $admin) {
  671. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  672. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  673. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  674. }
  675. $data = [
  676. "touser" => $openId,
  677. "template_id" => $tempId,
  678. "url" => Yii::$app->params['ghsDomain'],
  679. "data" => [
  680. "thing12" => ["value" => $ghsName],
  681. "thing7" => ["value" => $goods],
  682. "amount10" => ["value" => $actPrice],
  683. "phrase4" => ["value" => $road],
  684. ]
  685. ];
  686. $data['miniprogram']['appid'] = $wx['miniAppId'];
  687. $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $id;
  688. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  689. }
  690. }
  691. //花店新订单通知 ssh 20210529
  692. public static function hdNewOrderInform($shop, $order)
  693. {
  694. $ptStyle = $shop->ptStyle;
  695. $wxBase = WxOpenClass::getWxBase();
  696. $wx = $wxBase[$ptStyle] ?? [];
  697. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  698. $shortTempId = 'OPENTM417875155';//新订单通知
  699. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  700. if (empty($tempId)) {
  701. return false;
  702. }
  703. $orderId = $order->id;
  704. $actPrice = $order->actPrice;
  705. $adminList = ShopAdminClass::getRemainAdmin($shop);
  706. if (empty($adminList)) {
  707. return false;
  708. }
  709. foreach ($adminList as $admin) {
  710. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  711. if (empty($openId)) {
  712. continue;
  713. }
  714. $data = [
  715. "touser" => $openId,
  716. "template_id" => $tempId,
  717. "url" => Yii::$app->params['ghsDomain'],
  718. "data" => [
  719. "first" => ["value" => "您有新的订单,请注意查收", "color" => "#173177"],
  720. "keyword1" => ["value" => $order->orderSn, "color" => "#173177"],
  721. "keyword2" => ["value" => $actPrice, "color" => "#173177"],
  722. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  723. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  724. ]
  725. ];
  726. $data['miniprogram']['appid'] = $wx['miniAppId'];
  727. $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
  728. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  729. }
  730. }
  731. //审核通过通知 ssh 20210530
  732. public static function applyPass($shop)
  733. {
  734. $ptStyle = $shop->ptStyle;
  735. $wxBase = WxOpenClass::getWxBase();
  736. $wx = $wxBase[$ptStyle] ?? [];
  737. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  738. $shortTempId = 'OPENTM401915538';//审核通过通知
  739. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  740. if (empty($tempId)) {
  741. return false;
  742. }
  743. $adminList = ShopAdminClass::getRemainAdmin($shop);
  744. if (empty($adminList)) {
  745. return false;
  746. }
  747. foreach ($adminList as $admin) {
  748. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  749. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  750. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  751. }
  752. if (empty($openId)) {
  753. continue;
  754. }
  755. $data = array(
  756. "touser" => $openId,
  757. "template_id" => $tempId,
  758. "url" => Yii::$app->params['ghsDomain'],
  759. "data" => array(
  760. "first" => array(
  761. "value" => "恭喜,您的开店申请审核通过。",
  762. "color" => "#173177"
  763. ),
  764. "keyword1" => array(
  765. "value" => '审核通过',
  766. "color" => "#173177"
  767. ),
  768. "keyword2" => array(
  769. "value" => date("Y-m-d H:i:s"),
  770. "color" => "#173177"
  771. ),
  772. "remark" => array(
  773. "value" => '点击登陆后台',
  774. "color" => "#173177"
  775. )
  776. ),
  777. );
  778. $data['miniprogram']['appid'] = $wx['miniAppId'];
  779. $data['miniprogram']['pagepath'] = 'admin/home/workbench';
  780. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  781. }
  782. }
  783. //采购单下单成功 ssh 20210531
  784. public static function generateCgOrder($shop, $order)
  785. {
  786. $ptStyle = $shop->ptStyle;
  787. $wxBase = WxOpenClass::getWxBase();
  788. $wx = $wxBase[$ptStyle] ?? [];
  789. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  790. $shortTempId = 'OPENTM202297555';//下单成功通知
  791. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  792. if (empty($tempId)) {
  793. return false;
  794. }
  795. $orderId = $order->id;
  796. $orderSn = (string)$order->orderSn;
  797. $totalFee = $order->actPrice;
  798. $adminList = ShopAdminClass::getRemainAdmin($shop);
  799. if (empty($adminList)) {
  800. return false;
  801. }
  802. foreach ($adminList as $admin) {
  803. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  804. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  805. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  806. }
  807. if (empty($openId)) {
  808. continue;
  809. }
  810. $data = [
  811. "touser" => $openId,
  812. "template_id" => $tempId,
  813. "url" => Yii::$app->params['ghsDomain'],
  814. "data" => [
  815. "first" => ["value" => '亲,您的采购单已生成', "color" => "#173177"],
  816. "keyword1" => ["value" => $orderSn, "color" => "#173177"],
  817. "keyword2" => ["value" => '花材', "color" => "#173177"],
  818. "keyword3" => ["value" => $order->bigNum . '/' . $order->smallNum, "color" => "#173177"],
  819. "keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  820. "keyword5" => ["value" => '-', "color" => "#173177"],
  821. "remark" => ["value" => "", "color" => "#173177"]
  822. ]
  823. ];
  824. $data['miniprogram']['appid'] = $wx['miniAppId'];
  825. $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
  826. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  827. }
  828. }
  829. //采购单已发货 ssh 20210531
  830. public static function cgOrderHasSend($shop, $order)
  831. {
  832. $ptStyle = $shop->ptStyle;
  833. $wxBase = WxOpenClass::getWxBase();
  834. $wx = $wxBase[$ptStyle] ?? [];
  835. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  836. $shortTempId = 'OPENTM416881153';//下单成功通知
  837. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  838. if (empty($tempId)) {
  839. return false;
  840. }
  841. $orderId = $order->id;
  842. $orderSn = (string)$order->orderSn;
  843. $adminList = ShopAdminClass::getRemainAdmin($shop);
  844. if (empty($adminList)) {
  845. return false;
  846. }
  847. $ghsShopAdminName = $order->ghsShopAdminName ?? '';
  848. foreach ($adminList as $admin) {
  849. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  850. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  851. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  852. }
  853. if (empty($openId)) {
  854. continue;
  855. }
  856. $data = [
  857. "touser" => $openId,
  858. "template_id" => $tempId,
  859. "url" => Yii::$app->params['ghsDomain'],
  860. "data" => [
  861. "first" => ["value" => '亲,您的采购单已发货,请注意签收', "color" => "#173177"],
  862. "keyword1" => ["value" => $orderSn, "color" => "#173177"],
  863. "keyword2" => ["value" => date("Y-m-d H:i:s"), "color" => "#173177"],
  864. "keyword3" => ["value" => $ghsShopAdminName, "color" => "#173177"],
  865. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  866. ]
  867. ];
  868. $data['miniprogram']['appid'] = $wx['miniAppId'];
  869. $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
  870. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  871. }
  872. }
  873. //零售清算欠款通知供货商 ssh 20210531
  874. public static function clearInform($shop, $order, $custom)
  875. {
  876. $ptStyle = $shop->ptStyle;
  877. $wxBase = WxOpenClass::getWxBase();
  878. $wx = $wxBase[$ptStyle] ?? [];
  879. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  880. $shortTempId = 'OPENTM207422813';//收入提醒
  881. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  882. if (empty($tempId)) {
  883. return false;
  884. }
  885. $id = $order->id ?? 0;
  886. $actPrice = $order->actPrice;
  887. $actPrice = floatval($actPrice);
  888. $name = $custom->name ?? '';
  889. $adminList = ShopAdminClass::getRemainAdmin($shop);
  890. if (empty($adminList)) {
  891. return false;
  892. }
  893. foreach ($adminList as $admin) {
  894. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  895. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  896. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  897. }
  898. if (empty($openId)) {
  899. continue;
  900. }
  901. $data = [
  902. "touser" => $openId,
  903. "template_id" => $tempId,
  904. "url" => Yii::$app->params['ghsDomain'],
  905. "data" => [
  906. "first" => ["value" => "", "color" => "#173177"],
  907. "keyword1" => ["value" => '¥' . $actPrice, "color" => "#173177"],
  908. "keyword2" => ["value" => "{$name} 线上结账", "color" => "#173177"],
  909. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  910. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  911. ]
  912. ];
  913. $data['miniprogram']['appid'] = $wx['miniAppId'];
  914. $data['miniprogram']['pagepath'] = 'admin/clear/customInfo?id=' . $id;
  915. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  916. }
  917. }
  918. //收款码收入通知 ssh 20210531
  919. public static function gatheringIncomeInform($shop, $order)
  920. {
  921. if ($order->payStatus != 1) {
  922. return false;
  923. }
  924. $ptStyle = $shop->ptStyle;
  925. $wxBase = WxOpenClass::getWxBase();
  926. $wx = $wxBase[$ptStyle] ?? [];
  927. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  928. $shortTempId = 'OPENTM207422813';//收入提醒
  929. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  930. if (empty($tempId)) {
  931. return false;
  932. }
  933. $actPrice = $order->actPrice;
  934. $orderId = $order->id;
  935. $adminList = ShopAdminClass::getRemainAdmin($shop);
  936. if (empty($adminList)) {
  937. return false;
  938. }
  939. foreach ($adminList as $admin) {
  940. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  941. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  942. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  943. }
  944. if (empty($openId)) {
  945. continue;
  946. }
  947. $data = [
  948. "touser" => $openId,
  949. "template_id" => $tempId,
  950. "url" => Yii::$app->params['ghsDomain'],
  951. "data" => [
  952. "first" => ["value" => "您有新的收入。", "color" => "#173177"],
  953. "keyword1" => ["value" => $actPrice, "color" => "#173177"],
  954. "keyword2" => ["value" => '门店收入', "color" => "#173177"],
  955. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  956. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  957. ]
  958. ];
  959. $data['miniprogram']['appid'] = $wx['miniAppId'];
  960. $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
  961. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  962. }
  963. }
  964. //提现成功通知 ssh 20210531
  965. public static function cashInform($shop, $cash)
  966. {
  967. $ptStyle = $shop->ptStyle;
  968. $wxBase = WxOpenClass::getWxBase();
  969. $wx = $wxBase[$ptStyle] ?? [];
  970. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  971. $shortTempId = 'OPENTM411207151';
  972. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  973. if (empty($tempId)) {
  974. return false;
  975. }
  976. $amount = floatval($cash->amount);
  977. $beAmount = floatval($cash->beAmount);
  978. $adminList = ShopAdminClass::getRemainAdmin($shop);
  979. if (empty($adminList)) {
  980. return false;
  981. }
  982. $mainId = $shop->mainId ?? 0;
  983. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', 'adminId');
  984. foreach ($adminList as $admin) {
  985. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  986. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  987. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  988. }
  989. if (empty($openId)) {
  990. continue;
  991. }
  992. $adminId = $admin['id'] ?? 0;
  993. $super = $staffList[$adminId]['super'] ?? 0;
  994. //提现管理员才通知
  995. if ($super == 0) {
  996. continue;
  997. }
  998. $data = [
  999. "touser" => $openId,
  1000. "template_id" => $tempId,
  1001. "url" => Yii::$app->params['ghsDomain'],
  1002. "data" => [
  1003. "first" => ["value" => "", "color" => "#173177"],
  1004. "keyword1" => ["value" => "¥{$beAmount}", "color" => "#173177"],
  1005. "keyword2" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  1006. "remark" => ["value" => '', "color" => "#173177"]
  1007. ]
  1008. ];
  1009. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1010. $data['miniprogram']['pagepath'] = 'pagesStore/me/cashInfo?id=' . $cash->id;
  1011. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1012. }
  1013. }
  1014. //订单送达通知 ssh 20210607
  1015. public static function reachInform($shop, $order)
  1016. {
  1017. $ptStyle = $shop->ptStyle;
  1018. $wxBase = WxOpenClass::getWxBase();
  1019. $wx = $wxBase[$ptStyle] ?? [];
  1020. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1021. $shortTempId = 'OPENTM201205968';
  1022. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1023. if (empty($tempId)) {
  1024. return false;
  1025. }
  1026. $orderId = $order->id ?? '';
  1027. $orderSn = (string)$order->orderSn ?? '';
  1028. $customName = $order->customName ?? '';
  1029. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1030. if (empty($adminList)) {
  1031. return false;
  1032. }
  1033. foreach ($adminList as $admin) {
  1034. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1035. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1036. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1037. }
  1038. if (empty($openId)) {
  1039. continue;
  1040. }
  1041. $data = [
  1042. "touser" => $openId,
  1043. "template_id" => $tempId,
  1044. "url" => Yii::$app->params['ghsDomain'],
  1045. "data" => [
  1046. "first" => ["value" => '客户订单已送达', "color" => "#173177"],
  1047. "keyword1" => ["value" => $orderSn, "color" => "#173177"],
  1048. "keyword2" => ["value" => $customName, "color" => "#173177"],
  1049. "keyword3" => ["value" => '已送达', "color" => "#173177"],
  1050. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1051. ]
  1052. ];
  1053. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1054. $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
  1055. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1056. }
  1057. }
  1058. //采购退款成功通知 ssh 20210730
  1059. public static function cgRefundInform($shop, $cg, $amount)
  1060. {
  1061. $ptStyle = $shop->ptStyle;
  1062. $wxBase = WxOpenClass::getWxBase();
  1063. $wx = $wxBase[$ptStyle] ?? [];
  1064. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1065. $shortTempId = 'OPENTM407280253';
  1066. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1067. if (empty($tempId)) {
  1068. return false;
  1069. }
  1070. $orderId = $cg->id ?? '';
  1071. $orderSn = (string)$cg->orderSn ?? '';
  1072. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1073. if (empty($adminList)) {
  1074. return false;
  1075. }
  1076. foreach ($adminList as $admin) {
  1077. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1078. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1079. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1080. }
  1081. if (empty($openId)) {
  1082. continue;
  1083. }
  1084. $data = [
  1085. "touser" => $openId,
  1086. "template_id" => $tempId,
  1087. "url" => Yii::$app->params['ghsDomain'],
  1088. "data" => [
  1089. "first" => ["value" => '采购单:' . $orderSn, "color" => "#173177"],
  1090. "keyword1" => ["value" => "订单退款", "color" => "#173177"],
  1091. "keyword2" => ["value" => $amount . "元", "color" => "#173177"],
  1092. "keyword3" => ["value" => '已送达', "color" => "#173177"],
  1093. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1094. ]
  1095. ];
  1096. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1097. $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
  1098. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1099. }
  1100. }
  1101. //库存预警通知 ssh 20210909
  1102. public static function stockWarningInform($shop, $productList)
  1103. {
  1104. if (empty($productList)) {
  1105. return false;
  1106. }
  1107. $remark = '';
  1108. foreach ($productList as $key => $product) {
  1109. $stock = $product->stock ?? 0;
  1110. $currentStock = floatval($stock);
  1111. $name = $product->name ?? '';
  1112. $remark .= $name . "({$currentStock}) ";
  1113. }
  1114. $ptStyle = $shop->ptStyle;
  1115. $wxBase = WxOpenClass::getWxBase();
  1116. $wx = $wxBase[$ptStyle] ?? [];
  1117. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1118. $shortTempId = 'OPENTM206773265';
  1119. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1120. if (empty($tempId)) {
  1121. return false;
  1122. }
  1123. $shopName = $shop->shopName ?? '';
  1124. $date = date("Y-m-d H:i:s");
  1125. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1126. if (empty($adminList)) {
  1127. return false;
  1128. }
  1129. foreach ($adminList as $admin) {
  1130. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1131. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1132. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1133. }
  1134. if (empty($openId)) {
  1135. continue;
  1136. }
  1137. $data = [
  1138. "touser" => $openId,
  1139. "template_id" => $tempId,
  1140. "url" => Yii::$app->params['ghsDomain'],
  1141. "data" => [
  1142. "first" => ["value" => "", "color" => "#173177"],
  1143. "keyword1" => ["value" => $shopName, "color" => "#173177"],
  1144. "keyword2" => ["value" => "点击查看花材", "color" => "#173177"],
  1145. "keyword3" => ["value" => "库存不足", "color" => "#D52B4D"],
  1146. "keyword4" => ["value" => $date, "color" => "#173177"],
  1147. "remark" => ["value" => $remark, "color" => "#D52B4D"]
  1148. ]
  1149. ];
  1150. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1151. $data['miniprogram']['pagepath'] = 'admin/item/list?warning=1';
  1152. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1153. }
  1154. }
  1155. //供货商客户领取了新人红包 ssh 20211027
  1156. public static function ghsCustomGetNewGiftInform($shop, $custom)
  1157. {
  1158. $ptStyle = $shop->ptStyle ?? 0;
  1159. $wxBase = WxOpenClass::getWxBase();
  1160. $wx = $wxBase[$ptStyle] ?? [];
  1161. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1162. $shortTempId = 'OPENTM408238177';
  1163. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1164. if (empty($tempId)) {
  1165. return false;
  1166. }
  1167. $customId = $custom['id'] ?? 0;
  1168. $customName = $custom['name'] ?? '';
  1169. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1170. if (empty($adminList)) {
  1171. return false;
  1172. }
  1173. foreach ($adminList as $admin) {
  1174. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1175. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1176. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1177. }
  1178. if (empty($openId)) {
  1179. continue;
  1180. }
  1181. $data = [
  1182. "touser" => $openId,
  1183. "template_id" => $tempId,
  1184. "url" => Yii::$app->params['ghsDomain'],
  1185. "data" => [
  1186. "first" => ["value" => $customName . " 领取了新客红包", "color" => "#173177"],
  1187. "keyword1" => ["value" => "新客红包", "color" => "#173177"],
  1188. "keyword2" => ["value" => "已领取", "color" => "#173177"],
  1189. "remark" => ["value" => '点击查看客户', "color" => "#173177"]
  1190. ]
  1191. ];
  1192. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1193. $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
  1194. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1195. }
  1196. }
  1197. //供货商的客户介绍新客并且下单,获得红包通知商家 ssh 20211027
  1198. public static function ghsCustomTjGetGiftInform($shop, $custom, $beTjCustom)
  1199. {
  1200. $ptStyle = $shop->ptStyle ?? 0;
  1201. $wxBase = WxOpenClass::getWxBase();
  1202. $wx = $wxBase[$ptStyle] ?? [];
  1203. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1204. $shortTempId = 'OPENTM408238177';
  1205. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1206. if (empty($tempId)) {
  1207. return false;
  1208. }
  1209. $customId = $custom->id ?? 0;
  1210. $customName = $custom->name ?? '';
  1211. $beTjCustomName = $beTjCustom->name ?? '';
  1212. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1213. if (empty($adminList)) {
  1214. return false;
  1215. }
  1216. foreach ($adminList as $admin) {
  1217. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1218. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1219. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1220. }
  1221. if (empty($openId)) {
  1222. continue;
  1223. }
  1224. $data = [
  1225. "touser" => $openId,
  1226. "template_id" => $tempId,
  1227. "url" => Yii::$app->params['ghsDomain'],
  1228. "data" => [
  1229. "first" => ["value" => "【{$beTjCustomName}】推荐的客户【{$customName}】已下单", "color" => "#173177"],
  1230. "keyword1" => ["value" => "推荐新客红包", "color" => "#173177"],
  1231. "keyword2" => ["value" => "已发放给【{$beTjCustomName}】", "color" => "#173177"],
  1232. "remark" => ["value" => '点击查看客户', "color" => "#173177"]
  1233. ]
  1234. ];
  1235. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1236. $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
  1237. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1238. }
  1239. }
  1240. //花店推荐供货商客户获得红包 ssh 20211027
  1241. public static function hdTjGhsCustomGetGiftInform($shop, $ghs, $beTjCustom)
  1242. {
  1243. $ptStyle = $shop->ptStyle ?? 0;
  1244. $wxBase = WxOpenClass::getWxBase();
  1245. $wx = $wxBase[$ptStyle] ?? [];
  1246. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1247. $shortTempId = 'OPENTM408238177';
  1248. $tempId = $message[$shortTempId]['templateId'] ?? '';
  1249. if (empty($tempId)) {
  1250. return false;
  1251. }
  1252. $beTjCustomName = $beTjCustom->name ?? '';
  1253. $ghsName = $ghs->name ?? '';
  1254. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1255. if (empty($adminList)) {
  1256. return false;
  1257. }
  1258. foreach ($adminList as $admin) {
  1259. $openId = $admin['openId'] ?? '';
  1260. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1261. $openId = $admin['ghsOpenId'] ?? '';
  1262. }
  1263. if (empty($openId)) {
  1264. continue;
  1265. }
  1266. $data = [
  1267. "touser" => $openId,
  1268. "template_id" => $tempId,
  1269. "url" => Yii::$app->params['ghsDomain'],
  1270. "data" => [
  1271. "first" => ["value" => "您推荐的客户【{$beTjCustomName}】已在【{$ghsName}】下单", "color" => "#173177"],
  1272. "keyword1" => ["value" => "推荐新客红包", "color" => "#173177"],
  1273. "keyword2" => ["value" => "已获得", "color" => "#173177"],
  1274. "remark" => ["value" => '点击查看红包', "color" => "#173177"]
  1275. ]
  1276. ];
  1277. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1278. $data['miniprogram']['pagepath'] = 'admin/coupon/couponList';
  1279. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1280. }
  1281. }
  1282. //供货商新客户通知 ssh 20210909
  1283. public static function newGhsCustomInform($shop, $custom, $introduce = [])
  1284. {
  1285. $ptStyle = $shop->ptStyle ?? 0;
  1286. $wxBase = WxOpenClass::getWxBase();
  1287. $wx = $wxBase[$ptStyle] ?? [];
  1288. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1289. $shortTempId = 'OPENTM203447669';
  1290. $tempId = $message[$shortTempId]['templateId'] ?? '';
  1291. if (empty($tempId)) {
  1292. return false;
  1293. }
  1294. $customId = $custom->id ?? 0;
  1295. $customName = $custom->name ?? '';
  1296. $date = date("Y-m-d H:i:s");
  1297. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1298. if (empty($adminList)) {
  1299. return false;
  1300. }
  1301. $first = '';
  1302. if (!empty($introduce)) {
  1303. $introName = $introduce->name ?? '';
  1304. $first = "此客户由【{$introName}】介绍";
  1305. }
  1306. foreach ($adminList as $admin) {
  1307. $openId = $admin['openId'] ?? '';
  1308. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1309. $openId = $admin['ghsOpenId'] ?? '';
  1310. }
  1311. if (empty($openId)) {
  1312. continue;
  1313. }
  1314. $data = [
  1315. "touser" => $openId,
  1316. "template_id" => $tempId,
  1317. "url" => Yii::$app->params['ghsDomain'],
  1318. "data" => [
  1319. "first" => ["value" => $first, "color" => "#173177"],
  1320. "keyword1" => ["value" => $customId, "color" => "#173177"],
  1321. "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
  1322. "keyword3" => ["value" => $date, "color" => "#173177"],
  1323. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1324. ]
  1325. ];
  1326. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1327. $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
  1328. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1329. }
  1330. }
  1331. //客户充值通知供货商 ssh 20211005
  1332. public static function customRechargeInformGhs($recharge)
  1333. {
  1334. $amount = $recharge->amount ?? 0;
  1335. $hbId = $recharge->hbId ?? 0;
  1336. $ghsId = $recharge->ghsId ?? 0;
  1337. if (empty($ghsId)) {
  1338. return false;
  1339. }
  1340. if (empty($hbId)) {
  1341. return false;
  1342. }
  1343. $ghsInfo = GhsClass::getById($ghsId, true);
  1344. $shopId = $ghsInfo->shopId ?? 0;
  1345. $customId = $ghsInfo->customId ?? 0;
  1346. $customInfo = CustomClass::getById($customId, true);
  1347. $customName = $customInfo->name ?? '';
  1348. $shopInfo = ShopClass::getById($shopId, true);
  1349. $ptStyle = $shopInfo->ptStyle ?? 0;
  1350. $wxBase = WxOpenClass::getWxBase();
  1351. $wx = $wxBase[$ptStyle] ?? [];
  1352. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1353. $shortTempId = 'OPENTM411530050';
  1354. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1355. if (empty($tempId)) {
  1356. return false;
  1357. }
  1358. $adminList = ShopAdminClass::getRemainAdmin($shopInfo);
  1359. if (empty($adminList)) {
  1360. return false;
  1361. }
  1362. foreach ($adminList as $admin) {
  1363. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1364. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1365. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1366. }
  1367. if (empty($openId)) {
  1368. continue;
  1369. }
  1370. $data = [
  1371. "touser" => $openId,
  1372. "template_id" => $tempId,
  1373. "url" => Yii::$app->params['ghsDomain'],
  1374. "data" => [
  1375. "first" => ["value" => "有新客户充值", "color" => "#173177"],
  1376. "keyword1" => ["value" => $customName, "color" => "#173177"],
  1377. "keyword2" => ["value" => $customId, "color" => "#D52B4D"],
  1378. "keyword3" => ["value" => $amount, "color" => "#173177"],
  1379. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1380. ]
  1381. ];
  1382. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1383. $data['miniprogram']['pagepath'] = 'admin/hb/rechargeList';
  1384. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1385. }
  1386. }
  1387. //花店新客户通知 ssh 20220919
  1388. public static function newHdCustomInform($shop, $custom, $introduce = [])
  1389. {
  1390. $ptStyle = $shop->ptStyle ?? 0;
  1391. $wxBase = WxOpenClass::getWxBase();
  1392. $wx = $wxBase[$ptStyle] ?? [];
  1393. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1394. $shortTempId = 'OPENTM203447669';
  1395. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1396. if (empty($tempId)) {
  1397. return false;
  1398. }
  1399. $customId = $custom->id ?? 0;
  1400. $customName = $custom->name ?? '';
  1401. $date = date("Y-m-d H:i:s");
  1402. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1403. if (empty($adminList)) {
  1404. return false;
  1405. }
  1406. $first = '';
  1407. foreach ($adminList as $admin) {
  1408. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1409. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1410. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1411. }
  1412. if (empty($openId)) {
  1413. continue;
  1414. }
  1415. $data = [
  1416. "touser" => $openId,
  1417. "template_id" => $tempId,
  1418. "url" => Yii::$app->params['ghsDomain'],
  1419. "data" => [
  1420. "first" => ["value" => $first, "color" => "#173177"],
  1421. "keyword1" => ["value" => $customId, "color" => "#173177"],
  1422. "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
  1423. "keyword3" => ["value" => $date, "color" => "#173177"],
  1424. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1425. ]
  1426. ];
  1427. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1428. $data['miniprogram']['pagepath'] = 'admin/member/detail?id=' . $customId;
  1429. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1430. }
  1431. }
  1432. //预订变化通知供货商员工下架花材 ssh 20240729
  1433. public static function bookChangeOutStockInform($shop, $bookItemCustomRes, $num)
  1434. {
  1435. $ptStyle = $shop->ptStyle;
  1436. $wxBase = WxOpenClass::getWxBase();
  1437. $wx = $wxBase[$ptStyle] ?? [];
  1438. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1439. //取货提醒
  1440. $shortTempId = 'ZHH202407100108';
  1441. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1442. if (empty($tempId)) {
  1443. return false;
  1444. }
  1445. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1446. if (empty($adminList)) {
  1447. return false;
  1448. }
  1449. $itemId = $bookItemCustomRes->itemId ?? 0;
  1450. $itemName = $bookItemCustomRes->name ?? '';
  1451. $customName = $bookItemCustomRes->customName ?? '';
  1452. $seatSn = $bookItemCustomRes->seatSn ?? 0;
  1453. $seatName = empty($seatSn) ? '' : $seatSn;
  1454. foreach ($adminList as $admin) {
  1455. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1456. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1457. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1458. }
  1459. $data = [
  1460. "touser" => $openId,
  1461. "template_id" => $tempId,
  1462. "url" => Yii::$app->params['ghsDomain'],
  1463. "data" => [
  1464. "thing8" => ["value" => $customName . ' ' . $seatName],
  1465. "thing10" => ["value" => '请下架' . $num . '份'],
  1466. "thing7" => ["value" => $itemName],
  1467. ]
  1468. ];
  1469. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1470. $data['miniprogram']['pagepath'] = 'admin/notice/index';
  1471. //$data['miniprogram']['pagepath'] = 'admin/book/itemCustom?itemId=' . $itemId . '&itemName=' . $itemName;
  1472. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1473. }
  1474. }
  1475. }