作者 赵彬吉
@@ -292,7 +292,7 @@ class ProjectController extends BaseController @@ -292,7 +292,7 @@ class ProjectController extends BaseController
292 $domainModel = new DomainInfo(); 292 $domainModel = new DomainInfo();
293 $item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : ''; 293 $item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
294 $item['product_num'] = $data['product'] ?? 0; 294 $item['product_num'] = $data['product'] ?? 0;
295 - $item['keyword_num'] = $item['key'] ?? 0; 295 + $item['keyword_num'] = $data['key'] ?? 0;
296 $item['autologin_code'] = getAutoLoginCode($item['id']); 296 $item['autologin_code'] = getAutoLoginCode($item['id']);
297 $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0); 297 $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0);
298 $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN); 298 $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN);
@@ -758,6 +758,9 @@ class ProjectController extends BaseController @@ -758,6 +758,9 @@ class ProjectController extends BaseController
758 * @time :2023/11/8 14:17 758 * @time :2023/11/8 14:17
759 */ 759 */
760 public function copyProject(ProjectLogic $logic){ 760 public function copyProject(ProjectLogic $logic){
  761 + if($this->manage['mobile'] != '15680871314' || $this->manage['mobile'] != '18008059100'){
  762 + $this->response('当前账号不支持复制项目');
  763 + }
761 $this->request->validate([ 764 $this->request->validate([
762 'project_id'=>'required', 765 'project_id'=>'required',
763 ],[ 766 ],[
@@ -75,6 +75,9 @@ class ProjectLogic extends BaseLogic @@ -75,6 +75,9 @@ class ProjectLogic extends BaseLogic
75 if(empty($info['channel'])){ 75 if(empty($info['channel'])){
76 $info['channel'] = ["user_id"=>"", "zone_id"=>"", "channel_id"=>""]; 76 $info['channel'] = ["user_id"=>"", "zone_id"=>"", "channel_id"=>""];
77 } 77 }
  78 + if(empty($info['payment']['renewal_record'])){
  79 + $info['payment']['renewal_record'] = [["amount"=> null, "remark"=> null, "expire_at"=> null]];
  80 + }
78 return $this->success($info); 81 return $this->success($info);
79 } 82 }
80 83
@@ -533,71 +536,81 @@ class ProjectLogic extends BaseLogic @@ -533,71 +536,81 @@ class ProjectLogic extends BaseLogic
533 * @time :2023/11/8 14:23 536 * @time :2023/11/8 14:23
534 */ 537 */
535 public function copyProject(){ 538 public function copyProject(){
536 - //复制初始项目  
537 - $data = $this->model::where('id', $this->param['project_id'])->first();  
538 - $data = $data->getAttributes();  
539 - $data['type'] = 0;  
540 - $data['title'] = $data['title'].'-copy';  
541 - unset($data['id']);  
542 - $project_id = $this->model->insertGetId($data);  
543 - //复制部署表  
544 - $buildModel = new DeployBuild();  
545 - $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();  
546 - if(!empty($buildData)){  
547 - $buildData = $buildData->getAttributes();  
548 - $buildData['project_id'] = $project_id;  
549 - $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');  
550 - $code = $hashids->encode($project_id);  
551 - $buildData['test_domain'] = 'https://v6-' . $code . '.globalso.site/';  
552 - unset($buildData['id']);  
553 - $buildModel->insert($buildData);  
554 - }  
555 - //复制优化表  
556 - $optimizeModel = new DeployOptimize();  
557 - $optimizeData = $optimizeModel::where('project_id', $this->param['project_id'])->first();  
558 - if(!empty($optimizeData)){  
559 - $optimizeData = $optimizeData->getAttributes();  
560 - unset($optimizeData['id'],$optimizeData['domain']);  
561 - $optimizeData['project_id'] = $project_id;  
562 - $optimizeModel->insert($optimizeData);  
563 - }  
564 - //复制付费表  
565 - $paymentModel = new Payment();  
566 - $paymentData = $paymentModel::where('project_id', $this->param['project_id'])->first();  
567 - if(!empty($paymentData)){  
568 - $paymentData = $paymentData->getAttributes();  
569 - unset($paymentData['id']);  
570 - $paymentData['project_id'] = $project_id;  
571 - $paymentModel->insert($paymentData);  
572 - }  
573 - //复制售后表  
574 - $afterModel = new After();  
575 - $afterData = $afterModel::where('project_id', $this->param['project_id'])->first();  
576 - if(!empty($afterData)){  
577 - $afterData = $afterData->getAttributes();  
578 - unset($afterData['id']);  
579 - $afterData['project_id'] = $project_id;  
580 - $afterModel->insert($afterData);  
581 - }  
582 - //复制用户  
583 - $userModel = new UserModel();  
584 - $userData = $userModel::where('project_id', $this->param['project_id'])->where('role_id',0)->first();  
585 - if(!empty($userData)){  
586 - $userData = $userData->getAttributes();  
587 - unset($userData['id']);  
588 - $userData['project_id'] = $project_id;  
589 - $userModel->insert($userData);  
590 - }  
591 - //复制设置的模版  
592 - $settingTemplateModel = new Setting();  
593 - $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();  
594 - if(!empty($settingData)){  
595 - $settingData = $settingData->getAttributes();  
596 - unset($settingData['id']);  
597 - $settingData['project_id'] = $project_id;  
598 - $settingTemplateModel->insert($settingData);  
599 - }  
600 - $this->copyMysql($this->param['project_id'],$project_id); 539 + DB::beginTransaction();
  540 + try {
  541 + //复制初始项目
  542 + $data = $this->model::where('id', $this->param['project_id'])->first();
  543 + $data = $data->getAttributes();
  544 + $type = $data['type'];
  545 + $data['type'] = 0;
  546 + $data['title'] = $data['title'].'-copy';
  547 + unset($data['id']);
  548 + $project_id = $this->model->insertGetId($data);
  549 + //复制部署表
  550 + $buildModel = new DeployBuild();
  551 + $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();
  552 + if(!empty($buildData)){
  553 + $buildData = $buildData->getAttributes();
  554 + $buildData['project_id'] = $project_id;
  555 + $hashids = new Hashids('test_domain', 5, 'abcdefghjkmnpqrstuvwxyz1234567890');
  556 + $code = $hashids->encode($project_id);
  557 + $buildData['test_domain'] = 'https://v6-' . $code . '.globalso.site/';
  558 + unset($buildData['id']);
  559 + $buildModel->insert($buildData);
  560 + }
  561 + //复制优化表
  562 + $optimizeModel = new DeployOptimize();
  563 + $optimizeData = $optimizeModel::where('project_id', $this->param['project_id'])->first();
  564 + if(!empty($optimizeData)){
  565 + $optimizeData = $optimizeData->getAttributes();
  566 + unset($optimizeData['id'],$optimizeData['domain']);
  567 + $optimizeData['project_id'] = $project_id;
  568 + $optimizeModel->insert($optimizeData);
  569 + }
  570 + //复制付费表
  571 + $paymentModel = new Payment();
  572 + $paymentData = $paymentModel::where('project_id', $this->param['project_id'])->first();
  573 + if(!empty($paymentData)){
  574 + $paymentData = $paymentData->getAttributes();
  575 + unset($paymentData['id']);
  576 + $paymentData['project_id'] = $project_id;
  577 + $paymentModel->insert($paymentData);
  578 + }
  579 + //复制售后表
  580 + $afterModel = new After();
  581 + $afterData = $afterModel::where('project_id', $this->param['project_id'])->first();
  582 + if(!empty($afterData)){
  583 + $afterData = $afterData->getAttributes();
  584 + unset($afterData['id']);
  585 + $afterData['project_id'] = $project_id;
  586 + $afterModel->insert($afterData);
  587 + }
  588 + //复制用户
  589 + $userModel = new UserModel();
  590 + $userData = $userModel::where('project_id', $this->param['project_id'])->where('role_id',0)->first();
  591 + if(!empty($userData)){
  592 + $userData = $userData->getAttributes();
  593 + unset($userData['id']);
  594 + $userData['project_id'] = $project_id;
  595 + $userModel->insert($userData);
  596 + }
  597 + //复制设置的模版
  598 + $settingTemplateModel = new Setting();
  599 + $settingData = $settingTemplateModel::where('project_id', $this->param['project_id'])->first();
  600 + if(!empty($settingData)){
  601 + $settingData = $settingData->getAttributes();
  602 + unset($settingData['id']);
  603 + $settingData['project_id'] = $project_id;
  604 + $settingTemplateModel->insert($settingData);
  605 + }
  606 + DB::commit();
  607 + }catch (\Exception $e){
  608 + DB::rollBack();
  609 + $this->fail('error');
  610 + }
  611 + if($type != 0){
  612 + $this->copyMysql($this->param['project_id'],$project_id);
  613 + }
601 return $this->success($data); 614 return $this->success($data);
602 } 615 }
603 616
@@ -29,15 +29,11 @@ class UserLogic extends BaseLogic @@ -29,15 +29,11 @@ class UserLogic extends BaseLogic
29 */ 29 */
30 public function user_info() 30 public function user_info()
31 { 31 {
32 - $info = Common::get_user_cache($this->model, $this->param['id'], 'A');  
33 - if (empty($info)) {  
34 - $info = $this->model->read($this->param, ['id', 'project_id', 'name', 'status', 'role_id' ,'mobile', 'operator_id']);  
35 - if ($info === false) {  
36 - $this->fail('当前数据不存在');  
37 - }  
38 - $info['project_name'] = (new Project())->read(['id' => $info['project_id']], ['title'])['title'];  
39 - Common::set_user_cache($info, $this->model, $this->param['id'], 'A'); 32 + $info = $this->model->read($this->param, ['id', 'project_id', 'name', 'status', 'role_id' ,'mobile', 'operator_id']);
  33 + if ($info === false) {
  34 + $this->fail('当前数据不存在');
40 } 35 }
  36 + $info['project_name'] = (new Project())->read(['id' => $info['project_id']], ['title'])['title'];
41 return $this->success($info); 37 return $this->success($info);
42 } 38 }
43 39
@@ -59,6 +59,7 @@ class KeywordLogic extends BaseLogic @@ -59,6 +59,7 @@ class KeywordLogic extends BaseLogic
59 }else{ 59 }else{
60 $this->param['project_id'] = $this->user['project_id']; 60 $this->param['project_id'] = $this->user['project_id'];
61 $this->param['created_at'] = date('Y-m-d H:i:s'); 61 $this->param['created_at'] = date('Y-m-d H:i:s');
  62 + $this->param['title'] = $this->param['title'].'-tag';
62 $this->param['updated_at'] = $this->param['created_at']; 63 $this->param['updated_at'] = $this->param['created_at'];
63 $id = $this->model->insertGetId($this->param); 64 $id = $this->model->insertGetId($this->param);
64 //路由映射 65 //路由映射
@@ -36,8 +36,10 @@ class APublicModel extends Base @@ -36,8 +36,10 @@ class APublicModel extends Base
36 ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); 36 ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
37 $newsNumber = DB::connection('custom_mysql')->table('gl_news') 37 $newsNumber = DB::connection('custom_mysql')->table('gl_news')
38 ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count(); 38 ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
  39 + $keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword')
  40 + ->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
39 DB::disconnect('custom_mysql'); 41 DB::disconnect('custom_mysql');
40 - return ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber]; 42 + return ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber];
41 } 43 }
42 44
43 } 45 }