|
|
@@ -4,6 +4,7 @@ namespace bizHd\product\classes;
|
|
|
|
|
|
use biz\item\classes\PtItemClass;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
+use bizHd\custom\classes\CustomClass;
|
|
|
use common\components\imgUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\sms;
|
|
|
@@ -484,6 +485,35 @@ class ProductClass extends BaseClass
|
|
|
self::clearLimitBuyClearMark($productId);
|
|
|
}
|
|
|
|
|
|
+ public static function getHasLimitBuyList($product)
|
|
|
+ {
|
|
|
+ $productId = $product->id;
|
|
|
+ $limitBuy = $product->limitBuy ?? 0;
|
|
|
+ $limitKey = self::LIMIT_BUY_KEY . $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;
|
|
|
+ $avatar = $val['avatar'] ?? '';
|
|
|
+ $smallAvatar = imgUtil::groupImg($avatar);
|
|
|
+ $customList[$key]['smallAvatar'] = $smallAvatar . "?x-oss-process=image/resize,m_fill,h_80,w_80";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $customList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param $productId
|
|
|
* @param $customId
|