Api.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------------------------------
  4. * GouGuOPEN [ 左手研发,右手开源,未来可期!]
  5. +-----------------------------------------------------------------------------------------------
  6. * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
  7. +-----------------------------------------------------------------------------------------------
  8. * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
  9. +-----------------------------------------------------------------------------------------------
  10. * @Author 勾股工作室 <hdm58@qq.com>
  11. +-----------------------------------------------------------------------------------------------
  12. */
  13. declare (strict_types = 1);
  14. namespace app\user\controller;
  15. use app\api\BaseController;
  16. use app\user\model\Department as DepartmentModel;
  17. use think\facade\Db;
  18. class Api extends BaseController
  19. {
  20. //删除档案记录相关
  21. public function del_profiles()
  22. {
  23. $id = get_params("id");
  24. if (Db::name('AdminProfiles')->where('id', $id)->update(['delete_time'=>time()]) !== false) {
  25. return to_assign(0, "删除成功");
  26. } else {
  27. return to_assign(1, "删除失败");
  28. }
  29. }
  30. //一键调部门
  31. public function change_check()
  32. {
  33. $id = get_params("id");
  34. $data['id'] = $id;
  35. $data['connect_time'] = time();
  36. $data['status'] = 2;
  37. $detail = Db::name('DepartmentChange')->where('id', $id)->find();
  38. if (Db::name('DepartmentChange')->update($data) !== false) {
  39. Db::name('Admin')->where('id', $detail['uid'])->update(['did' => $detail['to_did']]);
  40. Db::name('DepartmentAdmin')->where(['admin_id'=>$detail['uid'],'department_id'=>$detail['to_did']])->delete();
  41. $info = Db::name('Admin')->where('id', $detail['uid'])->find();
  42. $model = new DepartmentModel();
  43. $auth_dids = $model->get_auth_departments($info);
  44. $son_dids = $model->get_son_departments($info);
  45. Db::name('Admin')->where('id',$detail['uid'])->update(['auth_dids'=>$auth_dids,'son_dids'=>$son_dids]);
  46. return to_assign(0, "操作成功");
  47. } else {
  48. return to_assign(1, "操作失败");
  49. }
  50. }
  51. //一键交接资料
  52. public function leave_check()
  53. {
  54. $id = get_params("id");
  55. $data['id'] = $id;
  56. $data['connect_time'] = time();
  57. $data['status'] = 2;
  58. $detail = Db::name('PersonalQuit')->where('id', $id)->find();
  59. $uid = $detail['uid'];
  60. $connect_uid = $detail['connect_id'];
  61. if (Db::name('PersonalQuit')->update($data) !== false) {
  62. //项目负责人
  63. Db::name('Project')->where([['director_uid','=',$uid],['status','<',3]])->update(['director_uid' => $connect_uid]);
  64. //任务负责人
  65. Db::name('ProjectTask')->where([['director_uid','=',$uid],['status','<',3]])->update(['director_uid' => $connect_uid]);
  66. //客户所属人
  67. $did = Db::name('Admin')->where('id', $connect_uid)->value('did');
  68. Db::name('Customer')->where([['belong_uid','=',$uid]])->update(['belong_uid' => $connect_uid,'belong_did'=>$did]);
  69. //合同
  70. Db::name('Contract')->where([['admin_id','=',$uid],['check_status','<',3]])->update(['admin_id' => $connect_uid]);
  71. Db::name('Admin')->where('id', $uid)->update(['status' => 2]);
  72. add_log('hand', $id);
  73. return to_assign(0, "交接成功");
  74. } else {
  75. return to_assign(1, "交接失败");
  76. }
  77. }
  78. }