From e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Sat, 17 Jan 2026 17:58:01 +0800
Subject: [PATCH] 团购组件增加筛选
---
admin/app/supplier/controller/product/Product.php | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/admin/app/supplier/controller/product/Product.php b/admin/app/supplier/controller/product/Product.php
index 15b42c5..865c090 100644
--- a/admin/app/supplier/controller/product/Product.php
+++ b/admin/app/supplier/controller/product/Product.php
@@ -4,10 +4,11 @@
use app\common\model\settings\Setting;
use app\supplier\model\product\Product as ProductModel;
-use app\common\model\product\Category as CategoryModel;
+use app\supplier\model\product\Category as CategoryModel;
use app\supplier\service\ProductService;
use app\supplier\model\supplier\Supplier as SupplierModel;
use app\supplier\controller\Controller;
+use think\facade\Cache;
/**
* 商品管理控制器
@@ -24,7 +25,8 @@
$model = new ProductModel;
$list = $model->getList(array_merge(['status' => -1, 'shop_supplier_id' => $this->getSupplierId()], $this->postData()));
// 商品分类
- $category = CategoryModel::getCacheTree();
+ $category = CategoryModel::getSupplierCacheTree($this->getSupplierId());
+
// 数量
$product_count = [
'sell' => $model->getCount('sell', $this->getSupplierId()),
@@ -43,12 +45,17 @@
*/
public function add($scene = 'add')
{
+ $supplier = SupplierModel::detail($this->getSupplierId());
// get请求
if($this->request->isGet()){
- return $this->getBaseData();
+ return $this->getBaseData($supplier);
}
//post请求
$data = json_decode($this->postData()['params'], true);
+ $data['is_newcomer'] = $supplier['is_newcomer'];
+ $data['is_repurchase'] = $supplier['is_repurchase'];
+ $data['is_vip'] = $supplier['is_vip'];
+ // 添加商品
if($scene == 'copy'){
unset($data['create_time']);
unset($data['sku']['product_sku_id']);
@@ -85,9 +92,9 @@
/**
* 获取基础数据
*/
- public function getBaseData()
+ public function getBaseData($supplier)
{
- return $this->renderSuccess('', array_merge(ProductService::getEditData(null, 'add', $this->getSupplierId()), []));
+ return $this->renderSuccess('', array_merge(ProductService::getEditData(null, 'add', $this->getSupplierId()),['is_newcomer'=>$supplier['is_newcomer'],'is_repurchase'=>$supplier['is_repurchase'],'is_vip'=>$supplier['is_vip']]));
}
/**
@@ -104,17 +111,30 @@
*/
public function edit($product_id, $scene = 'edit')
{
+ $supplier = SupplierModel::detail($this->getSupplierId());
if($this->request->isGet()){
$model = ProductModel::detail($product_id);
- return $this->renderSuccess('', array_merge(ProductService::getEditData($model, $scene, $this->getSupplierId()), compact('model')));
+ $is_newcomer = $supplier['is_newcomer'];
+ $is_repurchase = $supplier['is_repurchase'];
+ $is_vip = $supplier['is_vip'];
+ $supplierName='';
+ if($model['belonging_shop_supplier_id']){
+ $belonging_shop_supplier= SupplierModel::detail($model['belonging_shop_supplier_id']);
+ $supplierName=$belonging_shop_supplier['name'];
+ }
+ return $this->renderSuccess('', array_merge(ProductService::getEditData($model, $scene, $this->getSupplierId()), compact('model','is_newcomer','is_repurchase','is_vip','supplierName')));
}
if ($scene == 'copy') {
return $this->add($scene);
}
// 商品详情
$model = ProductModel::detail($product_id);
+ $data = json_decode($this->postData()['params'], true);
+ $data['is_newcomer'] = $supplier['is_newcomer'];
+ $data['is_repurchase'] = $supplier['is_repurchase'];
+ $data['is_vip'] = $supplier['is_vip'];
// 更新记录
- if ($model->edit(json_decode($this->postData()['params'], true),$this->getSupplierId())) {
+ if ($model->edit($data,$this->getSupplierId())) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
--
Gitblit v1.9.2