response; } public function init() { parent::init(); $service = new TaxConfigService(['mall_id' => $this->mall_id]); $config = $service->getLYConfig(); // 去除空格 $config = array_map(function($item) { return trim($item); }, $config); $this->api = new BaseApi([ 'email' => $config['email'], 'pwd' => $config['pwd'], 'accountId' => $config['accountId'], 'publicKey' => $config['publicKey'], 'privateKey' => $config['privateKey'], ]); // $this->api->setTest(); } /** * 无感电签 * * @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) { try { $this->response = $this->api->silentSign($name, $phone, $id_card); LySilentSign::addSilentSign( $this->mall_id, $uid, $name, $phone, $id_card, $this->api->accountId, $this->response ); if ($this->response['code'] == '0000') { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } return true; } /** * 查询身份证是否签约 * * @param string $idCard * @return boolean */ public function querySignUserByIdCard(string $idCard) { try { $this->response = $this->api->querySignUserByIdCard($idCard); if ($this->response['code'] == 200 && $this->response['data']['status'] == 1) { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * 查询用户是否注册 * * @param string $idCard * @return boolean */ public function queryRegisterUser(string $idCard) { try { $this->response = $this->api->queryRegisterUser($idCard); if ($this->response['code'] == 200 && $this->response['data']['result'] == true) { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * 批量导入签约用户接口 * * @param integer $uid * @param string $name * @param string $phone * @param string $idCard * @return boolean */ public function importSignUser(int $uid, string $name, string $phone, string $idCard) { $batchNum = date('YmdHis') . mt_rand(100, 999); $signUsers = [compact('name', 'phone', 'idCard')]; try { $this->response = $this->api->importSignUser($batchNum, $signUsers); LyImportSignUser::addImportSignUser( $uid, $this->mall_id, $batchNum, $signUsers, $this->response ); if ($this->response['code'] == 200 && $this->response['msg'] == '处理成功') { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * 支付时异步请求接口 * * @param TaxOrder $order 用户提现的订单 * @param TaxOrder $tax_order 手续费的订单 * @param LySilentSign $sign 用户签约信息 * @return boolean */ public function asyncTransferNotify(TaxOrder $order, TaxOrder $tax_order, LySilentSign $sign) { $batchNo = $order->batch_num; try { $this->response = $this->api->asyncTransferNotify($batchNo); if ($this->response['code'] == 200) { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * 订单失败通知 * * @param TaxOrder $user_order * @return boolean */ public function asyncTransferResultNotifyNo(TaxOrder $user_order) { try { $this->response = $this->api->asyncTransferResultNotifyNo( $user_order->order_sn ); if ($this->response['code'] == 200) { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * 订单完成通知 * * @param TaxOrder $order * @return boolean */ public function asyncTransferResultNotifyOk(TaxOrder $user_order) { try { $alipay = Json::decode($user_order->alipay_response); $this->response = $this->api->asyncTransferResultNotifyOk( $user_order->order_sn, $alipay['pay_fund_order_id'] // 支付宝成功订单号 ); if ($this->response['code'] == 200) { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * 打款批次风控接口 * * @return boolean */ public function riskCheck(TaxOrder $order, LySilentSign $sign) { try { $this->response = $this->api->riskCheck($order->batch_num, [ [ 'name' => $sign->name, 'idCard' => $sign->id_card, 'afterTaxMoney' => $order->amount, 'remark' => '', 'account' => $order->mobile, 'bizOutNo' => $order->order_sn, ] ]); if ($this->response['code'] == 200) { return true; } return $this->error($this->response['msg']); } catch (Exception $e) { return $this->error($e->getMessage()); } } }