From 90260975704d9594da95c6577f8a1279fbb7e0c5 Mon Sep 17 00:00:00 2001 From: 1748153932 <1748153932@qq.com> Date: Wed, 27 Dec 2023 11:54:34 +0800 Subject: [PATCH] 111 --- .../store/product/ProductRepository.php | 13 +++++++++++-- app/controller/admin/store/StoreProductAssist.php | 1 + app/controller/merchant/store/product/Product.php | 9 +++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 7d60dc1..161a87c 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -13,6 +13,8 @@ namespace app\common\repositories\store\product; +use app\common\model\store\product\Product; +use app\common\model\store\product\Spu; use app\common\model\store\product\ProductLabel; use app\common\model\user\User; use app\common\repositories\community\CommunityRepository; @@ -60,7 +62,7 @@ class ProductRepository extends BaseRepository protected $dao; const CREATE_PARAMS = [ - "image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', + "image", "slider_image", "store_name", "store_info", "keyword", "bar_code",'is_pre', "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', ["brand_id",0], ['once_max_count',0], ['once_min_count',0], @@ -258,6 +260,7 @@ class ProductRepository extends BaseRepository $data['attr'] = []; if (count($data['attrValue']) > 1) throw new ValidateException('单规格商品属性错误'); } + event('product.update.before', compact('id','data','merId','productType','conType')); $spuData = $product = $this->setProduct($data); $settleParams = $this->setAttrValue($data, $id, $productType, 1); @@ -270,7 +273,7 @@ class ProductRepository extends BaseRepository $spuData['price'] = $settleParams['data']['price']; $spuData['mer_id'] = $merId; $spuData['mer_labels'] = $data['mer_labels']; - + $spuData['is_pre'] = $data['is_pre']; Db::transaction(function () use ($id, $data, $productType, $settleParams,$content,$product,$spuData,$merId) { $this->save($id, $settleParams, $content, $product, $productType); if ($productType == 1) { //秒杀商品 @@ -593,6 +596,7 @@ class ProductRepository extends BaseRepository "extension_two" => $extension_status ? ($value['extension_two'] ?? 0) : 0, "product_id" => $productId, "type" => 0, + "sku" => $sku, "unique" => $unique, 'sales' => $isUpdate ? ($oldSku[$sku]['sales'] ?? 0) : 0, @@ -734,6 +738,11 @@ class ProductRepository extends BaseRepository if ($conType) $content = json_decode($content); unset($data['content']); $data['content'] = $content; + + $info = Spu::getDB() + ->where('product_id', $id)->find()->toArray(); + + $data['mer_labels'] = (int)$info['mer_labels'][0]; return $data; } diff --git a/app/controller/admin/store/StoreProductAssist.php b/app/controller/admin/store/StoreProductAssist.php index af06409..69d9634 100644 --- a/app/controller/admin/store/StoreProductAssist.php +++ b/app/controller/admin/store/StoreProductAssist.php @@ -97,6 +97,7 @@ class StoreProductAssist extends BaseController */ public function update($id, validate $validate) { + $data = $this->checkParams($validate); if (!$this->repository->getWhereCount([$this->repository->getPk() => $id])) return app('json')->fail('数据不存在'); diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index efa05be..210d661 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -12,6 +12,8 @@ namespace app\controller\merchant\store\product; +use app\common\model\store\product\StoreDiscountProduct; +use app\common\model\store\product\Product as smodel; use app\common\repositories\store\order\StoreCartRepository; use app\common\repositories\store\product\ProductAttrValueRepository; use app\common\repositories\store\product\SpuRepository; @@ -94,8 +96,11 @@ class Product extends BaseController */ public function update($id) { + $params = $this->request->params($this->repository::CREATE_PARAMS); + $data = $this->repository->checkParams($params,$this->request->merId(), $id); + if (!$this->repository->merExists($this->request->merId(), $id)) return app('json')->fail('数据不存在'); $pro = $this->repository->getWhere(['product_id' => $id]); @@ -106,7 +111,11 @@ class Product extends BaseController } $data['mer_status'] = ($this->request->merchant()->is_del || !$this->request->merchant()->mer_state || !$this->request->merchant()->status) ? 0 : 1; $data['mer_id'] = $this->request->merId(); + $this->repository->edit($id, $data, $this->request->merId(), 0); + $a = new smodel(); + + $a::getDB()->where('product_id',$id)->update(['is_pre'=>$data['is_pre']]); return app('json')->success('编辑成功'); }