From ef9ea92df2c7a050955be03783a99a07b946f817 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Tue, 9 Apr 2024 15:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=80=BB=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=95=86=E5=93=81=E7=BC=96=E8=BE=91=E6=97=B6=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91=E6=98=9F=E7=BA=A7=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E3=80=81=E5=95=86=E5=93=81=E6=8E=A8=E8=8D=90=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/product/ProductRepository.php | 26 ++++++++++--------- .../store/product/SpuRepository.php | 1 + app/controller/admin/store/StoreProduct.php | 11 +++++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 5516ce0..fee3a9a 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -259,6 +259,8 @@ class ProductRepository extends BaseRepository $product['price'] = $settleParams['data']['price']; $product['ot_price'] = $settleParams['data']['ot_price']; $product['mer_labels'] = $data['mer_labels']; + $product['star'] = $data['star'] ?? 1; + $product['rank'] = $data['rank'] ?? 0; app()->make(SpuRepository::class)->create($product, $result->product_id, $activity_id, $productType); } $product = $result; @@ -297,6 +299,8 @@ class ProductRepository extends BaseRepository $spuData['price'] = $settleParams['data']['price']; $spuData['mer_id'] = $merId; $spuData['mer_labels'] = $data['mer_labels']; + $spuData['star'] = $data['star'] ?? 1; + $spuData['rank'] = $data['rank'] ?? 0; Db::transaction(function () use ($id, $data, $productType, $settleParams,$content,$buyAgreement,$product,$spuData,$merId) { $this->save($id, $settleParams, $content, $product, $productType,$buyAgreement); @@ -486,6 +490,10 @@ class ProductRepository extends BaseRepository 'is_show' => $data['is_show'] ?? 0, 'is_used' => (isset($data['status']) && $data['status'] == 1) ? 1 : 0, 'is_good' => $data['is_good'] ?? 0, + 'is_benefit' => $data['is_benefit'] ?? 0, + 'is_hot' => $data['is_hot'] ?? 0, + 'is_best' => $data['is_best'] ?? 0, + 'is_new' => $data['is_new'] ?? 0, 'video_link' => $data['video_link'] ?? '', 'temp_id' => $data['delivery_free'] ? 0 : ($data['temp_id'] ?? 0), 'extension_type' => $data['extension_type'] ?? 0, @@ -522,18 +530,12 @@ class ProductRepository extends BaseRepository 'batch_num' => $data['batch_num'] ?? 0, 'batch_unit' => $data['batch_unit'] ?? '', ]; - if (isset($data['extend'])) - $result['extend'] = $data['extend'] ? json_encode($data['extend'], JSON_UNESCAPED_UNICODE) : ''; - if (isset($data['mer_id'])) - $result['mer_id'] = $data['mer_id']; - if (isset($data['old_product_id'])) - $result['old_product_id'] = $data['old_product_id']; - if (isset($data['product_type'])) - $result['product_type'] = $data['product_type']; - if (isset($data['type']) && $data['type']) - $result['type'] = $data['type']; - if (isset($data['param_temp_id'])) - $result['param_temp_id'] = $data['param_temp_id']; + if (isset($data['extend'])) $result['extend'] = $data['extend'] ? json_encode($data['extend'], JSON_UNESCAPED_UNICODE) : ''; + if (isset($data['mer_id'])) $result['mer_id'] = $data['mer_id']; + if (isset($data['old_product_id'])) $result['old_product_id'] = $data['old_product_id']; + if (isset($data['product_type'])) $result['product_type'] = $data['product_type']; + if (isset($data['type']) && $data['type']) $result['type'] = $data['type']; + if (isset($data['param_temp_id'])) $result['param_temp_id'] = $data['param_temp_id']; return $result; } diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index 7229991..9d80642 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -82,6 +82,7 @@ class SpuRepository extends BaseRepository 'temp_id' => $param['temp_id'], 'sort' => $param['sort'] ?? 0, 'mer_labels' => $param['mer_labels'] ?? '', + 'star' => $param['star'] ?? 1, ]; if (isset($param['mer_id'])) $data['mer_id'] = $param['mer_id']; return $data; diff --git a/app/controller/admin/store/StoreProduct.php b/app/controller/admin/store/StoreProduct.php index fe6a084..0d5b369 100644 --- a/app/controller/admin/store/StoreProduct.php +++ b/app/controller/admin/store/StoreProduct.php @@ -329,7 +329,8 @@ class StoreProduct extends BaseController // 总平台添加商品 public function create(){ - $params = $this->request->params($this->repository::CREATE_PARAMS); + $fields = array_merge(['is_hot','is_best','is_benefit','is_new','store_name','content','rank','star'],$this->repository::CREATE_PARAMS); + $params = $this->request->params($fields); $data = $this->repository->checkParams($params,$this->request->merId()); $data['mer_id'] = $this->request->merId(); $data['admin_id'] = $this->request->merAdminId(); @@ -338,11 +339,14 @@ class StoreProduct extends BaseController $data['mer_status'] = 1; $data['rate'] = 3; $this->repository->create($data,0); + return app('json')->success('添加成功'); } // 总平台编辑总平台添加的商品 - public function edit($id){ - $params = $this->request->params($this->repository::CREATE_PARAMS); + public function edit($id, validate $validate){ + $fields = array_merge(['is_hot','is_best','is_benefit','is_new','store_name','content','rank','star'],$this->repository::CREATE_PARAMS); + // 执行商品编辑 + $params = $this->request->params($fields); $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]); @@ -351,6 +355,7 @@ class StoreProduct extends BaseController $data['mer_status'] = 1; $data['mer_id'] = $this->request->merId(); $this->repository->edit($id, $data, $this->request->merId(), 0); + return app('json')->success('编辑成功'); } // 总平台商品下架 / 上架