会员充值/霸王餐支付 关联id问题
统一异常拦截 rootCause 值 CLIENT_LOGIC 与 USER_LOGIC 问题
This commit is contained in:
@@ -8,6 +8,7 @@ import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.core.NestedExceptionUtils;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
@@ -164,20 +165,23 @@ public class CzgControllerAdvice {
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> errorHandler(Exception ex) {
|
||||
log.error("系统未处理异常", ex);
|
||||
Throwable rootCause = ex;
|
||||
while (rootCause.getCause() != null && !(rootCause instanceof CzgException)) {
|
||||
rootCause = rootCause.getCause();
|
||||
}
|
||||
String rootMsg = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
|
||||
return CzgResult.failure(CzgRespCode.FAILURE.getCode(), rootMsg);
|
||||
|
||||
// 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());
|
||||
}
|
||||
// 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(), "系统错误,请联系管理员");
|
||||
}
|
||||
|
||||
private void setErrorLog(Exception ex) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
userConfig.setIsShare(true);
|
||||
// config2.setTimeout(2000);
|
||||
userConfig.setTokenStyle("simple-uuid");
|
||||
MyStpLogic.CLIENT_LOGIC.setConfig(userConfig);
|
||||
MyStpLogic.USER_LOGIC.setConfig(userConfig);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
@@ -62,18 +62,15 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
// 重置根路径,防止satoken切割根路径导致匹配不到路径
|
||||
ApplicationInfo.routePrefix = "";
|
||||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
|
||||
SaRouter
|
||||
.match("/user/**")
|
||||
.notMatch("/user/login", "/user/geo/**", "/user/home/**", "/user/dict/**", "/user/openId")
|
||||
.check(r -> MyStpLogic.USER_LOGIC.checkLogin())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
.notMatch("/user/**")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/admin/shopMsgPush/subscribe/**")
|
||||
.notMatch("/admin/coupon/grant")
|
||||
.check(r -> {
|
||||
ServletRequestAttributes attributes =
|
||||
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.function.Consumer;
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class MyStpLogic {
|
||||
public static final StpLogic CLIENT_LOGIC = new StpLogic("client");
|
||||
public static final StpLogic USER_LOGIC = new StpLogic("user");
|
||||
public static final StpLogic ADMIN_LOGIC = new StpLogic("admin");
|
||||
|
||||
public Object isPC() {
|
||||
@@ -42,7 +42,7 @@ public class MyStpLogic {
|
||||
private StpLogic getLogic() {
|
||||
boolean hit = SaRouter.match("/user/**").isHit();
|
||||
if (hit) {
|
||||
return CLIENT_LOGIC;
|
||||
return USER_LOGIC;
|
||||
}
|
||||
return ADMIN_LOGIC;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
||||
/**
|
||||
* 分销员中心-获取邀请码
|
||||
*/
|
||||
String getInviteCode(Long shopId, Long shopUserId) throws CzgException;
|
||||
String getInviteCode(Long shopId, Long shopUserId) throws CzgException, ValidateException ;
|
||||
|
||||
/**
|
||||
* 分销员中心-实名认证
|
||||
|
||||
@@ -58,8 +58,13 @@ public class LtPayOtherDTO {
|
||||
* 对应的记录Id 支付回调向该内容进行回填
|
||||
* 积分商品为 mk_points_goods_record 主键id
|
||||
* 团购商品为 gb_order_detail 主键id
|
||||
*
|
||||
*/
|
||||
private Long recordId;
|
||||
/**
|
||||
* 霸王餐充值为 订单id 会员充值为 活动id
|
||||
*/
|
||||
private Long relatedId;
|
||||
|
||||
public void checkPayInfo(){
|
||||
AssertUtil.isBlank(payType, "支付方式不能为空");
|
||||
|
||||
@@ -38,7 +38,7 @@ public class FunUtils {
|
||||
func.run();
|
||||
} catch (Exception e) {
|
||||
String message = NestedExceptionUtils.getMostSpecificCause(e).getMessage();
|
||||
log.warn(msg.length > 0 ? msg[0] : "方法执行失败: {}", message);
|
||||
log.warn((msg.length > 0 ? msg[0] : "方法执行失败") + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user