shish преди 6 години
родител
ревизия
3e13cdcf9f
променени са 2 файла, в които са добавени 51 реда и са изтрити 38 реда
  1. 19 6
      biz/goods/classes/GoodsClass.php
  2. 32 32
      biz/goods/classes/GoodsSettingClass.php

+ 19 - 6
biz/goods/classes/GoodsClass.php

@@ -33,9 +33,12 @@ class GoodsClass extends BaseClass
     //组装商品基本信息 shish 2019.12.2
     public static function groupGoodsBaseInfo($list)
     {
-        $merchantIdList = array_column($list, 'merchantId');
-        $merchantIdList = array_unique(array_filter($merchantIdList));
-        $merchantList = MerchantService::getByIds($merchantIdList, null, 'id');
+
+        //注意这里涉及商家节日涨价的问题,不要去取不同商家的商品,确有必要另外起方法!!!!!!
+
+        $merchantId = $list[0]['merchantId'];
+        $rise = GoodsSettingClass::getRise($merchantId);
+
         foreach ($list as $key => $val) {
             $id = $val['id'];
             //大中小图片转化
@@ -45,10 +48,20 @@ class GoodsClass extends BaseClass
             //多款式
             $val['goodsStyleList'] = isset($val['goodsStyle']) && $val['goodsStyle'] == 1 ? GoodsStyleClass::getStyleList($id) : [];
             $val['createDate'] = date("Y-m-d", strtotime($val['createTime']));
-            $merchantId = $val['merchantId'];
-            $val['merchantName'] = isset($merchantList[$merchantId]['merchantName']) ? $merchantList[$merchantId]['merchantName'] : '';
+            $val['merchantName'] = '';
+            //节日涨价
+            if (!empty($rise)) {
+                $price = $val['price'];
+                if ($rise['riseType'] == 0) {
+                    //百分比
+                    $val['price'] = $price + sprintf("%.1f", ($price * $rise['riseAmount'] / 100));
+                } else {
+                    //金额
+                    $val['price'] = $price + $rise['riseAmount'];
+                }
+            }
             $list[$key] = $val;
-            //涨价
+
         }
         return $list;
     }

+ 32 - 32
biz/goods/classes/GoodsSettingClass.php

@@ -15,38 +15,38 @@ use biz\base\classes\BaseClass;
 class GoodsSettingClass extends BaseClass
 {
 
-	public static $baseFile = '\biz\goods\models\GoodsSetting';
+    public static $baseFile = '\biz\goods\models\GoodsSetting';
 
-	//获取商品涨价比例或金额 shish 2020.5.20
-	public static function getRise($merchantId)
-	{
-		$festRise = FestRiseClass::getAllByCondition(['merchantId' => $merchantId], null, 'festId', 'festId');
-		if (empty($festRise)) {
-			return [];
-		}
-		$festId = array_keys($festRise);
-		$fest = FestClass::getByIds($festId);
-		$arr = [];
-		$today = date("Y-n-j");
-		$arr = [];
-		foreach ($fest as $single) {
-			$current = date("Y") . '-' . $single['month'] . '-' . $single['day'];
-			$past = date("Y-n-j", (strtotime($current) - 86400));
-			$arr = array_merge($arr, $current, $past);
-		}
-		if (in_array($today, $arr) == false) {
-			return [];
-		}
-		$set = self::getByCondition(['merchantId' => $merchantId]);
-		if (empty($set)) {
-			util::fail('没有找到涨价需求');
-		}
-		if ($set['riseSwitch'] == 0) {
-			return [];
-		}
-		$riseType = $set['riseType'];
-		$riseAmount = $set['riseAmount'];
-		return ['riseType' => $riseType, 'riseAmount' => $riseAmount];
-	}
+    //获取商品涨价比例或金额 shish 2020.5.20
+    public static function getRise($merchantId)
+    {
+        return ['riseType' => 0, 'riseAmount' => 96];
+        $festRise = FestRiseClass::getAllByCondition(['merchantId' => $merchantId], null, 'festId', 'festId');
+        if (empty($festRise)) {
+            return [];
+        }
+        $festId = array_keys($festRise);
+        $fest = FestClass::getByIds($festId);
+        $today = date("Y-n-j");
+        $arr = [];
+        foreach ($fest as $single) {
+            $current = date("Y") . '-' . $single['month'] . '-' . $single['day'];
+            $past = date("Y-n-j", (strtotime($current) - 86400));
+            $arr = array_merge($arr, $current, $past);
+        }
+        if (in_array($today, $arr) == false) {
+            return [];
+        }
+        $set = self::getByCondition(['merchantId' => $merchantId]);
+        if (empty($set)) {
+            util::fail('没有找到涨价需求');
+        }
+        if ($set['riseSwitch'] == 0) {
+            return [];
+        }
+        $riseType = $set['riseType'];
+        $riseAmount = $set['riseAmount'];
+        return ['riseType' => $riseType, 'riseAmount' => $riseAmount];
+    }
 
 }