usermodel.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /*
  3. * @Author: wang jun
  4. * @Date: 2022-01-18 09:43:33
  5. * @Last Modified by: wang jun
  6. * @Last Modified time: 2022-01-18 16:10:40
  7. */
  8. namespace app\index\model;
  9. use think\Model;
  10. class usermodel extends Model
  11. {
  12. protected $table = 't_users';
  13. public function insertData($data)
  14. {
  15. if (!isset($data['create_time']) || empty($data['create_time']) || !is_string($data['create_time'])) {
  16. $data['create_time'] = 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. public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
  42. {
  43. $sqlObj = $this->where($where);
  44. if ("count" != $field) {
  45. $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
  46. if ($row) {
  47. $data = $sqlObj->find();
  48. } else {
  49. $data = $sqlObj->select();
  50. }
  51. } else {
  52. $data = $sqlObj = $sqlObj->count();
  53. }
  54. return $data;
  55. }
  56. /**
  57. * 根据openid获取信息
  58. * wj
  59. * 20220118
  60. */
  61. public function getinfobyopenid($openid)
  62. {
  63. $where = ['openid' => $openid];
  64. $info = $this->where($where)->find();
  65. return $info;
  66. }
  67. /**
  68. * 根据openid获取信息
  69. * wj
  70. * 20220118
  71. */
  72. public function getinfobysfzid($sfzid)
  73. {
  74. $where = ['sfzid' => $sfzid];
  75. $info = $this->where($where)->find();
  76. return $info;
  77. }
  78. /**
  79. * 根据telno获取信息
  80. * wj
  81. * 20220118
  82. */
  83. public function getinfobytelno($telno)
  84. {
  85. $where = ['telno' => $telno];
  86. $info = $this->where($where)->find();
  87. return $info;
  88. }
  89. /**
  90. * 根据openid获取修改unionid
  91. * wj
  92. * 20220118
  93. */
  94. public function updateunionidbyopenid($openid, $unionid)
  95. {
  96. $where = ['openid' => $openid];
  97. $updateData = ['unionid' => $unionid];
  98. $row = $this->where($where)->update($updateData);
  99. return $row;
  100. }
  101. /**
  102. * 根据openid获取修改iscompany
  103. * wj
  104. * 20220118
  105. */
  106. public function updateiscompanybyopenid($openid, $iscompany = 1)
  107. {
  108. $where = ['openid' => $openid];
  109. $updateData = ['is_company' => $iscompany];
  110. $row = $this->where($where)->update($updateData);
  111. return $row;
  112. }
  113. /**
  114. * 根据id修改数据
  115. * wj
  116. * 20220118
  117. */
  118. public function updatebyid($id, $updateData)
  119. {
  120. $where = ['id' => $id];
  121. $row = $this->where($where)->update($updateData);
  122. return $row;
  123. }
  124. }