Răsfoiți Sursa

下单和通知

shish 3 ani în urmă
părinte
comite
0efc09d4f8

+ 3 - 3
app-ghs/controllers/OrderController.php

@@ -978,6 +978,7 @@ class OrderController extends BaseController
                 $shopId = $order->shopId ?? 0;
                 $shop = ShopClass::getById($shopId, true);
                 if (!empty($shop)) {
+                    //花店采购供货商端收到微信通知
                     WxMessageClass::ghsHasNewOrderInform($shop, $order);
                 }
                 //订单生成时唤起在线打印
@@ -989,10 +990,9 @@ class OrderController extends BaseController
                     }
                 }
                 if ($order->status != 1 && $order->status != 5) {
-                    //花店采购供货商端收到通知
-                    NoticeClass::ghsNewOrderNotice($order);
+                    //花店采购供货商端收到APP通知
+                    //NoticeClass::ghsNewOrderNotice($order);
                 }
-
                 //前台提醒出示付款码
                 if (isset($order->status) && $order->status == 1) {
                     if (isset($post['isCashier']) && $post['isCashier'] == 1) {

+ 5 - 0
app-hd/controllers/NoticeController.php

@@ -271,6 +271,11 @@ class NoticeController extends PublicController
                                 $order->printNum += 1;
                                 $order->save();
                             }
+                            $cgShopId = $cg->shopId ?? 0;
+                            $cgShop = ShopClass::getById($cgShopId, true);
+                            if (!empty($cgShop)) {
+                                \bizHd\notice\classes\NoticeClass::cgSuccessMiniNotice($cgShop, $cg);
+                            }
                             $shopId = $order->shopId ?? 0;
                             $shop = ShopClass::getById($shopId, true);
                             if (!empty($shop)) {

+ 61 - 0
biz-hd/notice/classes/NoticeClass.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace bizHd\notice\classes;
+
+use biz\base\classes\BaseClass;
+use bizHd\admin\classes\AdminClass;
+use bizHd\staff\classes\StaffClass;
+use bizHd\wx\classes\WxOpenClass;
+use common\components\dict;
+use common\components\miniUtil;
+use Yii;
+
+class NoticeClass extends BaseClass
+{
+
+    //采购成功之后小程序通知
+    public static function cgSuccessMiniNotice($cgShop, $cg)
+    {
+        $mainId = $cgShop->mainId ?? 0;
+        $staffList = StaffClass::getAllByCondition(['mainId' => $mainId], null, 'adminId');
+
+        $merchant = WxOpenClass::getWxInfo();
+        $ptStyle = dict::getDict('ptStyle', 'hd');
+        if (getenv('YII_ENV') == 'production') {
+            $msgList = dict::getDict('hdMiniMessage');
+        } else {
+            $msgList = dict::getDict('hdMiniMessageDev');
+        }
+        $msgId = $msgList['cgSuccess']['msgId'] ?? '';
+        if (empty($msgId)) {
+            return [];
+        }
+        $ghsName = $cg->ghsName ?? '';
+        $bigNum = $cg->bigNum ?? 0;
+        $actPrice = $cg->actPrice ? floatval($cg->actPrice) : 0;
+        $payTime = $cg->payTime ?? '';
+        if (!empty($staffList)) {
+            $ids = array_column($staffList, 'adminId');
+            if (!empty($ids)) {
+                $adminList = AdminClass::getByIds($ids);
+                if (!empty($adminList)) {
+                    foreach ($adminList as $admin) {
+                        $miniOpenId = $admin['miniOpenId'] ?? '';
+                        if (!empty($miniOpenId)) {
+                            $msg = [
+                                "thing1" => ["value" => $ghsName],
+                                "thing2" => ["value" => $bigNum . "扎花材"],
+                                "amount3" => ["value" => $actPrice],
+                                "date4" => ["value" => $payTime],
+                                "thing5" => ["value" => "点击查看详情"]
+                            ];
+                            $page = 'pagesPurchase/purDetails?id=' . $cg->id;
+                            miniUtil::commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+}

+ 2 - 8
common/components/miniUtil.php

@@ -1905,18 +1905,12 @@ class miniUtil
     /**************************即时配送相关接口 END *****************************************/
 
     //发送订阅消息通知 ssh 2023511
-    public static function commonSendSubscribeMessage($merchant, $ptStyle = 0)
+    public static function commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg)
     {
         $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
         $url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=' . $accessToken;
         $curl = new curl\Curl();
-        $msg = [
-            "date2" => ["value" => "2019-12-24 10:10:10"],
-            "thing1" => ["value" => "注意"],
-            "phrase5" => ["value" => "成功"],
-            "thing4" => ["value" => "点击查看详情"]
-        ];
-        $data = ['template_id' => 'dtzw008ZnN41VYRrLrpvZAJHJw-_2pLb9UVanNOatS0', 'page' => 'admin/home/workbench', 'touser' => 'owjM44zOb4mOC9fUI29iXFfB9o4g', 'data' => $msg];
+        $data = ['template_id' => $msgId, 'page' => $page, 'touser' => $miniOpenId, 'data' => $msg];
         $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
         $result = Json::decode($result);
         return $result;