123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-09-27 08:47:38
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-12-16 16:40:22
- */
- namespace app\index\model;
- use think\Model;
- class userinfomodel extends Model
- {
- protected $table = 't_userinfo';
- public function insertData($data)
- {
- if (!isset($data['createtime']) || empty($data['createtime'])) {
- $data['createtime'] = date('Y-m-d H:i:s');
- }
- $id = $this->insertGetId($data);
- return empty($id) ? false : $id;
- }
- public function getInfo($where, $field = "*", $row = true)
- {
- $info = $this->field($field)->where($where);
- if ($row) {
- $info = $info->find();
- } else {
- $info = $info->select();
- }
- return empty($info) ? false : $info;
- }
- public function updateinfo($where, $updateData)
- {
- $row = $this->where($where)->update($updateData);
- return empty($row) ? false : $row;
- }
- public function deleteinfo($where)
- {
- $row = $this->where($where)->delete();
- return empty($row) ? false : $row;
- }
- /*
- *20211003
- * 根据ID获取头像和身份证信息,未来可再增加获取的
- * steelxu5
- */
- public function selconinfobyid($id)
- {
- $where_arr['id'] = $id;
- $strfiled = 'telno,photourl,wage,wname,gender,sfzid,enterprisename';
- $rlist = $this->where($where_arr)->field($strfiled)->find();
- if (empty($rlist)) {
- return false;
- }
- if (empty($rlist['sfzid'])) {
- $rlist['is_realauth'] = false;
- } else {
- $rlist['is_realauth'] = true;
- }
- unset($rlist['sfzid']);
- return $rlist;
- }
- /*
- * 20211031
- * steelxu5
- * 更新信息,根据opoenid
- */
- public function updateinfobyopenid($openid, $updatearr)
- {
- $where_arr['openid'] = $openid;
- $rec = $this->where($where_arr)->update($updatearr);
- return $rec;
- }
- /*
- * 202120110
- * wj
- * 更新信息,根据id
- */
- public function updateinfobyid($id, $updatearr)
- {
- $where_arr['id'] = $id;
- $rec = $this->where($where_arr)->update($updatearr);
- return $rec;
- }
- /*
- * 20200813
- * 预检查是否有索引字段重复
- * 改为用身份证查重
- */
- public function precheckindex($info)
- {
- $where_arr['sfzid'] = $info['sfzid'];
- $rec = $this->where($where_arr)->find();
- if ($rec) {
- return false;
- } else {
- return true;
- }
- }
- /***
- * 获取全部字段名
- * 20211103
- * wj
- */
- public function gettablefields()
- {
- $sql = "desc " . $this->table;
- $fiekds = $this->query($sql);
- return $fiekds;
- }
- /**
- * 获取总数
- * 20211117
- * wj
- */
- public function getcount()
- {
- $count = $this->where([])->count();
- return $count;
- }
- /**
- * 获取分析数据
- * 20211117
- * wj
- */
- public function statistics()
- {
- $sql = "select isactive,isright,count(*) as count from " . $this->table . " group by isactive,isright";
- $list = $this->query("select * from (" . $sql . ") as t");
- return $list;
- }
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = '';
- if (isset($where['sfzid']) && 'NULL' == $where['sfzid']) {
- $sqlObj = $this->whereNull('sfzid');
- unset($where['sfzid']);
- }
- if (isset($where['wname']) && 'NULL' == $where['wname']) {
- if ($sqlObj) {
- $sqlObj = $sqlObj->whereNull('wname');
- } else {
- $sqlObj = $this->whereNull('wname');
- }
- unset($where['wname']);
- }
- if ($sqlObj) {
- $sqlObj = $sqlObj->where($where);
- } else {
- $sqlObj = $this->where($where);
- }
- if ("count" != $field) {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
- if ($row) {
- $data = $sqlObj->find();
- } else {
- $data = $sqlObj->select();
- }
- } else {
- $data = $sqlObj = $sqlObj->count();
- }
- return $data;
- }
- /*
- * 20220111
- * steelxu5
- * 根据ID返回qrcode
- */
- public function selqrcodebyuid($uid){
- $where_arr['id']=$uid;
- $rec=$this->where($where_arr)->field('qrcode')->find();
- return $rec;
- }
- }
|