getConfigService()->isXLApiType()) { $auth_user = TaxUserAuth::getAccountUser($this->mall_id, $user_id); if (empty($auth_user)) { return false; } if ($auth_user['status'] == TaxUserAuth::STATUS_WAIT) { // 签约中,查询签约结果 $service = new XinlongService(['mall_id' => $this->mall_id]); $res = $service->signQuery($auth_user); if ($res == TaxUserAuth::STATUS_OK) { // 已签约成功 return [ 'name' => $auth_user['name'], 'id_card' => $auth_user['id_card_no'], 'mobile' => $auth_user['mobile'] ]; } } if ($auth_user['status'] == TaxUserAuth::STATUS_OK) { // 签约成功 return [ 'name' => $auth_user['name'], 'id_card' => $auth_user['id_card_no'], 'mobile' => $auth_user['mobile'] ]; } return false; } if ($this->getConfigService()->isLYApiType()) { $auth_user = LySilentSign::getSignUser($user_id); if (empty($auth_user)) { return false; } return [ 'name' => $auth_user->name, 'id_card' => $auth_user->id_card, 'mobile' => $auth_user->phone ]; } } /** * 获取默认详情 * * @param integer $user_id * @return array|false */ public function getDefaultSignInfo(int $user_id) { if ($this->getConfigService()->isXLApiType()) { /** * @var TaxUserAuth */ $static = TaxUserAuth::class; } if ($this->getConfigService()->isLYApiType()) { /** * @var LySilentSign */ $static = LySilentSign::class; } $auth = $static::getDefaultSignInfo($this->mall_id, $user_id); if (empty($auth)) { return $this->error('还没有默认提现信息'); } // 如果设置了支付宝账号则替换 $auth['account'] && $auth['mobile'] = $auth['account']; return $auth; } /** * 去签约 * * @FormData(key="参数名|中文名", rule="") * @FormData(key="参数名|中文名", rule="") * @ApiResponse(code="500", template="error") * @ApiResponse(code="200", template="success") * @param $user_id * @param $mobile * @param $id_card * @param $name * * @return bool|array true 已经签约 false 有错误信息 array {签约的url, } */ public function goToSing($user_id, $mobile, $id_card, $name, $redirect_url = null) { // 签约前校验 // if (!$this->beforeSignCheckAccount($mobile, $id_card, $name)) { // return $this->error('实名信息不一致'); // } try { $service = new XinlongService(['mall_id' => $this->mall_id]); // 开账户 $auth_user_model = $service->createAccount($user_id, $mobile, $id_card, $name); if ($auth_user_model == false) { return $this->error($service->error); } // 生成签约链接 $url = $service->goToSign($auth_user_model, $redirect_url); return $url === false ? $this->error($service->error) : [ 'url' => $url, 'accountId' => $auth_user_model->accountId, 'flowId' => $auth_user_model->flowId, ]; } catch (\Exception$e) { return $this->error($e->getMessage()); } } /** * 身份信息是否签约, 是否当前签约, 如果不是生成一条已签约记录 * * @param string $idcard * @param string $name * @param integer $user_id * @return boolean */ public function idIsSignAndAddAuthOfUid(string $idcard, string $name, int $user_id, string $mobile = '') { // xl if ($this->getConfigService()->isXLApiType()) { $auth = TaxUserAuth::getAutnByIdcardAndName($this->mall_id, $idcard, $name); if (empty($auth)) { return false; } // 当前用户已经签约 if (TaxUserAuth::uidIsSign($this->mall_id, $user_id)) { return true; } // 生成一条新的记录 if ($auth->createNewAuth($user_id, $mobile) === false) { throw new \Exception('生成签约记录失败'); } return true; } // ly if ($this->getConfigService()->isLYApiType()) { $auth = LySilentSign::getAutnByIdcardAndName($this->mall_id, $idcard, $name); if (empty($auth)) { return false; } // 当前用户已经签约 if (LySilentSign::uidIsSign($this->mall_id, $user_id)) { return true; } // 生成一条新的记录 if ($auth->createNewAuth($user_id, $mobile) === false) { throw new \Exception('生成签约记录失败'); } return true; } return false; } /** * 签约 * * @param integer $uid * @param string $name * @param string $phone * @param string $id_card * @return boolean */ public function silentSign(int $uid, string $name, string $phone, string $id_card) { $service = new LuYongService(['mall_id' => $this->mall_id]); // 1、查询用户是否签约 if ($service->querySignUserByIdCard($id_card)) { // 1.1、使用签约返回用户信息 $response = $service->getResponse(); if (empty($user_data = $response['data'])) return $this->error('未查询到用户签约信息'); // 1.2、生成签约记录 if (LySilentSign::addSilentSign( $this->mall_id, $uid, $user_data['name'], $phone, $user_data['id_card'], $this->getConfigService()->getAccountId(), $response )) { return true; } return $this->error('生成签约记录失败'); } // 2、查询用户是否注册 if (!$service->queryRegisterUser($id_card)) { // 2.1、导入用户信息 if (!$service->importSignUser($uid, $name, $phone, $id_card)) { return $this->error($service->getError()); } } // 3、电签 if ($service->silentSign($uid, $name, $phone, $id_card)) { return true; } return $this->error($service->getError()); } /** * 新龙签约 * * @param integer $uid * @param string $name * @param string $mobile * @param string $id_card * @return boolean|array */ public function xlSign(int $uid, string $name, string $mobile, string $id_card, $url = '') { $auth = TaxUserAuth::getAutnByIdcardAndName($this->mall_id, $id_card, $name); if (!empty($auth)) { if ($auth->createNewAuth($uid, $mobile) === false) { return $this->error('添加失败'); } return true; } // if (TaxUserAuth::isSignWait($uid, $name, $mobile, $id_card)) { // return true; // } // $service = $this->getXlService(); $res = $this->goToSing( $uid, $mobile, $id_card, $name, $url ); if ($res === false) { return $this->error($this->getError()); } return $res; } /** * 签约前校验账号是否正确(需要跳转到支付宝 无法完成) * * @param string $mobile * @param string $id_card * @param string $name * @return boolean */ public function beforeSignCheckAccount($mobile, $id_card, $name) { $service = new AlipayService($this->mall_id); $res = $service->certdocCertverifyPreconsult($mobile, $id_card, $name); if (!($res && $res->code == '10000')) { return $this->error('支付宝配置有误'); } // 验证id $verify_id = $res->verify_id; $url = $service->getAppAuthorizeUrl($verify_id); header('Location:' . $url); die; $res = $service->certdocCertverifyConsult($verify_id); dd($res); } }