123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\Db;
- class User extends Base
- {
- public function info(){
- $info = model('User')->info($this->userId,$this->orgId);
- if($info){
- $orgName = Db::name('org')
- ->where('id',$this->orgId)
- ->value('name');
- $info['orgName'] = $orgName;
- $info['h5pre'] = config('app.addr_url');
- HelpHander::success($info);
- }else{
- HelpHander::error(model('User')->getError());
- }
- }
- public function exusers(){
- $id = input('id/d',0);
- $work = input('work/d',1);
- if(!in_array($work,[-1,0,1])){
- HelpHander::error('参数错误');
- }
- $users = model('WorkTypeMode')->getRolesUserApp($id,$this->orgId,$work);
- HelpHander::success($users);
- }
- //品控执行人列表
- public function qualityUserList(){
- $users = model('WorkTypeMode')->getRolesUser(18,$this->orgId,1);
- $list = [];
- foreach ($users as $k=>$v){
- foreach ($v['user'] as $v1){
- $list[] = $v1;
- }
- }
- HelpHander::success($list);
- }
- //品控知会人列表
- public function qualityIformUserList(){
- $id = input('id/d',0);
- $users = model('WorkTypeMode')->commonRolesUserList($id,$this->orgId);
- HelpHander::success($users);
- }
- //公共角色列表
- public function commonRoles(){
- $commons = model('Roles')->getCommonList(1);
- $a = [];
- foreach ($commons as $k=>$v){
- $a[] = [
- 'id'=>$v['id'],
- 'title'=>$v['name'],
- ];
- }
- HelpHander::success($a);
- }
- //获取二级调度角色
- public function getTwoDispatchRoles(){
- $type = input('id/d',1);
- $list = model('user')->get_two_dispatch_role1($this->orgId,$type);
- HelpHander::success($list);
- }
- //判断工人是否可以自发
- public function isSpontaneous(){
- $workType = input('WorkTypeMode/d',1);
- $roles = input('rolesId/d',0);
- if(!in_array($workType,[0,1,2,3,4])){
- HelpHander::error('订单类型错误');
- }
- $rolesInfo = Db::name('roles')
- ->where('id',$roles)
- ->find();
- if($rolesInfo['parent_id'] >0){
- $roles = $rolesInfo['parent_id'];
- }
- $map[] = ['','exp',Db::raw("FIND_IN_SET(".$roles.",roles)")];
- $info = Db::name('work_type_mode')
- ->where($map)
- ->column('id');
- if(empty($info)){
- $off = 0;
- }else{
- if(!in_array($workType,$info)){
- $off = 0;
- }else{
- $off = 1;
- }
- }
- HelpHander::success($off);
- }
- public function updateHeadImage(){
- $headimage = input('imageUrl','','trim');
- $ret=Db::name('user')
- ->where('id',$this->userId)
- ->update(['head_image'=>$headimage]);
- if($ret){
- HelpHander::success(null,'修改成功');
- }else{
- HelpHander::error('修改失败');
- }
- }
- public function updatePassword(){
- $data = [
- 'oldpass' => input('password','','trim'), //旧密码
- 'pass' => input('newPassword','','trim'), //新密码
- 'pass_confirm' => input('newPassword','','trim'),//确认密码
- 'id' => $this->userId
- ];
- $data['oldpass'] = aes_decrypt($data['oldpass']);
- $data['pass'] = aes_decrypt($data['pass']);
- $data['pass_confirm'] = aes_decrypt($data['pass_confirm']);
- $ret = model('User')->modifyPass($data);
- if(!$ret){
- HelpHander::error(model('User')->getError());
- }
- $token = model('Token')->updateToken($data['id']);
- if(!$token){
- HelpHander::error(model('Token')->getError());
- }
- $params = ['user_id' => $data['id'],'code' => $token];
- HelpHander::success($params,'修改成功,请重置登录信息');
- }
- //上下班
- public function worker(){
- $worker = input('work/d',0);
- $info = Db::name('user')->where('id',$this->userId)->where('del',0)->find();
- if(!$info){
- HelpHander::error('用户不存在');
- }
- if($worker == $info['work']){
- HelpHander::success([],'操作成功');
- }else{
- $res = Db::name('user')
- ->where('id',$this->userId)
- ->update([
- 'work'=>$worker,
- 'update_time'=>getTime(),
- ]);
- }
- $res?HelpHander::success([],'操作成功'):HelpHander::error('操作失败');
- }
- }
|