Certification.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. /**
  108. * 企业实名认证
  109. * @return mixed
  110. */
  111. public function enterprise()
  112. {
  113. $user_info = $this->getAdminInfo();
  114. if (request()->isPost()) {
  115. $enterprise = input('post.enterprise');
  116. $area = input('post.area');
  117. $enterprise_location = input('post.enterprise_location');
  118. $enterprise_address = input('post.enterprise_address');
  119. $contact_name = input('post.contact_name');
  120. $whether = input('post.whether');
  121. $credit_code = input('post.credit_code');
  122. $bank_location = input('post.bank_location');
  123. $bank = input('post.bank');
  124. $bankbranch = input('post.bankbranch');
  125. $debit_card = input('post.debit_card');
  126. $ch_box = input('post.ch_box');
  127. // 协议 校验
  128. if ($ch_box == false) {
  129. //验证失败
  130. $this->error('未勾选协议');
  131. }
  132. $update_info = array(
  133. 'enterprise' => $enterprise,
  134. 'area' => $area,
  135. 'enterprise_location' => $enterprise_location,
  136. 'enterprise_address' => $enterprise_address,
  137. 'contact_name' => $contact_name,
  138. 'whether' => $whether,
  139. 'credit_code' => $credit_code,
  140. 'bank_location' => $bank_location,
  141. 'bank' => $bank,
  142. 'bankbranch' => $bankbranch,
  143. 'userInfo_debit_card' => $debit_card
  144. );
  145. $imgurl = DS_THEME_STYLE_URL . 'images/certification';
  146. $numurl = '/static/user/images/certification';
  147. $file = request()->file('images');
  148. // print_r($file->getInfo());
  149. // echo $file->getInfo()['name'];
  150. if($file){
  151. $imgname = $file->getInfo()['name'];
  152. $file = $file->setSaveName($imgname);
  153. $imgo = $file->move($imgurl, $savename = $imgname, $replace = true);
  154. if($imgo){
  155. $update_info['businesslicense'] = $numurl.'/'.$imgname;
  156. }
  157. }
  158. // print_r($update_info);
  159. $date = array(
  160. 'user_status' => 0
  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. }