mall_id = $mall_id; if (empty($config)) { parent::__construct([]); } else { foreach ($config as $key => $val) { if (property_exists($this, $key)) { $this->{$key} = $val; } } } // parent::__construct($config); $this->getToken(); } public function getRedisKey() { return self::TOKEN_KEY . $this->mall_id; } /** * 初始化token * * @return string */ public function getToken() { $token = \Yii::$app->redis->get($this->getRedisKey()); if (!empty($token)) { return $token; } $token = $this->queryToken(); if (!isset($token['access_token'])) { throw new Exception("获取 token 失败"); } \Yii::$app->redis->setex($this->getRedisKey(), $token['expires_in'] - 600, $token['access_token']); return $token['access_token']; } /** * 创建签约 * * @param string $mobile * @param string $idNumber * @param string $realname * @return array */ public function submitCreateUser($mobile, $idNumber, $realname) { return $this->requestPost(__FUNCTION__, compact('mobile', 'idNumber', 'realname')); } /** * 电子签约 * * @param integer $accountId * @param string $notify_url * @param string $redirect_url * @return array */ public function submitSign($accountId, $notify_url = '', $redirect_url = '') { return $this->requestPost(__FUNCTION__, compact('accountId', 'notify_url', 'redirect_url')); } /** * 签约查询 * * @param string $mobile * @param string $idNumber * @param string $realname * @return array */ public function getEsign($mobile, $idNumber, $realname) { return $this->requestPost(__FUNCTION__, compact('mobile', 'idNumber', 'realname')); } /** * 风控接口(提交订单) * * @param array $order * @return array */ public function getRiskControl($order) { return $this->requestPost(__FUNCTION__, $order); } /** * 支付完成后给税务方发送推送 * * @param array $order * @return array */ public function withdrawOrder($order) { return $this->requestPost(__FUNCTION__, $order); } }