Răsfoiți Sursa

供货商订单

林琦海 5 ani în urmă
părinte
comite
099baf6d44

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

@@ -252,10 +252,14 @@ class OrderController extends BaseController
         //2021.3.28 接入达达
         $get = Yii::$app->request->get();
         $orderId = $get['id'] ?? 0; //订单ID
+
         $customId = $get['customId'] ?? 0;
         if (!empty($customId)) {
             util::success(['sedCost' => 27]);
         }
+        if(empty($orderId)){
+            util::success(['sedCost' => 10]);
+        }
         $province = $get['province'] ?? '';
         $city = $get['city'] ?? '';
         $address = $get['address'] ?? '';

+ 2 - 1
biz-ghs/express/services/DadaExpressServices.php

@@ -123,7 +123,8 @@ class DadaExpressServices
             'receiver_lat' =>(float)$orderInfo['lat'], // 存的是百度经纬度,需要转高德经纬度
             'receiver_lng' =>(float)$orderInfo['long'], // 存的是百度经纬度,需要转高德经纬度
             'callback'=> Yii::$app->params['ghsHost'].'/notice/express-call-back',
-            'cargo_weight'=>0.01,//订单重量(单位:Kg)
+
+            'cargo_weight'=>(float)$orderInfo['weight'],//订单重量(单位:Kg)
             'receiver_phone'=>$orderInfo['customMobile'],//否	收货人手机号(手机号和座机号必填一项)
             'info'=>'',//备注
             'cargo_type'=>3, //类型:鲜花

+ 8 - 0
biz-ghs/order/classes/OrderClass.php

@@ -94,6 +94,14 @@ class OrderClass extends BaseClass
         $data['deadline'] = date("Y-m-d H:i:s", (time() + 1800));
         $data['sendCost'] = isset($data['sendCost']) && is_numeric($data['sendCost']) ? $data['sendCost'] : 0;
         $data['status'] = self::ORDER_STATUS_UN_PAY;
+
+        //计算总重量(kg)
+        $weight = 0;
+        foreach ($product as $key => $val) {
+            $w = ProductClass::getWeight($val['productId'], $val['bigNum'], $val['smallNum']);
+            $weight = bcadd($w,$weight,2);
+        }
+        $data['weight'] = $weight;
         $return = self::add($data);
 
         //总订单和待付款订单增加

+ 13 - 0
biz-ghs/product/classes/ProductClass.php

@@ -10,6 +10,7 @@ use common\components\imgUtil;
 use common\components\util;
 use common\services\xhItemService;
 use Yii;
+use yii\di\ServiceLocator;
 
 class ProductClass extends BaseClass
 {
@@ -500,4 +501,16 @@ class ProductClass extends BaseClass
         return self::updateById($productId, ['addPrice' => $addPrice]);
     }
 
+    //根据productId 计算花材的重量
+    public static function getWeight($productId,$bigNum,$smallNum)
+    {
+        $productInfo = self::getById($productId);
+        if(empty($productInfo)){
+            return 0;
+        }
+        $ratio = $productInfo['ratio'];
+        $weight = $productInfo['weight'];
+        $mergeNum = self::mergeItemNum($bigNum,$smallNum,$ratio);
+        return bcmul($mergeNum,$weight,2);
+    }
 }

+ 3 - 0
sql.sql

@@ -2020,3 +2020,6 @@ ALTER TABLE xhCustom DROP COLUMN `totalBuyNum`;
 ==linqh 2021.4.9
 ALTER TABLE `xhGoods`
 ADD COLUMN `py`  varchar(20) NOT NULL DEFAULT '' COMMENT '拼音' AFTER `shortUrl`;
+
+ALTER TABLE `xhGhsOrder`
+ADD COLUMN `weight`  decimal(9,2) NOT NULL DEFAULT 0 COMMENT '花材总重量(公斤)' AFTER `status`;