|
|
@@ -49,6 +49,17 @@ public class OrderPayService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public String paddingOrderId(String orderId) {
|
|
|
+ if (orderId != null && orderId.length() < 12) {
|
|
|
+ StringBuilder orderIdBuilder = new StringBuilder(orderId);
|
|
|
+ for (int i = orderIdBuilder.length(); i < 12; i++) {
|
|
|
+ orderIdBuilder.insert(0, "0");
|
|
|
+ }
|
|
|
+ orderId = orderIdBuilder.toString();
|
|
|
+ }
|
|
|
+ return orderId;
|
|
|
+ }
|
|
|
+
|
|
|
@Cacheable(value = "payOrder", key = "'order#'+#orderId")
|
|
|
public String payOrder(Long orderId) {
|
|
|
Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
@@ -186,11 +197,6 @@ public class OrderPayService {
|
|
|
public JSONObject refund(String orderId, BigDecimal amount, String channel) {
|
|
|
switch (channel) {
|
|
|
case "sandPay": {
|
|
|
- if (orderId.length() < 12) {
|
|
|
- for (int i = orderId.length(); i < 12; i++) {
|
|
|
- orderId = "0" + orderId;
|
|
|
- }
|
|
|
- }
|
|
|
JSONObject res = sandPayService.refund(orderId, amount);
|
|
|
if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
|
|
|
throw new BusinessException("退款失败");
|
|
|
@@ -198,11 +204,6 @@ public class OrderPayService {
|
|
|
break;
|
|
|
}
|
|
|
case "hmPay": {
|
|
|
- if (orderId.length() < 12) {
|
|
|
- for (int i = orderId.length(); i < 12; i++) {
|
|
|
- orderId = "0" + orderId;
|
|
|
- }
|
|
|
- }
|
|
|
JSONObject res = hmPayService.refund(orderId, amount);
|
|
|
if (!"REFUND_SUCCESS".equals(res.getString("sub_code"))) {
|
|
|
throw new BusinessException("退款失败");
|