|
@@ -13,6 +13,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
@@ -102,37 +105,36 @@ public class AllInPayLogic {
|
|
|
/**
|
|
|
* 通联支付退款
|
|
|
*/
|
|
|
-// public Map<String, String> serviceRefundOrder(SalesPayList paylist, BigDecimal refundValue) throws RemoteServiceException {
|
|
|
-// Map<String, String> reqMap = new HashMap<>();
|
|
|
-// if (StringUtils.isNotBlank(paylist.getMchNo())) {
|
|
|
-// reqMap.put("orgid", paylist.getMchNo());
|
|
|
-// }
|
|
|
-// reqMap.put("appid", paylist.getAppid());
|
|
|
-// reqMap.put("cusid", paylist.getSubMchNo());
|
|
|
-// reqMap.put("trxamt", (int) ArithUtils.mul(refundValue.doubleValue(), 100) + ""); // 退款金额 单位:分
|
|
|
-// reqMap.put("reqsn", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"))); // 商户的退款订单号
|
|
|
-// reqMap.put("oldreqsn", paylist.getOutTradeNo()); // 原交易的商户订单号
|
|
|
-// reqMap.put("oldtrxid", paylist.getOrderNo()); // 原交易的收银宝平台流水
|
|
|
-// reqMap.put("trxid", paylist.getOrderNo());
|
|
|
-//
|
|
|
-// HashMap<String, String> heads = new HashMap();
|
|
|
-// String token = commonLogic.getInfToken();
|
|
|
-// if (StringUtils.isEmpty(token)) {
|
|
|
-// throw new RemoteServiceException("获取接口令牌失败");
|
|
|
-// }
|
|
|
-// heads.put("authorization_token", token);
|
|
|
-//
|
|
|
-// String content = HttpUtils.requestPostBody(commonLogic.getInfUrl() + "/pay/csb/order/refund", JSON.toJSONString(reqMap), heads);
|
|
|
-//
|
|
|
-// Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {});
|
|
|
-//
|
|
|
-// if (!Optional.ofNullable(resMap.get("message")).orElse("error").toString().equals("success")) {
|
|
|
-// log.error("通联交易退款接口执行失败: {}", resMap);
|
|
|
-// throw new RemoteServiceException("通联交易退款接口执行失败:" + resMap.get("message"));
|
|
|
-// }
|
|
|
-//
|
|
|
-// return (Map<String, String>) resMap.get("data");
|
|
|
-// }
|
|
|
+ public Map<String, String> serviceRefundOrder(WebsitSalesPayOrder order, String refundOrderId, BigDecimal refundValue) throws RemoteServiceException {
|
|
|
+ Map<String, String> reqMap = new HashMap<>();
|
|
|
+ if (StringUtils.isNotBlank(order.getOrgId())) {
|
|
|
+ reqMap.put("orgid", order.getOrgId());
|
|
|
+ }
|
|
|
+ reqMap.put("appid", order.getAppid());
|
|
|
+ reqMap.put("cusid", order.getMchNo());
|
|
|
+ reqMap.put("trxamt", (int) ArithUtils.mul(refundValue.doubleValue(), 100) + ""); // 退款金额 单位:分
|
|
|
+ reqMap.put("reqsn", StringUtils.isNotBlank(refundOrderId) ? refundOrderId : LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"))); // 商户的退款订单号
|
|
|
+ reqMap.put("oldreqsn", order.getOutTradeNo()); // 原交易的商户订单号
|
|
|
+ reqMap.put("oldtrxid", order.getOrderNo()); // 原交易的收银宝平台流水
|
|
|
+
|
|
|
+ HashMap<String, String> heads = new HashMap();
|
|
|
+ String token = commonLogic.getInfToken();
|
|
|
+ if (StringUtils.isEmpty(token)) {
|
|
|
+ throw new RemoteServiceException("获取接口令牌失败");
|
|
|
+ }
|
|
|
+ heads.put("authorization_token", token);
|
|
|
+
|
|
|
+ String content = HttpUtils.requestPostBody(commonLogic.getInfUrl() + "/pay/csb/order/refund", JSON.toJSONString(reqMap), heads);
|
|
|
+
|
|
|
+ Map<String, Object> resMap = JSON.parseObject(content, new TypeReference<HashMap<String, Object>>() {});
|
|
|
+
|
|
|
+ if (!Optional.ofNullable(resMap.get("message")).orElse("error").toString().equals("success")) {
|
|
|
+ log.error("通联交易退款接口执行失败: {}", resMap);
|
|
|
+ throw new RemoteServiceException("通联交易退款接口执行失败:" + resMap.get("message"));
|
|
|
+ }
|
|
|
+
|
|
|
+ return (Map<String, String>) resMap.get("data");
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 通联支付关闭
|