123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- namespace app\company\controller;
- use app\common\controller\Apic;
- use think\Db;
- use app\common\library\Tenim;
- /**
- * 师傅
- */
- class Worker extends Apic
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['info'];
- protected $table = 'worker';
- public function index(){
- $list = Db::name($this->table)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->order('id desc')->select();
- $list = list_domain_image($list,['avatar','idcard_z_image','idcard_f_image','jineng_image']);
- $this->success(1,$list);
- }
- public function add(){
- $mobile = input('mobile','');
- if(empty($mobile)){
- $this->error();
- }
- $check = Db::name($this->table)->where('mobile',$mobile)->where('deletetime',NULL)->find();
- if($check){
- $this->error('该手机号已被他人注册');
- }
- $data = [
- 'avatar' => input('avatar',''),
- 'truename' => input('truename',''),
- 'gonghao' => input('gonghao',''),
- 'mobile' => $mobile,
- 'password' => input('password',''),
- 'company_id' => $this->auth->company_id,
- 'status' => input('status',1),
- 'idcard_z_image' => input('idcard_z_image',''),
- 'idcard_f_image' => input('idcard_f_image',''),
- 'jineng_image' => input('jineng_image',''),
- ];
- $worker_id = Db::name($this->table)->insertGetId($data);
- //注册到im
- //user_用户端小程序,master_师傅,kefu_客服
- $tenim = new Tenim();
- $rs = $tenim->register('master_'. $worker_id, $data['truename'], localpath_to_netpath($data['avatar']));
- $this->success();
- }
- public function info(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
- $info = info_domain_image($info,['avatar','idcard_z_image','idcard_f_image','jineng_image']);
- $this->success(1,$info);
- }
- public function edit(){
- $id = input('id',0);
- $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
- if(empty($info)){
- $this->error('没找到该信息,请刷新重试');
- }
- $mobile = input('mobile','');
- if(empty($mobile)){
- $this->error();
- }
- $check = Db::name($this->table)->where('mobile',$mobile)->where('id','NEQ',$id)->where('deletetime',NULL)->find();
- if($check){
- $this->error('该手机号已被他人注册');
- }
- $data = [
- 'avatar' => input('avatar',''),
- 'truename' => input('truename',''),
- 'gonghao' => input('gonghao',''),
- 'mobile' => $mobile,
- 'password' => input('password',''),
- 'status' => input('status',1),
- 'idcard_z_image' => input('idcard_z_image',''),
- 'idcard_f_image' => input('idcard_f_image',''),
- 'jineng_image' => input('jineng_image',''),
- ];
- Db::name($this->table)->where('id',$id)->update($data);
- //如果有修改头像或昵称,同步到im
- //user_用户端小程序,master_师傅,kefu_客服
- $tenim = new Tenim();
- $rs = $tenim->useredit('master_'. $id, $data['truename'], localpath_to_netpath($data['avatar']));
- $this->success();
- }
- public function del(){
- $ids = input('ids','');
- $ids = explode(',',$ids);
- if (empty($ids)) {
- $this->error();
- }
- Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
- $this->success();
- }
- }
|