|
|
@@ -6,6 +6,7 @@ import com.izouma.nineth.config.GeneralProperties;
|
|
|
import com.izouma.nineth.domain.*;
|
|
|
import com.izouma.nineth.dto.PayQuery;
|
|
|
import com.izouma.nineth.dto.UserBankCard;
|
|
|
+import com.izouma.nineth.enums.AuctionOrderStatus;
|
|
|
import com.izouma.nineth.enums.MintOrderStatus;
|
|
|
import com.izouma.nineth.enums.OrderStatus;
|
|
|
import com.izouma.nineth.enums.PayMethod;
|
|
|
@@ -55,6 +56,7 @@ public class OrderPayService {
|
|
|
private final PasswordEncoder passwordEncoder;
|
|
|
private final PayEaseService payEaseService;
|
|
|
private final UserBankCardRepo userBankCardRepo;
|
|
|
+ private final AuctionOrderRepo auctionOrderRepo;
|
|
|
|
|
|
public static void setPayChannel(String payChannel) {
|
|
|
if (Constants.PayChannel.HM.equals(payChannel) || Constants.PayChannel.SAND.equals(payChannel)) {
|
|
|
@@ -247,7 +249,7 @@ public class OrderPayService {
|
|
|
throw new BusinessException("交易码错误");
|
|
|
}
|
|
|
BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getGasPrice(), orderId, "铸造活动");
|
|
|
- giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
+ mintOrderService.mintNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
}
|
|
|
|
|
|
@Cacheable(value = "payOrder", key = "'mint#'+#orderId")
|
|
|
@@ -357,4 +359,40 @@ public class OrderPayService {
|
|
|
.filter(q -> q != null && q.isExist())
|
|
|
.findFirst().orElse(PayQuery.builder().exist(false).build());
|
|
|
}
|
|
|
+
|
|
|
+ @Cacheable(value = "payOrder", key = "'auctionOrder#'+#orderId")
|
|
|
+ public String payAuctionOrder(Long orderId) {
|
|
|
+ AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
|
|
|
+ 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":
|
|
|
+ return hmPayService.requestAlipay(orderId + "", order.getTotalPrice(),
|
|
|
+ "拍卖:" + order.getName(),
|
|
|
+ HMPayService.getTimeout(order.getCreatedAt(), 180),
|
|
|
+ "auctionOrder", generalProperties.getHost() + "/9th/home");
|
|
|
+ }
|
|
|
+ throw new BusinessException("绿洲宇宙冷却系统已启动,请稍后支付");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void payAuctionOrderBalance(Long orderId, Long userId, String tradeCode) {
|
|
|
+ AuctionOrder order = auctionOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getStatus() != AuctionOrderStatus.NOT_PAID) {
|
|
|
+ throw new BusinessException("订单状态错误");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(order.getUserId(), userId)) {
|
|
|
+ throw new BusinessException("订单不属于该用户");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(userRepo.findTradeCode(userId), tradeCode)) {
|
|
|
+ throw new BusinessException("交易码错误");
|
|
|
+ }
|
|
|
+ BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getTotalPrice(), orderId, "拍卖");
|
|
|
+ giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
+ }
|
|
|
}
|