|
|
@@ -562,6 +562,58 @@ class MemberService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 认证
|
|
|
+ * @param $userId
|
|
|
+ * @param $params
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function auth($userId, $params)
|
|
|
+ {
|
|
|
+ $cacheLockKey = "caches:members:auth_{$userId}";
|
|
|
+ if (RedisService::get($cacheLockKey)) {
|
|
|
+ $this->error = 1034;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 用户验证
|
|
|
+ RedisService::set($cacheLockKey, ['user_id' => $userId, 'params' => $params], rand(2, 3));
|
|
|
+ $info = $this->model->where(['id' => $userId, 'mark' => 1])
|
|
|
+ ->select(['id', 'realname','idcard','bank_name','bank_card','bank_branch','is_auth', 'status'])
|
|
|
+ ->first();
|
|
|
+ if (!$info || $info['status'] != 1) {
|
|
|
+ $this->error = '账号或已被冻结,请联系客服';
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($info['is_auth'] == 1 && $info['idcard'] && $info['realname'] && $info['bank_name'] && $info['bank_card'] && $info['bank_branch']){
|
|
|
+ $this->error = '抱歉,您已完成认证';
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 认证数据
|
|
|
+ $data = [
|
|
|
+ 'realname'=> isset($params['realname'])?$params['realname'] : '',
|
|
|
+ 'idcard'=> isset($params['idcard'])?$params['idcard'] : '',
|
|
|
+ 'bank_name'=> isset($params['bank_name'])?$params['bank_name'] : '',
|
|
|
+ 'bank_card'=> isset($params['bank_card'])?$params['bank_card'] : '',
|
|
|
+ 'bank_branch'=> isset($params['bank_branch'])?$params['bank_branch'] : '',
|
|
|
+ 'is_auth'=> 1,
|
|
|
+ 'update_time' => time()
|
|
|
+ ];
|
|
|
+ if (!$this->model->where(['id' => $userId])->update($data)) {
|
|
|
+ $this->error = '认证提交失败';
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->error = '恭喜您,已完成认证';
|
|
|
+ RedisService::clear($cacheLockKey);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 账号注销
|
|
|
* @param $userId
|
|
|
* @return bool
|