AuthController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * 会员中心模块
  4. * @author wesmiler
  5. */
  6. namespace app\weixin\controller;
  7. use app\weixin\model\Member;
  8. use app\weixin\model\UserLog;
  9. use app\weixin\model\UserProfile;
  10. use app\weixin\model\Wechat;
  11. use app\weixin\service\PRedis;
  12. use app\weixin\validate\MemberValidate;
  13. use think\Db;
  14. use think\Request;
  15. class AuthController extends BaseController
  16. {
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. $needRegProfile = session('needRegProfile');
  21. if($needRegProfile == true){
  22. Wechat::redirectUrl(url('/weixin/index/entry', '', '', true));
  23. exit;
  24. }
  25. }
  26. /**
  27. * 认证
  28. * @return mixed
  29. */
  30. public function index()
  31. {
  32. return $this->fetch();
  33. }
  34. /**
  35. * VIP认证
  36. * @return mixed
  37. */
  38. public function vip()
  39. {
  40. return $this->fetch();
  41. }
  42. /**
  43. * 人工牵线
  44. * @return mixed
  45. */
  46. public function hand()
  47. {
  48. return $this->fetch();
  49. }
  50. /**
  51. * 身份证认证
  52. * @return mixed
  53. */
  54. public function idcard()
  55. {
  56. return $this->fetch();
  57. }
  58. /**
  59. * 认证结果
  60. * @return mixed|string
  61. */
  62. public function authResult(){
  63. $params = input();
  64. $data = input('data','');
  65. $data = $data? json_decode($data, true) : [];
  66. $code = isset($data['code'])? $data['code'] : '';
  67. $idcard = isset($data['id'])? $data['id'] : '';
  68. $realname = isset($data['name'])? $data['name'] : '';
  69. $bizNo = isset($data['bizNo'])? $data['bizNo'] : '';
  70. // 签名验证
  71. $len = mb_strlen($bizNo, 'utf-8');
  72. $userId = mb_substr($bizNo, 11, $len,'utf-8');
  73. if($idcard && $realname && $code == 'PASS' && $userId){
  74. // 更新信息
  75. Member::updateAuth($userId, $realname, $idcard);
  76. $this->assign('bizNo',$bizNo);
  77. $this->assign('code','success');
  78. $this->assign('result','<em>身份验证成功</em>,请等待审核');
  79. }else{
  80. $this->assign('bizNo', '');
  81. $this->assign('code','error');
  82. $this->assign('result','<em>身份验证失败</em>,请返回重试');
  83. }
  84. $params['user_id'] = $userId;
  85. var_dump($params);
  86. PRedis::set("caches:faceAuth:result:{$bizNo}", $params, 3600);
  87. return $this->fetch();
  88. }
  89. /**
  90. * 学历认证
  91. * @return mixed
  92. */
  93. public function education()
  94. {
  95. return $this->fetch();
  96. }
  97. /**
  98. * 职位认证
  99. * @return mixed
  100. */
  101. public function position()
  102. {
  103. return $this->fetch();
  104. }
  105. }