User.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 User extends Base
  7. {
  8. public function info(){
  9. $info = model('User')->info($this->userId,$this->orgId);
  10. if($info){
  11. $orgName = Db::name('org')
  12. ->where('id',$this->orgId)
  13. ->value('name');
  14. $info['orgName'] = $orgName;
  15. $info['h5pre'] = config('app.addr_url');
  16. HelpHander::success($info);
  17. }else{
  18. HelpHander::error(model('User')->getError());
  19. }
  20. }
  21. public function exusers(){
  22. $id = input('id/d',0);
  23. $work = input('work/d',1);
  24. if(!in_array($work,[-1,0,1])){
  25. HelpHander::error('参数错误');
  26. }
  27. $users = model('WorkTypeMode')->getRolesUserApp($id,$this->orgId,$work);
  28. HelpHander::success($users);
  29. }
  30. //品控执行人列表
  31. public function qualityUserList(){
  32. $users = model('WorkTypeMode')->getRolesUser(18,$this->orgId,1);
  33. $list = [];
  34. foreach ($users as $k=>$v){
  35. foreach ($v['user'] as $v1){
  36. $list[] = $v1;
  37. }
  38. }
  39. HelpHander::success($list);
  40. }
  41. //品控知会人列表
  42. public function qualityIformUserList(){
  43. $id = input('id/d',0);
  44. $users = model('WorkTypeMode')->commonRolesUserList($id,$this->orgId);
  45. HelpHander::success($users);
  46. }
  47. //公共角色列表
  48. public function commonRoles(){
  49. $commons = model('Roles')->getCommonList(1);
  50. $a = [];
  51. foreach ($commons as $k=>$v){
  52. $a[] = [
  53. 'id'=>$v['id'],
  54. 'title'=>$v['name'],
  55. ];
  56. }
  57. HelpHander::success($a);
  58. }
  59. //获取二级调度角色
  60. public function getTwoDispatchRoles(){
  61. $type = input('id/d',1);
  62. $list = model('user')->get_two_dispatch_role1($this->orgId,$type);
  63. HelpHander::success($list);
  64. }
  65. //判断工人是否可以自发
  66. public function isSpontaneous(){
  67. $workType = input('WorkTypeMode/d',1);
  68. $roles = input('rolesId/d',0);
  69. if(!in_array($workType,[0,1,2,3,4])){
  70. HelpHander::error('订单类型错误');
  71. }
  72. $rolesInfo = Db::name('roles')
  73. ->where('id',$roles)
  74. ->find();
  75. if($rolesInfo['parent_id'] >0){
  76. $roles = $rolesInfo['parent_id'];
  77. }
  78. $map[] = ['','exp',Db::raw("FIND_IN_SET(".$roles.",roles)")];
  79. $info = Db::name('work_type_mode')
  80. ->where($map)
  81. ->column('id');
  82. if(empty($info)){
  83. $off = 0;
  84. }else{
  85. if(!in_array($workType,$info)){
  86. $off = 0;
  87. }else{
  88. $off = 1;
  89. }
  90. }
  91. HelpHander::success($off);
  92. }
  93. public function updateHeadImage(){
  94. $headimage = input('imageUrl','','trim');
  95. $ret=Db::name('user')
  96. ->where('id',$this->userId)
  97. ->update(['head_image'=>$headimage]);
  98. if($ret){
  99. HelpHander::success(null,'修改成功');
  100. }else{
  101. HelpHander::error('修改失败');
  102. }
  103. }
  104. }