|
|
@@ -38,25 +38,25 @@ import java.util.stream.Stream;
|
|
|
public class OrderPayService {
|
|
|
private static String PAY_CHANNEL = Constants.PayChannel.SAND;
|
|
|
|
|
|
- private final OrderService orderService;
|
|
|
- private final OrderRepo orderRepo;
|
|
|
- private final MintOrderRepo mintOrderRepo;
|
|
|
- private final GiftOrderRepo giftOrderRepo;
|
|
|
- private final SandPayService sandPayService;
|
|
|
- private final HMPayService hmPayService;
|
|
|
- private final GeneralProperties generalProperties;
|
|
|
- private final UserBalanceService userBalanceService;
|
|
|
- private final RocketMQTemplate rocketMQTemplate;
|
|
|
- private final GiftOrderService giftOrderService;
|
|
|
- private final MintOrderService mintOrderService;
|
|
|
- private final UserRepo userRepo;
|
|
|
- private final SnowflakeIdWorker snowflakeIdWorker;
|
|
|
- private final RechargeOrderRepo rechargeOrderRepo;
|
|
|
- private final SysConfigService sysConfigService;
|
|
|
- private final PasswordEncoder passwordEncoder;
|
|
|
- private final PayEaseService payEaseService;
|
|
|
- private final UserBankCardRepo userBankCardRepo;
|
|
|
- private final AuctionOrderRepo auctionOrderRepo;
|
|
|
+ private final OrderService orderService;
|
|
|
+ private final OrderRepo orderRepo;
|
|
|
+ private final MintOrderRepo mintOrderRepo;
|
|
|
+ private final GiftOrderRepo giftOrderRepo;
|
|
|
+ private final SandPayService sandPayService;
|
|
|
+ private final HMPayService hmPayService;
|
|
|
+ private final GeneralProperties generalProperties;
|
|
|
+ private final UserBalanceService userBalanceService;
|
|
|
+ private final RocketMQTemplate rocketMQTemplate;
|
|
|
+ private final GiftOrderService giftOrderService;
|
|
|
+ private final MintOrderService mintOrderService;
|
|
|
+ private final UserRepo userRepo;
|
|
|
+ private final SnowflakeIdWorker snowflakeIdWorker;
|
|
|
+ private final RechargeOrderRepo rechargeOrderRepo;
|
|
|
+ private final SysConfigService sysConfigService;
|
|
|
+ private final PasswordEncoder passwordEncoder;
|
|
|
+ private final PayEaseService payEaseService;
|
|
|
+ private final UserBankCardRepo userBankCardRepo;
|
|
|
+ private final AuctionOrderRepo auctionOrderRepo;
|
|
|
private final AuctionOrderService auctionOrderService;
|
|
|
|
|
|
public static void setPayChannel(String payChannel) {
|
|
|
@@ -368,20 +368,28 @@ public class OrderPayService {
|
|
|
throw new BusinessException("订单状态错误");
|
|
|
}
|
|
|
switch (PAY_CHANNEL) {
|
|
|
- case "sandPay":
|
|
|
- return sandPayService.requestAlipay(orderId + "", order.getTotalPrice(),
|
|
|
- "拍卖:" + order.getName(), "拍卖:" + order.getName(),
|
|
|
- SandPayService.getTimeout(order.getCreatedAt(), 180),
|
|
|
- "{\"type\":\"auctionOrder\",\"id\":\"" + orderId + "\"}");
|
|
|
- case "hmPay":
|
|
|
+ case Constants.PayChannel.SAND:
|
|
|
+ return sandPayService.pay(orderId + "", "拍卖:" + order.getName(), order.getTotalPrice(),
|
|
|
+ order.getCreatedAt().plusMinutes(3), "auctionOrder");
|
|
|
+ case Constants.PayChannel.HM:
|
|
|
return hmPayService.requestAlipay(orderId + "", order.getTotalPrice(),
|
|
|
- "拍卖:" + order.getName(),
|
|
|
- HMPayService.getTimeout(order.getCreatedAt(), 180),
|
|
|
- "auctionOrder", generalProperties.getHost() + "/9th/home");
|
|
|
+ "拍卖:" + order.getName(), HMPayService.getTimeout(order.getCreatedAt(), 180),
|
|
|
+ Constants.OrderNotifyType.AUCTION, generalProperties.getHost() + "/9th/home");
|
|
|
}
|
|
|
throw new BusinessException("绿洲宇宙冷却系统已启动,请稍后支付");
|
|
|
}
|
|
|
|
|
|
+ @Cacheable(value = "payOrder", key = "'auctionOrder#'+#orderId")
|
|
|
+ public String payAuctionQuick(Long orderId) {
|
|
|
+ AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ return sandPayService.payQuick(orderId + "", "拍卖:" + order.getName(),
|
|
|
+ order.getTotalPrice(), order.getCreatedAt().plusMinutes(3), Constants.OrderNotifyType.AUCTION,
|
|
|
+ generalProperties.getHost() + "/9th/home");
|
|
|
+ }
|
|
|
+
|
|
|
public void payAuctionOrderBalance(Long orderId, Long userId, String tradeCode) {
|
|
|
AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
|
|
|
@@ -413,34 +421,4 @@ public class OrderPayService {
|
|
|
return payEaseService.pay("拍卖:" + order.getAuctionId(), orderId.toString(), order.getTotalPrice(),
|
|
|
order.getUserId().toString(), bindCardId, "auctionOrder");
|
|
|
}
|
|
|
-
|
|
|
- public JSONObject refund(String orderId, BigDecimal amount, String channel) {
|
|
|
- switch (channel) {
|
|
|
- case "sandPay": {
|
|
|
- JSONObject res = sandPayService.refund(orderId, amount);
|
|
|
- if (!"000000".equals(res.getJSONObject("head").getString("respCode"))) {
|
|
|
- throw new BusinessException("退款失败");
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case "hmPay": {
|
|
|
- JSONObject res = hmPayService.refund(orderId, amount);
|
|
|
- if (!"REFUND_SUCCESS".equals(res.getString("sub_code"))) {
|
|
|
- throw new BusinessException("退款失败");
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case "payEase": {
|
|
|
- JSONObject res = payEaseService.refund(orderId, amount);
|
|
|
- String status = res.getString("status");
|
|
|
- if (!"SUCCESS".equals(status)) {
|
|
|
- String error = res.getString("error");
|
|
|
- throw new BusinessException("退款失败:" + error);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- throw new BusinessException("退款失败");
|
|
|
- }
|
|
|
-
|
|
|
}
|