SalaryRecord.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. class SalaryRecord extends Base
  7. {
  8. // 发放薪水
  9. public function save(){
  10. model('SalaryRecord')->add();
  11. HelpHander::success([],'操作成功');
  12. }
  13. // 获取要发放薪水的人及检测该月是否已发放工资
  14. public function preSave(){
  15. $data = [
  16. 'type' => input('type/d',1),
  17. 'month' => input('month','','trim'),
  18. 'types' => input('types','','trim'),
  19. 'continue' => input('continue/d',0)
  20. ];
  21. if(!in_array($data['type'],[1,2,3,4,5,6,7,8,9])){
  22. HelpHander::error('未选择工资类型');
  23. }
  24. if(!$data['month']){
  25. HelpHander::error('未选择月份');
  26. }
  27. $map[] = ['del','=',0];
  28. // if($data['type'] == 1||$data['type'] == 6){
  29. // $map[] = ['type','in',[1,6]];
  30. // }
  31. // if($data['type'] == 2||$data['type'] == 7){
  32. // $map[] = ['type','in',[2,7]];
  33. // }
  34. // if($data['type'] == 3||$data['type'] == 8){
  35. // $map[] = ['type','in',[3,8]];
  36. // }
  37. // if($data['type'] == 4||$data['type'] == 9){
  38. // $map[] = ['type','in',[4,9]];
  39. // }
  40. // if($data['type'] == 5){
  41. // $map[] = ['type','=',$data['type']];
  42. // }
  43. $map[] = ['type','=',$data['type']];
  44. $map[] = ['status','in',[0,1,3]];
  45. $info = Db::name('salary_record')->where($map)->find();
  46. if($info){
  47. HelpHander::error('有正在处理的工资未发放');
  48. }
  49. // $res = Db::name('salary_record')
  50. // ->where('type',$data['type'])
  51. // ->where('del',0)
  52. // ->where('status','in',[0,1,3])
  53. // ->find();
  54. // if($res){
  55. // HelpHander::error('有正在处理的工资未发放');
  56. // }
  57. $ret = model('SalaryRecord')->preAdd($data,$this->orgId);
  58. HelpHander::success($ret,'操作成功');
  59. }
  60. public function reloadAdd(){
  61. $salaryRecordId = input('salaryRecordId/d',0);
  62. $uid = input('uid/d',0);
  63. $ret = model('SalaryRecord')->reloadAdd($salaryRecordId,$uid,$this->orgId);
  64. HelpHander::success($ret,'操作成功');
  65. }
  66. // 重新计算
  67. public function resend(){
  68. model('SalaryRecord')->resend();
  69. HelpHander::success([],'操作成功');
  70. }
  71. // 重新计算个税
  72. public function resendtax(){
  73. model('SalaryRecord')->resendtax();
  74. HelpHander::success([],'操作成功');
  75. }
  76. // 删除工资项
  77. public function delsalary(){
  78. model('SalaryRecord')->delsalary();
  79. HelpHander::success([],'操作成功');
  80. }
  81. // 添加工资项
  82. public function addsalary(){
  83. model('SalaryRecord')->addsalary();
  84. HelpHander::success([],'操作成功');
  85. }
  86. // 修改工资项
  87. public function modifysalary(){
  88. model('SalaryRecord')->modifysalary();
  89. HelpHander::success([],'操作成功');
  90. }
  91. // 同意
  92. public function agree(){
  93. $id = input('id/d',0);
  94. model('SalaryRecord')->agree($id,$this->userId,$this->orgId);
  95. HelpHander::success([],'操作成功');
  96. }
  97. // 打回
  98. public function disagree(){
  99. $id = input('id/d',0);
  100. model('SalaryRecord')->disagree($id,$this->userId,$this->orgId);
  101. HelpHander::success([],'操作成功');
  102. }
  103. // 重新提交
  104. public function reapply(){
  105. $id = input('id/d',0);
  106. model('SalaryRecord')->reapply($id,$this->userId,$this->orgId);
  107. HelpHander::success([],'操作成功');
  108. }
  109. // 发放
  110. public function confirm(){
  111. $id = input('id/d',0);
  112. model('SalaryRecord')->confirm($id,$this->userId);
  113. HelpHander::success([],'操作成功');
  114. }
  115. // 社保
  116. public function sbinfo(){
  117. $id = input('id/d',0);
  118. $uid = input('uid/d',0);
  119. $ret = model('SalaryRecord')->sbinfo($id,$uid);
  120. HelpHander::success($ret,'操作成功');
  121. }
  122. // 个税
  123. public function taxinfo(){
  124. $id = input('id/d',0);
  125. $uid = input('uid/d',0);
  126. $ret = model('SalaryRecord')->taxinfo($id,$uid);
  127. HelpHander::success($ret,'操作成功');
  128. }
  129. // 详情
  130. public function detail(){
  131. $id = input('id/d',0);
  132. $ret = model('SalaryRecord')->info($id);
  133. HelpHander::success($ret);
  134. }
  135. public function payinfo(){
  136. $id = input('id/d',0);
  137. $ret = model('SalaryRecord')->payinfo($id);
  138. HelpHander::success($ret);
  139. }
  140. // 列表
  141. public function list(){
  142. $page = input('page/d',1);
  143. $size = input('size/d',10);
  144. $month = input('month','','trim');
  145. $type = input('type/d',-1);
  146. $ret = model('SalaryRecord')->lists($page,$size,$month,$type);
  147. HelpHander::success($ret);
  148. }
  149. // 工资列表
  150. public function listLog(){
  151. $page = input('page/d',1);
  152. $size = input('size/d',10);
  153. $name = input('name','','trim');
  154. $id = input('id/d',0);
  155. $ret = model('SalaryRecord')->listLog($page,$size,$name,$id);
  156. HelpHander::success($ret);
  157. }
  158. public function listSpecial(){
  159. $page = input('page/d',1);
  160. $size = input('size/d',10);
  161. $name = input('name','','trim');
  162. $id = input('id/d',0);
  163. $ret = model('SalaryRecord')->listSpecial($page,$size,$name,$id);
  164. HelpHander::success($ret);
  165. }
  166. // 编辑个税
  167. public function taxEdit(){
  168. model('SalaryRecord')->taxEdit();
  169. HelpHander::success([],'操作成功');
  170. }
  171. // 导出
  172. public function exportListLog(){
  173. $name = input('name','','trim');
  174. $id = input('id/d',0);
  175. $ret = model('SalaryRecord')->exportListLog($name,$id);
  176. HelpHander::success($ret);
  177. }
  178. // 删除
  179. public function del(){
  180. $id = input('id/d',0);
  181. model('SalaryRecord')->del($id);
  182. HelpHander::success([],'操作成功');
  183. }
  184. // 重新发放
  185. public function send(){
  186. $id = input('id/d',0);
  187. model('SalaryRecord')->send($id);
  188. HelpHander::success([],'操作成功');
  189. }
  190. // 我的薪水列表
  191. public function mySalary(){
  192. $page = input('page/d',1);
  193. $size = input('size/d',10);
  194. $month = input('month','','trim');
  195. $ret = model('SalaryRecord')->mySalary($page,$size,$month,$this->userId);
  196. HelpHander::success($ret);
  197. }
  198. // 工资详情
  199. public function salaryDetail(){
  200. $id = input('id/d',0);
  201. if($id <= 0){
  202. HelpHander::error('参数错误');
  203. }
  204. $ret = model('SalaryRecord')->salaryDetail($id,$this->userId);
  205. HelpHander::success($ret);
  206. }
  207. // 列表
  208. public function taxlist(){
  209. $page = input('page/d',1);
  210. $size = input('size/d',10);
  211. $month = input('month','','trim');
  212. $name = input('name','','trim');
  213. $type = input('type/d',0);
  214. $ret = model('SalaryRecord')->taxlist($page,$size,$month,$name,$type);
  215. HelpHander::success($ret);
  216. }
  217. // 聚合列表
  218. public function ntaxlist(){
  219. $page = input('page/d',1);
  220. $size = input('size/d',10);
  221. $month = input('month','','trim');
  222. $name = input('name','','trim');
  223. $type = input('type/d',0);
  224. $ret = model('SalaryRecord')->ntaxlist($month,$name,$type);
  225. HelpHander::success($ret);
  226. }
  227. public function ntaxexport(){
  228. $month = input('month','','trim');
  229. $name = input('name','','trim');
  230. $type = input('type/d',0);
  231. $ret = model('SalaryRecord')->ntaxexport($month,$name,$type);
  232. HelpHander::success($ret);
  233. }
  234. // 社保公积金列表
  235. public function sblist(){
  236. $page = input('page/d',1);
  237. $size = input('size/d',10);
  238. $month = input('month','','trim');
  239. $name = input('name','','trim');
  240. $type = input('type/d',0);
  241. $ret = model('SalaryRecord')->sblist($month,$name,$type);
  242. HelpHander::success($ret);
  243. }
  244. // 社保公积金导出
  245. public function sbexport(){
  246. $month = input('month','','trim');
  247. $name = input('name','','trim');
  248. $type = input('type/d',0);
  249. $ret = model('SalaryRecord')->sbexport($month,$name,$type);
  250. HelpHander::success($ret);
  251. }
  252. // 待审批记录
  253. public function unapply(){
  254. $ret = model('SalaryRecord')->unapply($this->userId);
  255. HelpHander::success($ret);
  256. }
  257. // 个人明细
  258. public function userdetail(){
  259. $page = input('page/d',1);
  260. $size = input('size/d',10);
  261. $year = input('year','','trim');
  262. $type = input('type/d',1);
  263. if(!$year||!in_array($type,[1,2,3,4,5])){
  264. HelpHander::error('参数错误');
  265. }
  266. $ret = model('SalaryRecord')->userdetail($page,$size,$type,$year);
  267. HelpHander::success($ret);
  268. }
  269. //年度用工成本统计
  270. public function userYear(){
  271. $year = input('year','','trim');
  272. $month = input('month/d',0);
  273. $name = input('name','','trim');
  274. $type = input('type/d',1);
  275. if(!$year||!in_array($type,[1,2,3,4])){
  276. HelpHander::error('参数错误');
  277. }
  278. $ret = model('SalaryRecord')->userYear($type,$year,$name,$month);
  279. HelpHander::success($ret);
  280. }
  281. public function yearexport(){
  282. $year = input('year','','trim');
  283. $name = input('name','','trim');
  284. $month = input('month/d',0);
  285. $type = input('type/d',1);
  286. if(!$year||!in_array($type,[1,2,3,4])){
  287. HelpHander::error('参数错误');
  288. }
  289. $ret = model('SalaryRecord')->yearExport($type,$year,$name,$month);
  290. HelpHander::success($ret);
  291. }
  292. //年度工资积累
  293. public function workerYear(){
  294. $year = input('year','','trim');
  295. $name = input('name','','trim');
  296. $type = input('type/d',1);
  297. if(!$year||!in_array($type,[1,2,3,4])){
  298. HelpHander::error('参数错误');
  299. }
  300. $ret = model('SalaryRecord')->workerYear($type,$year,$name);
  301. HelpHander::success($ret);
  302. }
  303. public function yearworkerexport(){
  304. $year = input('year','','trim');
  305. $name = input('name','','trim');
  306. $type = input('type/d',1);
  307. if(!$year||!in_array($type,[1,2,3,4])){
  308. HelpHander::error('参数错误');
  309. }
  310. $ret = model('SalaryRecord')->yearWorkerExport($type,$year,$name);
  311. HelpHander::success($ret);
  312. }
  313. //个人年度工资积累
  314. public function userWorkerYear(){
  315. $year = input('year','','trim');
  316. $type = input('type/d',1);
  317. if(!$year||!in_array($type,[1,2,3,4,5,6,7,8,9])){
  318. HelpHander::error('参数错误');
  319. }
  320. $ret = model('SalaryRecord')->userWorkerYear($type,$year,$this->userId);
  321. HelpHander::success($ret);
  322. }
  323. public function userTypes(){
  324. $ret = model('SalaryRecord')->getUserSalayrTypes($this->userId);
  325. HelpHander::success($ret);
  326. }
  327. }