shish 5 роки тому
батько
коміт
a7a7bd0a95
2 змінених файлів з 31 додано та 31 видалено
  1. 30 30
      biz-ghs/ws/services/WsService.php
  2. 1 1
      biz-hd/order/classes/OrderClass.php

+ 30 - 30
biz-ghs/ws/services/WsService.php

@@ -9,40 +9,40 @@ use common\components\oss;
 use common\components\util;
 use GatewayClient\Gateway;
 use Yii;
+
 class WsService
 {
     //到账通知 $adminId 为 shopAdminId
-    public static function arrivalNotice($adminId,$money,$payWay='')
+    public static function arrivalNotice($adminId, $money, $payWay)
     {
-        $msg = '微信到账'.$money;
-        $audio = baiduAip::transfer($msg,4,0);
-        Yii::info("触发到账通知:".$adminId. " ".$money);
+        $payment = $payWay == dict::getDict('payWay', 'alipay') ? '支付宝' : '微信';
+        $msg = $payment . '收款' . $money;
+        $audio = baiduAip::transfer($msg, 4, 0);
+        Yii::info("触发到账通知:" . $adminId . " " . $money);
 
-        if(!is_array($audio)){
-            try{
+        if (!is_array($audio)) {
+            try {
                 //上传到oss
-                $file =time().rand(10000,999999).'.mp3';
-                $filePath = 'tmp/arrival/money/'.$file;
-                oss::uploadTmpAudio($filePath,$audio);
-                $url = 'https://hhb-tmp-audio.oss-cn-hangzhou.aliyuncs.com/'.$filePath;
+                $file = time() . rand(10000, 999999) . '.mp3';
+                $filePath = 'tmp/arrival/money/' . $file;
+                oss::uploadTmpAudio($filePath, $audio);
+                $url = 'https://hhb-tmp-audio.oss-cn-hangzhou.aliyuncs.com/' . $filePath;
                 // $audio = base64_encode($audio);
-                $data = ['type' => 'money','url'=>$url, 'msg' => $msg,'money'=>$money];
+                $data = ['type' => 'money', 'url' => $url, 'msg' => $msg, 'money' => $money];
                 $dataString = json_encode($data);
-                goWs::sendToUid($adminId,$dataString);
+                goWs::sendToUid($adminId, $dataString);
                 //判断是否在线
                 // $online = Gateway::isUidOnline($adminId);
                 //Gateway::sendToUid($adminId, json_encode($data));
                 //$client = Gateway::getClientIdByUid($adminId);
                 //Yii::info("getClientIdByUid res :".json_encode($client));
 
-            }catch (\Exception $exception){
-                Yii::warning("ws arrivalNotice error ". $exception->getMessage());
+            } catch (\Exception $exception) {
+                Yii::warning("ws arrivalNotice error " . $exception->getMessage());
             }
-        }else{
-            Yii::warning("到账通知 语音获取失败" .json_encode($audio));
+        } else {
+            Yii::warning("到账通知 语音获取失败" . json_encode($audio));
         }
-
-
         return true;
     }
 
@@ -52,34 +52,34 @@ class WsService
     {
         $ptStyle = Yii::$app->params['ptStyle'];
         $prefix = '';
-        if($ptStyle == dict::getDict('ptStyle','hd')){
+        if ($ptStyle == dict::getDict('ptStyle', 'hd')) {
             $prefix = Yii::$app->params['hdImgHost'];
-        }elseif($ptStyle == dict::getDict('ptStyle','ghs')){
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
             $prefix = Yii::$app->params['ghsImgHost'];
-        }elseif($ptStyle == dict::getDict('ptStyle','mall')){
+        } elseif ($ptStyle == dict::getDict('ptStyle', 'mall')) {
             $prefix = Yii::$app->params['mallImgHost'];
-        }else{
+        } else {
             util::fail('平台无效');
         }
-        $url = $prefix.'audio/new_order0.mp3';
+        $url = $prefix . 'audio/new_order0.mp3';
         $data = [
-            'type'=>'new_order',
-            'url'=>$url,
+            'type' => 'new_order',
+            'url' => $url,
         ];
-        Yii::info("触发订单通知:".$shopAdminId);
-        try{
+        Yii::info("触发订单通知:" . $shopAdminId);
+        try {
             //判断是否在线
             //$online = Gateway::isUidOnline($shopAdminId);
             $dataString = json_encode($data);
-            goWs::sendToUid($shopAdminId,$dataString);
+            goWs::sendToUid($shopAdminId, $dataString);
             //Gateway::sendToUid($shopAdminId, json_encode($data));
 //            if($online){
 //
 //            }else{
 //                Yii::info("用户不在线:".$shopAdminId);
 //            }
-        }catch (\Exception $exception){
-            Yii::warning("ws arrivalNotice error ". $exception->getMessage());
+        } catch (\Exception $exception) {
+            Yii::warning("ws arrivalNotice error " . $exception->getMessage());
         }
         return true;
     }

+ 1 - 1
biz-hd/order/classes/OrderClass.php

@@ -171,7 +171,7 @@ class OrderClass extends BaseClass
             $shopAdminIds = \bizGhs\shop\classes\ShopAdminClass::getRemindAdminIdsByShopId($order->shopId);
             if ($shopAdminIds) {
                 foreach ($shopAdminIds as $v) {
-                    WsService::arrivalNotice($v, $order->actPrice);
+                    WsService::arrivalNotice($v, $order->actPrice, $order->payWay);
                 }
             }
         }