不报错 内容的 调用

This commit is contained in:
2025-12-12 10:41:12 +08:00
parent 85498926ea
commit be70f11f45
2 changed files with 21 additions and 11 deletions

View File

@@ -9,7 +9,8 @@ import java.util.function.Consumer;
public class FunUtils {
/**
* 执行方法并捕获异常
* @param func 方法
*
* @param func 方法
* @param value 失败的值
*/
public static <T> T safeRun(Func0<T> func, T value) {
@@ -29,4 +30,12 @@ public class FunUtils {
log.warn(msg.length > 0 ? msg[0] : "方法执行失败: {}", e.getMessage());
}
}
public static void safeRunVoid(Runnable func, String errorMsg, Object... args) {
try {
func.run();
} catch (Exception e) {
log.error(errorMsg, args, e);
}
}
}

View File

@@ -50,6 +50,7 @@ import com.czg.service.order.mapper.OrderInfoCustomMapper;
import com.czg.service.order.print.PrinterHandler;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils;
import com.czg.utils.FunUtils;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
@@ -1293,13 +1294,15 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
shopUserUseInfo(orderInfo, shopUser);
// 后续 赠送等功能 挂账支付不赠送
if (!orderInfo.getPayType().equals(PayEnums.CREDIT_PAY.getValue())) {
try {
//消费赠券
consumerCouponService.receiveConsumerCoupon(shopUser.getSourceShopId(), orderInfo.getId(), orderInfo.getPayAmount(), shopUser.getUserId(), shopUser.getId());
//下单赠送积分
pointsConfigService.consumeAwardPoints(shopUser, orderInfo);
//消费返现
consumeCashbackService.cashback(orderInfo.getShopId(), shopUser.getUserId(), orderInfo.getPayAmount(), orderInfo.getId(), orderInfo.getOrderNo());
FunUtils.safeRunVoid(() -> consumerCouponService.receiveConsumerCoupon(shopUser.getSourceShopId(), orderInfo.getId(),
orderInfo.getPayAmount(), shopUser.getUserId(), shopUser.getId()), "订单{}消费赠券失败", orderInfo.getId());
FunUtils.safeRunVoid(() -> pointsConfigService.consumeAwardPoints(shopUser, orderInfo), "订单{}赠送积分失败", orderInfo.getId());
FunUtils.safeRunVoid(() -> consumeCashbackService.cashback(orderInfo.getShopId(), shopUser.getUserId(),
orderInfo.getPayAmount(), orderInfo.getId(), orderInfo.getOrderNo()), "订单{}消费返现失败", orderInfo.getId());
FunUtils.safeRunVoid(() -> {
if (shopUser.getIsVip().equals(0)) {
// 消费累计成为会员的情况
memberConfigService.joinMemberByCondition(orderInfo.getShopId(), orderInfo.getUserId(), shopUser);
@@ -1307,9 +1310,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
// 消费赠送成长值
memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getPayAmount(), null, orderInfo.getId());
}
} catch (Exception e) {
log.error("订单{}消费赠券失败", orderInfo.getId(), e);
}
}, "订单{}用户累计/赠送成长值失败", orderInfo.getId());
}
}