userinfomodel.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2021-09-27 08:47:38
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2021-12-16 16:40:22
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class userinfomodel extends Model
  11. {
  12. protected $table = 't_userinfo';
  13. public function insertData($data)
  14. {
  15. if (!isset($data['createtime']) || empty($data['createtime'])) {
  16. $data['createtime'] = date('Y-m-d H:i:s');
  17. }
  18. $id = $this->insertGetId($data);
  19. return empty($id) ? false : $id;
  20. }
  21. public function getInfo($where, $field = "*", $row = true)
  22. {
  23. $info = $this->field($field)->where($where);
  24. if ($row) {
  25. $info = $info->find();
  26. } else {
  27. $info = $info->select();
  28. }
  29. return empty($info) ? false : $info;
  30. }
  31. public function updateinfo($where, $updateData)
  32. {
  33. $row = $this->where($where)->update($updateData);
  34. return empty($row) ? false : $row;
  35. }
  36. public function deleteinfo($where)
  37. {
  38. $row = $this->where($where)->delete();
  39. return empty($row) ? false : $row;
  40. }
  41. /*
  42. *20211003
  43. * 根据ID获取头像和身份证信息,未来可再增加获取的
  44. * steelxu5
  45. */
  46. public function selconinfobyid($id)
  47. {
  48. $where_arr['id'] = $id;
  49. $strfiled = 'telno,photourl,wage,wname,gender,sfzid,enterprisename';
  50. $rlist = $this->where($where_arr)->field($strfiled)->find();
  51. if (empty($rlist)) {
  52. return false;
  53. }
  54. if (empty($rlist['sfzid'])) {
  55. $rlist['is_realauth'] = false;
  56. } else {
  57. $rlist['is_realauth'] = true;
  58. }
  59. unset($rlist['sfzid']);
  60. return $rlist;
  61. }
  62. /*
  63. * 20211031
  64. * steelxu5
  65. * 更新信息,根据opoenid
  66. */
  67. public function updateinfobyopenid($openid, $updatearr)
  68. {
  69. $where_arr['openid'] = $openid;
  70. $rec = $this->where($where_arr)->update($updatearr);
  71. return $rec;
  72. }
  73. /*
  74. * 202120110
  75. * wj
  76. * 更新信息,根据id
  77. */
  78. public function updateinfobyid($id, $updatearr)
  79. {
  80. $where_arr['id'] = $id;
  81. $rec = $this->where($where_arr)->update($updatearr);
  82. return $rec;
  83. }
  84. /*
  85. * 20200813
  86. * 预检查是否有索引字段重复
  87. * 改为用身份证查重
  88. */
  89. public function precheckindex($info)
  90. {
  91. $where_arr['sfzid'] = $info['sfzid'];
  92. $rec = $this->where($where_arr)->find();
  93. if ($rec) {
  94. return false;
  95. } else {
  96. return true;
  97. }
  98. }
  99. /***
  100. * 获取全部字段名
  101. * 20211103
  102. * wj
  103. */
  104. public function gettablefields()
  105. {
  106. $sql = "desc " . $this->table;
  107. $fiekds = $this->query($sql);
  108. return $fiekds;
  109. }
  110. /**
  111. * 获取总数
  112. * 20211117
  113. * wj
  114. */
  115. public function getcount()
  116. {
  117. $count = $this->where([])->count();
  118. return $count;
  119. }
  120. /**
  121. * 获取分析数据
  122. * 20211117
  123. * wj
  124. */
  125. public function statistics()
  126. {
  127. $sql = "select isactive,isright,count(*) as count from " . $this->table . " group by isactive,isright";
  128. $list = $this->query("select * from (" . $sql . ") as t");
  129. return $list;
  130. }
  131. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  132. {
  133. $sqlObj = '';
  134. if (isset($where['sfzid']) && 'NULL' == $where['sfzid']) {
  135. $sqlObj = $this->whereNull('sfzid');
  136. unset($where['sfzid']);
  137. }
  138. if (isset($where['wname']) && 'NULL' == $where['wname']) {
  139. if ($sqlObj) {
  140. $sqlObj = $sqlObj->whereNull('wname');
  141. } else {
  142. $sqlObj = $this->whereNull('wname');
  143. }
  144. unset($where['wname']);
  145. }
  146. if ($sqlObj) {
  147. $sqlObj = $sqlObj->where($where);
  148. } else {
  149. $sqlObj = $this->where($where);
  150. }
  151. if ("count" != $field) {
  152. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  153. if ($row) {
  154. $data = $sqlObj->find();
  155. } else {
  156. $data = $sqlObj->select();
  157. }
  158. } else {
  159. $data = $sqlObj = $sqlObj->count();
  160. }
  161. return $data;
  162. }
  163. /*
  164. * 20220111
  165. * steelxu5
  166. * 根据ID返回qrcode
  167. */
  168. public function selqrcodebyuid($uid){
  169. $where_arr['id']=$uid;
  170. $rec=$this->where($where_arr)->field('qrcode')->find();
  171. return $rec;
  172. }
  173. }