WxMessageClass.php 67 KB

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