Certification.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace app\user\controller;
  3. use think\Validate;
  4. use think\Lang;
  5. class Certification extends UserControl
  6. {
  7. public function _initialize()
  8. {
  9. parent::_initialize();
  10. Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/member.lang.php');
  11. }
  12. /**
  13. * 用户信息
  14. * @return mixed
  15. */
  16. public function index()
  17. {
  18. $user_info = $this->getAdminInfo();
  19. $user = db('user')->where('user_email',$user_info['user_email'])->find();
  20. if($user['user_status'] ==1){
  21. $user['user_status_cn'] = '已实名认证';
  22. }
  23. if($user['user_status'] ==-1){
  24. $user['user_status_cn'] = '未实名认证';
  25. }
  26. if($user['user_status'] ==0){
  27. $user['user_status_cn'] = '实名认证中';
  28. }
  29. $this->assign('user', $user);
  30. return $this->fetch();
  31. }
  32. /**
  33. * 个人实名认证信息
  34. * @return mixed
  35. */
  36. public function personal()
  37. {
  38. $user_info = $this->getAdminInfo();
  39. if (request()->isPost()) {
  40. $name = input('post.name');
  41. $identity = input('post.identity');
  42. $bank_card = input('post.bank_card');
  43. $debit_card = input('post.debit_card');
  44. $ch_box = input('post.ch_box');
  45. // 协议 校验
  46. if ($ch_box == false) {
  47. //验证失败
  48. $this->error('未勾选协议');
  49. }
  50. $update_info = array(
  51. 'userInfo_name' => $name,
  52. 'userInfo_identity' => $identity,
  53. 'userInfo_bank_card' => $bank_card,
  54. 'userInfo_debit_card' => $debit_card
  55. );
  56. $imgurl = DS_THEME_STYLE_URL . 'images/certification';
  57. $numurl = '/static/user/images/certification';
  58. $img_front = request()->file('img_front');
  59. $img_back = request()->file('img_back');
  60. if($img_front){
  61. $imgname = time().'_1.jpg';
  62. $file = $img_front->setSaveName($imgname);
  63. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  64. if($imgo){
  65. $update_info['img_front'] =$numurl.'/'.$imgname;
  66. }
  67. }
  68. if($img_back){
  69. $imgname = time().'_2.jpg';
  70. $file = $img_back->setSaveName($imgname);
  71. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  72. if($imgo){
  73. $update_info['img_back'] =$numurl.'/'.$imgname;
  74. }
  75. }
  76. $res = db('userinfo')->where('user_id', $user_info['user_id'])->update($update_info);
  77. if($res == 1){
  78. $date = array(
  79. 'user_status' => 0
  80. );
  81. $result = db('user')->where('user_id', $user_info['user_id'])->update($date);
  82. if($result == 1){
  83. return $this->redirect('User/Certification/index');
  84. }
  85. }
  86. }else{
  87. $user = db('user')->where('user_email',$user_info['user_email'])->find();
  88. if($user['user_status'] ==1){
  89. $user['user_status_cn'] = '已实名认证';
  90. }
  91. if($user['user_status'] ==-1){
  92. $user['user_status_cn'] = '未实名认证';
  93. }
  94. if($user['user_status'] ==0){
  95. $user['user_status_cn'] = '实名认证中';
  96. }
  97. if($user['user_type'] ==1){
  98. $user['user_type_cn'] = '个人用户';
  99. }
  100. if($user['user_type'] ==2){
  101. $user['user_type_cn'] = '企业用户';
  102. }
  103. $this->assign('user', $user);
  104. return $this->fetch();
  105. }
  106. }
  107. }