|
@@ -0,0 +1,563 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * 支付宝立减金接口
|
|
|
+ */
|
|
|
+namespace alibank;
|
|
|
+
|
|
|
+define('ALIBANK_PATHEX', BASE_DATA_PATH . '/api/alibank');
|
|
|
+if (!defined('ALIPAY_PATHEX')) define('ALIPAY_PATHEX', BASE_DATA_PATH . '/api/aop');
|
|
|
+
|
|
|
+require_once(ALIPAY_PATHEX.'/AopClient.php');
|
|
|
+require_once(ALIPAY_PATHEX.'/EncryptParseItem.php');
|
|
|
+require_once(ALIPAY_PATHEX.'/SignData.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankcustActivityconfigQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankcustChannelvoucherSendRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankcustActivityorderQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankcustChannelvoucherconfigQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankActivitybillQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankcustAccountQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankDailybillCreateRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayDataBillBalanceQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankcustChannelvoucherconfigQueryRequest.php');
|
|
|
+require_once(ALIPAY_PATHEX . '/request/AlipayUserDtbankDailybillQueryRequest.php');
|
|
|
+require_once(ALIBANK_PATHEX.'/encrypt.php');
|
|
|
+require_once(ALIBANK_PATHEX . '/client.php');
|
|
|
+require_once(ALIBANK_PATHEX . '/response.php');
|
|
|
+
|
|
|
+use alibank\client;
|
|
|
+use aop\AlipayUserDtbankcustActivityconfigQueryRequest;
|
|
|
+use aop\AlipayUserDtbankcustChannelvoucherSendRequest;
|
|
|
+use aop\AlipayUserDtbankcustActivityorderQueryRequest;
|
|
|
+use aop\AlipayUserDtbankActivitybillQueryRequest;
|
|
|
+use aop\AlipayUserDtbankcustAccountQueryRequest;
|
|
|
+use aop\AlipayUserDtbankDailybillCreateRequest;
|
|
|
+use aop\AlipayUserDtbankDailybillQueryRequest;
|
|
|
+use aop\AlipayDataBillBalanceQueryRequest;
|
|
|
+use aop\AlipayUserDtbankcustChannelvoucherconfigQueryRequest;
|
|
|
+use Exception;
|
|
|
+class coupon {
|
|
|
+
|
|
|
+ use \alibank\response;
|
|
|
+
|
|
|
+ const ALIPAY_SERVER_URL = "https://openapi.alipay.com";
|
|
|
+ const ALIPAY_GATEWAY = "/gateway.do";
|
|
|
+ const ALIPAY_SIGN_TYPE = "RSA2";
|
|
|
+ const ALIPAY_FORMAT = "json";
|
|
|
+ const ALIPAY_POST_CHARSET = "UTF-8";
|
|
|
+ const ALIPAY_API_VERSION = "1.0";
|
|
|
+
|
|
|
+ private $aop = NULL;
|
|
|
+ private static $_instance = NULL;
|
|
|
+
|
|
|
+ private function __construct(client $aop)
|
|
|
+ {
|
|
|
+ $this->aop = $aop;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function getInstance(): coupon
|
|
|
+ {
|
|
|
+ if (self::$_instance == NULL){
|
|
|
+ $config = self::load_config();
|
|
|
+
|
|
|
+ $aop = new client ();
|
|
|
+ $aop->gatewayUrl = self::ALIPAY_SERVER_URL.self::ALIPAY_GATEWAY;
|
|
|
+ $aop->appId = $config['app_id'];
|
|
|
+ $aop->rsaPrivateKey = $config['rsa_private_key'];
|
|
|
+ $aop->alipayrsaPublicKey = $config['alipay_rsa_public_key'];
|
|
|
+ $aop->apiVersion = self::ALIPAY_API_VERSION;
|
|
|
+ $aop->signType = self::ALIPAY_SIGN_TYPE;
|
|
|
+ $aop->postCharset = self::ALIPAY_POST_CHARSET;
|
|
|
+ $aop->format = self::ALIPAY_FORMAT;
|
|
|
+ $aop->encryptKey = $config['encrypt_key'];
|
|
|
+ self::$_instance = new coupon($aop);
|
|
|
+ }
|
|
|
+ return self::$_instance;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static function load_config()
|
|
|
+ {
|
|
|
+ return include(ALIBANK_PATHEX . '/config.php');
|
|
|
+ }
|
|
|
+
|
|
|
+ private function check_user(array $params): bool
|
|
|
+ {
|
|
|
+ $user_fields = ['open_id', 'logon_id', 'phone_id'];
|
|
|
+ foreach ($user_fields as $user_id)
|
|
|
+ {
|
|
|
+ if (!empty($params[$user_id])){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数字分行活动配置查询接口,$activity_type默认传DISCOUNT(立减金)
|
|
|
+ * @param string $activity_id
|
|
|
+ * @param string $activity_type DISCOUNT(立减金)|VOUCHER(通用渠道红包)|FIRST_BIND_CARD_GIFT(首绑有礼)
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_activity_config(string $activity_id, string $activity_type = 'DISCOUNT'): array
|
|
|
+ {
|
|
|
+ $biz_content = [];
|
|
|
+
|
|
|
+ $biz_content['activity_id'] = $activity_id;
|
|
|
+ $biz_content['activity_type'] = $activity_type;
|
|
|
+
|
|
|
+ if (empty($biz_content['activity_id'] || empty($biz_content['activity_type']))){
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankcustActivityconfigQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发放红包
|
|
|
+ * @param string $open_id 支付宝用户openid
|
|
|
+ * @param string $logon_id 支付宝用户ID
|
|
|
+ * @param string $phone_id 支付宝账号
|
|
|
+ * @param string $activity_id 数字分行活动id
|
|
|
+ * @param string $out_biz_no 外部业务号
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function send_voucher(string $open_id, string $logon_id, string $phone_id, string $activity_id, string $out_biz_no): array
|
|
|
+ {
|
|
|
+ $biz_content = [];
|
|
|
+ if (!empty($open_id)){
|
|
|
+ $biz_content['open_id'] = $open_id;
|
|
|
+ }
|
|
|
+ if (!empty($logon_id)){
|
|
|
+ $biz_content['logon_id'] = $logon_id;
|
|
|
+ }
|
|
|
+ if (!empty($phone_id)){
|
|
|
+ $biz_content['phone_id'] = $phone_id;
|
|
|
+ }
|
|
|
+
|
|
|
+ $biz_content['activity_id'] = $activity_id;
|
|
|
+ $biz_content['out_biz_no'] = $out_biz_no;
|
|
|
+
|
|
|
+ if (!$this->check_user($biz_content)){
|
|
|
+ return $this->failed('用户信息错误');
|
|
|
+ }
|
|
|
+ if (empty($biz_content['activity_id'] || empty($biz_content['out_biz_no']))){
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankcustChannelvoucherSendRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询红包流水
|
|
|
+ * @param string $activity_id 数字分行活动id
|
|
|
+ * @param string $out_biz_no 外部业务号
|
|
|
+ * @param string $open_id 支付宝用户open_id
|
|
|
+ * @param string $logon_id 登录ID
|
|
|
+ * @param string $phone_id 用户手机号
|
|
|
+ * @param string $activity_order_id 活动流水唯一id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_order(string $activity_order_id, string $open_id, string $logon_id, string $phone_id, string $activity_id, string $out_biz_no): array
|
|
|
+ {
|
|
|
+ $biz_content = [];
|
|
|
+
|
|
|
+ if (!empty($activity_order_id)){
|
|
|
+ $biz_content['activity_order_id'] = $activity_order_id;
|
|
|
+ }
|
|
|
+ if (!empty($open_id)){
|
|
|
+ $biz_content['open_id'] = $open_id;
|
|
|
+ }
|
|
|
+ if (!empty($logon_id)){
|
|
|
+ $biz_content['logon_id'] = $logon_id;
|
|
|
+ }
|
|
|
+ if (!empty($phone_id)){
|
|
|
+ $biz_content['phone_id'] = $phone_id;
|
|
|
+ }
|
|
|
+ if (!empty($activity_id)){
|
|
|
+ $biz_content['activity_id'] = $activity_id;
|
|
|
+ }
|
|
|
+ if (!empty($out_biz_no)){
|
|
|
+ $biz_content['out_biz_no'] = $out_biz_no;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$this->check_user($biz_content)){
|
|
|
+ return $this->failed('用户信息错误');
|
|
|
+ }
|
|
|
+ if (empty($biz_content['activity_order_id']) && (empty($biz_content['activity_id']) || empty($biz_content['out_biz_no'])))
|
|
|
+ {
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankcustActivityorderQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证签名
|
|
|
+ * @param array $params
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function verify_sign(array $params): bool
|
|
|
+ {
|
|
|
+ if (!$this->aop->rsaCheckV1($params, null, 'RSA2')){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询活动账单
|
|
|
+ * @param string $activity_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_activity_bill(string $activity_id): array
|
|
|
+ {
|
|
|
+ if (empty($activity_id)){
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $biz_content = [
|
|
|
+ 'activity_id' => $activity_id,
|
|
|
+ 'bill_type' => 'ALL'
|
|
|
+ ];
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankActivitybillQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false) {
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数字分行红包活动配置查询接口
|
|
|
+ * @param string $activity_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_channel_voucher_config(string $activity_id): array
|
|
|
+ {
|
|
|
+ if (empty($activity_id)){
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $biz_content = [
|
|
|
+ 'activity_id' => $activity_id
|
|
|
+ ];
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankcustChannelvoucherconfigQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false) {
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建日账单
|
|
|
+ * @param string $start_time eg.2020-01-01 00:00:00
|
|
|
+ * @param string $end_time eg.2020-01-01 00:00:00
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function create_daily_bill(string $start_time, string $end_time):array
|
|
|
+ {
|
|
|
+ $biz_content = [
|
|
|
+ 'start_time' => $start_time,
|
|
|
+ 'end_time' => $end_time,
|
|
|
+ 'bill_type' => 'ALL'
|
|
|
+ ];
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankDailybillCreateRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false) {
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载日账单
|
|
|
+ * @param string $bill_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_daily_bill(string $bill_id):array
|
|
|
+ {
|
|
|
+ $biz_content = [
|
|
|
+ 'bill_id' => $bill_id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankDailybillQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false) {
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数字分行用户账号查询接口
|
|
|
+ * $logon_id和$phone_id二选一
|
|
|
+ * @param string $logon_id
|
|
|
+ * @param string $phone_id
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_account(string $logon_id, string $phone_id): array
|
|
|
+ {
|
|
|
+ $biz_content = [];
|
|
|
+ if (!empty($phone_id)) {
|
|
|
+ $biz_content['phone_id'] = $phone_id;
|
|
|
+ }
|
|
|
+ if (!empty($logon_id)) {
|
|
|
+ $biz_content['logon_id'] = $logon_id;
|
|
|
+ }
|
|
|
+ if (empty($biz_content)) {
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $request = new AlipayUserDtbankcustAccountQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false) {
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode->account_no_info_list, '');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $bill_user_id 商户ID
|
|
|
+ * 查询商户余额
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function query_balance(string $bill_user_id): array
|
|
|
+ {
|
|
|
+ if (empty($bill_user_id)) {
|
|
|
+ return $this->failed('参数有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ $biz_content = [
|
|
|
+ 'bill_user_id' => $bill_user_id
|
|
|
+ ];
|
|
|
+
|
|
|
+ $request = new AlipayDataBillBalanceQueryRequest();
|
|
|
+ $request->setNeedEncrypt(true);
|
|
|
+ $request->setBizContent(json_encode($biz_content));
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ $resp = $this->aop->execute($request);
|
|
|
+ if ($resp === false) {
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception $e)
|
|
|
+ {
|
|
|
+ return $this->failed($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
+ if (!isset($resp->$responseNode)){
|
|
|
+ return $this->net_err();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($resp->$responseNode->code != "10000") {
|
|
|
+ $err_msg = $this->api_error_msg($resp->$responseNode);
|
|
|
+ return $this->failed($err_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($resp->$responseNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 回调通知解密
|
|
|
+ */
|
|
|
+ public function notify_parse(array $params):array
|
|
|
+ {
|
|
|
+ $charset = $params['charset'];
|
|
|
+ $biz_content = $params['biz_content'];
|
|
|
+ $data = $this->aop->decryptJSONSignSource($biz_content, $charset);
|
|
|
+ if (empty($data)) {
|
|
|
+ return $this->failed('回调通知解析失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success($data, '');
|
|
|
+ }
|
|
|
+}
|