|
|
@@ -353,6 +353,7 @@ class OrderItemClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
$productId = $val['productId'];
|
|
|
+ $name = $val['name'] ?? '';
|
|
|
$ratio = $val['ratio'] ?? 0;
|
|
|
$currentWeight = $val['weight'];
|
|
|
|
|
|
@@ -363,8 +364,20 @@ class OrderItemClass extends BaseClass
|
|
|
$weight = bcadd($w, $weight, 2);
|
|
|
|
|
|
$limitBuy = $val['limitBuy'] ?? 0;
|
|
|
+ $limitKey = 'limit_buy_' . $productId;
|
|
|
+ $currentNum = floatval($itemNum);
|
|
|
if ($limitBuy > 0) {
|
|
|
-
|
|
|
+ $has = Yii::$app->redis->executeCommand('HEXISTS', [$limitKey, $customId]);
|
|
|
+ if (!empty($has)) {
|
|
|
+ $hasNum = Yii::$app->redis->executeCommand('HGET', [$limitKey, $customId]);
|
|
|
+ $lastNum = bcadd($hasNum, $currentNum);
|
|
|
+ if ($lastNum > $limitBuy) {
|
|
|
+ util::fail($name . ' 超过可购买数量');
|
|
|
+ }
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $lastNum]);
|
|
|
+ } else {
|
|
|
+ Yii::$app->redis->executeCommand('HSET', [$limitKey, $customId, $currentNum]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($stockMayChange == true) {
|