|
|
@@ -2,9 +2,11 @@
|
|
|
declare(strict_types=1);
|
|
|
namespace SixShop\Lakala\Service;
|
|
|
|
|
|
+use SixShop\Lakala\OpenAPISDK\V3\Api\LakalaApi;
|
|
|
use SixShop\Lakala\OpenAPISDK\V3\Api\QueryTradequeryApi;
|
|
|
use SixShop\Lakala\OpenAPISDK\V3\Api\TransPreorderApi;
|
|
|
use SixShop\Lakala\OpenAPISDK\V3\Configuration;
|
|
|
+use SixShop\Lakala\OpenAPISDK\V3\Model\ModelRequest;
|
|
|
use SixShop\Lakala\OpenAPISDK\V3\Model\QueryTradequeryRequest;
|
|
|
use SixShop\Lakala\OpenAPISDK\V3\Model\TradeAccBusiFields;
|
|
|
use SixShop\Lakala\OpenAPISDK\V3\Model\TradePreorderWechaAccBusiFields;
|
|
|
@@ -23,10 +25,13 @@ class TransactionService
|
|
|
private TransPreorderApi $transPreorderApi;
|
|
|
|
|
|
private QueryTradequeryApi $queryTradequeryApi;
|
|
|
+
|
|
|
+ private LakalaApi $lakalaApi;
|
|
|
public function __construct(private Config $config)
|
|
|
{
|
|
|
$this->transPreorderApi = new TransPreorderApi($config->getV3Config());
|
|
|
$this->queryTradequeryApi = new QueryTradequeryApi($config->getV3Config());
|
|
|
+ $this->lakalaApi = new LakalaApi($config->getV3Config());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -119,4 +124,50 @@ class TransactionService
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 聚合扫码-交易退款
|
|
|
+ *
|
|
|
+ * @param string $refundTradeNo 退款订单号
|
|
|
+ * @param string $refundAmount 退款金额
|
|
|
+ * @param LocationInfo $locationInfo 地理位置信息
|
|
|
+ * @param string $originTradeNo 原交易拉卡拉交易订单号
|
|
|
+ * @param string $originOutTradeNo 原商户订单号
|
|
|
+ * @param string $refundReason 退款原因
|
|
|
+ * @link https://o.lakala.com/#/home/document/detail?id=892
|
|
|
+ */
|
|
|
+ public function refund(
|
|
|
+ string $refundTradeNo,
|
|
|
+ float $refundAmount,
|
|
|
+ LocationInfo $locationInfo,
|
|
|
+ string $originTradeNo = '',
|
|
|
+ string $originOutTradeNo = '',
|
|
|
+ string $refundReason = '',
|
|
|
+ )
|
|
|
+ {
|
|
|
+ $request = new ModelRequest();
|
|
|
+ $reqData = [
|
|
|
+ 'merchant_no' => $this->config->merchant_no,
|
|
|
+ 'term_no' => $this->config->term_no,
|
|
|
+ 'out_trade_no' => $refundTradeNo,
|
|
|
+ 'refund_amount' => round($refundAmount*100),
|
|
|
+ 'refund_reason' => $refundReason,
|
|
|
+ 'origin_out_trade_no' => $originOutTradeNo,
|
|
|
+ 'origin_trade_no' => $originTradeNo,
|
|
|
+ 'location_info' => $locationInfo->jsonSerialize(),
|
|
|
+ 'notify_url' => $this->config->notify_url,
|
|
|
+ 'refund_amt_sts' => '00'
|
|
|
+ ];
|
|
|
+ $request->setReqData($reqData);
|
|
|
+ $response = $this->lakalaApi->tradeApi('/api/v3/rfd/refund_front/refund', $request);
|
|
|
+ if ($response->getCode() == '000000') {
|
|
|
+ return $response->getRespData();
|
|
|
+ } else {
|
|
|
+ throw_logic_exception(
|
|
|
+ msg:$response->getMsg(),
|
|
|
+ status: $response->getCode(),
|
|
|
+ data: $response->getRespData(),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|