|
|
@@ -2603,4 +2603,30 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static function getHasLimitBuyList($product)
|
|
|
+ {
|
|
|
+ $productId = $product->id;
|
|
|
+ $limitBuy = $product->limitBuy ?? 0;
|
|
|
+ $limitKey = 'limit_buy_' . $productId;
|
|
|
+ $arr = Yii::$app->redis->executeCommand('HKEYS', [$limitKey]);
|
|
|
+ $customList = [];
|
|
|
+ if (!empty($arr)) {
|
|
|
+ $numMap = [];
|
|
|
+ $ids = [];
|
|
|
+ foreach ($arr as $customId) {
|
|
|
+ $num = Yii::$app->redis->executeCommand('HGET', [$limitKey, $customId]);
|
|
|
+ $numMap[$customId] = $num;
|
|
|
+ $ids[] = $customId;
|
|
|
+ }
|
|
|
+ $customList = CustomClass::getAllByCondition(['id' => ['in', $ids]], null, '*');
|
|
|
+ foreach ($customList as $key => $val) {
|
|
|
+ $customId = $val['id'];
|
|
|
+ $num = $numMap[$customId] ?? 0;
|
|
|
+ $customList[$key]['hasLimitBuyNum'] = $num;
|
|
|
+ $customList[$key]['hasReachLimitBuyNum'] = $num >= $limitBuy ? 1 : 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $customList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|