Bladeren bron

成本优化 价格对比

shish 7 maanden geleden
bovenliggende
commit
381186d3b5
2 gewijzigde bestanden met toevoegingen van 9 en 7 verwijderingen
  1. 1 1
      app-hd/controllers/ProductController.php
  2. 8 6
      biz-ghs/product/classes/ProductClass.php

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

@@ -704,7 +704,7 @@ class ProductController extends BaseController
             $where['frontHide'] = 0;
 
             $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';
+            $field = 'id,py,cover,name,ratio,classId,itemId,weight,smallUnit,bigUnit,smallUnit,smallRatio,ratioType,variety,price,skPrice,skDiscountPrice,hjPrice,hjDiscountPrice,avCost,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, $ghs);
             $myProduct = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'delStatus' => 0], null, 'id,stock,onStock,stockWarning,itemId', 'itemId');

+ 8 - 6
biz-ghs/product/classes/ProductClass.php

@@ -696,17 +696,19 @@ class ProductClass extends BaseClass
             $list[$k]['bigNum'] = $stockInfo['bigNum'];
             $list[$k]['smallNum'] = $stockInfo['smallNum'];
             $list[$k]['itemName'] = $v['name'] ?? '';
-            //小一级的价格
-            if ($level > 0) {
+
+            //今日特价、会员价
+            $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+            if ($level > 0 && $level < 9) {
+                //取出更低一级的客户价格,用于前端作对比。如果取零售价和成本价,则不取
                 $littleLevel = bcsub($level, 1);
+                $defaultGradePrice = self::getFinalPrice($v, $littleLevel, $priceMap, $addPriceMap);
             } else {
-                $littleLevel = $level;
+                $defaultGradePrice = $price;
             }
-            $defaultGradePrice = self::getFinalPrice($v, $littleLevel, $priceMap, $addPriceMap);
             $list[$k]['defaultGradePrice'] = $defaultGradePrice;
             $list[$k]['myLevel'] = $level;
-            //今日特价、会员价
-            $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+
             $reachPrice = 0;
             //满10扎多少钱
             if (isset($v['reachNum']) && $v['reachNum'] > 0) {