shish 2 سال پیش
والد
کامیت
3c33a278d3
2فایلهای تغییر یافته به همراه36 افزوده شده و 1 حذف شده
  1. 1 1
      app-ghs/controllers/ProductController.php
  2. 35 0
      biz-ghs/product/classes/ProductClass.php

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

@@ -244,7 +244,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';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-            $itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
+            $itemInfoData = ProductClass::bookItemGroup($itemInfoData, $level);
         } elseif ($requestType == 'itemList') {
             //花材列表
             if (in_array($this->mainId, $notShowFrontHide)) {

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

@@ -261,6 +261,41 @@ class ProductClass extends BaseClass
         return $list;
     }
 
+    //预订 ssh 20231121
+    public static function bookItemGroup($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);
+                }
+            }
+            $ratio = isset($v['ratio']) && $v['ratio'] > 0 ? $v['ratio'] : 1;
+            $list[$k]['cover'] = $cover;
+
+            $stockInfo = self::formatStock($v['stock'], $ratio);
+            $list[$k]['bigNum'] = $stockInfo['bigNum'];
+            $list[$k]['smallNum'] = $stockInfo['smallNum'];
+
+            $price = self::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+            $list[$k]['price'] = $price;
+            $list[$k]['bigPrice'] = $price;
+            $smallRatio = $v['smallRatio'] ?? 0;
+            $smallPrice = bcdiv($price, $ratio, 2);
+            $smallPrice = bcmul($smallPrice, $smallRatio, 2);
+            $list[$k]['smallPrice'] = $smallPrice;
+        }
+        return $list;
+    }
+
     //花材列表用到的数据组合 ssh 20221225
     public static function kdItemGroup($list, $level = 0)
     {