Browse Source

update

master
dengbiao 7 months ago
parent
commit
9926b8eb78
3 changed files with 94 additions and 2 deletions
  1. +22
    -0
      src/applet/app/controllers/Alipay/BPassController.php
  2. +71
    -0
      src/common/Service/AliBPass/demo/AliEcoService.php
  3. +1
    -2
      src/common/Service/Pay/AlipayService.php

+ 22
- 0
src/applet/app/controllers/Alipay/BPassController.php View File

@@ -108,6 +108,28 @@ class BPassController extends ControllerBase
} }
} }


public function AlipayPlanetEcocampusApiTradeRefundAction()
{
if ($this->request->isPost()) {
$args = $this->request->getJsonRawBody(true);

$result = (new AliEcoService())->alipayPlanetEcocampusApiTradeRefund(
$args["out_order_no"] ?? "",
$args["merchant_code"] ?? "",
$args["refund_out_order_no"] ?? "",
$args["refund_amount"] ?? "",
$args["refund_reason"] ?? "",
);

if (!$result["status"]) {
$this->api(Msg::NewError($result["data"]["code"] ?? 500, $result["msg"]));
}
$this->api($result["data"]);
} else {
$this->api(Msg::NewError(500, '提交方式错误!'));
}
}

public function AlipayPlanetEcocampusApiRosterConsumeLimitAction() public function AlipayPlanetEcocampusApiRosterConsumeLimitAction()
{ {
if ($this->request->isPost()) { if ($this->request->isPost()) {


+ 71
- 0
src/common/Service/AliBPass/demo/AliEcoService.php View File

@@ -372,6 +372,77 @@ class AliEcoService extends BaseService
} }
} }


/**
* alipay.planet.ecocampus.api.trade.refund(交易退款)
* @param $out_order_no string 外部订单号
* @param $merchant_code string 商户编号
* @param $refund_out_order_no string 外部退款单号
* @param $refund_amount string 退款金额
* @param $refund_reason string 退款原因
* @return array
*/
public function alipayPlanetEcocampusApiTradeRefund($out_order_no, $merchant_code, $refund_out_order_no, $refund_amount, $refund_reason): array
{

// cleint初始
$client = new \EcoApiClient();

// 根据环境,选择行星OPENAPI网关地址
$client->gatewayUrl = $this->serverUrl;
$client->rsaPrivateKey = $this->privateKey;
$client->alipayrsaPublicKey = $this->alipayPublicKey;
$client->signType = $this->signType;
$client->format = $this->format;

// 业务参数
$bizContent["merchant_code"] = $merchant_code;
$bizContent["out_order_no"] = $out_order_no;
$bizContent["refund_out_order_no"] = $refund_out_order_no;
$bizContent["refund_amount"] = $refund_amount;
$bizContent["refund_reason"] = $refund_reason;

// 指定需要调用的service接口
$params["service"] = "alipay.planet.ecocampus.api.trade.refund";
$params["request_id"] = "" . uuid();
$params["biz_content"] = json_encode($bizContent);
$params["version"] = "1.0";

// 其他参数
$params["charset"] = $this->charset;
$params["isv_app_id"] = $this->appId;
$params["utc_timestamp"] = "" . msectime();

//获取签名
$sign = $client->generateSign($params, $this->signType);

// 调用ECOAPI
$result = $client->call($params);

$jsonStr = json_encode($result);


// 响应的签名验证 转成Array 而非 Object
$resMapData = json_decode($jsonStr, true);
$this->logger($resMapData, 'alipayPlanetEcocampusApiTradeRefund', true);

// 验签
$verifyRes = checkResponse($resMapData, $client->alipayrsaPublicKey);

if ($verifyRes) {
// echo "响应验签成功";
$responseData = $resMapData["response"];
if ($responseData['code'] == 10000) {
return $this->returnRes(true, $responseData["msg"], $responseData);
} else {
return $this->returnRes(false, ($responseData['sub_msg'] ?? $responseData['msg']), $resMapData);
}
} else {
// echo "响应验签失败";
return $this->returnRes(false, "响应验签失败", []);

}
}

/** /**
* alipay.planet.ecocampus.api.roster.consumeLimit(消费限制信息批量同步) * alipay.planet.ecocampus.api.roster.consumeLimit(消费限制信息批量同步)
* @param $consume_limit_sync_info string 消费限制信息同步请求 * @param $consume_limit_sync_info string 消费限制信息同步请求


+ 1
- 2
src/common/Service/Pay/AlipayService.php View File

@@ -209,8 +209,7 @@ class AlipayService extends BaseService
{ {
$params["out_trade_no"] = $out_trade_no; $params["out_trade_no"] = $out_trade_no;
$params["out_request_no"] = $out_request_no; $params["out_request_no"] = $out_request_no;

$request = new \AlipayTradeRefundRequest();
$request = new \AlipayTradeFastpayRefundQueryRequest();
$paramsJson = json_encode($params); $paramsJson = json_encode($params);
$request->setBizContent($paramsJson); $request->setBizContent($paramsJson);
$response = self::$aopClient->execute($request, null, $app_auth_token); $response = self::$aopClient->execute($request, null, $app_auth_token);


Loading…
Cancel
Save