Explorar o código

向供货端App(或花店App)发通知

shizhongqi hai 9 meses
pai
achega
f1ec3ef748

+ 27 - 4
app-ghs/controllers/OrderController.php

@@ -1337,10 +1337,21 @@ class OrderController extends BaseController
                         Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
 
                         //通知花店
-//                        $noticeText = json_encode(['id' => $order->purchaseId]);
-//                        $noticeKey = "ghsKdNoticeHd";
-//                        Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
-
+                        //$noticeText = json_encode(['id' => $order->purchaseId]);
+                        //$noticeKey = "ghsKdNoticeHd";
+                        //Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+
+                        //向花店App发通知
+                        $allDevices = \bizHd\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                        $cids = array_column($allDevices, 'clientId');
+                        $title = '买花成功';
+                        $content = $shop->shopName . ' ¥' . $order->actPrice;
+                        $payload = [
+                            "page" => "admin/order/detail",
+                            "params" => ["id" => $order->id]
+                        ];
+                        $push = new \common\components\push('hd');
+                        $push->pushByCloud($cids, $title, $content, $payload);
                     }
                 }
                 //订单生成时唤起在线打印
@@ -1644,6 +1655,18 @@ class OrderController extends BaseController
             if ($order->status != 1 && $order->status != 5) {
                 //花店采购供货商端APP收到通知
                 //NoticeClass::ghsNewOrderNotice($order);
+
+                //向供货商APP发通知
+                $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                $cids = array_column($allDevices, 'clientId');
+                $title = '你有新的订单';
+                $content = $shop->shopName . ' ¥' . $order->actPrice;
+                $payload = [
+                    "page" => "pagesOrder/detail",
+                    "params" => ["id" => $order->id]
+                ];
+                $push = new \common\components\push('ghs');
+                $push->pushByCloud($cids, $title, $content, $payload);
             }
         }
 

+ 49 - 1
app-hd/controllers/NoticeController.php

@@ -232,11 +232,23 @@ class NoticeController extends PublicController
                         $shopId = $order->shopId ?? 0;
                         $shop = ShopClass::getById($shopId, true);
                         if (!empty($shop)) {
-                            //花店采购供货商端微信收到通知
+                            //花店采购供货商端微信收到通知
                             //WxMessageClass::ghsHasNewOrderInform($shop, $order);
                             $noticeText = json_encode(['orderId' => $saleId]);
                             $noticeKey = "hdCgNoticeGhs";
                             Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+
+                            //向供货商APP发通知
+                            $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                            $cids = array_column($allDevices, 'clientId');
+                            $title = '你有新的订单';
+                            $content = $shop->shopName . ' ¥' . $order->actPrice;
+                            $payload = [
+                                "page" => "pagesOrder/detail",
+                                "params" => ["id" => $order->id]
+                            ];
+                            $push = new \common\components\push('ghs');
+                            $push->pushByCloud($cids, $title, $content, $payload);
                         }
                         //花店采购供货商端APP收到通知
                         //NoticeClass::ghsNewOrderNotice($order);
@@ -464,6 +476,18 @@ class NoticeController extends PublicController
                             $noticeText = json_encode(['orderId' => $saleId]);
                             $noticeKey = "hdCgNoticeGhs";
                             Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+
+                            //向供货商APP发通知
+                            $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                            $cids = array_column($allDevices, 'clientId');
+                            $title = '你有新的订单';
+                            $content = $shop->shopName . ' ¥' . $order->actPrice;
+                            $payload = [
+                                "page" => "pagesOrder/detail",
+                                "params" => ["id" => $order->id]
+                            ];
+                            $push = new \common\components\push('ghs');
+                            $push->pushByCloud($cids, $title, $content, $payload);
                         }
                         //花店采购供货商端APP收到通知
                         //NoticeClass::ghsNewOrderNotice($order);
@@ -595,6 +619,18 @@ class NoticeController extends PublicController
                             $noticeText = json_encode(['orderId' => $saleId]);
                             $noticeKey = "hdCgNoticeGhs";
                             Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+
+                            //向供货商端APP发通知
+                            $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                            $cids = array_column($allDevices, 'clientId');
+                            $title = '你有新的订单';
+                            $content = $shop->shopName . ' ¥' . $order->actPrice;
+                            $payload = [
+                                "page" => "pagesOrder/detail",
+                                "params" => ["id" => $order->id]
+                            ];
+                            $push = new \common\components\push('ghs');
+                            $push->pushByCloud($cids, $title, $content, $payload);
                         }
                         //花店采购供货商端APP收到通知
                         //NoticeClass::ghsNewOrderNotice($order);
@@ -833,6 +869,18 @@ class NoticeController extends PublicController
                                 $noticeText = json_encode(['orderId' => $saleId]);
                                 $noticeKey = "hdCgNoticeGhs";
                                 Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+
+                                //向供货商端APP发通知
+                                $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                                $cids = array_column($allDevices, 'clientId');
+                                $title = '你有新的订单';
+                                $content = $shop->shopName . ' ¥' . $order->actPrice;
+                                $payload = [
+                                    "page" => "pagesOrder/detail",
+                                    "params" => ["id" => $order->id]
+                                ];
+                                $push = new \common\components\push('ghs');
+                                $push->pushByCloud($cids, $title, $content, $payload);
                             }
                             //花店采购供货商端APP收到通知
                             //NoticeClass::ghsNewOrderNotice($order);

+ 12 - 0
app-hd/controllers/PurchaseController.php

@@ -767,6 +767,18 @@ class PurchaseController extends BaseController
                     $noticeText = json_encode(['orderId' => $saleId]);
                     $noticeKey = "hdCgNoticeGhs";
                     Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
+
+                    //向供货商APP发通知
+                    $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                    $cids = array_column($allDevices, 'clientId');
+                    $title = '你有新的订单';
+                    $content = $shop->shopName . ' ¥' . $order->actPrice;
+                    $payload = [
+                        "page" => "pagesOrder/detail",
+                        "params" => ["id" => $order->id]
+                    ];
+                    $push = new \common\components\push('ghs');
+                    $push->pushByCloud($cids, $title, $content, $payload);
                 }
                 //订单生成时唤起在线打印
                 if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {

+ 12 - 0
console/controllers/MqController.php

@@ -49,6 +49,18 @@ class MqController extends Controller
                     $shop = ShopClass::getById($shopId, true);
                     if (!empty($shop)) {
                         WxMessageClass::ghsHasNewOrderInform($shop, $order);
+
+                        // 向供货商App发通知
+                        $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId'=>$shopId]);
+                        $cids = array_column($allDevices, 'clientId');
+                        $title = '你有新的订单';
+                        $content = $shop->shopName . ' ¥' . $order->actPrice;
+                        $payload = [
+                            "page" => "pagesOrder/detail",
+                            "params" => ["id" => $order->id]
+                        ];
+                        $push = new \common\components\push('ghs');
+                        $rs = $push->pushByCloud($cids, $title, $content, $payload);
                     }
                 }
             }