Bladeren bron

涨价设置

shish 6 maanden geleden
bovenliggende
commit
513e4e04c5

+ 1 - 1
app-ghs/controllers/ItemController.php

@@ -542,7 +542,7 @@ class ItemController extends BaseController
         } elseif ($requestType == 'changeStock') {
             $list = ProductClass::changeStockGroup($list, $level);
         } elseif ($requestType == 'kd') {
-            $list = ProductClass::kdItemGroup($list, $level);
+            $list = ProductClass::kdItemGroup($list, $level,$custom);
         } elseif ($requestType == 'book') {
             $list = ProductClass::bookItemGroup($list, $level);
         } elseif ($requestType == 'itemList') {

+ 2 - 1
app-ghs/controllers/ProductController.php

@@ -321,6 +321,7 @@ class ProductController extends BaseController
         //客户等级
         $customId = Yii::$app->request->get('customId', 0);
         $level = 1;
+        $custom = [];
         if (!empty($customId)) {
             $custom = CustomClass::getById($customId, true);
             $level = $custom->level ?? 1;
@@ -351,7 +352,7 @@ class ProductController extends BaseController
             //开单的花材列表
             $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide,reachNum,reachNumDiscount';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-            $itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level);
+            $itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level, $custom);
         } elseif ($requestType == 'book') {
             //预订花材列表
             $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide';

+ 2 - 2
app-hd/controllers/ProductController.php

@@ -617,7 +617,7 @@ class ProductController extends BaseController
             $level = $ghs['giveLevel'] ?? 1;
             $field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,skPrice,skDiscountPrice,hjPrice,hjDiscountPrice,actualSold,stock,stockWarning,discountPrice,presell,presellDate,reachNum,reachNumDiscount,limitBuy';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-            $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level);
+            $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level, $ghs);
             $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning,itemId', 'itemId');
             if (!empty($itemInfoData)) {
                 $myShop = $this->shop;
@@ -706,7 +706,7 @@ class ProductController extends BaseController
             $level = $ghs['giveLevel'] ?? 1;
             $field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,skPrice,skDiscountPrice,hjPrice,hjDiscountPrice,actualSold,stock,stockWarning,discountPrice,presell,presellDate,reachNum,reachNumDiscount,limitBuy';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-            $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level);
+            $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level, $ghs);
             $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning,itemId', 'itemId');
             if (!empty($itemInfoData)) {
                 $myShop = $this->shop;

+ 11 - 4
biz-ghs/product/classes/ProductClass.php

@@ -310,11 +310,15 @@ class ProductClass extends BaseClass
     }
 
     //花材列表用到的数据组合 ssh 20221225
-    public static function kdItemGroup($list, $level = 0)
+    public static function kdItemGroup($list, $level = 0, $custom = [])
     {
         //各个等级对应的price addPrice字段
         $priceMap = CustomClass::$levelPriceKeyMap;
+        //这个参数应该是要作废的,但下面加的参数是有用的,多处要同步修改,关键词 abandon_add_price_map ,ssh 20260116
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+        //但这边加的参数是有用的,给指定客户涨价的
+        $addPriceMap['risePercent'] = $custom['risePercent'] ?? 0;
+
         foreach ($list as $k => $v) {
             $shortCover = $v['cover'] ?? '';
             $cover = imgUtil::getPrefix() . 'hhb_small.png';
@@ -661,11 +665,14 @@ class ProductClass extends BaseClass
     }
 
     //零售端花店采购
-    public static function hdCgGroup($list, $level = 0)
+    public static function hdCgGroup($list, $level = 0, $ghs = [])
     {
         //各个等级对应的price addPrice字段
         $priceMap = CustomClass::$levelPriceKeyMap;
+        //这个参数应该是要作废的,但下面加的参数是有用的,多处要同步修改,关键词 abandon_add_price_map ,ssh 20260116
         $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+        //这里加的参数是有用的 ssh 20260116
+        $addPriceMap['risePercent'] = $ghs['risePercent'] ?? 0;
 
         foreach ($list as $k => $v) {
             $shortCover = $v['cover'] ?? '';
@@ -772,12 +779,12 @@ class ProductClass extends BaseClass
         }
 
         //这个 $risePercent 可能是正整数,也可能是负整数,如果是10表示$price涨价10%,如果是-10表示降价10%,同时$prce降价后,不能小于0.01
-        $risePercent = $param['risePercent'] ?? 0;
+        $risePercent = $params['risePercent'] ?? 0;
         if ($risePercent != 0) {
             // risePercent为正数表示涨价百分比,负数表示降价百分比
             $priceAdjustment = bcmul($price, bcdiv($risePercent, 100, 4), 2);
             $price = bcadd($price, $priceAdjustment, 2);
-            
+
             // 降价后不能小于0.01
             if ($price < 0.01) {
                 $price = 0.01;