| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843 |
- <?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 common\components\dict;
- use common\components\noticeUtil;
- 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' => '反馈进度通知',
- ],
- //供应商
- dict::getDict('ptStyle', 'ghs') => [
- 'OPENTM417875155' => '新订单通知',
- 'OPENTM207430125' => '操作成功通知',
- 'OPENTM401915538' => '审核通知',
- 'OPENTM201205968' => '订单送达通知',
- 'OPENTM207777535' => '付款提醒',
- 'OPENTM207422813' => '收入提醒',
- 'OPENTM202297555' => '下单成功通知',
- 'OPENTM207327227' => '宝贝售出提醒',
- 'OPENTM207188526' => '付款成功',
- 'OPENTM411207151' => '提现成功通知',
- 'OPENTM416881153' => '发货通知',
- 'OPENTM407280253' => '退款成功通知',
- 'OPENTM206773265' => '库存预警通知',
- 'OPENTM203447669' => '新客户加入通知',
- 'OPENTM411530050' => '充值成功提醒',
- 'OPENTM408238177' => '反馈进度通知',
- ],
- //商城
- dict::getDict('ptStyle', 'mall') => [
- ],
- ];
- }
- //初始化消息模板
- // ./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 20210529
- public static function newOrderInform($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;
- $first = "您有新的订单,请注意查收";
- $customName = $order->customName ?? '';
- if (!empty($customName)) {
- $first = '下单客户:' . $customName;
- }
- $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" => $first, "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'] = 'pagesOrder/detail?id=' . $orderId;
- 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);
- }
- }
- //审核通过通知 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 (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 (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 (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;
- }
- $actPrice = $order->actPrice;
- $name = $custom->name ?? '';
- $customId = $custom->id;
- $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" => "{$name}结帐付款{$actPrice}元", "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'] = 'pagesArrears/details?id=' . $customId;
- wxUtil::sendTaskInform($data, $wx, $ptStyle);
- }
- }
- //收款码收入通知 ssh 20210531
- public static function gatheringIncomeInform($shop, $order)
- {
- $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 (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 = $cash->amount;
- $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 (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" => $amount, "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/withdraw';
- 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 (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 (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 (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'] = 'pagesStorehouse/stockWarn/manage';
- 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 (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 (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 = isset($message[$shortTempId]['templateId']) ? $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 = isset($admin['openId']) ? $admin['openId'] : '';
- 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 = 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 = '';
- if (!empty($introduce)) {
- $introName = $introduce->name ?? '';
- $first = "此客户由【{$introName}】介绍";
- }
- 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" => $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 (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);
- }
- }
- }
|