|
|
@@ -3,6 +3,7 @@ package com.izouma.nineth.service;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.izouma.nineth.config.GeneralProperties;
|
|
|
import com.izouma.nineth.domain.*;
|
|
|
+import com.izouma.nineth.dto.UserBankCard;
|
|
|
import com.izouma.nineth.enums.MintOrderStatus;
|
|
|
import com.izouma.nineth.enums.OrderStatus;
|
|
|
import com.izouma.nineth.enums.PayMethod;
|
|
|
@@ -45,6 +46,8 @@ public class OrderPayService {
|
|
|
private final RechargeOrderRepo rechargeOrderRepo;
|
|
|
private final SysConfigService sysConfigService;
|
|
|
private final PasswordEncoder passwordEncoder;
|
|
|
+ private final PayEaseService payEaseService;
|
|
|
+ private final UserBankCardRepo userBankCardRepo;
|
|
|
|
|
|
public static void setPayChannel(String payChannel) {
|
|
|
if ("hmPay".equals(payChannel) || "sandPay".equals(payChannel)) {
|
|
|
@@ -103,13 +106,23 @@ public class OrderPayService {
|
|
|
System.currentTimeMillis()));
|
|
|
}
|
|
|
|
|
|
- public void payOrderAgreement(Long orderId) {
|
|
|
+ public void payOrderAgreement(Long orderId, String bindCardId) {
|
|
|
Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
if (order.getStatus() != OrderStatus.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("请先绑定银行卡");
|
|
|
+ }
|
|
|
+ payEaseService.pay(order.getName(), orderId.toString(), order.getTotalPrice(),
|
|
|
+ order.getUserId().toString(), bindCardId);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Cacheable(value = "payOrder", key = "'gift#'+#orderId")
|
|
|
public String payGiftOrder(Long orderId) {
|
|
|
GiftOrder order = giftOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|