WxMessageClass.php 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  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. public static function hdScanPayInform($shop, $scan)
  732. {
  733. if (empty($shop)) {
  734. return false;
  735. }
  736. $ptStyle = $shop->ptStyle;
  737. $wxBase = WxOpenClass::getWxBase();
  738. $wx = $wxBase[$ptStyle] ?? [];
  739. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  740. $shortTempId = 'OPENTM207422813';//收入提醒
  741. $tempId = $message[$shortTempId]['templateId'] ?? '';
  742. if (empty($tempId)) {
  743. return false;
  744. }
  745. $actPrice = $scan->actPrice;
  746. $adminList = ShopAdminClass::getRemainAdmin($shop);
  747. if (empty($adminList)) {
  748. return false;
  749. }
  750. foreach ($adminList as $admin) {
  751. $openId = $admin['openId'] ?? '';
  752. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  753. $openId = $admin['ghsOpenId'] ?? '';
  754. }
  755. if (empty($openId)) {
  756. continue;
  757. }
  758. $data = [
  759. "touser" => $openId,
  760. "template_id" => $tempId,
  761. "url" => Yii::$app->params['ghsDomain'],
  762. "data" => [
  763. "first" => ["value" => "您有新的收入。", "color" => "#173177"],
  764. "keyword1" => ["value" => $actPrice, "color" => "#173177"],
  765. "keyword2" => ["value" => '二维码收款', "color" => "#173177"],
  766. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  767. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  768. ]
  769. ];
  770. $data['miniprogram']['appid'] = $wx['miniAppId'];
  771. $data['miniprogram']['pagepath'] = 'admin/order/scanPay';
  772. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  773. }
  774. }
  775. //审核通过通知 ssh 20210530
  776. public static function applyPass($shop)
  777. {
  778. $ptStyle = $shop->ptStyle;
  779. $wxBase = WxOpenClass::getWxBase();
  780. $wx = $wxBase[$ptStyle] ?? [];
  781. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  782. $shortTempId = 'OPENTM401915538';//审核通过通知
  783. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  784. if (empty($tempId)) {
  785. return false;
  786. }
  787. $adminList = ShopAdminClass::getRemainAdmin($shop);
  788. if (empty($adminList)) {
  789. return false;
  790. }
  791. foreach ($adminList as $admin) {
  792. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  793. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  794. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  795. }
  796. if (empty($openId)) {
  797. continue;
  798. }
  799. $data = array(
  800. "touser" => $openId,
  801. "template_id" => $tempId,
  802. "url" => Yii::$app->params['ghsDomain'],
  803. "data" => array(
  804. "first" => array(
  805. "value" => "恭喜,您的开店申请审核通过。",
  806. "color" => "#173177"
  807. ),
  808. "keyword1" => array(
  809. "value" => '审核通过',
  810. "color" => "#173177"
  811. ),
  812. "keyword2" => array(
  813. "value" => date("Y-m-d H:i:s"),
  814. "color" => "#173177"
  815. ),
  816. "remark" => array(
  817. "value" => '点击登陆后台',
  818. "color" => "#173177"
  819. )
  820. ),
  821. );
  822. $data['miniprogram']['appid'] = $wx['miniAppId'];
  823. $data['miniprogram']['pagepath'] = 'admin/home/workbench';
  824. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  825. }
  826. }
  827. //采购单下单成功 ssh 20210531
  828. public static function generateCgOrder($shop, $order)
  829. {
  830. $ptStyle = $shop->ptStyle;
  831. $wxBase = WxOpenClass::getWxBase();
  832. $wx = $wxBase[$ptStyle] ?? [];
  833. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  834. $shortTempId = 'OPENTM202297555';//下单成功通知
  835. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  836. if (empty($tempId)) {
  837. return false;
  838. }
  839. $orderId = $order->id;
  840. $orderSn = (string)$order->orderSn;
  841. $totalFee = $order->actPrice;
  842. $adminList = ShopAdminClass::getRemainAdmin($shop);
  843. if (empty($adminList)) {
  844. return false;
  845. }
  846. foreach ($adminList as $admin) {
  847. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  848. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  849. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  850. }
  851. if (empty($openId)) {
  852. continue;
  853. }
  854. $data = [
  855. "touser" => $openId,
  856. "template_id" => $tempId,
  857. "url" => Yii::$app->params['ghsDomain'],
  858. "data" => [
  859. "first" => ["value" => '亲,您的采购单已生成', "color" => "#173177"],
  860. "keyword1" => ["value" => $orderSn, "color" => "#173177"],
  861. "keyword2" => ["value" => '花材', "color" => "#173177"],
  862. "keyword3" => ["value" => $order->bigNum . '/' . $order->smallNum, "color" => "#173177"],
  863. "keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
  864. "keyword5" => ["value" => '-', "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 cgOrderHasSend($shop, $order)
  875. {
  876. $ptStyle = $shop->ptStyle;
  877. $wxBase = WxOpenClass::getWxBase();
  878. $wx = $wxBase[$ptStyle] ?? [];
  879. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  880. $shortTempId = 'OPENTM416881153';//下单成功通知
  881. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  882. if (empty($tempId)) {
  883. return false;
  884. }
  885. $orderId = $order->id;
  886. $orderSn = (string)$order->orderSn;
  887. $adminList = ShopAdminClass::getRemainAdmin($shop);
  888. if (empty($adminList)) {
  889. return false;
  890. }
  891. $ghsShopAdminName = $order->ghsShopAdminName ?? '';
  892. foreach ($adminList as $admin) {
  893. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  894. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  895. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  896. }
  897. if (empty($openId)) {
  898. continue;
  899. }
  900. $data = [
  901. "touser" => $openId,
  902. "template_id" => $tempId,
  903. "url" => Yii::$app->params['ghsDomain'],
  904. "data" => [
  905. "first" => ["value" => '亲,您的采购单已发货,请注意签收', "color" => "#173177"],
  906. "keyword1" => ["value" => $orderSn, "color" => "#173177"],
  907. "keyword2" => ["value" => date("Y-m-d H:i:s"), "color" => "#173177"],
  908. "keyword3" => ["value" => $ghsShopAdminName, "color" => "#173177"],
  909. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  910. ]
  911. ];
  912. $data['miniprogram']['appid'] = $wx['miniAppId'];
  913. $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
  914. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  915. }
  916. }
  917. //零售清算欠款通知供货商 ssh 20210531
  918. public static function clearInform($shop, $order, $custom)
  919. {
  920. $ptStyle = $shop->ptStyle;
  921. $wxBase = WxOpenClass::getWxBase();
  922. $wx = $wxBase[$ptStyle] ?? [];
  923. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  924. $shortTempId = 'OPENTM207422813';//收入提醒
  925. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  926. if (empty($tempId)) {
  927. return false;
  928. }
  929. $id = $order->id ?? 0;
  930. $actPrice = $order->actPrice;
  931. $actPrice = floatval($actPrice);
  932. $name = $custom->name ?? '';
  933. $adminList = ShopAdminClass::getRemainAdmin($shop);
  934. if (empty($adminList)) {
  935. return false;
  936. }
  937. foreach ($adminList as $admin) {
  938. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  939. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  940. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  941. }
  942. if (empty($openId)) {
  943. continue;
  944. }
  945. $data = [
  946. "touser" => $openId,
  947. "template_id" => $tempId,
  948. "url" => Yii::$app->params['ghsDomain'],
  949. "data" => [
  950. "first" => ["value" => "", "color" => "#173177"],
  951. "keyword1" => ["value" => '¥' . $actPrice, "color" => "#173177"],
  952. "keyword2" => ["value" => "{$name} 线上结账", "color" => "#173177"],
  953. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  954. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  955. ]
  956. ];
  957. $data['miniprogram']['appid'] = $wx['miniAppId'];
  958. $data['miniprogram']['pagepath'] = 'admin/clear/customInfo?id=' . $id;
  959. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  960. }
  961. }
  962. //收款码收入通知 ssh 20210531
  963. public static function gatheringIncomeInform($shop, $order)
  964. {
  965. if ($order->payStatus != 1) {
  966. return false;
  967. }
  968. $ptStyle = $shop->ptStyle;
  969. $wxBase = WxOpenClass::getWxBase();
  970. $wx = $wxBase[$ptStyle] ?? [];
  971. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  972. $shortTempId = 'OPENTM207422813';//收入提醒
  973. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  974. if (empty($tempId)) {
  975. return false;
  976. }
  977. $actPrice = $order->actPrice;
  978. $orderId = $order->id;
  979. $adminList = ShopAdminClass::getRemainAdmin($shop);
  980. if (empty($adminList)) {
  981. return false;
  982. }
  983. foreach ($adminList as $admin) {
  984. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  985. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  986. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  987. }
  988. if (empty($openId)) {
  989. continue;
  990. }
  991. $data = [
  992. "touser" => $openId,
  993. "template_id" => $tempId,
  994. "url" => Yii::$app->params['ghsDomain'],
  995. "data" => [
  996. "first" => ["value" => "您有新的收入。", "color" => "#173177"],
  997. "keyword1" => ["value" => $actPrice, "color" => "#173177"],
  998. "keyword2" => ["value" => '门店收入', "color" => "#173177"],
  999. "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  1000. "remark" => ["value" => "点击查看详情", "color" => "#173177"]
  1001. ]
  1002. ];
  1003. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1004. $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
  1005. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1006. }
  1007. }
  1008. //提现成功通知 ssh 20210531
  1009. public static function cashInform($shop, $cash)
  1010. {
  1011. $ptStyle = $shop->ptStyle;
  1012. $wxBase = WxOpenClass::getWxBase();
  1013. $wx = $wxBase[$ptStyle] ?? [];
  1014. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1015. $shortTempId = 'OPENTM411207151';
  1016. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1017. if (empty($tempId)) {
  1018. return false;
  1019. }
  1020. $amount = floatval($cash->amount);
  1021. $beAmount = floatval($cash->beAmount);
  1022. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1023. if (empty($adminList)) {
  1024. return false;
  1025. }
  1026. $mainId = $shop->mainId ?? 0;
  1027. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', 'adminId');
  1028. foreach ($adminList as $admin) {
  1029. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1030. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1031. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1032. }
  1033. if (empty($openId)) {
  1034. continue;
  1035. }
  1036. $adminId = $admin['id'] ?? 0;
  1037. $super = $staffList[$adminId]['super'] ?? 0;
  1038. //提现管理员才通知
  1039. if ($super == 0) {
  1040. continue;
  1041. }
  1042. $data = [
  1043. "touser" => $openId,
  1044. "template_id" => $tempId,
  1045. "url" => Yii::$app->params['ghsDomain'],
  1046. "data" => [
  1047. "first" => ["value" => "", "color" => "#173177"],
  1048. "keyword1" => ["value" => "¥{$beAmount}", "color" => "#173177"],
  1049. "keyword2" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
  1050. "remark" => ["value" => '', "color" => "#173177"]
  1051. ]
  1052. ];
  1053. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1054. $data['miniprogram']['pagepath'] = 'pagesStore/me/cashInfo?id=' . $cash->id;
  1055. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1056. }
  1057. }
  1058. //订单送达通知 ssh 20210607
  1059. public static function reachInform($shop, $order)
  1060. {
  1061. $ptStyle = $shop->ptStyle;
  1062. $wxBase = WxOpenClass::getWxBase();
  1063. $wx = $wxBase[$ptStyle] ?? [];
  1064. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1065. $shortTempId = 'OPENTM201205968';
  1066. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1067. if (empty($tempId)) {
  1068. return false;
  1069. }
  1070. $orderId = $order->id ?? '';
  1071. $orderSn = (string)$order->orderSn ?? '';
  1072. $customName = $order->customName ?? '';
  1073. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1074. if (empty($adminList)) {
  1075. return false;
  1076. }
  1077. foreach ($adminList as $admin) {
  1078. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1079. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1080. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1081. }
  1082. if (empty($openId)) {
  1083. continue;
  1084. }
  1085. $data = [
  1086. "touser" => $openId,
  1087. "template_id" => $tempId,
  1088. "url" => Yii::$app->params['ghsDomain'],
  1089. "data" => [
  1090. "first" => ["value" => '客户订单已送达', "color" => "#173177"],
  1091. "keyword1" => ["value" => $orderSn, "color" => "#173177"],
  1092. "keyword2" => ["value" => $customName, "color" => "#173177"],
  1093. "keyword3" => ["value" => '已送达', "color" => "#173177"],
  1094. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1095. ]
  1096. ];
  1097. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1098. $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
  1099. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1100. }
  1101. }
  1102. //采购退款成功通知 ssh 20210730
  1103. public static function cgRefundInform($shop, $cg, $amount)
  1104. {
  1105. $ptStyle = $shop->ptStyle;
  1106. $wxBase = WxOpenClass::getWxBase();
  1107. $wx = $wxBase[$ptStyle] ?? [];
  1108. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1109. $shortTempId = 'OPENTM407280253';
  1110. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1111. if (empty($tempId)) {
  1112. return false;
  1113. }
  1114. $orderId = $cg->id ?? '';
  1115. $orderSn = (string)$cg->orderSn ?? '';
  1116. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1117. if (empty($adminList)) {
  1118. return false;
  1119. }
  1120. foreach ($adminList as $admin) {
  1121. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1122. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1123. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1124. }
  1125. if (empty($openId)) {
  1126. continue;
  1127. }
  1128. $data = [
  1129. "touser" => $openId,
  1130. "template_id" => $tempId,
  1131. "url" => Yii::$app->params['ghsDomain'],
  1132. "data" => [
  1133. "first" => ["value" => '采购单:' . $orderSn, "color" => "#173177"],
  1134. "keyword1" => ["value" => "订单退款", "color" => "#173177"],
  1135. "keyword2" => ["value" => $amount . "元", "color" => "#173177"],
  1136. "keyword3" => ["value" => '已送达', "color" => "#173177"],
  1137. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1138. ]
  1139. ];
  1140. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1141. $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
  1142. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1143. }
  1144. }
  1145. //库存预警通知 ssh 20210909
  1146. public static function stockWarningInform($shop, $productList)
  1147. {
  1148. if (empty($productList)) {
  1149. return false;
  1150. }
  1151. $remark = '';
  1152. foreach ($productList as $key => $product) {
  1153. $stock = $product->stock ?? 0;
  1154. $currentStock = floatval($stock);
  1155. $name = $product->name ?? '';
  1156. $remark .= $name . "({$currentStock}) ";
  1157. }
  1158. $ptStyle = $shop->ptStyle;
  1159. $wxBase = WxOpenClass::getWxBase();
  1160. $wx = $wxBase[$ptStyle] ?? [];
  1161. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1162. $shortTempId = 'OPENTM206773265';
  1163. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1164. if (empty($tempId)) {
  1165. return false;
  1166. }
  1167. $shopName = $shop->shopName ?? '';
  1168. $date = date("Y-m-d H:i:s");
  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" => "", "color" => "#173177"],
  1187. "keyword1" => ["value" => $shopName, "color" => "#173177"],
  1188. "keyword2" => ["value" => "点击查看花材", "color" => "#173177"],
  1189. "keyword3" => ["value" => "库存不足", "color" => "#D52B4D"],
  1190. "keyword4" => ["value" => $date, "color" => "#173177"],
  1191. "remark" => ["value" => $remark, "color" => "#D52B4D"]
  1192. ]
  1193. ];
  1194. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1195. $data['miniprogram']['pagepath'] = 'admin/item/list?warning=1';
  1196. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1197. }
  1198. }
  1199. //供货商客户领取了新人红包 ssh 20211027
  1200. public static function ghsCustomGetNewGiftInform($shop, $custom)
  1201. {
  1202. $ptStyle = $shop->ptStyle ?? 0;
  1203. $wxBase = WxOpenClass::getWxBase();
  1204. $wx = $wxBase[$ptStyle] ?? [];
  1205. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1206. $shortTempId = 'OPENTM408238177';
  1207. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1208. if (empty($tempId)) {
  1209. return false;
  1210. }
  1211. $customId = $custom['id'] ?? 0;
  1212. $customName = $custom['name'] ?? '';
  1213. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1214. if (empty($adminList)) {
  1215. return false;
  1216. }
  1217. foreach ($adminList as $admin) {
  1218. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1219. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1220. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1221. }
  1222. if (empty($openId)) {
  1223. continue;
  1224. }
  1225. $data = [
  1226. "touser" => $openId,
  1227. "template_id" => $tempId,
  1228. "url" => Yii::$app->params['ghsDomain'],
  1229. "data" => [
  1230. "first" => ["value" => $customName . " 领取了新客红包", "color" => "#173177"],
  1231. "keyword1" => ["value" => "新客红包", "color" => "#173177"],
  1232. "keyword2" => ["value" => "已领取", "color" => "#173177"],
  1233. "remark" => ["value" => '点击查看客户', "color" => "#173177"]
  1234. ]
  1235. ];
  1236. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1237. $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
  1238. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1239. }
  1240. }
  1241. //供货商的客户介绍新客并且下单,获得红包通知商家 ssh 20211027
  1242. public static function ghsCustomTjGetGiftInform($shop, $custom, $beTjCustom)
  1243. {
  1244. $ptStyle = $shop->ptStyle ?? 0;
  1245. $wxBase = WxOpenClass::getWxBase();
  1246. $wx = $wxBase[$ptStyle] ?? [];
  1247. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1248. $shortTempId = 'OPENTM408238177';
  1249. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1250. if (empty($tempId)) {
  1251. return false;
  1252. }
  1253. $customId = $custom->id ?? 0;
  1254. $customName = $custom->name ?? '';
  1255. $beTjCustomName = $beTjCustom->name ?? '';
  1256. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1257. if (empty($adminList)) {
  1258. return false;
  1259. }
  1260. foreach ($adminList as $admin) {
  1261. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1262. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1263. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1264. }
  1265. if (empty($openId)) {
  1266. continue;
  1267. }
  1268. $data = [
  1269. "touser" => $openId,
  1270. "template_id" => $tempId,
  1271. "url" => Yii::$app->params['ghsDomain'],
  1272. "data" => [
  1273. "first" => ["value" => "【{$beTjCustomName}】推荐的客户【{$customName}】已下单", "color" => "#173177"],
  1274. "keyword1" => ["value" => "推荐新客红包", "color" => "#173177"],
  1275. "keyword2" => ["value" => "已发放给【{$beTjCustomName}】", "color" => "#173177"],
  1276. "remark" => ["value" => '点击查看客户', "color" => "#173177"]
  1277. ]
  1278. ];
  1279. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1280. $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
  1281. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1282. }
  1283. }
  1284. //花店推荐供货商客户获得红包 ssh 20211027
  1285. public static function hdTjGhsCustomGetGiftInform($shop, $ghs, $beTjCustom)
  1286. {
  1287. $ptStyle = $shop->ptStyle ?? 0;
  1288. $wxBase = WxOpenClass::getWxBase();
  1289. $wx = $wxBase[$ptStyle] ?? [];
  1290. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1291. $shortTempId = 'OPENTM408238177';
  1292. $tempId = $message[$shortTempId]['templateId'] ?? '';
  1293. if (empty($tempId)) {
  1294. return false;
  1295. }
  1296. $beTjCustomName = $beTjCustom->name ?? '';
  1297. $ghsName = $ghs->name ?? '';
  1298. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1299. if (empty($adminList)) {
  1300. return false;
  1301. }
  1302. foreach ($adminList as $admin) {
  1303. $openId = $admin['openId'] ?? '';
  1304. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1305. $openId = $admin['ghsOpenId'] ?? '';
  1306. }
  1307. if (empty($openId)) {
  1308. continue;
  1309. }
  1310. $data = [
  1311. "touser" => $openId,
  1312. "template_id" => $tempId,
  1313. "url" => Yii::$app->params['ghsDomain'],
  1314. "data" => [
  1315. "first" => ["value" => "您推荐的客户【{$beTjCustomName}】已在【{$ghsName}】下单", "color" => "#173177"],
  1316. "keyword1" => ["value" => "推荐新客红包", "color" => "#173177"],
  1317. "keyword2" => ["value" => "已获得", "color" => "#173177"],
  1318. "remark" => ["value" => '点击查看红包', "color" => "#173177"]
  1319. ]
  1320. ];
  1321. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1322. $data['miniprogram']['pagepath'] = 'admin/coupon/couponList';
  1323. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1324. }
  1325. }
  1326. //供货商新客户通知 ssh 20210909
  1327. public static function newGhsCustomInform($shop, $custom, $introduce = [])
  1328. {
  1329. $ptStyle = $shop->ptStyle ?? 0;
  1330. $wxBase = WxOpenClass::getWxBase();
  1331. $wx = $wxBase[$ptStyle] ?? [];
  1332. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1333. $shortTempId = 'OPENTM203447669';
  1334. $tempId = $message[$shortTempId]['templateId'] ?? '';
  1335. if (empty($tempId)) {
  1336. return false;
  1337. }
  1338. $customId = $custom->id ?? 0;
  1339. $customName = $custom->name ?? '';
  1340. $date = date("Y-m-d H:i:s");
  1341. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1342. if (empty($adminList)) {
  1343. return false;
  1344. }
  1345. $first = '';
  1346. if (!empty($introduce)) {
  1347. $introName = $introduce->name ?? '';
  1348. $first = "此客户由【{$introName}】介绍";
  1349. }
  1350. foreach ($adminList as $admin) {
  1351. $openId = $admin['openId'] ?? '';
  1352. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1353. $openId = $admin['ghsOpenId'] ?? '';
  1354. }
  1355. if (empty($openId)) {
  1356. continue;
  1357. }
  1358. $data = [
  1359. "touser" => $openId,
  1360. "template_id" => $tempId,
  1361. "url" => Yii::$app->params['ghsDomain'],
  1362. "data" => [
  1363. "first" => ["value" => $first, "color" => "#173177"],
  1364. "keyword1" => ["value" => $customId, "color" => "#173177"],
  1365. "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
  1366. "keyword3" => ["value" => $date, "color" => "#173177"],
  1367. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1368. ]
  1369. ];
  1370. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1371. $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
  1372. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1373. }
  1374. }
  1375. //客户充值通知供货商 ssh 20211005
  1376. public static function customRechargeInformGhs($recharge)
  1377. {
  1378. $amount = $recharge->amount ?? 0;
  1379. $hbId = $recharge->hbId ?? 0;
  1380. $ghsId = $recharge->ghsId ?? 0;
  1381. if (empty($ghsId)) {
  1382. return false;
  1383. }
  1384. if (empty($hbId)) {
  1385. return false;
  1386. }
  1387. $ghsInfo = GhsClass::getById($ghsId, true);
  1388. $shopId = $ghsInfo->shopId ?? 0;
  1389. $customId = $ghsInfo->customId ?? 0;
  1390. $customInfo = CustomClass::getById($customId, true);
  1391. $customName = $customInfo->name ?? '';
  1392. $shopInfo = ShopClass::getById($shopId, true);
  1393. $ptStyle = $shopInfo->ptStyle ?? 0;
  1394. $wxBase = WxOpenClass::getWxBase();
  1395. $wx = $wxBase[$ptStyle] ?? [];
  1396. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1397. $shortTempId = 'OPENTM411530050';
  1398. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1399. if (empty($tempId)) {
  1400. return false;
  1401. }
  1402. $adminList = ShopAdminClass::getRemainAdmin($shopInfo);
  1403. if (empty($adminList)) {
  1404. return false;
  1405. }
  1406. foreach ($adminList as $admin) {
  1407. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1408. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1409. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1410. }
  1411. if (empty($openId)) {
  1412. continue;
  1413. }
  1414. $data = [
  1415. "touser" => $openId,
  1416. "template_id" => $tempId,
  1417. "url" => Yii::$app->params['ghsDomain'],
  1418. "data" => [
  1419. "first" => ["value" => "有新客户充值", "color" => "#173177"],
  1420. "keyword1" => ["value" => $customName, "color" => "#173177"],
  1421. "keyword2" => ["value" => $customId, "color" => "#D52B4D"],
  1422. "keyword3" => ["value" => $amount, "color" => "#173177"],
  1423. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1424. ]
  1425. ];
  1426. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1427. $data['miniprogram']['pagepath'] = 'admin/hb/rechargeList';
  1428. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1429. }
  1430. }
  1431. //花店新客户通知 ssh 20220919
  1432. public static function newHdCustomInform($shop, $custom, $introduce = [])
  1433. {
  1434. $ptStyle = $shop->ptStyle ?? 0;
  1435. $wxBase = WxOpenClass::getWxBase();
  1436. $wx = $wxBase[$ptStyle] ?? [];
  1437. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1438. $shortTempId = 'OPENTM203447669';
  1439. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1440. if (empty($tempId)) {
  1441. return false;
  1442. }
  1443. $customId = $custom->id ?? 0;
  1444. $customName = $custom->name ?? '';
  1445. $date = date("Y-m-d H:i:s");
  1446. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1447. if (empty($adminList)) {
  1448. return false;
  1449. }
  1450. $first = '';
  1451. foreach ($adminList as $admin) {
  1452. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1453. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1454. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1455. }
  1456. if (empty($openId)) {
  1457. continue;
  1458. }
  1459. $data = [
  1460. "touser" => $openId,
  1461. "template_id" => $tempId,
  1462. "url" => Yii::$app->params['ghsDomain'],
  1463. "data" => [
  1464. "first" => ["value" => $first, "color" => "#173177"],
  1465. "keyword1" => ["value" => $customId, "color" => "#173177"],
  1466. "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
  1467. "keyword3" => ["value" => $date, "color" => "#173177"],
  1468. "remark" => ["value" => '点击查看详情', "color" => "#173177"]
  1469. ]
  1470. ];
  1471. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1472. $data['miniprogram']['pagepath'] = 'admin/member/detail?id=' . $customId;
  1473. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1474. }
  1475. }
  1476. //预订变化通知供货商员工下架花材 ssh 20240729
  1477. public static function bookChangeOutStockInform($shop, $bookItemCustomRes, $num)
  1478. {
  1479. $ptStyle = $shop->ptStyle;
  1480. $wxBase = WxOpenClass::getWxBase();
  1481. $wx = $wxBase[$ptStyle] ?? [];
  1482. $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
  1483. //取货提醒
  1484. $shortTempId = 'ZHH202407100108';
  1485. $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
  1486. if (empty($tempId)) {
  1487. return false;
  1488. }
  1489. $adminList = ShopAdminClass::getRemainAdmin($shop);
  1490. if (empty($adminList)) {
  1491. return false;
  1492. }
  1493. $itemId = $bookItemCustomRes->itemId ?? 0;
  1494. $itemName = $bookItemCustomRes->name ?? '';
  1495. $customName = $bookItemCustomRes->customName ?? '';
  1496. $seatSn = $bookItemCustomRes->seatSn ?? 0;
  1497. $seatName = empty($seatSn) ? '' : $seatSn;
  1498. foreach ($adminList as $admin) {
  1499. $openId = isset($admin['openId']) ? $admin['openId'] : '';
  1500. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  1501. $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
  1502. }
  1503. $data = [
  1504. "touser" => $openId,
  1505. "template_id" => $tempId,
  1506. "url" => Yii::$app->params['ghsDomain'],
  1507. "data" => [
  1508. "thing8" => ["value" => $customName . ' ' . $seatName],
  1509. "thing10" => ["value" => '请下架' . $num . '份'],
  1510. "thing7" => ["value" => $itemName],
  1511. ]
  1512. ];
  1513. $data['miniprogram']['appid'] = $wx['miniAppId'];
  1514. $data['miniprogram']['pagepath'] = 'admin/notice/index';
  1515. //$data['miniprogram']['pagepath'] = 'admin/book/itemCustom?itemId=' . $itemId . '&itemName=' . $itemName;
  1516. wxUtil::sendTaskInform($data, $wx, $ptStyle);
  1517. }
  1518. }
  1519. }