123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\common\model;
- use traits\model\SoftDelete;
- class WxUserModel extends BaseModel
- {
- use SoftDelete;
- protected $table = 'wx_user';
- protected $deleteTime = 'delete_time';
- protected $autoWriteTimestamp = true;
- public function getCreateTimeAttr($value,$data)
- {
- return date('Y-m-d H:i:s',$value);
- }
- public function getGenderTAttr($value,$data)
- {
- $arr = ['','男','女'];
- return $arr[$data['gender']];
- }
- public function getUserPage($page,$limit,$param=[]){
- $where = [];
- if(!empty($param['keyword'])){
- $where['nickname|a.openid'] = ['like','%'.$param['keyword'].'%'];
- }
- $join=[
- ['user user','user.id=a.user_id','LEFT'],
- ];
- $this->alias('a')
- ->field('a.*')
- ->group('user_id')
- ->join($join);
- if(!empty($condition)){
- $this->where($condition);
- }
- return $this->where($where)->paginate($limit,false,['page'=>$page]);
- }
- //获取用户信息
- public function getUserInfo($condition=[])
- {
- $join=[
- ['department department','department.department_id=user.department_id','LEFT'],
- ];
- $this->alias('user')
- ->field('user.*,department_name')
- ->join($join);
- //获取用户信息
- if($condition){
- $this->where($condition);
- }
- $user_info=$this->find();
- return $user_info;
- }
- }
|