|
@@ -38,21 +38,12 @@ class ProductLogic extends BaseLogic |
|
@@ -38,21 +38,12 @@ class ProductLogic extends BaseLogic |
|
38
|
* @time :2023/8/21 18:35
|
38
|
* @time :2023/8/21 18:35
|
|
39
|
*/
|
39
|
*/
|
|
40
|
public function productSave(){
|
40
|
public function productSave(){
|
|
41
|
- //扩展字段
|
|
|
|
42
|
- $extend = [];
|
|
|
|
43
|
- if(!empty($this->param['extend'])){
|
|
|
|
44
|
- $extend = $this->param['extend'];
|
|
|
|
45
|
- unset($this->param['extend']);
|
|
|
|
46
|
- }
|
|
|
|
47
|
- $this->param = $this->handleSaveParam($this->param);
|
41
|
+ //处理扩展字段
|
|
|
|
42
|
+ $extend = $this->handleExtent();
|
|
48
|
//单独处理分类
|
43
|
//单独处理分类
|
|
49
|
- $category_ids = [];
|
|
|
|
50
|
- if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
|
|
|
|
51
|
- $category_ids = $this->getLastCategoryArr($this->param['category_id']);
|
|
|
|
52
|
- $this->param['category_id'] = ','.implode(',',$category_ids).',';
|
|
|
|
53
|
- }else{
|
|
|
|
54
|
- $this->param['category_id'] = '';
|
|
|
|
55
|
- }
|
44
|
+ $category_ids = $this->handleCategory();
|
|
|
|
45
|
+ //处理其他字段
|
|
|
|
46
|
+ $this->param = $this->handleSaveParam($this->param);
|
|
56
|
DB::connection('custom_mysql')->beginTransaction();
|
47
|
DB::connection('custom_mysql')->beginTransaction();
|
|
57
|
try {
|
48
|
try {
|
|
58
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
49
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
@@ -81,6 +72,40 @@ class ProductLogic extends BaseLogic |
|
@@ -81,6 +72,40 @@ class ProductLogic extends BaseLogic |
|
81
|
}
|
72
|
}
|
|
82
|
|
73
|
|
|
83
|
/**
|
74
|
/**
|
|
|
|
75
|
+ * @remark :处理扩展字段
|
|
|
|
76
|
+ * @name :handleExtent
|
|
|
|
77
|
+ * @author :lyh
|
|
|
|
78
|
+ * @method :post
|
|
|
|
79
|
+ * @time :2023/12/6 15:06
|
|
|
|
80
|
+ */
|
|
|
|
81
|
+ public function handleExtent(){
|
|
|
|
82
|
+ //扩展字段
|
|
|
|
83
|
+ $extend = [];
|
|
|
|
84
|
+ if(!empty($this->param['extend'])){
|
|
|
|
85
|
+ $extend = $this->param['extend'];
|
|
|
|
86
|
+ unset($this->param['extend']);
|
|
|
|
87
|
+ }
|
|
|
|
88
|
+ return $extend;
|
|
|
|
89
|
+ }
|
|
|
|
90
|
+
|
|
|
|
91
|
+ /**
|
|
|
|
92
|
+ * @remark :处理分类数据
|
|
|
|
93
|
+ * @name :handleCategory
|
|
|
|
94
|
+ * @author :lyh
|
|
|
|
95
|
+ * @method :post
|
|
|
|
96
|
+ * @time :2023/12/6 15:01
|
|
|
|
97
|
+ */
|
|
|
|
98
|
+ public function handleCategory(){
|
|
|
|
99
|
+ $category_ids = [];
|
|
|
|
100
|
+ if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
|
|
|
|
101
|
+ $category_ids = $this->getLastCategoryArr($this->param['category_id']);
|
|
|
|
102
|
+ $this->param['category_id'] = ','.implode(',',$category_ids).',';
|
|
|
|
103
|
+ }else{
|
|
|
|
104
|
+ $this->param['category_id'] = '';
|
|
|
|
105
|
+ }
|
|
|
|
106
|
+ return $category_ids;
|
|
|
|
107
|
+ }
|
|
|
|
108
|
+ /**
|
|
84
|
* @remark :新增时处理字段
|
109
|
* @remark :新增时处理字段
|
|
85
|
* @name :addHandleParam
|
110
|
* @name :addHandleParam
|
|
86
|
* @author :lyh
|
111
|
* @author :lyh
|
|
@@ -112,27 +137,38 @@ class ProductLogic extends BaseLogic |
|
@@ -112,27 +137,38 @@ class ProductLogic extends BaseLogic |
|
112
|
if(empty($v['values'])){
|
137
|
if(empty($v['values'])){
|
|
113
|
continue;
|
138
|
continue;
|
|
114
|
}
|
139
|
}
|
|
115
|
- unset($v['title']);
|
|
|
|
116
|
- if($v['type'] == 3){
|
|
|
|
117
|
- foreach ($v['values'] as $k1=>$v1){
|
|
|
|
118
|
- $v1['url'] = str_replace_url($v1['url']);
|
|
|
|
119
|
- $v['values'][$k1] = $v1;
|
|
|
|
120
|
- }
|
|
|
|
121
|
- $v['values'] = json_encode($v['values']);
|
|
|
|
122
|
- }elseif ($v['type'] == 4){
|
|
|
|
123
|
- foreach ($v['values'] as $k1=>$v1){
|
|
|
|
124
|
- $v1 = str_replace_url($v1);
|
|
|
|
125
|
- $v['values'][$k1] = $v1;
|
|
|
|
126
|
- }
|
|
|
|
127
|
- $v['values'] = json_encode($v['values']);
|
|
|
|
128
|
- }
|
|
|
|
129
|
- $v['project_id'] = $this->user['project_id'];
|
|
|
|
130
|
- $v['product_id'] = $product_id;
|
140
|
+ $v = $this->saveHandleExtend($v,$product_id);
|
|
131
|
$extendInfoModel->add($v);
|
141
|
$extendInfoModel->add($v);
|
|
132
|
}
|
142
|
}
|
|
133
|
return $this->success();
|
143
|
return $this->success();
|
|
134
|
}
|
144
|
}
|
|
135
|
|
145
|
|
|
|
|
146
|
+ /**
|
|
|
|
147
|
+ * @remark :保存扩展字段时处理数据
|
|
|
|
148
|
+ * @name :saveHandleExtend
|
|
|
|
149
|
+ * @author :lyh
|
|
|
|
150
|
+ * @method :post
|
|
|
|
151
|
+ * @time :2023/12/6 15:11
|
|
|
|
152
|
+ */
|
|
|
|
153
|
+ public function saveHandleExtend(&$v,$product_id){
|
|
|
|
154
|
+ unset($v['title']);
|
|
|
|
155
|
+ if($v['type'] == 3){
|
|
|
|
156
|
+ foreach ($v['values'] as $k1=>$v1){
|
|
|
|
157
|
+ $v1['url'] = str_replace_url($v1['url']);
|
|
|
|
158
|
+ $v['values'][$k1] = $v1;
|
|
|
|
159
|
+ }
|
|
|
|
160
|
+ $v['values'] = json_encode($v['values']);
|
|
|
|
161
|
+ }elseif ($v['type'] == 4){
|
|
|
|
162
|
+ foreach ($v['values'] as $k1=>$v1){
|
|
|
|
163
|
+ $v1 = str_replace_url($v1);
|
|
|
|
164
|
+ $v['values'][$k1] = $v1;
|
|
|
|
165
|
+ }
|
|
|
|
166
|
+ $v['values'] = json_encode($v['values']);
|
|
|
|
167
|
+ }
|
|
|
|
168
|
+ $v['project_id'] = $this->user['project_id'];
|
|
|
|
169
|
+ $v['product_id'] = $product_id;
|
|
|
|
170
|
+ return $this->success($v);
|
|
|
|
171
|
+ }
|
|
136
|
|
172
|
|
|
137
|
/**
|
173
|
/**
|
|
138
|
* @remark :编辑列表数据
|
174
|
* @remark :编辑列表数据
|