|
|
@@ -447,27 +447,28 @@ class ProductClass extends BaseClass
|
|
|
$has = Yii::$app->redis->executeCommand('HEXISTS', [$limitKey, $customId]);
|
|
|
if (!empty($has)) {
|
|
|
$hasNum = Yii::$app->redis->executeCommand('HGET', [$limitKey, $customId]);
|
|
|
- $lastNum = bcadd($hasNum, $num);
|
|
|
+ self::recordLimitBuyRollbackSnapshot($productId, $customId, true, $hasNum);
|
|
|
+ $lastNum = bcadd($hasNum, $num, 2);
|
|
|
if ($lastNum > $limitBuy) {
|
|
|
// 如果有特价,则超过的数量按原价卖;否则中断
|
|
|
if ($product['hjDiscountPrice'] > 0 && $product['discountPrice'] > 0 && $product['skDiscountPrice'] > 0) {
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $limitBuy]);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
util::error(-1, '累计已超出限购数', ['productId'=>$productId, 'limitBuy'=>$limitBuy, 'exceed'=>$lastNum - $limitBuy]);
|
|
|
}
|
|
|
- self::recordLimitBuyRollbackSnapshot($productId, $customId, true, $hasNum);
|
|
|
Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $lastNum]);
|
|
|
} else {
|
|
|
+ self::recordLimitBuyRollbackSnapshot($productId, $customId, false, 0);
|
|
|
if ($num > $limitBuy) {
|
|
|
// 如果有特价,则超过的数量按原价卖;否则中断
|
|
|
if ($product['hjDiscountPrice'] > 0 && $product['discountPrice'] > 0 && $product['skDiscountPrice'] > 0) {
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $limitBuy]);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
util::error(-1, '超出限购数', ['productId'=>$productId, 'limitBuy'=>$limitBuy, 'exceed'=>$num - $limitBuy]);
|
|
|
}
|
|
|
- self::recordLimitBuyRollbackSnapshot($productId, $customId, false, 0);
|
|
|
Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $num]);
|
|
|
}
|
|
|
}
|