|
|
@@ -352,8 +352,6 @@ class GoodsClass extends BaseClass
|
|
|
return $data;
|
|
|
}
|
|
|
$mainId = $shop->mainId;
|
|
|
- $shopId = $shop->id;
|
|
|
- $userId = $custom['userId'] ?? 0;
|
|
|
$rise = GoodsSettingClass::getRise($mainId);
|
|
|
$riseSwitch = $rise['riseSwitch'] ?? 0;
|
|
|
$riseType = $rise['riseType'] ?? 0;
|
|
|
@@ -361,45 +359,38 @@ class GoodsClass extends BaseClass
|
|
|
reset($data);
|
|
|
$current = current($data);
|
|
|
if (is_array($current)) {
|
|
|
- /** 处理多个商品 **/
|
|
|
+ //处理多个商品
|
|
|
foreach ($data as $key => $item) {
|
|
|
- // 从redis获取报价,关键词 shopId-userId-goodsId
|
|
|
- $goodsId = $item['id'] ?? 0;
|
|
|
- $key = 'report_price' . $shopId . '_' . $userId . '_' . $goodsId;
|
|
|
- $reportPrice = Yii::$app->redis->executeCommand('GET', [$key]);
|
|
|
- if (floatval($reportPrice) > 0) {
|
|
|
- //只要报价,不管是有无价格类型,就从报价里取,不参与涨价
|
|
|
- $item['price'] = $reportPrice;
|
|
|
- //无价类型变成有价类型
|
|
|
- $item['priceType'] = 1;
|
|
|
- } else {
|
|
|
- if (isset($item['priceType']) && $item['priceType'] == 0) {
|
|
|
- //没有报价,无价格商品不参与涨价
|
|
|
- } else {
|
|
|
- //没有报价,有价格商品参与涨价
|
|
|
- $item = self::obeyRiseRule($item, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
- }
|
|
|
- }
|
|
|
+ $item = self::modifyAndRisePrice($item, $shop, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
$data[$key] = $item;
|
|
|
}
|
|
|
} else {
|
|
|
- /** 处理单个商品 **/
|
|
|
- // 从redis获取报价,关键词 shopId-userId-goodsId
|
|
|
- $goodsId = $data['id'] ?? 0;
|
|
|
- $key = 'report_price' . $shopId . '_' . $userId . '_' . $goodsId;
|
|
|
- $reportPrice = Yii::$app->redis->executeCommand('GET', [$key]);
|
|
|
- if (floatval($reportPrice) > 0) {
|
|
|
- //只要报价,不管是有无价格类型,就从报价里取,不参与涨价
|
|
|
- $data['price'] = $reportPrice;
|
|
|
- //无价类型变成有价类型
|
|
|
- $data['priceType'] = 1;
|
|
|
+ //单个商品
|
|
|
+ $data = self::modifyAndRisePrice($data, $shop, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ //改价和涨价的处理 ssh 20250907
|
|
|
+ public static function modifyAndRisePrice($data, $shop, $riseSwitch, $riseType, $riseAmount, $custom, $params)
|
|
|
+ {
|
|
|
+ // 从redis获取报价,关键词 shopId_userId_goodsId
|
|
|
+ $shopId = $shop->id;
|
|
|
+ $userId = $custom['userId'] ?? 0;
|
|
|
+ $goodsId = $data['id'] ?? 0;
|
|
|
+ $key = 'report_price' . $shopId . '_' . $userId . '_' . $goodsId;
|
|
|
+ $reportPrice = Yii::$app->redis->executeCommand('GET', [$key]);
|
|
|
+ if (floatval($reportPrice) > 0) {
|
|
|
+ //只要报价,不管是有无价格类型,就从报价里取,不参与涨价
|
|
|
+ $data['price'] = $reportPrice;
|
|
|
+ //无价类型变成有价类型
|
|
|
+ $data['priceType'] = 1;
|
|
|
+ } else {
|
|
|
+ if (isset($data['priceType']) && $data['priceType'] == 0) {
|
|
|
+ //没有报价,无价商品不参与涨价
|
|
|
} else {
|
|
|
- if (isset($data['priceType']) && $data['priceType'] == 0) {
|
|
|
- //没有报价,无价商品不参与涨价
|
|
|
- } else {
|
|
|
- //没有报价,有价商品参与涨价
|
|
|
- $data = self::obeyRiseRule($data, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
- }
|
|
|
+ //没有报价,有价商品参与涨价
|
|
|
+ $data = self::obeyRiseRule($data, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
}
|
|
|
}
|
|
|
return $data;
|