123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- use think\Model;
- class UserSpecial extends Model
- {
- public function add(){
- $data = [
- 'user_id' => input('uid/d',0),
- 'znjy' => input('znjy/f',0),
- 'jxjy' => input('jxjy/f',0),
- 'zfdklx' => input('zfdklx/f',0),
- 'zfzj' => input('zfzj/f',0),
- 'sylr' => input('sylr/f',0),
- 'syjkbx' => input('syjkbx/f',0),
- 'ysylbx' => input('ysylbx/f',0),
- 'nzjds' => input('nzjds/f',0),
- 'gzds' => input('gzds/f',0),
- 'grbk' => input('grbk/f',0),
- 'zykcjze' => input('zykcjze/f',0),
- 'jmsebl' => input('jmsebl/f',0),
- 'qtkc' => input('qtkc/f',0),
- 'mssr' => input('mssr/f',0),
- 'yyezh' => input('yyezh/f',0),
- 'grylj' => input('grylj/f',0),
- ];
- $result = validate('UserSpecial')->check($data,[],'');
- if(true !== $result){
- HelpHander::error(validate('UserSpecial')->getError());
- }
- $ubase = Db::name('user_special')->where('user_id',$data['user_id'])->find();
- if($ubase){ // 修改
- $data['update_time'] = date('Y-m-d H:i:s');
- $res = Db::name('user_special')->where('id',$ubase['id'])->update($data);
- } else {// 新增
- $data['create_time'] = date('Y-m-d H:i:s');
- $data['update_time'] = date('Y-m-d H:i:s');
- $res = Db::name('user_special')->insert($data);
- }
- if(!$res){
- HelpHander::error('操作失败');
- }
- return true;
- }
- public function info($id){
- $info = $this->where('id',$id)->find();
- if(!$info){
- HelpHander::error('数据不存在');
- }
- $data = $info->toArray();
- $data['userName'] = Db::name('user_info')->where('user_id',$info['user_id'])->value('name');
- return $data;
- }
- public function lists($page,$size,$orgId,$name,$phone,$companyId){
- if($name != ''){
- $map[] = ['ui.name','like','%'.$name.'%'];
- }
- if($phone != ''){
- $map[] = ['u.phone','like','%'.$phone.'%'];
- }
- if($companyId > 0){
- $map[] = ['ui.company_id','=',$companyId];
- }
- $uids = model('User')->getAdminUsers();
- if($uids){
- $map[] = ['u.id','not in',$uids];
- }
- $map[] = ['u.del','=',0];
- $map[] = ['r.type','=',3];
- $map[] = ['r.org_id','=',$orgId];
- $map[] = ['ui.pay_type','in',[1,2]];
- $lists = Db::name('user_info')
- ->alias('ui')
- ->join('user u','ui.user_id = u.id')
- ->join('user_roles ur','ur.user_id = u.id')
- ->join('roles r','ur.roles_id = r.id')
- ->join('user_special us','us.user_id = u.id','left')
- ->where($map)
- ->field('us.*,u.phone,ui.name,ui.gender,ui.user_id as uid')
- ->page($page,$size)
- ->order('ui.sorts2 asc,ui.id desc')
- ->select();
- $lists = $lists?$lists:[];
- // foreach ($lists as $k=>$v){
- // $lists[$k]['company'] = Db::name('company')->where('id',$v['company_id'])->value('title');
- // }
- $total = Db::name('user_info')
- ->alias('ui')
- ->join('user u','ui.user_id = u.id')
- ->join('user_roles ur','ur.user_id = u.id')
- ->join('roles r','ur.roles_id = r.id')
- ->join('user_special us','us.user_id = u.id','left')
- ->where($map)->count();
- $data = [
- 'total' => $total,
- 'list' => $lists?$lists:[]
- ];
- return $data;
- }
- public function del($id){
- $ret = $this->where('id',$id)->delete();
- if(!$ret){
- HelpHander::error('删除失败');
- }
- return true;
- }
- }
|