shish 4 лет назад
Родитель
Сommit
a5d8f4aabe
2 измененных файлов с 23 добавлено и 2 удалено
  1. 18 0
      common/components/payUtil.php
  2. 5 2
      common/components/pushNotice.php

+ 18 - 0
common/components/payUtil.php

@@ -5,6 +5,7 @@ namespace common\components;
 use biz\hb\classes\HbClass;
 use biz\recharge\classes\RechargeClass;
 use biz\renew\classes\RenewClass;
+use biz\shop\classes\ShopAdminClass;
 use biz\shop\classes\ShopExtClass;
 use biz\wx\classes\WxMessageClass;
 use bizHd\order\classes\OrderClass;
@@ -66,6 +67,23 @@ class payUtil
                                 $curl->get($url);
                             }
                         }
+
+                        //app消息通知
+                        $shopId = $order->shopId ?? 0;
+                        $adminList = ShopAdminClass::getRemainAdmin($shopId);
+                        if (empty($adminList)) {
+                            return false;
+                        }
+                        $customName = $order->customName ?? '';
+                        $actPrice = $order->actPrice ?? 0;
+                        foreach ($adminList as $admin) {
+                            $clientId = $admin['clientId'] ?? '';
+                            if (empty($clientId)) {
+                                continue;
+                            }
+                            $adminId = $admin['id'] ?? 0;
+                            pushNotice::push($adminId, $clientId, '新订单通知', $customName . '下单' . $actPrice . '元');
+                        }
                     }
                     break;
                 case dict::getDict('capitalType', 'hdPurchaseClear', 'id'):

+ 5 - 2
common/components/pushNotice.php

@@ -10,13 +10,16 @@ class pushNotice
     const appId = 'YjALucIHmI7DylcjlMZEx2';
     const masterSecret = 'zSbdBLOQrxAa5IcDNqIne7';
 
-    public static function push($cId, $title, $body)
+    public static function push($adminId, $cId, $title, $body)
     {
         //创建API,APPID等配置参考 环境要求 进行获取
         $api = new \GTClient(self::domainUrl, self::appKey, self::appId, self::masterSecret);
         //设置推送参数
         $push = new \GTPushRequest();
-        $push->setRequestId("1100000000000049");
+        $time = time();
+        $rand = rand(1000, 9999);
+        $rId = $time . $rand . $adminId;
+        $push->setRequestId($rId);
         $message = new \GTPushMessage();
         $notify = new \GTNotification();
         $notify->setTitle($title);