Procházet zdrojové kódy

微信和app通知的开与关

shish před 1 měsícem
rodič
revize
eb9456b5c3

+ 5 - 1
common/components/dict.php

@@ -8,6 +8,10 @@ class dict
 {
 
     public static $data = [
+        //APP通知打开关闭状态 1打开 0关闭
+        'appNotice' => 1,
+        //微信通知打开关闭状态 1打开 0关闭
+        'wxNotice' => 1,
         //是否具备地址功能 0不具备 1具备
         'hasMap' => 1,
         //mainId对应物流月结账号
@@ -609,4 +613,4 @@ class dict
         return $respond;
     }
 
-}
+}

+ 4 - 0
common/components/miniUtil.php

@@ -2003,6 +2003,10 @@ class miniUtil
     //发送订阅消息通知 ssh 2023511
     public static function commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg)
     {
+        $wxNotice = dict::getDict('wxNotice');
+        if($wxNotice == 0) {
+            return [];
+        }
         $accessToken = self::getMiniProgramAccessToken($merchant, $ptStyle);
         $url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=' . $accessToken;
         $curl = new curl\Curl();

+ 5 - 0
common/components/push.php

@@ -300,6 +300,11 @@ class push
      */
     public function ghsOrderMessage($shop, $cgShop, $order)
     {
+        $appNotice = dict::getDict('appNotice');
+        //app禁止通知
+        if($appNotice == 0) {
+            return [];
+        }
         try {
             $allDevices = \bizGhs\device\classes\GhsDeviceClass::getAllByCondition(['shopId' => $shop->id, 'status' => 1]);
             $cids = array_column($allDevices, 'clientId');

+ 4 - 12
common/components/wxUtil.php

@@ -531,6 +531,10 @@ class wxUtil
      */
     public static function sendTaskInform($data, $merchant, $isOpen = 0)
     {
+        $wxNotice = dict::getDict('wxNotice');
+        if($wxNotice == 0){
+            return [];
+        }
         $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
         $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$accessToken}";
         $data = urldecode(json_encode($data, JSON_UNESCAPED_UNICODE));
@@ -542,18 +546,6 @@ class wxUtil
         return $arr;
     }
 
-    public static function sendTaskInform2($data, $merchant, $isOpen = 0)
-    {
-        $accessToken = self::getAuthorizerAccessToken($merchant, $isOpen);
-        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$accessToken}";
-        $data = urldecode(json_encode($data, JSON_UNESCAPED_UNICODE));
-        $curl = new curl\Curl();
-        $response = $curl->setOption(CURLOPT_POSTFIELDS, $data)->post($url);
-        Yii::info('发送模板消息返回哈:' . $response);
-        $arr = json_decode($response);
-        return $arr;
-    }
-
     /**
      * 创建模板消息
      */