Staffwages.php
3.77 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
namespace addons\qingdong\controller;
use addons\qingdong\model\Staffwages as wagesModel;
use addons\fastflow\model\Jxbunq;
use addons\fastflow\model\Ekmdnj;
class Staffwages extends StaffApi
{
protected $noNeedLogin = ['*'];
//工资列表
public function wagesList(){
$year = input('year',date('Y'));
$staff_id = $this->auth->id;
$list = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->select();
$reimburse_all = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->sum('reimburse_price');
$ekmdnjmodel = new Ekmdnj();
$jxbunqmodel = new Jxbunq();
foreach ($list as &$item){
$takes_ids = $item['takes_ids'];
$item['ekmdnj'] = $ekmdnjmodel->where("find_in_set(id,'$takes_ids')")->select();
$reimburse_ids = $item['reimburse_ids'];
$item['jxbunq'] = $jxbunqmodel->where("find_in_set(id,'$reimburse_ids')")->select();
$item['reimburse_all'] = $reimburse_all;
}
$this->success('工资列表',$list);
}
//提成 列表
public function commissionList(){
$year = input('year',date('Y'));
$staff_id = $this->auth->id;
$list = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->select();
// halt((new wagesModel())->select());
$ekmdnjmodel = new Ekmdnj();
foreach ($list as &$item){
$takes_ids = $item['takes_ids'];
$item['ekmdnj'] = $ekmdnjmodel->where("find_in_set(id,'$takes_ids')")->select();
}
$this->success('提成列表',$list);
}
//报销 列表
public function jxbunqList(){
$year = input('year',date('Y'));
$staff_id = $this->auth->id;
$list = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->select();
$reimburse_all = (new wagesModel())->with('staff')->where('time','LIKE','%'.$year.'%')->where('staff_id',$staff_id)->sum('reimburse_price');
$jxbunqmodel = new Jxbunq();
foreach ($list as &$item){
$reimburse_ids = $item['reimburse_ids'];
$item['jxbunq'] = $jxbunqmodel->where("find_in_set(id,'$reimburse_ids')")->select();
$item['reimburse_all'] = $reimburse_all;
}
$this->success('提成列表',$list);
}
//我的任务
public function myTask(){
$staffModel = new \addons\qingdong\model\Staff();
$data = $staffModel->where('id',$this->auth->id)->field('id,admin_id,group_ids,role,rules,name,basic_task,target_task,monthly_salary')->find();
$this->success('我的任务',$data);
}
//修改任务
public function editmyTask(){
$monthly_salary = input('monthly_salary','');
$target_task = input('target_task','');
$staffModel = new \addons\qingdong\model\Staff();
$data = $staffModel->where('id',$this->auth->id)->field('id,admin_id,group_ids,role,rules,name,basic_task,target_task,monthly_salary')->find();
$data->monthly_salary = $monthly_salary;
$data->target_task = $target_task;
$data->save();
$this->success('修改成功');
}
//广告费用
public function advertisement(){
$contractModel = new \addons\qingdong\model\Contract();
$list = $contractModel->with([
'customer',
'contacts',
'ownerStaff',
])->where('owner_staff_id',$this->auth->id)->select();
$price = $contractModel->where('owner_staff_id',$this->auth->id)->sum('main_ljpzvx');
$this->success('广告费用',['list'=>$list,'price'=>$price]);
}
}