|
|
@@ -93,16 +93,7 @@ public class OrderPayService {
|
|
|
if (order.getStatus() != OrderStatus.NOT_PAID) {
|
|
|
throw new BusinessException("订单状态错误");
|
|
|
}
|
|
|
- if (!Objects.equals(order.getUserId(), userId)) {
|
|
|
- throw new BusinessException("订单不属于该用户");
|
|
|
- }
|
|
|
- String encodedPwd = userRepo.findTradeCode(userId);
|
|
|
- if (StringUtils.isEmpty(encodedPwd)) {
|
|
|
- throw new BusinessException("请先设置交易密码");
|
|
|
- }
|
|
|
- if (!passwordEncoder.matches(tradeCode, encodedPwd)) {
|
|
|
- throw new BusinessException("交易码错误");
|
|
|
- }
|
|
|
+ checkTradeCode(userId, tradeCode, order.getUserId());
|
|
|
BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getTotalPrice(), orderId, order.getName());
|
|
|
rocketMQTemplate.syncSend(generalProperties.getOrderNotifyTopic(),
|
|
|
new OrderNotifyEvent(orderId, PayMethod.BALANCE, record.getId().toString(),
|
|
|
@@ -175,12 +166,7 @@ public class OrderPayService {
|
|
|
if (order.getStatus() != OrderStatus.NOT_PAID) {
|
|
|
throw new BusinessException("订单状态错误");
|
|
|
}
|
|
|
- if (!Objects.equals(order.getUserId(), userId)) {
|
|
|
- throw new BusinessException("订单不属于该用户");
|
|
|
- }
|
|
|
- if (!Objects.equals(userRepo.findTradeCode(userId), tradeCode)) {
|
|
|
- throw new BusinessException("交易码错误");
|
|
|
- }
|
|
|
+ checkTradeCode(userId, tradeCode, order.getUserId());
|
|
|
BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getGasPrice(), orderId, "转赠");
|
|
|
giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
}
|
|
|
@@ -237,14 +223,22 @@ public class OrderPayService {
|
|
|
if (order.getStatus() != MintOrderStatus.NOT_PAID) {
|
|
|
throw new BusinessException("订单状态错误");
|
|
|
}
|
|
|
- if (!Objects.equals(order.getUserId(), userId)) {
|
|
|
+ checkTradeCode(userId, tradeCode, order.getUserId());
|
|
|
+ BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getGasPrice(), orderId, "铸造活动");
|
|
|
+ giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkTradeCode(Long userId, String tradeCode, Long orderUserId) {
|
|
|
+ if (!Objects.equals(orderUserId, userId)) {
|
|
|
throw new BusinessException("订单不属于该用户");
|
|
|
}
|
|
|
- if (!Objects.equals(userRepo.findTradeCode(userId), tradeCode)) {
|
|
|
+ String encodedPwd = userRepo.findTradeCode(userId);
|
|
|
+ if (StringUtils.isEmpty(encodedPwd)) {
|
|
|
+ throw new BusinessException("请先设置交易密码");
|
|
|
+ }
|
|
|
+ if (!passwordEncoder.matches(tradeCode, encodedPwd)) {
|
|
|
throw new BusinessException("交易码错误");
|
|
|
}
|
|
|
- BalanceRecord record = userBalanceService.balancePay(order.getUserId(), order.getGasPrice(), orderId, "铸造活动");
|
|
|
- giftOrderService.giftNotify(orderId, PayMethod.BALANCE, record.getId().toString());
|
|
|
}
|
|
|
|
|
|
@Cacheable(value = "payOrder", key = "'mint#'+#orderId")
|