UserInfo.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 UserInfo extends Base
  7. {
  8. // 新增
  9. public function save(){
  10. model('User')->add();
  11. HelpHander::success([],'操作成功');
  12. }
  13. // 编辑
  14. public function update(){
  15. model('User')->add();
  16. HelpHander::success([],'操作成功');
  17. }
  18. // 调整薪资
  19. public function changeSalary(){
  20. $data = [
  21. 'company_id' => input('companyId/d',0),
  22. 'remark' => input('remark','','trim'),
  23. 'type' => input('type/d',0),
  24. 'pwlevel' => input('pwlevel/d',0),
  25. 'psid' => input('psid/d',0),
  26. 'imgs' => input('imgs','','trim')
  27. ];
  28. $id = input('id/d',0);
  29. if($id <= 0){
  30. HelpHander::error('参数错误');
  31. }
  32. model('UserInfo')->changeSalary($data, $id, $this->userId, $this->orgId);
  33. HelpHander::success([],'修改成功');
  34. }
  35. // 详情
  36. public function detail(){
  37. $id = input('id/d',0);
  38. $ret = model('User')->info($id);
  39. HelpHander::success($ret);
  40. }
  41. // 列表
  42. public function queryUserInfoList(){
  43. $page = input('page/d',1);
  44. $size = input('size/d',10);
  45. $name = input('name','','trim');
  46. $code = input('code','','trim');
  47. $phone = input('phone','','trim');
  48. $ret = model('User')->lists($page,$size,$this->orgId,$name,$code,$phone);
  49. HelpHander::success($ret);
  50. }
  51. // 修改状态
  52. public function updateEnable(){
  53. $id = input('id/d',0);
  54. $enable = input('enable/d',0);
  55. model('User')->changeStatus($id,$enable);
  56. HelpHander::success([],'操作成功');
  57. }
  58. // 人员档案列表
  59. public function lists(){
  60. $ret = model('UserInfo')->lists($this->orgId);
  61. HelpHander::success($ret);
  62. }
  63. // 人员请假统计列表
  64. public function listsholiday(){
  65. $ret = model('UserInfo')->listsholiday($this->orgId);
  66. HelpHander::success($ret);
  67. }
  68. // 花名册列表
  69. public function roster(){
  70. $ret = model('UserInfo')->rosterLists($this->orgId);
  71. HelpHander::success($ret);
  72. }
  73. // 人员薪资岗位列表
  74. public function lists2(){
  75. $ret = model('UserInfo')->lists2($this->orgId);
  76. HelpHander::success($ret);
  77. }
  78. // 人员档案导出列表
  79. public function exportLists(){
  80. $ret = model('UserInfo')->exportLists($this->orgId);
  81. HelpHander::success($ret);
  82. }
  83. // 请假报表导出列表
  84. public function exportHolidayLists(){
  85. $ret = model('UserInfo')->exportHolidayLists($this->orgId);
  86. HelpHander::success($ret);
  87. }
  88. // 花名册导出列表
  89. public function exportRosterLists(){
  90. $ret = model('UserInfo')->exportRosterLists($this->orgId);
  91. HelpHander::success($ret);
  92. }
  93. // 详情
  94. public function info(){
  95. $id = input('id/d',0);
  96. $ret = model('UserInfo')->info($id);
  97. HelpHander::success($ret);
  98. }
  99. // 我的详情
  100. public function myinfo(){
  101. $userinfo = Db::name('user_info')->where('user_id',$this->userId)->find();
  102. if(!$userinfo){
  103. HelpHander::error('数据不存在');
  104. }
  105. $ret = model('UserInfo')->info($userinfo['id']);
  106. HelpHander::success($ret);
  107. }
  108. // 修改基本信息
  109. public function edit(){
  110. $data = [
  111. 'id' => input('id/d',0),
  112. 'name' => input('name','','trim'),
  113. 'email' => input('email','','trim'),
  114. 'img' => input('img','','trim'),
  115. // 'gender' => input('gender/d',1),
  116. 'nation' => input('nation','','trim'),
  117. 'native_place' => input('nativePlace','','trim'),
  118. // 'birthday' => input('birthday','','trim'),
  119. 'id_card' => input('idCard','','trim'),
  120. 'education' => input('education','','trim'),
  121. 'profession' => input('profession','','trim'),
  122. 'dang_date' => input('dangDate','','trim'),
  123. 'work_date' => input('workDate','','trim'),
  124. 'cur_job_date' => input('curJobDate','','trim'),
  125. 'profession_position' => input('professionPosition','','trim'),
  126. 'assess_date' => input('assessDate','','trim'),
  127. 'qualification' => input('qualification','','trim'),
  128. 'lb_date' => input('lbDate','','trim'),
  129. 'in_shape' => input('inShape','','trim'),
  130. 'level_job_date' => input('levelJobDate','','trim'),
  131. 'join_time' => input('joinTime','','trim'),
  132. 'political' => input('political','','trim'),
  133. 'degree' => input('degree','','trim'),
  134. 'is_working' => input('isWorking/d',0),
  135. 'company_id' => input('companyId/d',0),
  136. 'marital' => input('marital','','trim'),
  137. 'remark1' => input('remark1','','trim'),
  138. 'remark2' => input('remark2','','trim'),
  139. 'remark3' => input('remark3','','trim'),
  140. 'remark4' => input('remark4','','trim'),
  141. 'remark5' => input('remark5','','trim'),
  142. 'job' => input('job','','trim'),
  143. 'job_date' => input('jobDate','','trim'),
  144. 'position' => input('position','','trim'),
  145. 'sorts' => input('sorts/d',200),
  146. ];
  147. if(empty($data['name'])){
  148. HelpHander::error('姓名不能为空');
  149. }
  150. if(empty($data['id'])){
  151. HelpHander::error('参数错误');
  152. }
  153. if(!$data['join_time']){
  154. unset($data['join_time']);
  155. }
  156. $id = $data['id'];
  157. unset($data['id']);
  158. model('UserInfo')->edit($data,$id);
  159. HelpHander::success([],'修改成功');
  160. }
  161. // 用户岗位调整记录
  162. public function jobLogList(){
  163. $page = input('page/d',1);
  164. $size = input('size/d',10);
  165. $uid = input('uid/d',0);
  166. $ret = model('UserJob')->jobLogList($page,$size,$this->orgId,$uid);
  167. HelpHander::success($ret);
  168. }
  169. // 用户薪资调整记录
  170. public function salaryLogList(){
  171. $page = input('page/d',1);
  172. $size = input('size/d',10);
  173. $uid = input('uid/d',0);
  174. $ret = model('UserInfo')->salaryLogList($page,$size,$this->orgId,$uid);
  175. HelpHander::success($ret);
  176. }
  177. // 调整用户岗位
  178. public function changeJob(){
  179. $data = [
  180. 'uid' => input('uid/d',0),
  181. 'jobId' => input('jobId/d',0),
  182. 'type' => input('type/d',1),
  183. 'remark' => input('remark','','trim'),
  184. 'imgs' => input('imgs','','trim'),
  185. ];
  186. model('UserJob')->changeJob($data,$this->userId,$this->orgId);
  187. HelpHander::success([],'调整岗位成功');
  188. }
  189. // 办理离职/退休
  190. public function departure(){
  191. $data = [
  192. 'user_id' => input('uid/d',0),
  193. 'is_work' => input('isWork/d',0),
  194. 'out_time' => input('outTime','','trim'),
  195. 'out_reason' => input('outReason','','trim')
  196. ];
  197. model('UserInfo')->departure($data,$this->userId,$this->orgId);
  198. HelpHander::success([],'办理成功');
  199. }
  200. // 重新入职
  201. public function back(){
  202. $data = [
  203. 'user_id' => input('uid/d',0),
  204. 'is_work' => input('isWork/d',0),
  205. 'join_time' => input('joinTime','','trim')
  206. ];
  207. model('UserInfo')->back($data,$this->userId,$this->orgId);
  208. HelpHander::success([],'办理成功');
  209. }
  210. // 调整薪级
  211. public function changePay(){
  212. $id = input('id/d',0); // user_info的id
  213. if($id <= 0){
  214. HelpHander::error('参数错误');
  215. }
  216. $info = Db::name('user_info')->where('id',$id)->find();
  217. if(!$info){
  218. HelpHander::error('记录不存在');
  219. }
  220. $data = [
  221. 'company_id' => $info['company_id'],
  222. 'remark' => input('remark','快速调整','trim'),
  223. 'type' => $info['type'],
  224. 'pwlevel' => input('pwlevel/d',0),
  225. 'psid' => $info['psid'],
  226. 'imgs' => ''
  227. ];
  228. model('UserInfo')->changeSalary($data, $id, $this->userId, $this->orgId);
  229. HelpHander::success([],'修改成功');
  230. }
  231. // 调整发工资类型
  232. public function changePayType(){
  233. $id = input('id/d',0); // user_info的id
  234. if($id <= 0){
  235. HelpHander::error('参数错误');
  236. }
  237. $info = Db::name('user_info')->where('id',$id)->find();
  238. if(!$info){
  239. HelpHander::error('记录不存在');
  240. }
  241. $payType = input('payType/d',0);
  242. if($info['pay_type'] == $payType){
  243. HelpHander::error('未作出任何调整');
  244. }
  245. if($info['company_id'] == 1 && in_array($payType,[2,4])){
  246. HelpHander::error('修改失败');
  247. }
  248. if($info['company_id'] == 2 && in_array($payType,[1,3,5])){
  249. HelpHander::error('修改失败');
  250. }
  251. $ret = Db::name('user_info')->where('id',$id)->setField('pay_type',$payType);
  252. if(!$ret){
  253. HelpHander::error('修改失败');
  254. }
  255. HelpHander::success([],'修改成功');
  256. }
  257. // 薪级普调
  258. public function changePayBatch(){
  259. $companyId = input('companyId/d',0);
  260. if($companyId <= 0){
  261. HelpHander::error('没有薪级的用户无法普调');
  262. }
  263. model('UserInfo')->changePayBatch($companyId, $this->userId, $this->orgId);
  264. HelpHander::success([],'操作成功');
  265. }
  266. // 修改基础绩效或子女统筹
  267. public function changeFixed(){
  268. $id = input('id/d',0);
  269. $money = input('money/f',0);
  270. $type = input('type/d',0);
  271. model('UserInfo')->changeFixed($id, $money, $type);
  272. HelpHander::success([],'操作成功');
  273. }
  274. // 修改花名册排序
  275. public function changeSortsFixed(){
  276. $id = input('id/d',0);
  277. $sorts2 = input('sorts2/d',0);
  278. model('UserInfo')->changeSortsFixed($id, $sorts2);
  279. HelpHander::success([],'操作成功');
  280. }
  281. }