Auth.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace User\Lib;
  3. use Dever;
  4. class Auth
  5. {
  6. # 获取是否认证
  7. public function status($uid)
  8. {
  9. $info = $this->getInfo();
  10. if (!$info) {
  11. # 未提交资料
  12. return -1;
  13. }
  14. return $info['status'];
  15. }
  16. # 获取认证信息
  17. public function getInfo($uid)
  18. {
  19. return Dever::db('user/auth')->find(array('uid' => $uid));
  20. }
  21. # 更新
  22. public function update($id, $uid, $name, $idcard, $idcard_front, $idcard_back, $type = 1, $tel = '', $email = '', $area = '', $address = '')
  23. {
  24. if ($name) {
  25. $update['name'] = $name;
  26. } else {
  27. Dever::alert('请输入真实姓名');
  28. }
  29. if ($idcard) {
  30. $update['idcard'] = $idcard;
  31. } else {
  32. Dever::alert('请输入身份证号');
  33. }
  34. if ($idcard_front) {
  35. $update['idcard_front'] = $city;
  36. } else {
  37. Dever::alert('请上传身份证正面');
  38. }
  39. if ($idcard_back) {
  40. $update['idcard_back'] = $county;
  41. } else {
  42. Dever::alert('请上传身份证背面');
  43. }
  44. if ($tel) {
  45. $update['tel'] = $tel;
  46. }
  47. if ($email) {
  48. $update['email'] = $email;
  49. }
  50. if ($area) {
  51. $update['area'] = $area;
  52. }
  53. if ($address) {
  54. $update['address'] = $address;
  55. }
  56. $update['type'] = $type;
  57. $update['status'] = 1;
  58. if ($id) {
  59. $update['where_id'] = $id;
  60. Dever::db('user/auth')->update($update);
  61. } else {
  62. $update['uid'] = $uid;
  63. $id = Dever::db('user/auth')->insert($update);
  64. }
  65. return $id;
  66. }
  67. public function manage_update($id, $name, $param)
  68. {
  69. $area = Dever::param('area', $param);
  70. $audit_status = Dever::param('audit_status', $param);
  71. if ($audit_status) {
  72. $admin = Dever::load('manage/auth.info');
  73. $update['where_id'] = $id;
  74. $update['status'] = $audit_status;
  75. $update['audit_date'] = time();
  76. if ($admin) {
  77. $update['audit_admin'] = $admin['id'];
  78. }
  79. Dever::db('user/auth')->update($update);
  80. }
  81. }
  82. }