| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580 |
- <?php
- namespace biz\wx\classes;
- use biz\base\classes\BaseClass;
- use biz\ghs\classes\GhsClass;
- use biz\shop\classes\ShopAdminClass;
- use biz\shop\classes\ShopClass;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\order\classes\PurchaseOrderItemClass;
- use common\components\dict;
- use common\components\noticeUtil;
- use common\components\stringUtil;
- use common\components\util;
- use common\components\wxUtil;
- use Yii;
- class WxMessageClass extends BaseClass
- {
- public static $baseFile = '\biz\wx\models\WxMessage';
- public static function has()
- {
- return [
- //零售
- dict::getDict('ptStyle', 'hd') => [
- 'OPENTM417875155' => '新订单通知',
- 'OPENTM207430125' => '操作成功通知',
- 'OPENTM401915538' => '审核通知',
- 'OPENTM201205968' => '订单送达通知',
- 'OPENTM207777535' => '付款提醒',
- 'OPENTM207422813' => '收入提醒',
- 'OPENTM202297555' => '下单成功通知',
- 'OPENTM207327227' => '宝贝售出提醒',
- 'OPENTM207188526' => '付款成功',
- 'OPENTM411207151' => '提现成功通知',
- 'OPENTM416881153' => '发货通知',
- 'OPENTM407280253' => '退款成功通知',
- 'OPENTM411530050' => '充值成功提醒',
- 'OPENTM408238177' => '反馈进度通知',
- 'OPENTM203447669' => '新客户加入通知',
- 'ZHH202308150025' => '退款申请处理通知',
- 'ZHH202311282308' => '采购申请处理通知',
- 'ZHH202405111701' => '采购单已确认通知',
- 'ZHH202405111702' => '异常订单提醒',
- 'ZHH202405111703' => '账单已结清提醒',
- 'ZHH202405111704' => '充值成功通知',
- 'ZHH202405121036' => '采购商品入库成功通知',
- 'ZHH202407100108' => '取货提醒',
- ],
- //供货商
- dict::getDict('ptStyle', 'ghs') => [
- 'OPENTM417875155' => '新订单通知',
- 'OPENTM207430125' => '操作成功通知',
- 'OPENTM401915538' => '审核通知',
- 'OPENTM201205968' => '订单送达通知',
- 'OPENTM207777535' => '付款提醒',
- 'OPENTM207422813' => '收入提醒',
- 'OPENTM202297555' => '下单成功通知',
- 'OPENTM207327227' => '宝贝售出提醒',
- 'OPENTM207188526' => '付款成功',
- 'OPENTM411207151' => '提现成功通知',
- 'OPENTM416881153' => '发货通知',
- 'OPENTM407280253' => '退款成功通知',
- 'OPENTM206773265' => '库存预警通知',
- 'OPENTM203447669' => '新客户加入通知',
- 'OPENTM411530050' => '充值成功提醒',
- 'OPENTM408238177' => '反馈进度通知',
- 'ZHH202308150025' => '退款申请处理通知',
- 'ZHH202311282308' => '采购申请处理通知',
- 'ZHH202405111701' => '采购单已确认通知',
- 'ZHH202405111702' => '异常订单提醒',
- 'ZHH202405111703' => '账单已结清提醒',
- 'ZHH202405111704' => '充值成功通知',
- 'ZHH202405121036' => '采购商品入库成功通知',
- 'ZHH202407100108' => '取货提醒',
- ],
- //商城
- dict::getDict('ptStyle', 'mall') => [
- ],
- ];
- }
- /**
- * 跑腿配送异常通知 ssh 20250825
- * @param \yii\db\ActiveRecord $shop 对象
- * @param string $customName 客户名称
- * @param int $orderId 订单id
- * @param string $result 异常状态说明内容:配送异常、配送员撤单、配送方取消订单、商家取消订单,这四种情况,其它不是异常的不需要通知
- * @return false|void
- */
- public static function expressErrorInform($shop, $customName, $orderId, $result)
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM408238177';
- $tempId = $message[$shortTempId]['templateId'] ?? '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = $admin['openId'] ?? '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = $admin['ghsOpenId'] ?? '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => $result, "color" => "#173177"],
- "keyword1" => ["value" => $result, "color" => "#173177"],
- "keyword2" => ["value" => $customName . '的订单', "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
- } else {
- $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
- }
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //客户发留言通知花店 ssh 20250906
- public static function newMessageInform($shop, $result)
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM408238177';
- $tempId = $message[$shortTempId]['templateId'] ?? '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = $admin['openId'] ?? '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = $admin['ghsOpenId'] ?? '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => $result, "color" => "#173177"],
- "keyword1" => ["value" => $result, "color" => "#173177"],
- "keyword2" => ["value" => '请及时回复', "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/chat/list';
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //初始化消息模板
- // ./yii.bat wx-message/init
- public static function init()
- {
- $wxBase = [
- dict::getDict('ptStyle', 'hd') => \bizHd\wx\classes\WxOpenClass::getWxInfo(),
- dict::getDict('ptStyle', 'ghs') => \bizHd\wx\classes\WxOpenClass::getGhsWxInfo(),
- dict::getDict('ptStyle', 'mall') => \bizHd\wx\classes\WxOpenClass::getMallWxInfo(),
- ];
- $message = self::getAllByCondition([], null, '*', null, true);
- if (!empty($message)) {
- foreach ($message as $item) {
- $ptStyle = $item->ptStyle;
- $wx = $wxBase[$ptStyle] ?? [];
- if (empty($wx)) {
- util::fail('没有找到微信平台信息');
- }
- $templateId = $item->templateId;
- $respond = wxUtil::delTMessage($wx, $templateId, $ptStyle);
- if (isset($respond['errcode']) && $respond['errcode'] == 0) {
- $item->delete();
- }
- }
- }
- $wxMessageList = self::has();
- foreach ($wxMessageList as $k => $message) {
- $ptStyle = $k;
- if (empty($message)) {
- continue;
- }
- $wx = $wxBase[$ptStyle] ?? [];
- foreach ($message as $shortId => $title) {
- $wxReturn = wxUtil::tMessageCreate($wx, $shortId, $ptStyle);
- echo json_encode($wxReturn) . "\n";
- if (isset($wxReturn['errcode']) && $wxReturn['errcode'] == 0) {
- $templateId = $wxReturn['template_id'];
- $data = [
- 'shortTemplateId' => $shortId,
- 'templateId' => $templateId,
- 'templateName' => $title,
- 'ptStyle' => $ptStyle,
- ];
- self::add($data);
- //Yii::warning("add tmessage:" . $title . " success\n");
- } else {
- Yii::warning("add tmessage error:" . json_encode($wxReturn) . " \n");
- noticeUtil::push("add wx message {$shortId} error:" . json_encode($wxReturn), '15280215347');
- }
- }
- }
- }
- //供货商有新的退款申请 ssh 20230815
- public static function ghsHasNewRefundApplyInform($shop, $refund)
- {
- $id = $refund->id;
- $refundSn = $refund->orderSn ?? '';
- $refundType = $refund->refundType ?? 1;
- $refundName = $refundType == 1 ? '退货退款' : '只退款';
- $addTime = $refund->addTime ?? '';
- $refundPrice = $refund->refundPrice ?? '';
- $refundPrice = floatval($refundPrice);
- $customId = $refund->customId ?? 0;
- $custom = CustomClass::getById($customId, true);
- $customName = $custom->name ?? '--';
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'ZHH202308150025';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "amount1" => ["value" => $refundPrice . '元'],
- "thing7" => ["value" => $customName],
- "time10" => ["value" => $addTime],
- "thing2" => ["value" => $refundName],
- "character_string3" => ["value" => $refundSn],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesOrder/refundDetail?from=1&id=' . $id;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //供货商采购确认通知相关人员 ssh 20240511
- public static function ghsCgInform($shop, $cg)
- {
- $orderSn = $cg->orderSn ?? '';
- $ptStyle = $shop->ptStyle;
- $ghsName = $cg->ghsName ?? '';
- $actPrice = $cg->actPrice ?? 0;
- $entryTime = $cg->entryTime ?? '';
- $staffName = $cg->shopAdminName ?? '';
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'ZHH202405111701';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (!empty($openId)) {
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "thing4" => ["value" => $ghsName],
- "character_string1" => ["value" => $orderSn],
- "amount2" => ["value" => $actPrice],
- "time3" => ["value" => $entryTime],
- "thing5" => ["value" => $staffName],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- }
- //供货商采购入库成功通知相关人员 ssh 20240511
- public static function ghsCgEntryInform($shop, $cg)
- {
- return true;
- $orderSn = $cg->orderSn ?? '';
- $ptStyle = $shop->ptStyle;
- $ghsName = $cg->ghsName ?? '';
- $actPrice = $cg->actPrice ?? 0;
- $entryTime = $cg->entryTime ?? '';
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'ZHH202405121036';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- $title = '花材';
- $totalNum = 0;
- $itemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
- if (!empty($itemList)) {
- $title = '';
- foreach ($itemList as $item) {
- $name = $item->name ?? '';
- if (empty($title)) {
- $title = $name;
- } else {
- $title .= ',' . $name;
- }
- $itemNum = $item->itemNum ?? 0;
- $refundNum = $item->refundNum ?? 0;
- $num = bcsub($itemNum, $refundNum, 2);
- $totalNum = bcadd($totalNum, $num, 2);
- }
- $totalNum = floatval($totalNum);
- $title = stringUtil::subStringUtf8($title, 15, '...');
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (!empty($openId)) {
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "thing5" => ["value" => $ghsName],
- "character_string4" => ["value" => $orderSn],
- "time3" => ["value" => $entryTime],
- "character_string2" => ["value" => $totalNum . ' ¥' . $actPrice],
- "thing1" => ["value" => $title],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- }
- //客户结清账单提醒 ssh 20240512
- public static function customHasClearToGhsInform($shop, $clearInfo, $custom)
- {
- //账单编号 合同金额 客户名称
- $ptStyle = $shop->ptStyle;
- $id = $clearInfo->id ?? 0;
- $actPrice = $clearInfo->actPrice ?? 0;
- $actPrice = bcadd($actPrice, 0, 2);
- $customName = isset($custom->name) && !empty($custom->name) ? $custom->name : '-';
- $customName = stringUtil::subStringUtf8($customName, 6, '...');
- $orderSn = $clearInfo->orderSn ?? '';
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'ZHH202405111703';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (!empty($openId)) {
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "character_string1" => ["value" => $orderSn],
- "amount5" => ["value" => $actPrice],
- "thing3" => ["value" => $customName . ' 线上结账'],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/clear/customInfo?id=' . $id;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- }
- //客户充值清账通知 ssh 20240511
- public static function customRechargeClearInform($shop, $recharge)
- {
- //充值金额 商品名称 姓名 操作人 充值时间
- $ptStyle = $shop->ptStyle;
- $amount = $recharge->amount ?? 0;
- $amount = bcadd($amount, 0, 2);
- $staffName = isset($recharge->staffName) && !empty($recharge->staffName) ? $recharge->staffName : '-';
- $onlinePay = $recharge->onlinePay ?? 1;
- $onlineName = $onlinePay == 1 ? '线下' : '线上';
- $payWay = $recharge->payWay ?? 0;
- $nameMap = dict::getDict('payWayName');
- $payWayName = $nameMap[$payWay] ?? '微信';
- $payName = $onlineName . $payWayName;
- $title = $payName . ' 付款';
- $customName = isset($recharge->customName) && !empty($recharge->customName) ? $recharge->customName : '-';
- $customName = stringUtil::subStringUtf8($customName, 6, '...');
- $customId = $recharge->customId ?? 0;
- $payTime = $recharge->payTime ?? '';
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'ZHH202405111704';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (!empty($openId)) {
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "amount1" => ["value" => $amount],
- "thing9" => ["value" => $title],
- "thing7" => ["value" => $customName . ' 充值销账'],
- "thing11" => ["value" => $staffName],
- "time3" => ["value" => $payTime],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/custom/balanceChange?customId=' . $customId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- }
- //供货商重复打印通知 ssh 20240511
- public static function ghsCgRepeatPrintInform($cg)
- {
- $shopId = $cg->shopId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if (empty($shop)) {
- return false;
- }
- $orderSn = $cg->orderSn ?? '';
- $num = $cg->printNum ?? 0;
- $ptStyle = $shop->ptStyle;
- $ghsName = $cg->ghsName ?? '';
- $ghsName = stringUtil::subStringUtf8($ghsName, 6, '...');
- $staffName = $cg->shopAdminName ?? '';
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'ZHH202405111702';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (!empty($openId)) {
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "character_string20" => ["value" => $orderSn],
- "thing13" => ["value" => $ghsName],
- "thing17" => ["value" => "采购单 打印了【{$num}】次"],
- "thing23" => ["value" => $staffName],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/info?orderSn=' . $orderSn;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- }
- //供货商新订单通知 ssh 20210529
- public static function ghsHasNewOrderInform($shop, $order)
- {
- if ($order->payStatus != 1) {
- return false;
- }
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM417875155';//新订单通知
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $title = '';
- if (isset($order->book) && $order->book == 1) {
- $title = '【预订】';
- }
- if (isset($order->presell) && $order->presell == 1) {
- $title = '【预售】';
- }
- $orderId = $order->id;
- $actPrice = $order->actPrice;
- $actPrice = floatval($actPrice);
- $shopName = $shop->shopName ?? '';
- $first = isset($order->shopAdminId) && !empty($order->shopAdminId) ? "【门店开单】" : "";
- $customName = $order->customName ?? '';
- $customName = stringUtil::subStringUtf8($customName, 5, '...');
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- $orderSn = $shopName == '首店' ? $order->orderSn : $shopName;
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => '', "color" => "#173177"],
- "keyword1" => ["value" => $orderSn . $title, "color" => "#173177"],
- "keyword2" => ["value" => $customName . ' ¥' . $actPrice . $first, "color" => "#173177"],
- "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //预订增加减少通知 ssh 20240820
- public static function bookChangeInform($shop, $arr)
- {
- $orderId = $arr['orderId'] ?? 0;
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM417875155';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $itemName = $arr['itemName'] ?? '';
- $io = $arr['io'] ?? 0;
- $plus = $io == 1 ? '加' : '减';
- $num = $arr['num'] ?? 0;
- $title = $plus . $num . ' ' . $itemName;
- $customName = $arr['customName'] ?? '';
- $customName = stringUtil::subStringUtf8($customName, 5, '...');
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => '', "color" => "#173177"],
- "keyword1" => ["value" => $title, "color" => "#173177"],
- "keyword2" => ["value" => '客户-' . $customName, "color" => "#173177"],
- "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //花店新采购单通知 ssh 20231128
- public static function hdNewCgOrderInform($shop, $cg)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- //采购申请处理通知
- $shortTempId = 'ZHH202311282308';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $id = $cg->id;
- $ghsName = $cg->ghsName;
- $actPrice = $cg->actPrice;
- $book = $cg->book;
- $goods = '花材';
- $status = $cg->status;
- if ($status == 1) {
- $road = '待付款';
- } elseif ($status == 2) {
- $road = '待发货';
- if ($book == 0) {
- $goods = '请查阅';
- } else {
- $goods = '请查阅(预订)';
- }
- } elseif ($status == 3) {
- $road = '已发货';
- if ($book == 0) {
- $goods = '请查阅';
- } else {
- $goods = '请查阅(预订)';
- }
- } elseif ($status == 4) {
- $road = '已完成';
- } else {
- $road = '已取消';
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "thing12" => ["value" => $ghsName],
- "thing7" => ["value" => $goods],
- "amount10" => ["value" => $actPrice],
- "phrase4" => ["value" => $road],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $id;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //花店新订单通知 ssh 20210529
- public static function hdNewOrderInform($shop, $order)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM417875155';//新订单通知
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $orderId = $order->id;
- $actPrice = $order->actPrice;
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "您有新的订单,请注意查收", "color" => "#173177"],
- "keyword1" => ["value" => $order->orderSn, "color" => "#173177"],
- "keyword2" => ["value" => $actPrice, "color" => "#173177"],
- "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- public static function hdScanPayInform($shop, $scan)
- {
- if (empty($shop)) {
- return false;
- }
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM207422813';//收入提醒
- $tempId = $message[$shortTempId]['templateId'] ?? '';
- if (empty($tempId)) {
- return false;
- }
- $actPrice = $scan->actPrice;
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = $admin['openId'] ?? '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = $admin['ghsOpenId'] ?? '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "您有新的收入。", "color" => "#173177"],
- "keyword1" => ["value" => $actPrice, "color" => "#173177"],
- "keyword2" => ["value" => '二维码收款', "color" => "#173177"],
- "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/order/scanPay';
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //审核通过通知 ssh 20210530
- public static function applyPass($shop)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM401915538';//审核通过通知
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = array(
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => array(
- "first" => array(
- "value" => "恭喜,您的开店申请审核通过。",
- "color" => "#173177"
- ),
- "keyword1" => array(
- "value" => '审核通过',
- "color" => "#173177"
- ),
- "keyword2" => array(
- "value" => date("Y-m-d H:i:s"),
- "color" => "#173177"
- ),
- "remark" => array(
- "value" => '点击登陆后台',
- "color" => "#173177"
- )
- ),
- );
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/home/workbench';
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //采购单下单成功 ssh 20210531
- public static function generateCgOrder($shop, $order)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM202297555';//下单成功通知
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $orderId = $order->id;
- $orderSn = (string)$order->orderSn;
- $totalFee = $order->actPrice;
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => '亲,您的采购单已生成', "color" => "#173177"],
- "keyword1" => ["value" => $orderSn, "color" => "#173177"],
- "keyword2" => ["value" => '花材', "color" => "#173177"],
- "keyword3" => ["value" => $order->bigNum . '/' . $order->smallNum, "color" => "#173177"],
- "keyword4" => ["value" => number_format($totalFee, 2) . '元', "color" => "#173177"],
- "keyword5" => ["value" => '-', "color" => "#173177"],
- "remark" => ["value" => "", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //采购单已发货 ssh 20210531
- public static function cgOrderHasSend($shop, $order)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM416881153';//下单成功通知
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $orderId = $order->id;
- $orderSn = (string)$order->orderSn;
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- $ghsShopAdminName = $order->ghsShopAdminName ?? '';
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => '亲,您的采购单已发货,请注意签收', "color" => "#173177"],
- "keyword1" => ["value" => $orderSn, "color" => "#173177"],
- "keyword2" => ["value" => date("Y-m-d H:i:s"), "color" => "#173177"],
- "keyword3" => ["value" => $ghsShopAdminName, "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //零售清算欠款通知供货商 ssh 20210531
- public static function clearInform($shop, $order, $custom)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM207422813';//收入提醒
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $id = $order->id ?? 0;
- $actPrice = $order->actPrice;
- $actPrice = floatval($actPrice);
- $name = $custom->name ?? '';
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "", "color" => "#173177"],
- "keyword1" => ["value" => '¥' . $actPrice, "color" => "#173177"],
- "keyword2" => ["value" => "{$name} 线上结账", "color" => "#173177"],
- "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/clear/customInfo?id=' . $id;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //收款码收入通知 ssh 20210531
- public static function gatheringIncomeInform($shop, $order)
- {
- if ($order->payStatus != 1) {
- return false;
- }
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM207422813';//收入提醒
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $actPrice = $order->actPrice;
- $orderId = $order->id;
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "您有新的收入。", "color" => "#173177"],
- "keyword1" => ["value" => $actPrice, "color" => "#173177"],
- "keyword2" => ["value" => '门店收入', "color" => "#173177"],
- "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => "点击查看详情", "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/order/detail?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //提现成功通知 ssh 20210531
- public static function cashInform($shop, $cash)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM411207151';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $amount = floatval($cash->amount);
- $beAmount = floatval($cash->beAmount);
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- $mainId = $shop->mainId ?? 0;
- $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', 'adminId');
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $adminId = $admin['id'] ?? 0;
- $super = $staffList[$adminId]['super'] ?? 0;
- //提现管理员才通知
- if ($super == 0) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "", "color" => "#173177"],
- "keyword1" => ["value" => "¥{$beAmount}", "color" => "#173177"],
- "keyword2" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
- "remark" => ["value" => '', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesStore/me/cashInfo?id=' . $cash->id;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //订单送达通知 ssh 20210607
- public static function reachInform($shop, $order)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM201205968';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $orderId = $order->id ?? '';
- $orderSn = (string)$order->orderSn ?? '';
- $customName = $order->customName ?? '';
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => '客户订单已送达', "color" => "#173177"],
- "keyword1" => ["value" => $orderSn, "color" => "#173177"],
- "keyword2" => ["value" => $customName, "color" => "#173177"],
- "keyword3" => ["value" => '已送达', "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesOrder/detail?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //采购退款成功通知 ssh 20210730
- public static function cgRefundInform($shop, $cg, $amount)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM407280253';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $orderId = $cg->id ?? '';
- $orderSn = (string)$cg->orderSn ?? '';
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => '采购单:' . $orderSn, "color" => "#173177"],
- "keyword1" => ["value" => "订单退款", "color" => "#173177"],
- "keyword2" => ["value" => $amount . "元", "color" => "#173177"],
- "keyword3" => ["value" => '已送达', "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesPurchase/purDetails?id=' . $orderId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //库存预警通知 ssh 20210909
- public static function stockWarningInform($shop, $productList)
- {
- if (empty($productList)) {
- return false;
- }
- $remark = '';
- foreach ($productList as $key => $product) {
- $stock = $product->stock ?? 0;
- $currentStock = floatval($stock);
- $name = $product->name ?? '';
- $remark .= $name . "({$currentStock}) ";
- }
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM206773265';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $shopName = $shop->shopName ?? '';
- $date = date("Y-m-d H:i:s");
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "", "color" => "#173177"],
- "keyword1" => ["value" => $shopName, "color" => "#173177"],
- "keyword2" => ["value" => "点击查看花材", "color" => "#173177"],
- "keyword3" => ["value" => "库存不足", "color" => "#D52B4D"],
- "keyword4" => ["value" => $date, "color" => "#173177"],
- "remark" => ["value" => $remark, "color" => "#D52B4D"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/item/list?warning=1';
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //供货商客户领取了新人红包 ssh 20211027
- public static function ghsCustomGetNewGiftInform($shop, $custom)
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM408238177';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $customId = $custom['id'] ?? 0;
- $customName = $custom['name'] ?? '';
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => $customName . " 领取了新客红包", "color" => "#173177"],
- "keyword1" => ["value" => "新客红包", "color" => "#173177"],
- "keyword2" => ["value" => "已领取", "color" => "#173177"],
- "remark" => ["value" => '点击查看客户', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //供货商的客户介绍新客并且下单,获得红包通知商家 ssh 20211027
- public static function ghsCustomTjGetGiftInform($shop, $custom, $beTjCustom)
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM408238177';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $customId = $custom->id ?? 0;
- $customName = $custom->name ?? '';
- $beTjCustomName = $beTjCustom->name ?? '';
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "【{$beTjCustomName}】推荐的客户【{$customName}】已下单", "color" => "#173177"],
- "keyword1" => ["value" => "推荐新客红包", "color" => "#173177"],
- "keyword2" => ["value" => "已发放给【{$beTjCustomName}】", "color" => "#173177"],
- "remark" => ["value" => '点击查看客户', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //花店推荐供货商客户获得红包 ssh 20211027
- public static function hdTjGhsCustomGetGiftInform($shop, $ghs, $beTjCustom)
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM408238177';
- $tempId = $message[$shortTempId]['templateId'] ?? '';
- if (empty($tempId)) {
- return false;
- }
- $beTjCustomName = $beTjCustom->name ?? '';
- $ghsName = $ghs->name ?? '';
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = $admin['openId'] ?? '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = $admin['ghsOpenId'] ?? '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "您推荐的客户【{$beTjCustomName}】已在【{$ghsName}】下单", "color" => "#173177"],
- "keyword1" => ["value" => "推荐新客红包", "color" => "#173177"],
- "keyword2" => ["value" => "已获得", "color" => "#173177"],
- "remark" => ["value" => '点击查看红包', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/coupon/couponList';
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //供货商新客户通知 ssh 20210909
- public static function newGhsCustomInform($shop, $custom, $introduce = [])
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM203447669';
- $tempId = $message[$shortTempId]['templateId'] ?? '';
- if (empty($tempId)) {
- return false;
- }
- $customId = $custom->id ?? 0;
- $customName = $custom->name ?? '';
- $date = date("Y-m-d H:i:s");
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- $first = '';
- if (!empty($introduce)) {
- $introName = $introduce->name ?? '';
- $first = "此客户由【{$introName}】介绍";
- }
- foreach ($adminList as $admin) {
- $openId = $admin['openId'] ?? '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = $admin['ghsOpenId'] ?? '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => $first, "color" => "#173177"],
- "keyword1" => ["value" => $customId, "color" => "#173177"],
- "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
- "keyword3" => ["value" => $date, "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'pagesClient/member/detail?id=' . $customId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //客户充值通知供货商 ssh 20211005
- public static function customRechargeInformGhs($recharge)
- {
- $amount = $recharge->amount ?? 0;
- $hbId = $recharge->hbId ?? 0;
- $ghsId = $recharge->ghsId ?? 0;
- if (empty($ghsId)) {
- return false;
- }
- if (empty($hbId)) {
- return false;
- }
- $ghsInfo = GhsClass::getById($ghsId, true);
- $shopId = $ghsInfo->shopId ?? 0;
- $customId = $ghsInfo->customId ?? 0;
- $customInfo = CustomClass::getById($customId, true);
- $customName = $customInfo->name ?? '';
- $shopInfo = ShopClass::getById($shopId, true);
- $ptStyle = $shopInfo->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM411530050';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shopInfo);
- if (empty($adminList)) {
- return false;
- }
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => "有新客户充值", "color" => "#173177"],
- "keyword1" => ["value" => $customName, "color" => "#173177"],
- "keyword2" => ["value" => $customId, "color" => "#D52B4D"],
- "keyword3" => ["value" => $amount, "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/hb/rechargeList';
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //花店新客户通知 ssh 20220919
- public static function newHdCustomInform($shop, $custom, $introduce = [])
- {
- $ptStyle = $shop->ptStyle ?? 0;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- $shortTempId = 'OPENTM203447669';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $customId = $custom->id ?? 0;
- $customName = $custom->name ?? '';
- $date = date("Y-m-d H:i:s");
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- $first = '';
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- if (empty($openId)) {
- continue;
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "first" => ["value" => $first, "color" => "#173177"],
- "keyword1" => ["value" => $customId, "color" => "#173177"],
- "keyword2" => ["value" => $customName, "color" => "#D52B4D"],
- "keyword3" => ["value" => $date, "color" => "#173177"],
- "remark" => ["value" => '点击查看详情', "color" => "#173177"]
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/member/detail?id=' . $customId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //预订变化通知供货商员工下架花材 ssh 20240729
- public static function bookChangeOutStockInform($shop, $bookItemCustomRes, $num)
- {
- $ptStyle = $shop->ptStyle;
- $wxBase = WxOpenClass::getWxBase();
- $wx = $wxBase[$ptStyle] ?? [];
- $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
- //取货提醒
- $shortTempId = 'ZHH202407100108';
- $tempId = isset($message[$shortTempId]['templateId']) ? $message[$shortTempId]['templateId'] : '';
- if (empty($tempId)) {
- return false;
- }
- $adminList = ShopAdminClass::getRemainAdmin($shop);
- if (empty($adminList)) {
- return false;
- }
- $itemId = $bookItemCustomRes->itemId ?? 0;
- $itemName = $bookItemCustomRes->name ?? '';
- $customName = $bookItemCustomRes->customName ?? '';
- $seatSn = $bookItemCustomRes->seatSn ?? 0;
- $seatName = empty($seatSn) ? '' : $seatSn;
- foreach ($adminList as $admin) {
- $openId = isset($admin['openId']) ? $admin['openId'] : '';
- if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
- $openId = isset($admin['ghsOpenId']) ? $admin['ghsOpenId'] : '';
- }
- $data = [
- "touser" => $openId,
- "template_id" => $tempId,
- "url" => Yii::$app->params['ghsDomain'],
- "data" => [
- "thing8" => ["value" => $customName . ' ' . $seatName],
- "thing10" => ["value" => '请下架' . $num . '份'],
- "thing7" => ["value" => $itemName],
- ]
- ];
- $data['miniprogram']['appid'] = $wx['miniAppId'];
- $data['miniprogram']['pagepath'] = 'admin/notice/index';
- //$data['miniprogram']['pagepath'] = 'admin/book/itemCustom?itemId=' . $itemId . '&itemName=' . $itemName;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- }
|