shish 1 年間 前
コミット
cec200c201

+ 17 - 1
app-ghs/controllers/ItemController.php

@@ -22,6 +22,22 @@ use Yii;
 class ItemController extends BaseController
 {
 
+    //花材已购客户列表 ssh 20250710
+    public function actionHasLimitBuyCustomList()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $customList = ProductClass::getHasLimitBuyList($item);
+        util::success(['customList' => $customList]);
+    }
+
     //取消花材的限购,重新开始计算
     public function actionClearLimitBuy()
     {
@@ -980,7 +996,7 @@ class ItemController extends BaseController
         $productList = [];
         if (!empty($list)) {
             foreach ($list as $key => $item) {
-                if(!empty($item)){
+                if (!empty($item)) {
                     $productList = array_merge($productList, $item);
                 }
             }

+ 26 - 0
biz-ghs/product/classes/ProductClass.php

@@ -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;
+    }
+
 }