فهرست منبع

音频oss切换
损耗方法迁移

林琦海 5 سال پیش
والد
کامیت
b228deb9f3
3فایلهای تغییر یافته به همراه55 افزوده شده و 2 حذف شده
  1. 51 0
      app-ghs/controllers/WastageController.php
  2. 2 1
      biz-ghs/ws/services/WsService.php
  3. 2 1
      common/components/oss.php

+ 51 - 0
app-ghs/controllers/WastageController.php

@@ -0,0 +1,51 @@
+<?php
+//损耗
+namespace ghs\controllers;
+
+use Yii;
+use bizGhs\order\classes\StockWastageOrderClass;
+use common\components\util;
+use bizGhs\product\classes\ProductClass;
+class WastageController extends BaseController
+{
+
+    //新增损耗
+    public function actionCreateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $post['shopId'] = $this->shopId;
+        $post['sjId'] = $this->sjId;
+        $post['adminId'] = $this->adminId;
+        $productJson = $post['product'] ?? '';
+        if (empty($productJson)) {
+            util::fail('请选择花材');
+        }
+        $productList = json_decode($productJson, true);
+        if (empty($productList)) {
+            util::fail('请选择花材');
+        }
+        //判断花材里的信息
+        foreach ($productList as $v) {
+            $bigNum = $v['bigNum'] ?? 0;
+            $smallNum = $v['smallNum'] ?? 0;
+            if ($bigNum <= 0 && $smallNum <= 0) {
+                util::fail('花材数量不能为0');
+            }
+        }
+        $connection = Yii::$app->db;//事务处理
+        $transaction = $connection->beginTransaction();
+        try {
+            //判断花材有效性
+            ProductClass::valid($productList, $this->shopId);
+            $post['product'] = $productList;
+            $return = StockWastageOrderClass::addOrder($post);
+            $transaction->commit();
+            util::success($return);
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            Yii::info("报损失败原因:" . $e->getMessage());
+            util::fail('报损保存失败');
+        }
+    }
+
+}

+ 2 - 1
biz-ghs/ws/services/WsService.php

@@ -5,6 +5,7 @@ namespace bizGhs\ws\services;
 use common\components\baiduAip;
 use common\components\dict;
 use common\components\goWs;
+use common\components\imgUtil;
 use common\components\oss;
 use common\components\util;
 use GatewayClient\Gateway;
@@ -26,7 +27,7 @@ class WsService
                 $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;
+                $url = imgUtil::getPrefix(). $filePath;
                 // $audio = base64_encode($audio);
                 $data = ['type' => 'money', 'url' => $url, 'msg' => $msg, 'money' => $money];
                 $dataString = json_encode($data);

+ 2 - 1
common/components/oss.php

@@ -63,9 +63,10 @@ class oss
     }
 
     //上传语音
-    public static function uploadTmpAudio($object, $filePath,$bucket = 'hhb-tmp-audio')
+    public static function uploadTmpAudio($object, $filePath,$bucket = '')
     {
         $ossClient = self::getOssClient();
+        $bucket = Yii::$app->params['ossBucket'];
         try {
             $ossClient->putObject($bucket, $object, $filePath);
         } catch (OssException $e) {