shish 3 lat temu
rodzic
commit
39ce311394

+ 5 - 0
app-ghs/controllers/ProductController.php

@@ -220,6 +220,11 @@ class ProductController extends BaseController
             $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,presell';
             $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,presell';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
             $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
             $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
+        } elseif ($requestType == 'changeStock') {
+            //修改价格列表
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::changeStockGroup($itemInfoData, $level);
         } elseif ($requestType == 'kd') {
         } elseif ($requestType == 'kd') {
             //开单的花材列表
             //开单的花材列表
             $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio';
             $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio';

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

@@ -330,6 +330,55 @@ class ProductClass extends BaseClass
         return $list;
         return $list;
     }
     }
 
 
+    //通用花材列表数组组合
+    public static function changeStockGroup($list, $level = 0)
+    {
+        //各个等级对应的price addPrice字段
+        $priceMap = CustomClass::$levelPriceKeyMap;
+        $addPriceMap = CustomClass::$levelAddPriceKeyMap;
+        foreach ($list as $k => $v) {
+            $shortCover = $v['cover'] ?? '';
+            $cover = imgUtil::getPrefix() . 'hhb_small.png';
+            if (!empty($shortCover)) {
+                $parse = parse_url(self::groupImg($shortCover));
+                if (empty($parse['query'])) {
+                    $cover = self::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
+                } else {
+                    $cover = self::groupImg($shortCover);
+                }
+            }
+            $list[$k]['cover'] = $cover;
+            $list[$k]['prePrice'] = $v['price'] ?? 0;
+            //今日特价、会员价
+            $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+            //零售做特价时的原价
+            if ($level == 0) {
+                $currentAddPrice = $v['skMore'] ?? 0;
+                $list[$k]['prePrice'] = bcadd($v['price'], $currentAddPrice, 2);
+            }
+            if (isset($v['discountPrice']) && $v['discountPrice'] > 0) {
+                $currentAddPrice = $v['skMore'] ?? 0;
+                $list[$k]['skPrice'] = bcadd($v['discountPrice'], $currentAddPrice, 2);
+            }
+            $list[$k]['price'] = $price;
+
+            $cost = $v['cost'] ?? 0;
+            $ml = 0;
+            if ($price > 0) {
+                $profit = bcsub($price, $cost, 2);
+                $ml = $profit;
+                $mll = bcdiv($profit, $price, 3);
+                $mll = bcmul($mll, 100);
+                $mll = round($mll, 1);
+            } else {
+                $mll = 0;
+            }
+            $list[$k]['mll'] = $mll;
+            $list[$k]['ml'] = $ml;
+        }
+        return $list;
+    }
+
     //通用花材列表数组组合
     //通用花材列表数组组合
     public static function changePriceGroup($list, $level = 0)
     public static function changePriceGroup($list, $level = 0)
     {
     {