作者 赵彬吉

update

@@ -9,13 +9,10 @@ use App\Http\Logic\Aside\BaseLogic; @@ -9,13 +9,10 @@ use App\Http\Logic\Aside\BaseLogic;
9 use App\Http\Logic\Aside\Manage\ManageLogic; 9 use App\Http\Logic\Aside\Manage\ManageLogic;
10 use App\Models\City; 10 use App\Models\City;
11 use App\Models\InquirySet; 11 use App\Models\InquirySet;
12 -use App\Models\Manage\Manage;  
13 use App\Models\Project\DeployBuild; 12 use App\Models\Project\DeployBuild;
14 use App\Models\Project\DeployOptimize; 13 use App\Models\Project\DeployOptimize;
15 use App\Models\Project\Payment; 14 use App\Models\Project\Payment;
16 use App\Models\Project\Project; 15 use App\Models\Project\Project;
17 -use Illuminate\Database\Eloquent\Model;  
18 -use Illuminate\Support\Facades\Cache;  
19 use Illuminate\Support\Facades\DB; 16 use Illuminate\Support\Facades\DB;
20 17
21 /** 18 /**
@@ -42,20 +39,20 @@ class ProjectLogic extends BaseLogic @@ -42,20 +39,20 @@ class ProjectLogic extends BaseLogic
42 'id' => $item['id'], 39 'id' => $item['id'],
43 'title' => $item['title'], 40 'title' => $item['title'],
44 'channel' => $item['channel']['channel'] . ' - ' . $item['channel']['saler'], 41 'channel' => $item['channel']['channel'] . ' - ' . $item['channel']['saler'],
45 - 'key' => $item['deploy_build']['keyword_num'],  
46 - 'day' => $item['deploy_build']['service_duration'],  
47 - 'amount' => $item['payment']['amount'],  
48 - 'build_leader' => ManageLogic::getCacheName($item['deploy_build']['leader_mid']), //组长  
49 - 'build_manager' => ManageLogic::getCacheName($item['deploy_build']['manager_mid']), //项目经理  
50 - 'build_designer' => ManageLogic::getCacheName($item['deploy_build']['designer_mid']), //设计师  
51 - 'build_tech' => ManageLogic::getCacheName($item['deploy_build']['tech_mid']), //技术助理  
52 - 'optimize_manager' => ManageLogic::getCacheName($item['deploy_optimize']['manager_mid']), //优化服务经理  
53 - 'optimize_optimist' => ManageLogic::getCacheName($item['deploy_optimize']['optimist_mid']), //优化师  
54 - 'optimize_assist' => ManageLogic::getCacheName($item['deploy_optimize']['assist_mid']), //优化助理  
55 - 'optimize_tech' => ManageLogic::getCacheName($item['deploy_optimize']['tech_mid']), //售后技术  
56 - 'type' => $this->model::typeMap()[$item['type']] ?: '',  
57 - 'test_domain' => $item['deploy_build']['test_domain'],  
58 - 'domain' => $item['deploy_optimize']['domain'], 42 + 'key' => $item['deploy_build']['keyword_num'] ?? 0,
  43 + 'day' => $item['deploy_build']['service_duration'] ?? 0,
  44 + 'amount' => $item['payment']['amount'] ?? 0,
  45 + 'build_leader' => ManageLogic::getCacheName($item['deploy_build']['leader_mid'] ?? 0), //组长
  46 + 'build_manager' => ManageLogic::getCacheName($item['deploy_build']['manager_mid'] ?? 0), //项目经理
  47 + 'build_designer' => ManageLogic::getCacheName($item['deploy_build']['designer_mid'] ?? 0), //设计师
  48 + 'build_tech' => ManageLogic::getCacheName($item['deploy_build']['tech_mid'] ?? 0), //技术助理
  49 + 'optimize_manager' => ManageLogic::getCacheName($item['deploy_optimize']['manager_mid'] ?? 0), //优化服务经理
  50 + 'optimize_optimist' => ManageLogic::getCacheName($item['deploy_optimize']['optimist_mid'] ?? 0), //优化师
  51 + 'optimize_assist' => ManageLogic::getCacheName($item['deploy_optimize']['assist_mid'] ?? 0), //优化助理
  52 + 'optimize_tech' => ManageLogic::getCacheName($item['deploy_optimize']['tech_mid'] ?? 0), //售后技术
  53 + 'type' => $this->model::typeMap()[$item['type']] ?? '',
  54 + 'test_domain' => $item['deploy_build']['test_domain'] ?? 0,
  55 + 'domain' => $item['deploy_optimize']['domain'] ?? 0,
59 'crated_at' => date('Y年m月d日', strtotime($item['created_at'])), 56 'crated_at' => date('Y年m月d日', strtotime($item['created_at'])),
60 ]; 57 ];
61 } 58 }
@@ -69,12 +66,6 @@ class ProjectLogic extends BaseLogic @@ -69,12 +66,6 @@ class ProjectLogic extends BaseLogic
69 } 66 }
70 67
71 public function save($param){ 68 public function save($param){
72 - if(!empty($param['deploy_build']['test_domain'])){  
73 - $param['deploy_build']['test_domain'] = checkDomain($param['deploy_build']['test_domain']);  
74 - if(!$param['deploy_build']['test_domain']){  
75 - $this->fail('测试域名格式不正确');  
76 - }  
77 - }  
78 if(!empty($param['deploy_optimize']['domain'])){ 69 if(!empty($param['deploy_optimize']['domain'])){
79 $param['deploy_optimize']['domain'] = checkDomain($param['deploy_optimize']['domain']); 70 $param['deploy_optimize']['domain'] = checkDomain($param['deploy_optimize']['domain']);
80 if(!$param['deploy_optimize']['domain']){ 71 if(!$param['deploy_optimize']['domain']){
@@ -84,6 +75,9 @@ class ProjectLogic extends BaseLogic @@ -84,6 +75,9 @@ class ProjectLogic extends BaseLogic
84 75
85 DB::beginTransaction(); 76 DB::beginTransaction();
86 try { 77 try {
  78 + if(!empty($param['payment']['amount'])) unset($param['payment']['amount']);
  79 + if(!empty($param['deploy_build']['test_domain'])) unset($param['deploy_build']['test_domain']);
  80 + if(!empty($param['deploy_build']['plan'])) unset($param['deploy_build']['plan']);
87 $res = parent::save($param); 81 $res = parent::save($param);
88 $param['id'] = $res['id']; 82 $param['id'] = $res['id'];
89 $this->savePayment($param); 83 $this->savePayment($param);
@@ -30,10 +30,10 @@ class LoginAuthMiddleware @@ -30,10 +30,10 @@ class LoginAuthMiddleware
30 return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'当前用户未登录']); 30 return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'当前用户未登录']);
31 } 31 }
32 // 设置数据信息 32 // 设置数据信息
33 - $project = ProjectServer::useProject($info['project_id']);  
34 - if(empty($project)){  
35 - return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);  
36 - } 33 +// $project = ProjectServer::useProject($info['project_id']);
  34 +// if(empty($project)){
  35 +// return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']);
  36 +// }
37 //操作权限设置 37 //操作权限设置
38 $projectRoleModel = new ProjectRoleModel(); 38 $projectRoleModel = new ProjectRoleModel();
39 $role_info = $projectRoleModel->read(['id'=>$info['role_id']]); 39 $role_info = $projectRoleModel->read(['id'=>$info['role_id']]);
@@ -4,12 +4,14 @@ namespace App\Models\Project; @@ -4,12 +4,14 @@ namespace App\Models\Project;
4 4
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Models\Base; 6 use App\Models\Base;
  7 +use Hashids\Hashids;
7 use Illuminate\Support\Facades\Cache; 8 use Illuminate\Support\Facades\Cache;
8 9
9 class DeployBuild extends Base 10 class DeployBuild extends Base
10 { 11 {
11 //设置关联表名 12 //设置关联表名
12 protected $table = 'gl_project_deploy_build'; 13 protected $table = 'gl_project_deploy_build';
  14 + protected $appends = ['test_domain'];
13 15
14 16
15 public function setPlanAttribute($value){ 17 public function setPlanAttribute($value){
@@ -20,7 +22,13 @@ class DeployBuild extends Base @@ -20,7 +22,13 @@ class DeployBuild extends Base
20 return Arr::setToArr($value, 'trim'); 22 return Arr::setToArr($value, 'trim');
21 } 23 }
22 24
23 - public static function clearCache($row){ 25 + public function getTestDomainAttribute(){
  26 + $hashids = new Hashids('test_domain', 4, 'abcdefghjkmnpqrstuvwxyz1234567890');
  27 + $code = $hashids->encode($this->project_id);
  28 + return $code . '.test.com';
  29 + }
  30 +
  31 + public static function clearCache($row){
24 $cache_key = 'project_' . $row->original['test_domain']; 32 $cache_key = 'project_' . $row->original['test_domain'];
25 Cache::forget($cache_key); 33 Cache::forget($cache_key);
26 } 34 }
@@ -10,13 +10,14 @@ @@ -10,13 +10,14 @@
10 "doctrine/dbal": "^3.6", 10 "doctrine/dbal": "^3.6",
11 "fruitcake/laravel-cors": "^2.0", 11 "fruitcake/laravel-cors": "^2.0",
12 "guzzlehttp/guzzle": "^7.0.1", 12 "guzzlehttp/guzzle": "^7.0.1",
  13 + "hashids/hashids": "^4.1",
13 "intervention/image": "^2.7", 14 "intervention/image": "^2.7",
14 "laravel/framework": "^8.75", 15 "laravel/framework": "^8.75",
15 "laravel/sanctum": "^2.11", 16 "laravel/sanctum": "^2.11",
16 "laravel/tinker": "^2.5", 17 "laravel/tinker": "^2.5",
17 "mongodb/mongodb": "^1.6", 18 "mongodb/mongodb": "^1.6",
18 - "phpoffice/phpspreadsheet": "^1.28",  
19 - "mrgoon/aliyun-sms": "^2.0" 19 + "mrgoon/aliyun-sms": "^2.0",
  20 + "phpoffice/phpspreadsheet": "^1.28"
20 }, 21 },
21 "require-dev": { 22 "require-dev": {
22 "barryvdh/laravel-ide-helper": "^2.13", 23 "barryvdh/laravel-ide-helper": "^2.13",