Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

后端对事务控制的部分是不是有点问题 #93

Open
qw19696 opened this issue Nov 15, 2024 · 1 comment
Open

后端对事务控制的部分是不是有点问题 #93

qw19696 opened this issue Nov 15, 2024 · 1 comment

Comments

@qw19696
Copy link

qw19696 commented Nov 15, 2024

    Boolean execute = transactionTemplate.execute(e -> {
        updateById(storeOrder);
        if (storeOrder.getPayType().equals(Constants.PAY_TYPE_YUE)) {
            //新增日志
            request.setOrderId(storeOrder.getId());
            userBillService.saveRefundBill(request, user);

            // 更新用户金额
            userService.operationNowMoney(user.getUid(), request.getAmount(), user.getNowMoney(), "add");

            // 退款task
            redisUtil.lPush(Constants.ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER, storeOrder.getId());
        }
        if (storeOrder.getPayType().equals(Constants.PAY_TYPE_WE_CHAT) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
            //新增日志
            userBillService.saveRefundBill(request, user);

            // 退款task
            redisUtil.lPush(Constants.ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER, storeOrder.getId());
        }
        return Boolean.TRUE;
    });
    if (!execute) {
        storeOrderStatusService.saveRefund(storeOrder.getId(), request.getAmount(), "失败");
        throw new CrmebException("订单更新失败");
    }
    
    比如这里,如果execute方法里面执行抛出了异常,这里也没有捕获,整个方法直接就被返回了 
    下面整个记录报错的部分根本就没机会进去
    if (!execute) {
        storeOrderStatusService.saveRefund(storeOrder.getId(), request.getAmount(), "失败");
        throw new CrmebException("订单更新失败");
    }
@pk2993635720
Copy link

pk2993635720 commented Nov 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants