diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index b901f34b..6f36ec4e 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -330,6 +330,19 @@ class ProductRepository extends BaseRepository public function freeTrial(int $id, array $data, int $merId) { + if (isset($data['mer_labels'])&& $data['mer_labels']!='') { + $value = $data['mer_labels']; + if (!empty($value)) { + if (!is_array($value)) { + $data['mer_labels'] = ',' . $value . ','; + } else { + $data['mer_labels'] = ',' . implode(',', $value) . ','; + } + } + $ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type', [0, 98, 99])->find(); + app()->make(SpuRepository::class)->update($ret->spu_id, ['mer_labels' => $data['mer_labels']]); + return false; + } if (!$data['spec_type']) { $data['attr'] = []; if (count($data['attrValue']) > 1) throw new ValidateException('单规格商品属性错误'); @@ -344,15 +357,7 @@ class ProductRepository extends BaseRepository $ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type', [0, 98, 99])->find(); Db::transaction(function () use ($id, $data, $settleParams, $ret) { $this->save($id, $settleParams, null, [], 0); - $value = $data['mer_labels']; - if (!empty($value)) { - if (!is_array($value)) { - $data['mer_labels'] = ',' . $value . ','; - } else { - $data['mer_labels'] = ',' . implode(',', $value) . ','; - } - } - app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price'],'mer_labels'=>$data['mer_labels']]); + app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price']]); Queue(SendSmsJob::class, ['tempId' => 'PRODUCT_INCREASE', 'id' => $id]); }); } @@ -734,7 +739,7 @@ class ProductRepository extends BaseRepository if ($data['product_type'] == 3) $make = app()->make(ProductAssistSkuRepository::class); if ($data['product_type'] == 4) $make = app()->make(ProductGroupSkuRepository::class); - $spu_where = ['activity_id' => $activeId??0, 'product_type' => $data['product_type'], 'product_id' => $id]; + $spu_where = ['activity_id' => $activeId ?? 0, 'product_type' => $data['product_type'], 'product_id' => $id]; $spu = $spu_make->getSearch($spu_where)->find(); $data['star'] = $spu['star'] ?? ''; $data['mer_labels'] = $spu['mer_labels'] ?? ''; @@ -2607,7 +2612,7 @@ class ProductRepository extends BaseRepository $data['type'] = 8; break; } - $store_product=Db::name('store_product')->where('product_id',$data['product_id'])->find(); + $store_product = Db::name('store_product')->where('product_id', $data['product_id'])->find(); $datas = [ 'product_id' => $data['product_id'], 'cate_id' => $store_product['cate_id'], @@ -2621,11 +2626,11 @@ class ProductRepository extends BaseRepository 'create_time' => date('Y-m-d H:i:s'), 'mer_labels' => ',' . $data['type'] . ',', ]; - $res= Db::name('cloud_product')->where('product_id',$data['product_id'])->where('mer_id',$merchant['mer_id'])->find(); - if($res){ + $res = Db::name('cloud_product')->where('product_id', $data['product_id'])->where('mer_id', $merchant['mer_id'])->find(); + if ($res) { throw new ValidateException('该商品已设置过'); } - return Db::name('cloud_product')->insert($datas); + return Db::name('cloud_product')->insert($datas); } return false; } diff --git a/app/controller/api/store/product/StoreProduct.php b/app/controller/api/store/product/StoreProduct.php index 5625a0c2..601cc19c 100644 --- a/app/controller/api/store/product/StoreProduct.php +++ b/app/controller/api/store/product/StoreProduct.php @@ -224,7 +224,7 @@ class StoreProduct extends BaseController return app('json')->fail('编辑免申商品参数错误'); } $res=$this->repository->freeTrial($id, $data,$mer_id); - if($res && $params['is_stock']==1){ + if($res && $data['is_stock']==1){ $arr=[ 'mer_id'=>$mer_id, 'uid'=>$uid, diff --git a/public/mer.html b/public/mer.html index c9f83c1f..37140559 100644 --- a/public/mer.html +++ b/public/mer.html @@ -1 +1 @@ -