Browse Source

fix:活动

super-yimizi 2 months ago
parent
commit
ef3131086c

+ 19 - 23
application/admin/controller/shop/Goods.php

@@ -747,38 +747,34 @@ class Goods extends Backend
     }
     }
 
 
     /**
     /**
-     * 获取个商品信息
+     * 获取个商品信息
      */
      */
-    public function info()
+    public function getGoodsByIds()
     {
     {
-        $id = $this->request->request('id');
-        if (!$id) {
-            $this->error('商品ID不能为空');
+        $ids = $this->request->request('ids');
+        if (!$ids) {
+            $this->error('请选择商品');
         }
         }
         
         
-        $goods = $this->model
-            ->with(['Brand'])
-            ->where('id', $id)
-            ->find();
+        $ids = explode(',', $ids);
+        $list = $this->model
+            ->with(['Category'])
+            ->where('id', 'in', $ids)
+            ->select();
             
             
-        if (!$goods) {
-            $this->error('商品不存在');
-        }
-        
         // 处理图片URL和SKU信息
         // 处理图片URL和SKU信息
-        if ($goods['image']) {
-            $goods['image'] = cdnurl($goods['image'], true);
+        foreach ($list as &$item) {
+            if ($item['image']) {
+                $item['image'] = cdnurl($item['image'], true);
+            }
+            
+            // 获取商品的第一个SKU ID(单规格商品通常只有一个SKU)
+            $sku = \app\common\model\Sku::where('goods_id', $item['id'])->find();
+            $item['sku_id'] = $sku ? $sku['id'] : 0;
         }
         }
         
         
-        // 获取商品的第一个SKU ID(单规格商品通常只有一个SKU)
-        $sku = \app\common\model\Sku::where('goods_id', $goods['id'])->find();
-        $goods['sku_id'] = $sku ? $sku['id'] : 0;
-        
-        // 添加商品类型文本
-        $goodsTypeMap = GoodsEnum::getGoodsTypeMap();
-        $goods['type_text'] = isset($goodsTypeMap[$goods['type']]) ? $goodsTypeMap[$goods['type']] : '';
         
         
-        $this->success('获取成功', null, $goods);
+        $this->success('获取成功', null, $list);
     }
     }
 
 
     /**
     /**

+ 1 - 1
public/assets/js/backend/lottery/activity.js

@@ -758,7 +758,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
                 
                 
                 // 调用商品信息API
                 // 调用商品信息API
                 $.ajax({
                 $.ajax({
-                    url: Fast.api.fixurl('shop/goods/info'),
+                    url: Fast.api.fixurl('shop/goods/getGoodsByIds'),
                     type: 'POST',
                     type: 'POST',
                     data: {
                     data: {
                         ids: goodsIds.join(',')
                         ids: goodsIds.join(',')