|
|
@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
@@ -107,7 +108,7 @@ public class OrderPayService {
|
|
|
}
|
|
|
|
|
|
@Cacheable(value = "payOrder", key = "'order#'+#orderId")
|
|
|
- public Object payOrderAgreement(Long orderId, String bindCardId) {
|
|
|
+ public Map<String, Object> payOrderAgreement(Long orderId, String bindCardId) {
|
|
|
Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
if (order.getStatus() != OrderStatus.NOT_PAID) {
|
|
|
throw new BusinessException("订单状态错误");
|
|
|
@@ -119,10 +120,13 @@ public class OrderPayService {
|
|
|
if (StringUtils.isEmpty(bindCardId)) {
|
|
|
throw new BusinessException("请先绑定银行卡");
|
|
|
}
|
|
|
- return payEaseService.pay(order.getName(), orderId.toString(), order.getTotalPrice(),
|
|
|
+ return payEaseService.pay(order.getName(), orderId.toString(), order.getTotalPrice(),
|
|
|
order.getUserId().toString(), bindCardId);
|
|
|
}
|
|
|
|
|
|
+ public void confirmOrderAgreement(String requestId, String paymentOrderId, String code) {
|
|
|
+ payEaseService.payConfirm(requestId, paymentOrderId, code);
|
|
|
+ }
|
|
|
|
|
|
@Cacheable(value = "payOrder", key = "'gift#'+#orderId")
|
|
|
public String payGiftOrder(Long orderId) {
|
|
|
@@ -160,6 +164,23 @@ public class OrderPayService {
|
|
|
giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
}
|
|
|
|
|
|
+ @Cacheable(value = "payOrder", key = "'gift#'+#orderId")
|
|
|
+ public Map<String, Object> payGiftOrderAgreement(Long orderId, String bindCardId) {
|
|
|
+ GiftOrder order = giftOrderRepo.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("请先绑定银行卡");
|
|
|
+ }
|
|
|
+ return payEaseService.pay("转赠" + order.getAssetId(), orderId.toString(), order.getGasPrice(),
|
|
|
+ order.getUserId().toString(), bindCardId);
|
|
|
+ }
|
|
|
+
|
|
|
@Cacheable(value = "payOrder", key = "'mintOrder#'+#orderId")
|
|
|
public String payMintOrder(Long orderId) {
|
|
|
MintOrder order = mintOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
@@ -196,6 +217,23 @@ public class OrderPayService {
|
|
|
giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
}
|
|
|
|
|
|
+ @Cacheable(value = "payOrder", key = "'mint#'+#orderId")
|
|
|
+ public Map<String, Object> payMintOrderAgreement(Long orderId, String bindCardId) {
|
|
|
+ MintOrder order = mintOrderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ if (order.getStatus() != MintOrderStatus.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.getMintActivityId(), orderId.toString(), order.getGasPrice(),
|
|
|
+ order.getUserId().toString(), bindCardId);
|
|
|
+ }
|
|
|
+
|
|
|
public String recharge(Long userId, BigDecimal amount) {
|
|
|
BigDecimal minAmount = sysConfigService.getBigDecimal("min_recharge_amount");
|
|
|
if (amount.compareTo(minAmount) < 0) {
|