WxMessageClass.php 61 KB

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