|
|
@@ -2591,12 +2591,6 @@ class ProductClass extends BaseClass
|
|
|
return $product['mainId'] ?? 0;
|
|
|
}
|
|
|
|
|
|
- public static function cancelOneLimitBuy($productId, $customId)
|
|
|
- {
|
|
|
- $limitKey = 'limit_buy_' . $productId;
|
|
|
- Yii::$app->redis->executeCommand('HDEL', [$limitKey, $customId]);
|
|
|
- }
|
|
|
-
|
|
|
//取消限购的缓存 ssh 20240605
|
|
|
public static function cancelLimitBuy($productId)
|
|
|
{
|
|
|
@@ -2604,7 +2598,26 @@ class ProductClass extends BaseClass
|
|
|
$arr = Yii::$app->redis->executeCommand('HKEYS', [$limitKey]);
|
|
|
if (!empty($arr)) {
|
|
|
foreach ($arr as $field) {
|
|
|
- Yii::$app->redis->executeCommand('HDEL', [$limitKey, $field]);
|
|
|
+ self::baseClearLimitBuy($productId, $field);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //$num -1 表示减全部,大于-1表示减值
|
|
|
+ public static function baseClearLimitBuy($productId, $customId, $num = -1)
|
|
|
+ {
|
|
|
+ $limitKey = 'limit_buy_' . $productId;
|
|
|
+ if ($num <= -1) {
|
|
|
+ //清掉全部
|
|
|
+ Yii::$app->redis->executeCommand('HDEL', [$limitKey, $customId]);
|
|
|
+ } else {
|
|
|
+ $hasNum = Yii::$app->redis->executeCommand('HGET', [$limitKey, $customId]);
|
|
|
+ $remainNum = $hasNum > $num ? bcsub($num, $hasNum) : 0;
|
|
|
+ $remainNum = floor($remainNum);
|
|
|
+ if ($remainNum > 0) {
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $remainNum]);
|
|
|
+ } else {
|
|
|
+ Yii::$app->redis->executeCommand('HDEL', [$limitKey, $customId]);
|
|
|
}
|
|
|
}
|
|
|
}
|