mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
支付订单错误码枚举类变量添加 PAY_ 前缀和交易订单区分开避免冲突
This commit is contained in:
parent
50354462fe
commit
51dab96889
@ -34,6 +34,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode ORDER_DELIVERY_FAIL_BARGAIN_RECORD_STATUS_NOT_SUCCESS = new ErrorCode(1011000023, "交易订单发货失败,砍价未成功");
|
||||
ErrorCode ORDER_DELIVERY_FAIL_DELIVERY_TYPE_NOT_EXPRESS = new ErrorCode(1011000024, "交易订单发货失败,发货类型不是快递");
|
||||
ErrorCode ORDER_CANCEL_FAIL_STATUS_NOT_UNPAID = new ErrorCode(1011000025, "交易订单取消失败,订单不是【待支付】状态");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_PAID = new ErrorCode(1011000026, "支付订单调价失败,原因:支付订单已付款,不能调价");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_EQUAL = new ErrorCode(1011000027, "支付订单调价失败,原因:价格没有变化");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_NOT_ITEM = new ErrorCode(1011000028, "支付订单调价失败,原因:订单项不存在");
|
||||
|
||||
// ========== After Sale 模块 1011000100 ==========
|
||||
ErrorCode AFTER_SALE_NOT_FOUND = new ErrorCode(1011000100, "售后单不存在");
|
||||
|
@ -21,19 +21,17 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CHANNEL_EXIST_SAME_CHANNEL_ERROR = new ErrorCode(1007001004, "已存在相同的渠道");
|
||||
|
||||
// ========== ORDER 模块 1007002000 ==========
|
||||
ErrorCode ORDER_NOT_FOUND = new ErrorCode(1007002000, "支付订单不存在");
|
||||
ErrorCode ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1007002001, "支付订单不处于待支付");
|
||||
ErrorCode ORDER_STATUS_IS_SUCCESS = new ErrorCode(1007002002, "订单已支付,请刷新页面");
|
||||
ErrorCode ORDER_IS_EXPIRED = new ErrorCode(1007002003, "支付订单已经过期");
|
||||
ErrorCode ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1007002004, "发起支付报错,错误码:{},错误提示:{}");
|
||||
ErrorCode ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1007002005, "支付订单退款失败,原因:状态不是已支付或已退款");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_PAID = new ErrorCode(1007002006, "支付订单调价失败,原因:支付订单已付款,不能调价");
|
||||
ErrorCode ORDER_UPDATE_PRICE_FAIL_EQUAL = new ErrorCode(1007002007, "支付订单调价失败,原因:价格没有变化");
|
||||
ErrorCode PAY_ORDER_NOT_FOUND = new ErrorCode(1007002000, "支付订单不存在");
|
||||
ErrorCode PAY_ORDER_STATUS_IS_NOT_WAITING = new ErrorCode(1007002001, "支付订单不处于待支付");
|
||||
ErrorCode PAY_ORDER_STATUS_IS_SUCCESS = new ErrorCode(1007002002, "订单已支付,请刷新页面");
|
||||
ErrorCode PAY_ORDER_IS_EXPIRED = new ErrorCode(1007002003, "支付订单已经过期");
|
||||
ErrorCode PAY_ORDER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1007002004, "发起支付报错,错误码:{},错误提示:{}");
|
||||
ErrorCode PAY_ORDER_REFUND_FAIL_STATUS_ERROR = new ErrorCode(1007002005, "支付订单退款失败,原因:状态不是已支付或已退款");
|
||||
|
||||
// ========== ORDER 模块(拓展单) 1007003000 ==========
|
||||
ErrorCode ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1007003000, "支付交易拓展单不存在");
|
||||
ErrorCode ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1007003001, "支付交易拓展单不处于待支付");
|
||||
ErrorCode ORDER_EXTENSION_IS_PAID = new ErrorCode(1007003002, "订单已支付,请等待支付结果");
|
||||
ErrorCode PAY_ORDER_EXTENSION_NOT_FOUND = new ErrorCode(1007003000, "支付交易拓展单不存在");
|
||||
ErrorCode PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING = new ErrorCode(1007003001, "支付交易拓展单不处于待支付");
|
||||
ErrorCode PAY_ORDER_EXTENSION_IS_PAID = new ErrorCode(1007003002, "订单已支付,请等待支付结果");
|
||||
|
||||
// ========== 支付模块(退款) 1007006000 ==========
|
||||
ErrorCode REFUND_PRICE_EXCEED = new ErrorCode(1007006000, "退款金额超过订单可退款金额");
|
||||
|
@ -26,7 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.ORDER_EXTENSION_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.PAY_ORDER_EXTENSION_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.REFUND_NOT_FOUND;
|
||||
|
||||
/**
|
||||
@ -99,8 +99,8 @@ public class WalletPayClient extends AbstractPayClient<NonePayClientConfig> {
|
||||
PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo);
|
||||
// 支付交易拓展单不存在, 返回关闭状态
|
||||
if (orderExtension == null) {
|
||||
return PayOrderRespDTO.closedOf(String.valueOf(ORDER_EXTENSION_NOT_FOUND.getCode()),
|
||||
ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, "");
|
||||
return PayOrderRespDTO.closedOf(String.valueOf(PAY_ORDER_EXTENSION_NOT_FOUND.getCode()),
|
||||
PAY_ORDER_EXTENSION_NOT_FOUND.getMsg(), outTradeNo, "");
|
||||
}
|
||||
// 关闭状态
|
||||
if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) {
|
||||
|
@ -25,7 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.hutool.core.util.ObjectUtil.*;
|
||||
import static cn.hutool.core.util.ObjectUtil.notEqual;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||
@ -156,7 +156,7 @@ public class PayDemoOrderServiceImpl implements PayDemoOrderService {
|
||||
PayOrderRespDTO payOrder = payOrderApi.getOrder(payOrderId);
|
||||
if (payOrder == null) {
|
||||
log.error("[validateDemoOrderCanPaid][order({}) payOrder({}) 不存在,请进行处理!]", id, payOrderId);
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
// 2.2 校验支付单已支付
|
||||
if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) {
|
||||
|
@ -160,7 +160,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
getSelf().notifyOrder(channel, unifiedOrderResp);
|
||||
// 如有渠道错误码,则抛出业务异常,提示用户
|
||||
if (StrUtil.isNotEmpty(unifiedOrderResp.getChannelErrorCode())) {
|
||||
throw exception(ORDER_SUBMIT_CHANNEL_ERROR, unifiedOrderResp.getChannelErrorCode(),
|
||||
throw exception(PAY_ORDER_SUBMIT_CHANNEL_ERROR, unifiedOrderResp.getChannelErrorCode(),
|
||||
unifiedOrderResp.getChannelErrorMsg());
|
||||
}
|
||||
// 此处需要读取最新的状态
|
||||
@ -172,16 +172,16 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
private PayOrderDO validateOrderCanSubmit(Long id) {
|
||||
PayOrderDO order = orderMapper.selectById(id);
|
||||
if (order == null) { // 是否存在
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
if (PayOrderStatusEnum.isSuccess(order.getStatus())) { // 校验状态,发现已支付
|
||||
throw exception(ORDER_STATUS_IS_SUCCESS);
|
||||
throw exception(PAY_ORDER_STATUS_IS_SUCCESS);
|
||||
}
|
||||
if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
if (LocalDateTimeUtils.beforeNow(order.getExpireTime())) { // 校验是否过期
|
||||
throw exception(ORDER_IS_EXPIRED);
|
||||
throw exception(PAY_ORDER_IS_EXPIRED);
|
||||
}
|
||||
|
||||
// 【重要】校验是否支付拓展单已支付,只是没有回调、或者数据不正常
|
||||
@ -202,7 +202,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) {
|
||||
log.warn("[validateOrderCanSubmit][order({}) 的 extension({}) 已支付,可能是数据不一致]",
|
||||
id, orderExtension.getId());
|
||||
throw exception(ORDER_EXTENSION_IS_PAID);
|
||||
throw exception(PAY_ORDER_EXTENSION_IS_PAID);
|
||||
}
|
||||
// 情况二:调用三方接口,查询支付单状态,是不是已支付
|
||||
PayClient payClient = payClientFactory.getPayClient(orderExtension.getChannelId());
|
||||
@ -214,7 +214,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
if (respDTO != null && PayOrderStatusRespEnum.isSuccess(respDTO.getStatus())) {
|
||||
log.warn("[validateOrderCanSubmit][order({}) 的 PayOrderRespDTO({}) 已支付,可能是回调延迟]",
|
||||
id, toJsonString(respDTO));
|
||||
throw exception(ORDER_EXTENSION_IS_PAID);
|
||||
throw exception(PAY_ORDER_EXTENSION_IS_PAID);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -256,7 +256,8 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
* @param channel 支付渠道
|
||||
* @param notify 通知
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class) // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
// 注意,如果是方法内调用该方法,需要通过 getSelf().notifyPayOrder(channel, notify) 调用,否则事务不生效
|
||||
public void notifyOrder(PayChannelDO channel, PayOrderRespDTO notify) {
|
||||
// 情况一:支付成功的回调
|
||||
if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) {
|
||||
@ -295,21 +296,21 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
// 1. 查询 PayOrderExtensionDO
|
||||
PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo());
|
||||
if (orderExtension == null) {
|
||||
throw exception(ORDER_EXTENSION_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) { // 如果已经是成功,直接返回,不用重复更新
|
||||
log.info("[updateOrderExtensionSuccess][orderExtension({}) 已经是已支付,无需更新]", orderExtension.getId());
|
||||
return orderExtension;
|
||||
}
|
||||
if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
|
||||
// 2. 更新 PayOrderExtensionDO
|
||||
int updateCounts = orderExtensionMapper.updateByIdAndStatus(orderExtension.getId(), orderExtension.getStatus(),
|
||||
PayOrderExtensionDO.builder().status(PayOrderStatusEnum.SUCCESS.getStatus()).channelNotifyData(toJsonString(notify)).build());
|
||||
if (updateCounts == 0) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
log.info("[updateOrderExtensionSuccess][orderExtension({}) 更新为已支付]", orderExtension.getId());
|
||||
return orderExtension;
|
||||
@ -328,7 +329,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
// 1. 判断 PayOrderDO 是否处于待支付
|
||||
PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId());
|
||||
if (order == null) {
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
if (PayOrderStatusEnum.isSuccess(order.getStatus()) // 如果已经是成功,直接返回,不用重复更新
|
||||
&& Objects.equals(order.getExtensionId(), orderExtension.getId())) {
|
||||
@ -336,7 +337,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
return true;
|
||||
}
|
||||
if (!PayOrderStatusEnum.WAITING.getStatus().equals(order.getStatus())) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
|
||||
// 2. 更新 PayOrderDO
|
||||
@ -349,7 +350,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
.channelFeePrice(MoneyUtils.calculateRatePrice(order.getPrice(), channel.getFeeRate()))
|
||||
.build());
|
||||
if (updateCounts == 0) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
log.info("[updateOrderExtensionSuccess][order({}) 更新为已支付]", order.getId());
|
||||
return false;
|
||||
@ -363,7 +364,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
// 1. 查询 PayOrderExtensionDO
|
||||
PayOrderExtensionDO orderExtension = orderExtensionMapper.selectByNo(notify.getOutTradeNo());
|
||||
if (orderExtension == null) {
|
||||
throw exception(ORDER_EXTENSION_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) { // 如果已经是关闭,直接返回,不用重复更新
|
||||
log.info("[updateOrderExtensionClosed][orderExtension({}) 已经是支付关闭,无需更新]", orderExtension.getId());
|
||||
@ -375,7 +376,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.notEqual(orderExtension.getStatus(), PayOrderStatusEnum.WAITING.getStatus())) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
|
||||
// 2. 更新 PayOrderExtensionDO
|
||||
@ -383,7 +384,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
PayOrderExtensionDO.builder().status(PayOrderStatusEnum.CLOSED.getStatus()).channelNotifyData(toJsonString(notify))
|
||||
.channelErrorCode(notify.getChannelErrorCode()).channelErrorMsg(notify.getChannelErrorMsg()).build());
|
||||
if (updateCounts == 0) { // 校验状态,必须是待支付
|
||||
throw exception(ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
throw exception(PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
log.info("[updateOrderExtensionClosed][orderExtension({}) 更新为支付关闭]", orderExtension.getId());
|
||||
}
|
||||
@ -392,10 +393,10 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
public void updateOrderRefundPrice(Long id, Integer incrRefundPrice) {
|
||||
PayOrderDO order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) {
|
||||
throw exception(ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
}
|
||||
if (order.getRefundPrice() + incrRefundPrice > order.getPrice()) {
|
||||
throw exception(REFUND_PRICE_EXCEED);
|
||||
@ -407,16 +408,21 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
.setStatus(PayOrderStatusEnum.REFUND.getStatus());
|
||||
int updateCount = orderMapper.updateByIdAndStatus(id, order.getStatus(), updateObj);
|
||||
if (updateCount == 0) {
|
||||
throw exception(ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePayOrderPriceById(Long payOrderId, Integer payPrice) {
|
||||
// TODO @puhui999:不能直接这样修改哈;应该只有未支付状态的订单才可以改;另外,如果价格如果没变,可以直接 return 哈;
|
||||
PayOrderDO order = orderMapper.selectById(payOrderId);
|
||||
public void updatePayOrderPrice(Long id, Integer payPrice) {
|
||||
PayOrderDO order = orderMapper.selectById(id);
|
||||
if (order == null) {
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
if (ObjectUtil.notEqual(PayOrderStatusEnum.WAITING.getStatus(), order.getStatus())) {
|
||||
throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
if (ObjectUtil.equal(order.getPrice(), payPrice)) {
|
||||
return;
|
||||
}
|
||||
|
||||
order.setPrice(payPrice);
|
||||
|
@ -160,11 +160,11 @@ public class PayRefundServiceImpl implements PayRefundService {
|
||||
private PayOrderDO validatePayOrderCanRefund(PayRefundCreateReqDTO reqDTO) {
|
||||
PayOrderDO order = orderService.getOrder(reqDTO.getAppId(), reqDTO.getMerchantOrderId());
|
||||
if (order == null) {
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
// 校验状态,必须是已支付、或者已退款
|
||||
if (!PayOrderStatusEnum.isSuccessOrRefund(order.getStatus())) {
|
||||
throw exception(ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
throw exception(PAY_ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
}
|
||||
|
||||
// 校验金额,退款金额不能大于原定的金额
|
||||
|
@ -74,7 +74,7 @@ public class PayWalletServiceImpl implements PayWalletService {
|
||||
// 1. 判断支付交易拓展单是否存
|
||||
PayOrderExtensionDO orderExtension = orderService.getOrderExtensionByNo(outTradeNo);
|
||||
if (orderExtension == null) {
|
||||
throw exception(ORDER_EXTENSION_NOT_FOUND);
|
||||
throw exception(PAY_ORDER_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
// 2. 扣减余额
|
||||
return reduceWalletBalance(userId, userType, orderExtension.getOrderId(), PAYMENT, price);
|
||||
|
@ -261,7 +261,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
String userIp = randomString();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), ORDER_NOT_FOUND);
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -274,7 +274,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
String userIp = randomString();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), ORDER_STATUS_IS_NOT_WAITING);
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -287,7 +287,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
String userIp = randomString();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), ORDER_STATUS_IS_SUCCESS);
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_STATUS_IS_SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -301,7 +301,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
String userIp = randomString();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), ORDER_IS_EXPIRED);
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp), PAY_ORDER_IS_EXPIRED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -366,7 +366,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.submitOrder(reqVO, userIp),
|
||||
ORDER_SUBMIT_CHANNEL_ERROR, "001", "模拟异常");
|
||||
PAY_ORDER_SUBMIT_CHANNEL_ERROR, "001", "模拟异常");
|
||||
// 断言,数据记录(PayOrderExtensionDO)
|
||||
PayOrderExtensionDO orderExtension = orderExtensionMapper.selectOne(null);
|
||||
assertNotNull(orderExtension);
|
||||
@ -450,7 +450,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.validateOrderActuallyPaid(id),
|
||||
ORDER_EXTENSION_IS_PAID);
|
||||
PAY_ORDER_EXTENSION_IS_PAID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -469,7 +469,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.validateOrderActuallyPaid(id),
|
||||
ORDER_EXTENSION_IS_PAID);
|
||||
PAY_ORDER_EXTENSION_IS_PAID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -519,7 +519,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||
ORDER_EXTENSION_NOT_FOUND);
|
||||
PAY_ORDER_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -537,7 +537,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||
ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -555,7 +555,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||
ORDER_NOT_FOUND);
|
||||
PAY_ORDER_NOT_FOUND);
|
||||
// 断言 PayOrderExtensionDO :数据更新被回滚
|
||||
assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null));
|
||||
}
|
||||
@ -588,7 +588,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||
ORDER_STATUS_IS_NOT_WAITING);
|
||||
PAY_ORDER_STATUS_IS_NOT_WAITING);
|
||||
// 断言 PayOrderExtensionDO :数据未更新,因为它是 SUCCESS
|
||||
assertPojoEquals(orderExtension, orderExtensionMapper.selectOne(null));
|
||||
}
|
||||
@ -673,7 +673,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||
ORDER_EXTENSION_NOT_FOUND);
|
||||
PAY_ORDER_EXTENSION_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -729,7 +729,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.notifyOrder(channel, notify),
|
||||
ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
PAY_ORDER_EXTENSION_STATUS_IS_NOT_WAITING);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -762,7 +762,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice),
|
||||
ORDER_NOT_FOUND);
|
||||
PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -786,7 +786,7 @@ public class PayOrderServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> orderService.updateOrderRefundPrice(id, incrRefundPrice),
|
||||
ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
PAY_ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -219,7 +219,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> refundService.createPayRefund(reqDTO),
|
||||
ORDER_NOT_FOUND);
|
||||
PAY_ORDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -245,7 +245,7 @@ public class PayRefundServiceTest extends BaseDbAndRedisUnitTest {
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> refundService.createPayRefund(reqDTO),
|
||||
ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
PAY_ORDER_REFUND_FAIL_STATUS_ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user