shish 3 年 前
コミット
9434dd2301

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

@@ -204,6 +204,7 @@ class ProductController extends BaseController
             $where['removeStatus'] = 0;
             $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::simpleGroup($itemInfoData, $level);
         } elseif ($requestType == 'stopList') {
             //停用花材列表
             $where['status'] = 2;
@@ -211,6 +212,7 @@ class ProductController extends BaseController
             $where['removeStatus'] = 0;
             $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::simpleGroup($itemInfoData, $level);
         } elseif ($requestType == 'removeList') {
             //删除花材列表
             $where['status'] = 2;
@@ -218,6 +220,7 @@ class ProductController extends BaseController
             $where['removeStatus'] = 1;
             $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::simpleGroup($itemInfoData, $level);
         } elseif ($requestType == 'check') {
             //盘点花材列表
             $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';

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

@@ -276,6 +276,41 @@ class ProductClass extends BaseClass
         return $list;
     }
 
+    //简单组合
+    public static function simpleGroup($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;
+        }
+        return $list;
+    }
+
     //通用花材列表数组组合
     public static function groupProductInfo($list, $level = 0)
     {