Resigninfo.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ProcessOrder;
  4. use app\BaseController;
  5. use think\App;
  6. use think\facade\Db;
  7. use app\admin\model\ActionLog;
  8. //交接
  9. class Resigninfo extends Base
  10. {
  11. public function __construct(App $app)
  12. {
  13. parent::__construct($app);
  14. }
  15. public function list(){
  16. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  17. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  18. $where =[['is_del',"=",0]];
  19. // $resign_depart_id = isset($this->post['resign_depart_id']) && $this->post['resign_depart_id'] !== "" ? intval($this->post['resign_depart_id']) : "";
  20. // if ($resign_depart_id !== "") {
  21. // $where = ["resign_depart_id"=>$resign_depart_id];
  22. // }
  23. // $hand_depart_id = isset($this->post['hand_depart_id']) && $this->post['hand_depart_id'] !== "" ? intval($this->post['hand_depart_id']) : "";
  24. // if ($hand_depart_id !== "") {
  25. // $where = ["hand_depart_id"=>$hand_depart_id];
  26. // }
  27. $status =isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  28. if ($status !== "") {
  29. $where[]= ["status",'=',$status];
  30. }
  31. $resign_uid = isset($this->post['resign_uid']) && $this->post['resign_uid'] !== "" ? intval($this->post['resign_uid']) : "";
  32. if ($resign_uid !== "") {
  33. //$where = ["resign_uid"=>$resign_uid];
  34. $where[]= ["resign_uid",'=',$resign_uid];
  35. }
  36. $hand_uid = isset($this->post['hand_uid']) && $this->post['hand_uid'] !== "" ? intval($this->post['hand_uid']) : "";
  37. if ($hand_uid !== "") {
  38. // $where = ["hand_uid"=>$hand_uid];
  39. $where[]= ["hand_uid",'=',$hand_uid];
  40. }
  41. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  42. if ($start !="") {
  43. // $where = ["addtime"=>Db::raw(">= '{$start}'")];
  44. $where[]= ["addtime",'>=',$start];
  45. }
  46. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  47. if($end !=""){
  48. // $where = ["addtime"=>Db::raw("<= '{$end}'")];
  49. $where[]= ["addtime",'<=',$end];
  50. }
  51. $count = Db::name('resign_info')->where($where)->count();
  52. $total = ceil($count/$size);
  53. $page = $page >= $total ? $total : $page;
  54. $list = Db::name('resign_info')->where($where)->order("addtime desc")->page($page,$size)->select();
  55. return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
  56. }
  57. public function create(){
  58. $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
  59. $condition=[];
  60. $resign_id = isset($this->post['resign_uid']) && $this->post['resign_uid'] !==""? trim($this->post['resign_uid']) :"";
  61. if($resign_id==""){
  62. return error_show(1002,"离职人id不能为空");
  63. }
  64. $condition['id']=$resign_id;
  65. $resign_uid=GetInfoById($token,$condition);
  66. if(empty($resign_uid)||$resign_uid['code']!=0){
  67. return error_show(1002,"离职人员信息不存在");
  68. }
  69. $ri= isset($resign_uid["data"]['nickname']) ? $resign_uid["data"]['nickname'] : "";
  70. $hand_id = isset($this->post['hand_uid']) && $this->post['hand_uid'] !==""? trim($this->post['hand_uid']) :"";
  71. if($hand_id==""){
  72. return error_show(1002,"交接人名称不能为空");
  73. }
  74. $condition['id']=$hand_id;
  75. $hand_uid = GetInfoById($token,$condition);
  76. if(empty($hand_uid)||$hand_uid['code']!=0){
  77. return error_show(1002,"交接人员信息不存在");
  78. }
  79. $rp= isset($hand_uid["data"]['nickname']) ? $hand_uid["data"]['nickname'] : "";
  80. $resign_date = isset($this->post['resign_date']) && $this->post['resign_date']!== "" ? $this->post['resign_date']:date("Y-m-d H:i:s");
  81. if($resign_date==""){
  82. return error_show(1005,'离职日期不能为空');
  83. }
  84. $expire_date = isset($this->post['expire_date']) && $this->post['expire_date']!== "" ?
  85. $this->post['expire_date']:date("Y-m-d H:i:s");
  86. if($expire_date==""){
  87. return error_show(1005,'生效时间不能为空');
  88. }
  89. $is_hand = isset($this->post['is_hand']) && $this->post['is_hand'] !=="" ? trim($this->post['is_hand']):"0";
  90. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "0";
  91. $remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? intval($this->post['remark']) : "";
  92. $data=[
  93. "resign_uid"=>$resign_id,
  94. "hand_uid"=>$hand_id,
  95. // "resign_depart_id"=>$resign_depart_id,
  96. // "hand_depart_id"=>$hand_depart_id,
  97. "resign_name"=>$ri,
  98. "hand_name"=>$rp,
  99. "resign_date"=> $resign_date,
  100. "expire_date"=>$expire_date,
  101. "is_hand"=>$is_hand,
  102. "status"=>$status,
  103. "remark"=>$remark,
  104. "is_del"=>0,
  105. "addtime"=>date("Y-m-d H:i:s"),
  106. "updatetime"=>date("Y-m-d H:i:s"),
  107. ];
  108. $in = Db::name('resign_info')->insertGetId($data);
  109. $stn = ["order_code"=>'',"status"=>$status,"action_remark"=>'',"action_type"=>"create"];
  110. ActionLog::logAdd(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$stn,"LZJJ",$status,$stn);
  111. $process=["order_code"=>'',"order_id"=>$in,"order_status"=>$status,"order_type"=>'LZJJ',"before_status"=>0, 'holder_id' => $data['hand_uid']];
  112. ProcessOrder::AddProcess(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$process);
  113. return $in ? error_show(0,"添加成功") : error_show(1002,"添加失败");
  114. }
  115. public function selec(){
  116. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
  117. if($id==""){
  118. return error_show(1002,"离职人员信息不存在");
  119. }
  120. $rid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find();
  121. return app_show(0,"获取成功",$rid);
  122. }
  123. public function edit(){
  124. $condition=[];
  125. $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
  126. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
  127. $eid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find();
  128. if($eid==""){
  129. return error_show(1002,"离职信息不存在");
  130. }
  131. $resign_id = isset($this->post['resign_uid']) && $this->post['resign_uid'] !=="" ? trim($this->post['resign_uid']):"";
  132. if($resign_id==""){
  133. return error_show(1002,"离职人员ID不能为空");
  134. }
  135. $condition['id']=$resign_id;
  136. $resign_uid=GetInfoById($token,$condition);
  137. if(empty($resign_uid)||$resign_uid['code']!=0){
  138. return error_show(1002,"离职人员信息不存在");
  139. }
  140. $rr= isset($resign_uid["data"]['nickname']) ? $resign_uid["data"]['nickname'] : "";
  141. $resign_date = isset($this->post['resign_date']) && $this->post['resign_date']!== "" ? $this->post['resign_date']:date("Y-m-d H:i:s");
  142. if($resign_date==""){
  143. return error_show(1005,'离职日期不能为空');
  144. }
  145. $hand_id = isset($this->post['hand_uid']) && $this->post['hand_uid'] !=="" ? trim($this->post['hand_uid']) :"";
  146. if($hand_id=="") {
  147. return error_show(1002, "交接人员id不能为空");
  148. }
  149. $condition['id']=$hand_id;
  150. $hand_uid = GetInfoById($token,$condition);
  151. if(empty($hand_uid)||$hand_uid['code']!=0){
  152. return error_show(1002,"交接人员信息不存在");
  153. }
  154. $r= isset($hand_uid["data"]['nickname']) ? $hand_uid["data"]['nickname'] : "";
  155. $is_hand = isset($this->post['is_hand']) && $this->post['is_hand'] !=="" ? trim($this->post['is_hand']):"0";
  156. $str=[
  157. "hand_name"=>$r,
  158. "resign_name"=>$rr,
  159. "id"=>$id,
  160. "resign_uid"=>$resign_id,
  161. "hand_uid"=>$hand_id,
  162. "is_hand"=>$is_hand,
  163. "resign_date"=>date('Y-m-d H:i:s'),
  164. "is_del"=>0,
  165. "updatetime"=>date('Y-m-d H:i:s'),
  166. ];
  167. $it = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->save($str);
  168. if($it){
  169. $stn = ["order_code"=>$id,"status"=>0,"action_remark"=>'',"action_type"=>"edit"];
  170. ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn);
  171. $process=["order_code"=>'',"order_id"=>$id,"order_status"=>$eid['status'],"order_type"=>'LZJJ',"before_status"=>0, 'holder_id' => $eid['hand_uid']];
  172. ProcessOrder::AddProcess(['id'=>$hand_id,'nickname'=>$r],$process);
  173. return error_show(0,"编辑成功");
  174. }else{
  175. return error_show(1002,"编辑失败");
  176. }
  177. }
  178. public function del(){
  179. $id = isset($this->post['id']) && $this->post['id'] !=="" ? $this->post['id']:"";
  180. $fid = Db::name('resign_info')->where(['is_del'=>0,'id'=>$id])->find();
  181. if($fid==false){
  182. return error_show(1002,"离职人员不存在");
  183. }
  184. $num = Db::name('resign_info')->update(['is_del'=>1,'id'=>$id,"updatetime"=>date("Y-m-d H:i:s")]);
  185. if($num){
  186. $stn = ["order_code"=>"BH","status"=>0,"action_remark"=>'',"action_type"=>"delete"];
  187. ActionLog::logAdd($this->post['token'],$stn,"LZJJ",0,$stn);
  188. return error_show(0,"删除成功");
  189. }else{
  190. return error_show(1002,"删除失败");
  191. }
  192. }
  193. public function statu(){
  194. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
  195. if($id==""){
  196. return error_show(1002,"离职人id不能为空");
  197. }
  198. $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? trim($this->post['remark']) :"";
  199. $stauts = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
  200. if($stauts===""){
  201. return error_show(1002,"状态不能为空");
  202. }
  203. $st = Db::name('resign_info')->where(['id'=>$id,"is_del"=>0])->find();
  204. if(empty($st)){
  205. return error_show(1002,"离职人员信息未找到");
  206. }
  207. $tn =$st['status'];
  208. $st['remark']=$remark;
  209. $st['status']=$stauts==3 && strtotime($st['expire_date'])>=time() ? 4 :$stauts;
  210. $st['updatetime']= date('Y-m-d H:i:s');
  211. $sv = Db::name('resign_info')->save($st);
  212. if($sv){
  213. $stn = ["order_code"=>$id,"status"=>$tn,"action_remark"=>'',"action_type"=>"edit"];
  214. ActionLog::logAdd($this->post['token'],$stn,"LZJJ",$stauts,$st);
  215. $process = ["order_code" => '', "order_id" => $id, "order_status" => $stauts, "order_type" => 'LZJJ', "before_status" => $tn, 'holder_id' => $st['hand_uid']];
  216. ProcessOrder::AddProcess($this->post['token'],$process);
  217. return error_show(0,"状态更新成功");
  218. }else{
  219. return error_show(1002,"状态更新失败");
  220. }
  221. }
  222. }