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