shish 3 år sedan
förälder
incheckning
dd09ed468c

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

@@ -3,6 +3,7 @@
 namespace ghs\controllers;
 
 use biz\item\classes\PtItemClass;
+use bizGhs\custom\classes\CustomClass;
 use bizGhs\item\classes\ItemClass;
 use common\components\dict;
 use common\components\imgUtil;
@@ -316,10 +317,17 @@ class ItemController extends BaseController
     //列出所有花材,包括特价花材列表 ssh 20220315
     public function actionShowList()
     {
+        $get = Yii::$app->request->get();
+        $customId = $get['customId'] ?? 0;
+        $custom = CustomClass::getById($customId, true);
+        if ($custom->ownMainId != $this->mainId) {
+            util::fail('不是你的客户');
+        }
+
         $where['mainId'] = $this->mainId;
         $where['delStatus'] = 0;
         $where['status'] = 1;
-        $list = ItemClass::getShowList($where);
+        $list = ItemClass::getShowList($where, $custom);
 
         $mainId = $this->mainId;
         $get = Yii::$app->request->get();

+ 3 - 3
biz-ghs/item/classes/ItemClass.php

@@ -188,10 +188,10 @@ class ItemClass extends BaseClass
         }
     }
 
-    public static function getShowList($where)
+    public static function getShowList($where, $custom)
     {
-        $level = 1;
-        $field = 'id,cover,name,cost,itemId,classId,property,skPrice,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallRatio,smallUnit,bigUnit,ratio,addPrice';
+        $level = $custom->level ?? 1;
+        $field = 'id,cover,name,cost,itemId,classId,property,skPrice,variety,price,hjPrice,discountPrice,stock,stockWarning,presell,ratioType,smallRatio,smallUnit,bigUnit,ratio,hjAddPrice,addPrice';
         $list = self::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
         if (empty($list)) {
             return $list;

+ 26 - 19
biz-ghs/product/classes/ProductClass.php

@@ -307,7 +307,7 @@ class ProductClass extends BaseClass
             $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
             if ($level == 0) {
                 //零售做特价时显示的原价,不能删除
-                if(isset($v['skPrice'])){
+                if (isset($v['skPrice'])) {
                     $list[$k]['prePrice'] = $v['skPrice'];
                 }
             }
@@ -323,10 +323,10 @@ class ProductClass extends BaseClass
                 }
                 $list[$k]['hjPrice'] = floatval($hjPrice);
                 $skMore = $v['skMore'] ?? 0;
-                $diff = bcsub($skMore,$addPrice,2);
-                if($diff>0){
-                    $skPrice = bcadd($v['discountPrice'],$diff,2);
-                }else{
+                $diff = bcsub($skMore, $addPrice, 2);
+                if ($diff > 0) {
+                    $skPrice = bcadd($v['discountPrice'], $diff, 2);
+                } else {
                     $skPrice = $v['discountPrice'];
                 }
                 $list[$k]['skPrice'] = floatval($skPrice);
@@ -418,7 +418,7 @@ class ProductClass extends BaseClass
             $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
             if ($level == 0) {
                 //零售做特价时显示的原价,不能删除
-                if(isset($v['skPrice'])){
+                if (isset($v['skPrice'])) {
                     $list[$k]['prePrice'] = $v['skPrice'];
                 }
             }
@@ -434,10 +434,10 @@ class ProductClass extends BaseClass
                 }
                 $list[$k]['hjPrice'] = floatval($hjPrice);
                 $skMore = $v['skMore'] ?? 0;
-                $diff = bcsub($skMore,$addPrice,2);
-                if($diff>0){
-                    $skPrice = bcadd($v['discountPrice'],$diff,2);
-                }else{
+                $diff = bcsub($skMore, $addPrice, 2);
+                if ($diff > 0) {
+                    $skPrice = bcadd($v['discountPrice'], $diff, 2);
+                } else {
                     $skPrice = $v['discountPrice'];
                 }
                 $list[$k]['skPrice'] = floatval($skPrice);
@@ -535,21 +535,28 @@ class ProductClass extends BaseClass
             //零售做特价时的原价
             if ($level == 0) {
                 //零售做特价时显示的原价,不能删除
-                if(isset($v['skPrice'])){
+                if (isset($v['skPrice'])) {
                     $list[$k]['prePrice'] = $v['skPrice'];
                 }
             }
 
             if (isset($v['discountPrice']) && $v['discountPrice'] > 0) {
-                $addPrice = $v['addPrice'] ?? 0;
-                $skMore = $v['skMore'] ?? 0;
-                $diff = bcsub($skMore,$addPrice,2);
-                if($diff>0){
-                    $skPrice = bcadd($v['discountPrice'],$diff,2);
-                }else{
-                    $skPrice = $v['discountPrice'];
-                }
+                $skPrice = $v['discountPrice'];
                 $list[$k]['skPrice'] = floatval($skPrice);
+                if ($level == 1) {
+                    $price = floatval($v['discountPrice']);
+                }
+                if ($level == 2) {
+                    $hjAddPrice = $v['hjAddPrice'] ?? 0;
+                    $addPrice = $v['addPrice'] ?? 0;
+                    $diff = bcsub($addPrice, $hjAddPrice, 2);
+                    if ($diff > 0 && $v['discountPrice'] > $diff) {
+                        $price = bcsub($v['discountPrice'], $diff, 2);
+                        $price = floatval($price);
+                    } else {
+                        $price = 0.1;
+                    }
+                }
             }
 
             $list[$k]['price'] = $price;

+ 8 - 2
biz-hd/item/classes/ItemClass.php

@@ -507,7 +507,7 @@ class ItemClass extends BaseClass
     public static function getShowList($where)
     {
         $level = 0;
-        $field = 'id,cover,name,cost,itemId,classId,property,skPrice,skMore,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallRatio,smallUnit,bigUnit,ratio';
+        $field = 'id,cover,name,cost,itemId,classId,property,skPrice,skMore,addPrice,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallRatio,smallUnit,bigUnit,ratio';
         $list = self::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
         if (empty($list)) {
             return $list;
@@ -550,7 +550,13 @@ class ItemClass extends BaseClass
             $discountPrice = $v['discountPrice'] ?? 0;
             if ($discountPrice > 0) {
                 $skMore = $v['skMore'] ?? 0;
-                $skPrice = bcadd($discountPrice, $skMore, 2);
+                $addPrice = $v['addPrice'] ?? 0;
+                $diff = bcsub($skMore, $addPrice, 2);
+                if ($diff > 0) {
+                    $skPrice = bcadd($discountPrice, $diff, 2);
+                } else {
+                    $skPrice = $discountPrice;
+                }
             } else {
                 $skPrice = $v['skPrice'] ?? 0;
             }