shish пре 1 година
родитељ
комит
1c3b0091c5
2 измењених фајлова са 53 додато и 0 уклоњено
  1. 2 0
      app-hd/controllers/ItemController.php
  2. 51 0
      biz-hd/product/classes/ProductClass.php

+ 2 - 0
app-hd/controllers/ItemController.php

@@ -114,6 +114,8 @@ class ItemController extends BaseController
             $list = ProductClass::kdItemGroup($list, $level);
         } elseif ($requestType == 'itemList') {
             $list = ProductClass::itemListGroup($list, $level);
+        } elseif ($requestType == 'changePrice') {
+            $list = ProductClass::changePriceGroup($list, $level);
         } else {
             util::fail('没有数据');
         }

+ 51 - 0
biz-hd/product/classes/ProductClass.php

@@ -223,4 +223,55 @@ class ProductClass extends BaseClass
         ];
     }
 
+    //通用花材列表数组组合
+    public static function changePriceGroup($list, $level = 0)
+    {
+        //各个等级对应的price addPrice字段
+        $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
+        $addPriceMap = \bizGhs\custom\classes\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 = \bizGhs\product\classes\ProductClass::getFinalPrice($v, $level, $priceMap, $addPriceMap);
+            if ($level == 0) {
+                //零售做特价时显示的原价,不能删除
+                if (isset($v['skPrice'])) {
+                    $list[$k]['prePrice'] = $v['skPrice'];
+                }
+            }
+            if (isset($v['discountPrice']) && $v['discountPrice'] > 0) {
+                //做特价花材时,花材列表和改价列表显示的会员价和零售价,不能删除
+                $list[$k]['hjPrice'] = floatval($v['hjDiscountPrice']);
+                $list[$k]['skPrice'] = floatval($v['skDiscountPrice']);
+            }
+            $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;
+    }
+
 }