|
|
@@ -819,12 +819,17 @@ class ProductClass extends BaseClass
|
|
|
|
|
|
//超出限购情况的价格计算
|
|
|
if ($limitBuy > 0 && $totalBuyNum > $limitBuy) {
|
|
|
- $overBuyNum = $totalBuyNum - $limitBuy;
|
|
|
- $overBuyPrice = bcmul($overBuyNum, $oldPrice, 2); // 超出限购部分的价格
|
|
|
+ $hasBuyNum = $totalBuyNum - $buyNum;
|
|
|
+ if ($hasBuyNum >= $limitBuy) {
|
|
|
+ $price = $oldPrice;
|
|
|
+ } else {
|
|
|
+ $overBuyNum = $totalBuyNum - $limitBuy;
|
|
|
+ $overBuyPrice = bcmul($overBuyNum, $oldPrice, 2); // 超出限购部分的价格
|
|
|
|
|
|
- $leftBuyNum = $buyNum - $overBuyNum;
|
|
|
- $leftBuyPrice = bcmul($leftBuyNum, $price, 2); // 未超出限购部分的价格
|
|
|
- $price = bcdiv($overBuyPrice + $leftBuyPrice, $buyNum, 2); // 最终价格
|
|
|
+ $leftBuyNum = $buyNum - $overBuyNum;
|
|
|
+ $leftBuyPrice = bcmul($leftBuyNum, $price, 2); // 未超出限购部分的价格
|
|
|
+ $price = bcdiv($overBuyPrice + $leftBuyPrice, $buyNum, 2); // 最终价格
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2825,7 +2830,7 @@ class ProductClass extends BaseClass
|
|
|
if ($lastNum > $limitBuy) {
|
|
|
// 如果有特价,则超过的数量按原价卖;否则中断
|
|
|
if ($product['hjDiscountPrice'] > 0 && $product['discountPrice'] > 0 && $product['skDiscountPrice'] > 0) {
|
|
|
- Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $limitBuy]);
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $lastNum]);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -2837,7 +2842,7 @@ class ProductClass extends BaseClass
|
|
|
if ($num > $limitBuy) {
|
|
|
// 如果有特价,则超过的数量按原价卖;否则中断
|
|
|
if ($product['hjDiscountPrice'] > 0 && $product['discountPrice'] > 0 && $product['skDiscountPrice'] > 0) {
|
|
|
- Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $limitBuy]);
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $num]);
|
|
|
return;
|
|
|
}
|
|
|
|