shish 3 лет назад
Родитель
Сommit
9d288e3755
2 измененных файлов с 65 добавлено и 1 удалено
  1. 1 1
      app-hd/controllers/ProductController.php
  2. 64 0
      biz-ghs/product/classes/ProductClass.php

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

@@ -309,7 +309,7 @@ class ProductController extends BaseController
             $level = $ghs['giveLevel'] ?? 0;
             $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,itemId,smallUnit,smallRatio,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
             $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
-            $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
+            $itemInfoData = ProductClass::hdCgGroup($itemInfoData, $level);
 
             $data = ProductService::assembleData($classIds, $itemInfoData, true);
 

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

@@ -337,6 +337,70 @@ class ProductClass extends BaseClass
         return $list;
     }
 
+    //零售端花店采购
+    public static function hdCgGroup($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;
+            $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;
+            $list[$k]['bigPrice'] = $price;
+            $smallRatio = $v['smallRatio'] ?? 0;
+            $smallPrice = bcdiv($price, $ratio, 2);
+            $smallPrice = bcmul($smallPrice, $smallRatio, 2);
+            $list[$k]['smallPrice'] = $smallPrice;
+
+            $presellDate = $v['presellDate'] ?? '';
+            $presellDateList = [];
+            $presellDateShow = [];
+            if (!empty($presellDate)) {
+                $dateArr = explode(',', trim($presellDate));
+                if (!empty($dateArr)) {
+                    foreach ($dateArr as $sellTime) {
+                        $sellDate = date("Y-m-d", $sellTime);
+                        $showDate = date("n月j日", $sellTime);
+                        $presellDateList[] = $sellDate;
+                        $presellDateShow[] = $showDate;
+                    }
+                }
+            }
+            $list[$k]['presellDateList'] = $presellDateList;
+            $list[$k]['presellDateShow'] = $presellDateShow;
+        }
+        return $list;
+    }
+
     //输出价格 ssh 20211009
     public static function getFinalPrice($product, $level, $priceMap, $addPriceMap, $changePrice = 0)
     {