作者 lyh

gx

@@ -28,11 +28,9 @@ class ProductLogic extends BaseLogic @@ -28,11 +28,9 @@ class ProductLogic extends BaseLogic
28 } 28 }
29 29
30 public function productSave(){ 30 public function productSave(){
31 - //封面取第一个图片  
32 - $this->param['thumb'] = $this->param['gallery'][0] ?? ''; 31 + $this->param = $this->handleSaveParam($this->param);
33 // DB::beginTransaction(); 32 // DB::beginTransaction();
34 // try { 33 // try {
35 - $this->param['created_uid'] = $this->user['id'];  
36 if(isset($this->param['id']) && !empty($this->param['id'])){ 34 if(isset($this->param['id']) && !empty($this->param['id'])){
37 $id = $this->param['id']; 35 $id = $this->param['id'];
38 $this->model->edit($this->param,['id'=>$this->param['id']]); 36 $this->model->edit($this->param,['id'=>$this->param['id']]);
@@ -54,6 +52,28 @@ class ProductLogic extends BaseLogic @@ -54,6 +52,28 @@ class ProductLogic extends BaseLogic
54 return $this->success(); 52 return $this->success();
55 } 53 }
56 54
  55 + /**
  56 + * @remark :不使用save处理参数
  57 + * @name :handleSaveParam
  58 + * @author :lyh
  59 + * @method :post
  60 + * @time :2023/8/21 17:03
  61 + */
  62 + public function handleSaveParam(&$param){
  63 + $param['thumb'] = Arr::a2s($param['gallery'][0] ?? '');
  64 + $param['gallery'] = Arr::a2s($param['gallery'] ?? '');
  65 + $param['attrs'] = Arr::a2s($param['attrs'] ?? '');
  66 + $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
  67 + $param['category_id'] = ','.Arr::arrToSet($param['category_id']).',';
  68 + $param['keyword_id'] = Arr::arrToSet($param['keyword_id'] ?? '');
  69 + $param['describe'] = Arr::a2s($param['describe'] ?? '');
  70 + $param['describe_id'] = Arr::arrToSet($param['describe_id'] ?? '');
  71 + $param['seo_mate'] = Arr::a2s($param['seo_mate']);
  72 + $param['related_product_id'] = Arr::arrToSet($param['related_product_id'] ?? '');
  73 + $param['icon'] = Arr::a2s($param['icon'] ?? '');
  74 + $param['created_uid'] = $this->user['id'];
  75 + return $param;
  76 + }
57 public function delete($ids, $map =[]){ 77 public function delete($ids, $map =[]){
58 $ids= array_filter(Arr::splitFilterToArray($ids), 'intval'); 78 $ids= array_filter(Arr::splitFilterToArray($ids), 'intval');
59 DB::beginTransaction(); 79 DB::beginTransaction();