Explorar o código

获取商品涨价比例或金额

shish %!s(int64=6) %!d(string=hai) anos
pai
achega
dfe001ad24

+ 37 - 2
biz/goods/classes/GoodsSettingClass.php

@@ -4,14 +4,49 @@ namespace biz\goods\classes;
 
 use biz\goods\services\GoodsCategoryService;
 use biz\goods\services\GoodsStyleService;
+use biz\saas\classes\FestClass;
+use biz\saas\classes\FestRiseClass;
 use common\components\business;
 use common\components\stringUtil;
+use common\components\util;
 use Yii;
 use biz\base\classes\BaseClass;
 
 class GoodsSettingClass extends BaseClass
 {
-	
+
 	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];
+	}
+
 }

+ 3 - 1
biz/goods/services/GoodsSettingService.php

@@ -25,5 +25,7 @@ class GoodsSettingService extends BaseService
 		$set['festIdList'] = $festIdList;
 		return $set;
 	}
-	
+
+
+
 }