소스 검색

零售端--花材已购客户列表

shizhongqi 4 달 전
부모
커밋
3219b9a1fb
2개의 변경된 파일32개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      app-hd/controllers/ItemController.php
  2. 30 0
      biz-hd/product/classes/ProductClass.php

+ 2 - 2
app-hd/controllers/ItemController.php

@@ -490,7 +490,7 @@ class ItemController extends BaseController
         util::complete('清除成功');
     }
 
-    //花材已购客户列表
+    //零售端--花材已购客户列表
     public function actionHasLimitBuyCustomList()
     {
         $get = Yii::$app->request->get();
@@ -502,7 +502,7 @@ class ItemController extends BaseController
         if ($item->mainId != $this->mainId) {
             util::fail('不是你的花材');
         }
-        $customList = \bizGhs\product\classes\ProductClass::getHasLimitBuyList($item);
+        $customList = ProductClass::getHasLimitBuyList($item);
         util::success(['customList' => $customList]);
     }
 }

+ 30 - 0
biz-hd/product/classes/ProductClass.php

@@ -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