MemberAuth.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class MemberAuth extends BaseMember
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/member_auth.lang.php');
  18. }
  19. /**
  20. * 会员升级
  21. *
  22. * @param
  23. * @return
  24. */
  25. public function index()
  26. {
  27. $member_model = model('member');
  28. if (request()->isPost()) {
  29. $member_array = array();
  30. $member_array['member_auth_state'] = 1;
  31. $member_array['member_idcard'] = input('post.member_idcard');
  32. $member_array['member_truename'] = input('post.member_truename');
  33. $member_validate = ds_validate('member');
  34. if (!$member_validate->scene('auth')->check($member_array)) {
  35. ds_json_encode(10001, $member_validate->getError());
  36. }
  37. if (!$this->member_info['member_idcard_image1']) {
  38. ds_json_encode(10001, lang('member_idcard_image1_require'));
  39. }
  40. if (!$this->member_info['member_idcard_image2']) {
  41. ds_json_encode(10001, lang('member_idcard_image2_require'));
  42. }
  43. if (!$this->member_info['member_idcard_image3']) {
  44. ds_json_encode(10001, lang('member_idcard_image3_require'));
  45. }
  46. $res = $this->getIdCardInfo($this->member_info);
  47. if ($res['code'] == 200) {
  48. $info = $res['data'];
  49. if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
  50. ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
  51. }
  52. } else {
  53. ds_json_encode(10001,$res['msg']);
  54. }
  55. $update = $member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id']);
  56. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  57. if ($update) {
  58. ds_json_encode(10000, $message);
  59. } else {
  60. ds_json_encode(10001, $message);
  61. }
  62. }
  63. View::assign('member_info', $this->member_info);
  64. /* 设置买家当前菜单 */
  65. $this->setMemberCurMenu('member_auth');
  66. /* 设置买家当前栏目 */
  67. $this->setMemberCurItem('index');
  68. return View::fetch($this->template_dir . 'index');
  69. }
  70. public function index2()
  71. {
  72. ds_json_encode(10001, lang('member_idcard_image2_require'));
  73. $member_model = model('member');
  74. if (request()->isPost()) {
  75. $member_array = array();
  76. $member_array['member_auth_state'] = 1;
  77. $member_array['member_idcard'] = input('post.member_idcard');
  78. $member_array['member_truename'] = input('post.member_truename');
  79. // $member_validate = ds_validate('member');
  80. // if (!$member_validate->scene('auth')->check($member_array)) {
  81. // ds_json_encode(10001, $member_validate->getError());
  82. // }
  83. if (!$this->member_info['member_idcard_image2']) {
  84. ds_json_encode(10001, lang('member_idcard_image2_require'));
  85. }
  86. $res = $this->getIdCardInfo($this->member_info);
  87. if ($res['code'] == 200) {
  88. $info = $res['data'];
  89. if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
  90. ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
  91. }
  92. } else {
  93. ds_json_encode(10001,$res['msg']);
  94. }
  95. $update = $member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id']);
  96. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  97. if ($update) {
  98. ds_json_encode(10000, $message);
  99. } else {
  100. ds_json_encode(10001, $message);
  101. }
  102. }
  103. View::assign('member_info', $this->member_info);
  104. /* 设置买家当前菜单 */
  105. $this->setMemberCurMenu('member_auth');
  106. /* 设置买家当前栏目 */
  107. $this->setMemberCurItem('index');
  108. return View::fetch($this->template_dir . 'index');
  109. }
  110. public function image_upload()
  111. {
  112. $file_name = input('param.id');
  113. if (!empty($_FILES[$file_name]['name'])) {
  114. $res = ds_upload_pic(ATTACH_IDCARD_IMAGE, $file_name);
  115. if (!$res['code']) {
  116. ds_json_encode(10001, $res['msg']);
  117. }
  118. if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  119. ds_json_encode(10001, lang('param_error'));
  120. }
  121. $member_array = array();
  122. $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
  123. $member_model = model('member');
  124. if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  125. ds_json_encode(10001, lang('ds_common_save_fail'));
  126. }
  127. ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_member_idcard_image($res['data']['file_name'])));
  128. }
  129. ds_json_encode(10001, lang('param_error'));
  130. }
  131. public function image_upload2()
  132. {
  133. $memberId = session('member_id');
  134. session('member_image_'.$memberId,'');
  135. $file_name = input('param.id');
  136. if (!empty($_FILES[$file_name]['name'])) {
  137. $res = ds_upload_pic(ATTACH_STORE_JOININ, $file_name);
  138. if (!$res['code']) {
  139. ds_json_encode(10001, $res['msg']);
  140. }
  141. if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  142. ds_json_encode(10001, lang('param_error'));
  143. }
  144. $member_array = array();
  145. $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
  146. $member_model = model('member');
  147. // if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  148. // ds_json_encode(10001, lang('ds_common_save_fail'));
  149. // }
  150. ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_store_joinin_imageurl($res['data']['file_name'])));
  151. }
  152. ds_json_encode(10001, lang('param_error'));
  153. }
  154. public function image_drop()
  155. {
  156. $file_name = input('param.file_name');
  157. if (!in_array($file_name, array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  158. ds_json_encode(10001, lang('param_error'));
  159. }
  160. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_IDCARD_IMAGE . DIRECTORY_SEPARATOR . $this->member_info[$file_name]);
  161. $member_array = array();
  162. $member_array[$file_name] = '';
  163. $member_model = model('member');
  164. if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  165. ds_json_encode(10001, lang('ds_common_save_fail'));
  166. }
  167. ds_json_encode(10000);
  168. }
  169. public function image_drop2()
  170. {
  171. $memberId = session('member_id');
  172. $data2 = session('member_image2_'.$memberId);
  173. $data3 = session('member_image3_'.$memberId);
  174. ds_json_encode(10000, '',
  175. array('image2' =>get_store_joinin_imageurl($data2['business_licence_number_electronic']),
  176. 'image3'=>get_store_joinin_imageurl($data3['business_author_letter']))
  177. );
  178. }
  179. /**
  180. * 用户中心右边,小导航
  181. *
  182. * @param string $menu_type 导航类型
  183. * @param string $menu_key 当前导航的menu_key
  184. * @return
  185. */
  186. public function getMemberItemList()
  187. {
  188. $menu_array = array(
  189. array(
  190. 'name' => 'index',
  191. 'text' => lang('member_auth'),
  192. 'url' => (string)url('MemberAuth/index')
  193. ),
  194. );
  195. return $menu_array;
  196. }
  197. }