Merge branch 'prod' into test

This commit is contained in:
2025-12-24 14:52:16 +08:00
3 changed files with 17 additions and 7 deletions

View File

@@ -4,8 +4,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.CzgPayUtils; import com.czg.CzgPayUtils;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.CzgBaseRespParams; import com.czg.entity.CzgBaseRespParams;
import com.czg.market.entity.MkShopConsumeDiscountRecord; import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkDistributionUserService; import com.czg.market.service.MkDistributionUserService;
@@ -13,7 +13,6 @@ import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.market.service.OrderInfoService; import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment; import com.czg.order.entity.OrderPayment;
import com.czg.constants.PayTypeConstants;
import com.czg.order.service.OrderInfoCustomService; import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService; import com.czg.order.service.OrderPaymentService;
import com.czg.service.market.service.impl.AppWxServiceImpl; import com.czg.service.market.service.impl.AppWxServiceImpl;

View File

@@ -86,7 +86,6 @@ public class CzgControllerAdvice {
} }
/** /**
* 处理自定义异常 * 处理自定义异常
*/ */
@@ -164,9 +163,20 @@ public class CzgControllerAdvice {
@ExceptionHandler(value = Exception.class) @ExceptionHandler(value = Exception.class)
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public CzgResult<Object> errorHandler(Exception ex) { public CzgResult<Object> errorHandler(Exception ex) {
// setErrorLog(ex);
// 3. 处理未捕获的异常(系统异常,隐藏敏感信息)
log.error("系统未处理异常", ex); log.error("系统未处理异常", ex);
Throwable rootCause = ex;
while (rootCause.getCause() != null && !(rootCause instanceof CzgException)) {
rootCause = rootCause.getCause();
}
// 2. 如果根因是CzgException直接抛出/返回该异常
if (rootCause instanceof CzgException exception) {
return CzgResult.failure(exception.getCode(), exception.getMsg());
}else if (rootCause instanceof ValidateException exception) {
return CzgResult.failure(exception.getStatus(), exception.getMessage());
}
// 3. 非业务异常,按原有逻辑处理
return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), "系统错误,请联系管理员"); return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), "系统错误,请联系管理员");
} }

View File

@@ -106,13 +106,14 @@ public class MkShopConsumeDiscountRecordServiceImpl extends ServiceImpl<MkShopCo
.eq(MkShopConsumeDiscountRecord::getIsUse, 1) .eq(MkShopConsumeDiscountRecord::getIsUse, 1)
.eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId())); .eq(MkShopConsumeDiscountRecord::getShopUserId, shopUser.getId()));
boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId()) boolean exists = orderInfoService.exists(new QueryWrapper().eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, shopUser.getSourceShopId()).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())); .eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
return !exists && discountRecord == null; return !exists && discountRecord == null;
} }
@Override @Override
public MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId) { public MkShopConsumeDiscountRecord getDiscount(Long shopId, Long userId, Long orderId) {
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getUserId, userId).eq(ShopUser::getSourceShopId, shopId)); ShopUser shopUser = shopUserService.getUserInfo(shopId, userId);
AssertUtil.isTrue(shopUser == null, "用户不存在");
boolean newUser = isNewUser(shopUser, shopId); boolean newUser = isNewUser(shopUser, shopId);
if (!newUser) { if (!newUser) {
// throw new CzgException("新客立减仅新用户可用"); // throw new CzgException("新客立减仅新用户可用");