RenewLogic.php
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @remark :
* @name :RenewLogic.php
* @author :lyh
* @method :post
* @time :2023/8/11 17:29
*/
namespace App\Http\Logic\Aside\Project;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\Project\ProjectRenew;
use Illuminate\Support\Facades\DB;
class RenewLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new ProjectRenew();
}
/**
* @remark :续费单记录列表
* @name :renewLog
* @author :lyh
* @method :post
* @time :2023/8/11 17:30
*/
public function renewListsLog($map,$page,$row,$order,$field = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$field);
if(!empty($lists['list'])){
$projectModel = new Project();
foreach ($lists['list'] as $k => $v){
$v['plan'] = Project::planMap()[$v['plan']];
$v['project_name'] = $projectModel->getProjectName($v['project_id']);
$lists['list'][$k] = $v;
}
}
return $this->success($lists);
}
/**
* @remark :根据主键获取续费单详情
* @name :renewRead
* @author :lyh
* @method :post
* @time :2023/8/14 9:12
*/
public function renewRead(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在或者被删除');
}
return $this->success($info);
}
/**
* @remark :关联续费单
* @name :editProjectRenew
* @author :lyh
* @method :post
* @time :2023/9/19 10:21
*/
public function editProjectRenew(){
//获取续费单详情
$info = $this->model->read(['id'=>$this->param['renew_id']]);
if($info === false){
$this->fail('当前续费单不存在');
}
if($info['project_id'] != 0){
$this->fail('当前续费单已关联项目,请重新选择');
}
DB::beginTransaction();
try {
$this->model->edit(['project_id'=>$this->param['id'],'operator_id'=>$this->manager['id']],['id'=>$this->param['renew_id']]);
$project = new Project();
$project->edit(['extend_type'=>0],['id'=>$this->param['id']]);
$deployBuild = new DeployBuild();
$deployBuild->edit(
['service_duration'=>DB::raw('service_duration + ' . $info['service_duration']),
'plan'=>$info['plan']], ['project_id'=>$this->param['id']]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
/**
* @remark :编辑续费单状态
* @name :editStatus
* @author :lyh
* @method :post
* @time :2023/9/19 15:50
*/
public function editStatus(){
$rs = $this->model->edit(['status'=>$this->param['status']],['id'=>$this->param['id']]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}