From a4b3ee325c7354579d495bc74a777e494e5ec38c Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Fri, 06 Feb 2026 18:18:44 +0800
Subject: [PATCH] 商品可以价格面议 选择走访时显示输入走访企业名 分会添加活动时要总会审核 分类添加人数限制,添加活动选择了填写人数限制的分类时活动名额下显示该分类人数限制为15 同一个企业30天内只能走访一次,在30天内走访同一个企业时提示该企业已被走访xx天后才可以从新走访

---
 admin/app/shop/controller/plus/groupbuy/Product.php |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/admin/app/shop/controller/plus/groupbuy/Product.php b/admin/app/shop/controller/plus/groupbuy/Product.php
index 4901e9f..584f1e3 100644
--- a/admin/app/shop/controller/plus/groupbuy/Product.php
+++ b/admin/app/shop/controller/plus/groupbuy/Product.php
@@ -37,12 +37,40 @@
         
         $model = new ProductModel();
         $data = $this->postData();
-        // 设置店铺ID为自营供应商ID
-        $data['shop_supplier_id'] = $this->getSupplierId();
-        if ($model->add($data)) {
-            return $this->renderSuccess('添加成功');
+        
+        // 如果传递的是批量数据,则处理多个商品
+        if (isset($data['product_list']) && is_array($data['product_list']) && count($data['product_list']) > 0) {
+            // 处理批量添加
+            $successCount = 0;
+            $errors = [];
+            
+            foreach ($data['product_list'] as $productData) {
+                $productData['shop_supplier_id'] = $this->getSupplierId();
+                if ($model->add($productData)) {
+                    $successCount++;
+                } else {
+                    $errors[] = "商品ID {$productData['product_id']} 添加失败: " . $model->getError();
+                }
+            }
+            
+            if ($successCount > 0) {
+                $message = "成功添加 {$successCount} 个商品";
+                if (!empty($errors)) {
+                    $message .= ", 部分商品添加失败: " . implode(', ', $errors);
+                    return $this->renderSuccess($message);
+                }
+                return $this->renderSuccess($message);
+            } else {
+                return $this->renderError('所有商品添加失败: ' . implode(', ', $errors));
+            }
+        } else {
+            // 单个商品添加
+            $data['shop_supplier_id'] = $this->getSupplierId();
+            if ($model->add($data)) {
+                return $this->renderSuccess('添加成功');
+            }
+            return $this->renderError($model->getError() ?: '添加失败');
         }
-        return $this->renderError($model->getError() ?: '添加失败');
     }
 
     /**
@@ -119,7 +147,7 @@
         }
         
         $model = ProductModel::detail($groupbuy_product_id, [
-            'product', 'groupbuySku'
+            'product', 'groupbuySku', 'active'
         ]);
         if (!$model) {
             return $this->renderError('团购商品不存在');

--
Gitblit v1.9.2