Просмотр исходного кода

Merge branch 'zhongqi-itemUpdate' into dev

shizhongqi 3 месяцев назад
Родитель
Сommit
82d8ee2cfb
2 измененных файлов с 49 добавлено и 0 удалено
  1. 8 0
      app-hd/controllers/ProductController.php
  2. 41 0
      biz-hd/product/classes/ProductClass.php

+ 8 - 0
app-hd/controllers/ProductController.php

@@ -851,6 +851,14 @@ class ProductController extends BaseController
     {
         $id = Yii::$app->request->get('id', 0);
         $respond = ProductClass::getItemInfo($id);
+        if (empty($respond) || !is_array($respond)) {
+            util::fail('没有找到花材');
+        }
+        $limitBuyClearInfo = \bizHd\product\classes\ProductClass::getLimitBuyClearInfo($id);
+        if (!is_array($limitBuyClearInfo)) {
+            $limitBuyClearInfo = [];
+        }
+        $respond['limitBuyClearInfo'] = $limitBuyClearInfo;
         $ptItemId = $respond['itemId'] ?? 0;
         $ptItemInfo = PtItemClass::getById($ptItemId);
         $respond['ptItemInfo'] = $ptItemInfo;

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

@@ -700,6 +700,47 @@ class ProductClass extends BaseClass
         return is_array($config) ? $config : [];
     }
 
+    // 获取限购清空配置,用于商品详情回显
+    public static function getLimitBuyClearInfo($productId)
+    {
+        $productId = intval($productId);
+        $info = [
+            'limitBuyClearType' => 0, // 0不清空 1循环清空 2定时清空
+            'limitBuyClearTypeName' => '不清空',
+            'limitBuyClearAt' => 0,
+            'limitBuyClearTime' => '',
+            'limitBuyNextClearAt' => 0,
+            'limitBuyNextClearTime' => '',
+            'limitBuyClearIntervalDays' => 0,
+            'cleartAt' => '',
+        ];
+        if ($productId <= 0) {
+            return $info;
+        }
+
+        $clearMarkKey = self::CLEAR_MARK_KEY . $productId;
+        $clearAt = intval(Yii::$app->redis->executeCommand('GET', [$clearMarkKey]));
+        if ($clearAt <= 0) {
+            return $info;
+        }
+
+        $info['limitBuyClearType'] = 2;
+        $info['limitBuyClearTypeName'] = '定时清空';
+        $info['limitBuyClearAt'] = $clearAt;
+        $info['limitBuyClearTime'] = date('Y-m-d H:i:s', $clearAt);
+        $info['limitBuyNextClearAt'] = $clearAt;
+        $info['limitBuyNextClearTime'] = $info['limitBuyClearTime'];
+
+        $loopConfig = self::getLimitBuyClearLoopConfigByProductId($productId);
+        if (!empty($loopConfig)) {
+            $info['limitBuyClearType'] = 1;
+            $info['limitBuyClearTypeName'] = '循环清空';
+            $info['limitBuyClearIntervalDays'] = intval($loopConfig['intervalDays'] ?? 0);
+            $info['cleartAt'] = intval($loopConfig['clearHour'] ?? 0);
+        }
+        return $info;
+    }
+
     // 清理循环清空限购配置
     public static function clearLimitBuyClearLoopConfig($productId)
     {