正在显示
1 个修改的文件
包含
94 行增加
和
2 行删除
| @@ -9,6 +9,7 @@ use App\Models\Product\CategoryRelated; | @@ -9,6 +9,7 @@ use App\Models\Product\CategoryRelated; | ||
| 9 | use App\Models\Product\KeywordRelated; | 9 | use App\Models\Product\KeywordRelated; |
| 10 | use App\Models\Product\Product; | 10 | use App\Models\Product\Product; |
| 11 | use App\Models\RouteMap; | 11 | use App\Models\RouteMap; |
| 12 | +use App\Models\Template\BTemplate; | ||
| 12 | use Illuminate\Support\Facades\DB; | 13 | use Illuminate\Support\Facades\DB; |
| 13 | 14 | ||
| 14 | /** | 15 | /** |
| @@ -152,7 +153,98 @@ class ProductLogic extends BaseLogic | @@ -152,7 +153,98 @@ class ProductLogic extends BaseLogic | ||
| 152 | */ | 153 | */ |
| 153 | public function setCopyProduct(){ | 154 | public function setCopyProduct(){ |
| 154 | $info = $this->model->read(['id'=>$this->param['id']]); | 155 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 155 | - var_dump($info); | ||
| 156 | - die(); | 156 | + $param = $this->setProductParams($info); |
| 157 | + $save_id = $this->model->insertGetId($param); | ||
| 158 | + //同步关联分类 | ||
| 159 | + CategoryRelated::saveRelated($save_id, $param['category_id']); | ||
| 160 | + //同步关联关键词 | ||
| 161 | + KeywordRelated::saveRelated($save_id, $param['keyword_id']); | ||
| 162 | + //同步可视化装修数据 | ||
| 163 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 164 | + return $this->success(); | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * @remark :同步模版数据 | ||
| 169 | + * @name :copyTemplate | ||
| 170 | + * @author :lyh | ||
| 171 | + * @method :post | ||
| 172 | + * @time :2023/7/29 15:53 | ||
| 173 | + */ | ||
| 174 | + public function copyTemplate($id,$project_id,$save_id){ | ||
| 175 | + $BTemplateModel = new BTemplate(); | ||
| 176 | + $list = $BTemplateModel->list(['source'=>2,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 177 | + if(!empty($list)){ | ||
| 178 | + $data = []; | ||
| 179 | + foreach ($list as $k => $v){ | ||
| 180 | + $data[] = $this->setTemplateParams($v,$project_id,$save_id); | ||
| 181 | + } | ||
| 182 | + $rs = $BTemplateModel->insert($data); | ||
| 183 | + if($rs === false){ | ||
| 184 | + $this->fail('error'); | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + return $this->success(); | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + /** | ||
| 191 | + * @remark :组装模版数据 | ||
| 192 | + * @name :setTemplateParams | ||
| 193 | + * @author :lyh | ||
| 194 | + * @method :post | ||
| 195 | + * @time :2023/7/29 15:54 | ||
| 196 | + */ | ||
| 197 | + public function setTemplateParams($v,$project_id,$save_id){ | ||
| 198 | + $param = [ | ||
| 199 | + 'html'=>$v['html'], | ||
| 200 | + 'project_id'=>$project_id, | ||
| 201 | + 'source'=>$v['source'], | ||
| 202 | + 'source_id'=>$save_id, | ||
| 203 | + 'template_id'=>$v['template_id'], | ||
| 204 | + 'section_list_id'=>$v['section_list_id'], | ||
| 205 | + 'head_html'=>$v['head_html'], | ||
| 206 | + 'main_html'=>$v['main_html'], | ||
| 207 | + 'footer_html'=>$v['footer_html'], | ||
| 208 | + 'head_css'=>$v['head_css'], | ||
| 209 | + 'main_css'=>$v['main_css'], | ||
| 210 | + 'footer_css'=>$v['footer_css'], | ||
| 211 | + 'created_at'=>$v['created_at'], | ||
| 212 | + 'updated_at'=>$v['updated_at'] | ||
| 213 | + ]; | ||
| 214 | + return $this->success($param); | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + /** | ||
| 218 | + * @remark :组装数据 | ||
| 219 | + * @name :setParams | ||
| 220 | + * @author :lyh | ||
| 221 | + * @method :post | ||
| 222 | + * @time :2023/7/29 15:45 | ||
| 223 | + */ | ||
| 224 | + public function setProductParams($info){ | ||
| 225 | + $param = [ | ||
| 226 | + 'project_id'=>$info['project_id'], | ||
| 227 | + 'title'=>$info['title'], | ||
| 228 | + 'thumb'=>$info['thumb'], | ||
| 229 | + 'gallery'=>$info['gallery'], | ||
| 230 | + 'attrs'=>$info['attrs'], | ||
| 231 | + 'attr_id'=>$info['attr_id'], | ||
| 232 | + 'category_id'=>$info['category_id'], | ||
| 233 | + 'keyword_id'=>$info['keyword_id'], | ||
| 234 | + 'intro'=>$info['intro'], | ||
| 235 | + 'content'=>$info['content'], | ||
| 236 | + 'describe'=>$info['describe'], | ||
| 237 | + 'describe_id'=>$info['describe_id'], | ||
| 238 | + 'seo_mate'=>$info['seo_mate'], | ||
| 239 | + 'related_product_id'=>$info['related_product_id'], | ||
| 240 | + 'sort'=>$info['sort'], | ||
| 241 | + 'status'=>$info['status'], | ||
| 242 | + 'product_type'=>$info['product_type'], | ||
| 243 | + 'created_uid'=>$this->user['id'], | ||
| 244 | + 'icon'=>$info['icon'], | ||
| 245 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 246 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 247 | + ]; | ||
| 248 | + return $this->success($param); | ||
| 157 | } | 249 | } |
| 158 | } | 250 | } |
-
请 注册 或 登录 后发表评论