Certification.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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'] = '已实名认证';
  22. }
  23. if($user['user_status'] ==-1){
  24. $user['user_status'] = '未实名认证';
  25. }
  26. if($user['user_status'] ==2){
  27. $user['user_status'] = '实名认证中';
  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_USER_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. $date = array(
  78. 'user_status' => 2,
  79. 'user_type' => 1
  80. );
  81. $result = db('user')->where('user_id', $user_info['user_id'])->update($date);
  82. return $this->redirect('User/Certification/index');
  83. }else{
  84. $user = db('user')->where('user_email',$user_info['user_email'])->find();
  85. $userinfo = db('userinfo')->where('user_id',$user_info['user_id'])->find();
  86. if($user['user_status'] ==1){
  87. $user['user_status_cn'] = '已实名认证';
  88. }
  89. if($user['user_status'] ==-1){
  90. $user['user_status_cn'] = '未实名认证';
  91. }
  92. if($user['user_status'] ==0){
  93. $user['user_status_cn'] = '实名认证中';
  94. }
  95. if($user['user_type'] ==1){
  96. $user['user_type_cn'] = '个人用户';
  97. }
  98. if($user['user_type'] ==2){
  99. $user['user_type_cn'] = '企业用户';
  100. }
  101. $this->assign('user', $user);
  102. $this->assign('userinfo', $userinfo);
  103. return $this->fetch();
  104. }
  105. }
  106. /**
  107. * 企业实名认证
  108. * @return mixed
  109. */
  110. public function enterprise()
  111. {
  112. $user_info = $this->getAdminInfo();
  113. if (request()->isPost()) {
  114. $enterprise = input('post.enterprise');
  115. $area = input('post.area');
  116. $enterprise_location = input('post.enterprise_location');
  117. $enterprise_address = input('post.enterprise_address');
  118. $contact_name = input('post.contact_name');
  119. $whether = input('post.whether');
  120. $credit_code = input('post.credit_code');
  121. $bank_location = input('post.bank_location');
  122. $bank = input('post.bank');
  123. $bankbranch = input('post.bankbranch');
  124. $debit_card = input('post.debit_card');
  125. $ch_box = input('post.ch_box');
  126. // 协议 校验
  127. if ($ch_box == false) {
  128. //验证失败
  129. $this->error('未勾选协议');
  130. }
  131. $update_info = array(
  132. 'enterprise' => $enterprise,
  133. 'area' => $area,
  134. 'enterprise_location' => $enterprise_location,
  135. 'enterprise_address' => $enterprise_address,
  136. 'contact_name' => $contact_name,
  137. 'whether' => $whether,
  138. 'credit_code' => $credit_code,
  139. 'bank_location' => $bank_location,
  140. 'bank' => $bank,
  141. 'bankbranch' => $bankbranch,
  142. 'userInfo_debit_card' => $debit_card
  143. );
  144. $imgurl = DS_THEME_USER_URL . 'images/certification';
  145. $numurl = '/static/user/images/certification';
  146. $file = request()->file('images');
  147. // print_r($file->getInfo());
  148. // echo $file->getInfo()['name'];
  149. if($file){
  150. $imgname = $file->getInfo()['name'];
  151. $file = $file->setSaveName($imgname);
  152. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  153. if($imgo){
  154. $update_info['businesslicense'] = $numurl.'/'.$imgname;
  155. }
  156. }
  157. // print_r($update_info);
  158. $date = array(
  159. 'user_status' => 2,
  160. 'user_type' => 2
  161. );
  162. $res = db('userinfo')->where('user_id', $user_info['user_id'])->update($update_info);
  163. $result = db('user')->where('user_id', $user_info['user_id'])->update($date);
  164. return $this->redirect('User/Certification/index');
  165. }else{
  166. $user = db('user')->where('user_email',$user_info['user_email'])->find();
  167. $userinfo = db('userinfo')->where('user_id',$user_info['user_id'])->find();
  168. if($user['user_status'] ==1){
  169. $user['user_status_cn'] = '已实名认证';
  170. }
  171. if($user['user_status'] ==-1){
  172. $user['user_status_cn'] = '未实名认证';
  173. }
  174. if($user['user_status'] ==0){
  175. $user['user_status_cn'] = '实名认证中';
  176. }
  177. if($user['user_type'] ==1){
  178. $user['user_type_cn'] = '个人用户';
  179. }
  180. if($user['user_type'] ==2){
  181. $user['user_type_cn'] = '企业用户';
  182. }
  183. $this->assign('user', $user);
  184. $this->assign('userinfo', $userinfo);
  185. return $this->fetch();
  186. }
  187. }
  188. }