|
|
@@ -57,6 +57,7 @@ public class OrderPayService {
|
|
|
private final PayEaseService payEaseService;
|
|
|
private final UserBankCardRepo userBankCardRepo;
|
|
|
private final AuctionOrderRepo auctionOrderRepo;
|
|
|
+ private final AuctionOrderService auctionOrderService;
|
|
|
|
|
|
public static void setPayChannel(String payChannel) {
|
|
|
if (Constants.PayChannel.HM.equals(payChannel) || Constants.PayChannel.SAND.equals(payChannel)) {
|
|
|
@@ -393,6 +394,53 @@ public class OrderPayService {
|
|
|
throw new BusinessException("交易码错误");
|
|
|
}
|
|
|
BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getTotalPrice(), orderId, "拍卖");
|
|
|
- giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
+ auctionOrderService.notify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
}
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'auctionOrder#'+#orderId")
|
|
|
+ public Map<String, Object> payAuctionOrderAgreement(Long orderId, String bindCardId) {
|
|
|
+ AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(bindCardId)) {
|
|
|
+ bindCardId = userBankCardRepo.findByUserId(order.getUserId())
|
|
|
+ .stream().map(UserBankCard::getBindCardId).findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(bindCardId)) {
|
|
|
+ throw new BusinessException("请先绑定银行卡");
|
|
|
+ }
|
|
|
+ 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("退款失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|