Userinfo.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Userinfo extends Model
  5. {
  6. public function updateUserInfo($condition, $data)
  7. {
  8. $result = $this
  9. ->where($condition)
  10. ->update($data);
  11. return $result;
  12. }
  13. public function getUserInfo($condition)
  14. {
  15. $result = $this
  16. ->where($condition)
  17. ->find();
  18. return $result;
  19. }
  20. public function findOne($uid, $format = 0)
  21. {
  22. $ret = $this->where(['user_id' => $uid])->find();
  23. if (!$ret) {
  24. return false;
  25. }
  26. if ($format) {
  27. return $this->FormatData($ret);
  28. } else {
  29. return $ret;
  30. }
  31. }
  32. private function FormatData($model)
  33. {
  34. $return = [];
  35. $arr = $model->toArray();
  36. $allKey = $this->KeyMap();
  37. $skipF = ['userInfo_id', 'user_id'];
  38. $imgF = ['userInfo_header', 'img_front', 'img_back', 'businesslicense'];
  39. foreach ($arr as $key => $val) {
  40. if (in_array($key, $skipF)) {
  41. continue;
  42. }
  43. if (!empty($val)) {
  44. $kname = $allKey[$key];
  45. if (in_array($key, $imgF)) {
  46. $return[$kname] = "<a href='$val' target='_blank'><img width='120' src='$val'></a>";
  47. } else {
  48. $return[$kname] = $val;
  49. }
  50. }
  51. }
  52. return $return;
  53. }
  54. private function KeyMap()
  55. {
  56. return [
  57. 'userInfo_id' => '用户信息自增ID',
  58. 'user_id' => '用户ID',
  59. 'userInfo_money' => '用户余额',
  60. 'userInfo_header' => '用户头像',
  61. 'userInfo_name' => '真实姓名',
  62. 'userInfo_identity' => '身份证号码',
  63. 'userInfo_bank_card' => '银行卡卡号',
  64. 'userInfo_debit_card' => '借记卡卡号',
  65. 'img_front' => '证件正面',
  66. 'img_back' => '证件反面',
  67. 'enterprise' => '企业名称',
  68. 'area' => '企业地区',
  69. 'enterprise_location' => '企业所在地',
  70. 'enterprise_address' => '企业通讯地址',
  71. 'contact_name' => '联系人姓名',
  72. 'whether' => '是否三证合一',
  73. 'credit_code' => '社会信用代码',
  74. 'bank_location' => '开户银行所在地',
  75. 'bank' => '银行名称',
  76. 'bankbranch' => '银行支行名称',
  77. 'businesslicense' => '营业执照',
  78. ];
  79. }
  80. }