|
|
@@ -352,6 +352,8 @@ 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;
|
|
|
@@ -359,12 +361,46 @@ class GoodsClass extends BaseClass
|
|
|
reset($data);
|
|
|
$current = current($data);
|
|
|
if (is_array($current)) {
|
|
|
+ /** 处理多个商品 **/
|
|
|
foreach ($data as $key => $item) {
|
|
|
- $item = self::obeyRiseRule($item, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
+ // 从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);
|
|
|
+ }
|
|
|
+ }
|
|
|
$data[$key] = $item;
|
|
|
}
|
|
|
} else {
|
|
|
- $data = self::obeyRiseRule($data, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
+ /** 处理单个商品 **/
|
|
|
+ // 从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;
|
|
|
+ } else {
|
|
|
+ if (isset($data['priceType']) && $data['priceType'] == 0) {
|
|
|
+ //没有报价,无价商品不参与涨价
|
|
|
+ } else {
|
|
|
+ //没有报价,有价商品参与涨价
|
|
|
+ $data = self::obeyRiseRule($data, $riseSwitch, $riseType, $riseAmount, $custom, $params);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
@@ -808,8 +844,8 @@ class GoodsClass extends BaseClass
|
|
|
util::fail("非法参数");
|
|
|
}
|
|
|
//改库存
|
|
|
- $preStock = $goodsData['stock']??0;
|
|
|
- $newStock = bcsub($preStock,$num);
|
|
|
+ $preStock = $goodsData['stock'] ?? 0;
|
|
|
+ $newStock = bcsub($preStock, $num);
|
|
|
|
|
|
if ($newStock < 0) {
|
|
|
if ($checkStock) {
|