From e44d9fe136efff873a9fd997ef4453fab56d03e4 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 10:37:06 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix=EF=BC=9A=E3=80=90mall=20=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E3=80=91=E4=BC=98=E6=83=A0=E5=8A=B5=E5=9C=A8=E2=80=9C?= =?UTF-8?q?=E9=A2=86=E5=8F=96=E4=B9=8B=E5=90=8E=E2=80=9D=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E8=AE=A1=E7=AE=97=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/convert/coupon/CouponConvert.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java b/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java index 0ac9c58da1..6af2f65cb5 100755 --- a/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java +++ b/yudao-module-mall/yudao-module-promotion/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java @@ -30,7 +30,7 @@ public interface CouponConvert { CouponRespDTO convert(CouponDO bean); default CouponDO convert(CouponTemplateDO template, Long userId) { - CouponDO couponDO = new CouponDO() + CouponDO coupon = new CouponDO() .setTemplateId(template.getId()) .setName(template.getName()) .setTakeType(template.getTakeType()) @@ -44,13 +44,13 @@ public interface CouponConvert { .setStatus(CouponStatusEnum.UNUSED.getStatus()) .setUserId(userId); if (CouponTemplateValidityTypeEnum.DATE.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(template.getValidStartTime()); - couponDO.setValidEndTime(template.getValidEndTime()); + coupon.setValidStartTime(template.getValidStartTime()); + coupon.setValidEndTime(template.getValidEndTime()); } else if (CouponTemplateValidityTypeEnum.TERM.getType().equals(template.getValidityType())) { - couponDO.setValidStartTime(LocalDateTime.now().plusDays(template.getFixedStartTerm())); - couponDO.setValidEndTime(LocalDateTime.now().plusDays(template.getFixedEndTerm())); + coupon.setValidStartTime(LocalDateTime.now().plusDays(template.getFixedStartTerm())); + coupon.setValidEndTime(coupon.getValidStartTime().plusDays(template.getFixedEndTerm())); } - return couponDO; + return coupon; } CouponPageReqVO convert(AppCouponPageReqVO pageReqVO, Collection userIds); From ba068c353a0411ea7689cbe6a73996e541d91eb8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 10:46:50 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat=EF=BC=9A=E3=80=90framework=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91=E5=A2=9E=E5=8A=A0=E5=AF=B9=20MaxUploadSizeEx?= =?UTF-8?q?ceededException=20=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E8=BF=87?= =?UTF-8?q?=E5=A4=A7=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/core/handler/GlobalExceptionHandler.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java index 22234ba3bf..43f4c1cfdf 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java @@ -36,6 +36,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; +import org.springframework.web.multipart.MaxUploadSizeExceededException; import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.resource.NoResourceFoundException; @@ -93,6 +94,9 @@ public class GlobalExceptionHandler { if (ex instanceof ValidationException) { return validationException((ValidationException) ex); } + if (ex instanceof MaxUploadSizeExceededException) { + return maxUploadSizeExceededExceptionHandler((MaxUploadSizeExceededException) ex); + } if (ex instanceof NoHandlerFoundException) { return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex); } @@ -213,6 +217,14 @@ public class GlobalExceptionHandler { return CommonResult.error(BAD_REQUEST); } + /** + * 处理上传文件过大异常 + */ + @ExceptionHandler(MaxUploadSizeExceededException.class) + public CommonResult maxUploadSizeExceededExceptionHandler(MaxUploadSizeExceededException ex) { + return CommonResult.error(BAD_REQUEST.getCode(), "上传文件过大,请调整后重试"); + } + /** * 处理 SpringMVC 请求地址不存在 * From b5d5fa8ea4167468f84e37b0926166f3d2799def Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 10:56:13 +0800 Subject: [PATCH 3/7] =?UTF-8?q?fix=EF=BC=9A=E3=80=90mall=20=E5=95=86?= =?UTF-8?q?=E5=9F=8E=E3=80=91=E9=97=A8=E5=BA=97=E8=87=AA=E6=8F=90=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E7=BC=BA=E5=B0=91=E4=B8=8A=E4=BC=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=89=A9=E6=B5=81=E4=BF=A1=E6=81=AF=E5=88=B0=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TradeStatusSyncToWxaOrderHandler.java | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java b/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java index 8bd1a802ea..5d436727ae 100644 --- a/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java +++ b/yudao-module-mall/yudao-module-trade/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeStatusSyncToWxaOrderHandler.java @@ -42,6 +42,40 @@ public class TradeStatusSyncToWxaOrderHandler implements TradeOrderHandler { if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) { return; } + + // 上传订单物流信息到微信小程序 + uploadWxaOrderShippingInfo(order); + } + + @Override + public void afterReceiveOrder(TradeOrderDO order) { + // 注意:只有微信小程序支付的订单,才需要同步 + if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) { + return; + } + PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId()); + SocialWxaOrderNotifyConfirmReceiveReqDTO reqDTO = new SocialWxaOrderNotifyConfirmReceiveReqDTO() + .setTransactionId(payOrder.getChannelOrderNo()) + .setReceivedTime(order.getReceiveTime()); + try { + socialClientApi.notifyWxaOrderConfirmReceive(UserTypeEnum.MEMBER.getValue(), reqDTO); + } catch (Exception ex) { + log.error("[afterReceiveOrder][订单({}) 通知订单收货到微信小程序失败]", order, ex); + } + + // 如果是门店自提订单,上传订单物流信息到微信小程序 + // 原因是,门店自提订单没有 “afterDeliveryOrder” 阶段。可见 https://t.zsxq.com/KWD3u 反馈 + if (DeliveryTypeEnum.PICK_UP.getType().equals(order.getDeliveryType())) { + uploadWxaOrderShippingInfo(order); + } + } + + /** + * 上传订单物流信息到微信小程序 + * + * @param order 订单 + */ + private void uploadWxaOrderShippingInfo(TradeOrderDO order) { PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId()); SocialWxaOrderUploadShippingInfoReqDTO reqDTO = new SocialWxaOrderUploadShippingInfoReqDTO() .setTransactionId(payOrder.getChannelOrderNo()) @@ -64,23 +98,6 @@ public class TradeStatusSyncToWxaOrderHandler implements TradeOrderHandler { } } - @Override - public void afterReceiveOrder(TradeOrderDO order) { - // 注意:只有微信小程序支付的订单,才需要同步 - if (ObjUtil.notEqual(order.getPayChannelCode(), PayChannelEnum.WX_LITE.getCode())) { - return; - } - PayOrderRespDTO payOrder = payOrderApi.getOrder(order.getPayOrderId()); - SocialWxaOrderNotifyConfirmReceiveReqDTO reqDTO = new SocialWxaOrderNotifyConfirmReceiveReqDTO() - .setTransactionId(payOrder.getChannelOrderNo()) - .setReceivedTime(order.getReceiveTime()); - try { - socialClientApi.notifyWxaOrderConfirmReceive(UserTypeEnum.MEMBER.getValue(), reqDTO); - } catch (Exception ex) { - log.error("[afterReceiveOrder][订单({}) 通知订单收货到微信小程序失败]", order, ex); - } - } - // TODO @芋艿:【设置路径】 https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/order-shipping/order-shipping.html#%E5%85%AD%E3%80%81%E6%B6%88%E6%81%AF%E8%B7%B3%E8%BD%AC%E8%B7%AF%E5%BE%84%E8%AE%BE%E7%BD%AE%E6%8E%A5%E5%8F%A3 } From 2e47ffdba1b9b92a15c6d94f6caa8a97d6978efc Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 11:24:31 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fix=EF=BC=9A=E3=80=90framework=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91MyBatisUtils=20addOrder=20=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E5=85=BC=E5=AE=B9=20LambdaQueryWrapper=20=E5=9C=BA?= =?UTF-8?q?=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/core/util/MyBatisUtils.java | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java index ac33ba8eff..56f51d91df 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/util/MyBatisUtils.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.pojo.SortingField; import cn.iocoder.yudao.framework.mybatis.core.enums.DbTypeEnum; import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.toolkit.StringPool; @@ -47,16 +48,36 @@ public class MyBatisUtils { return page; } + @SuppressWarnings("PatternVariableCanBeUsed") public static void addOrder(Wrapper wrapper, Collection sortingFields) { if (CollUtil.isEmpty(sortingFields)) { return; } - QueryWrapper query = (QueryWrapper) wrapper; - for (SortingField sortingField : sortingFields) { - query.orderBy(true, - SortingField.ORDER_ASC.equals(sortingField.getOrder()), - StrUtil.toUnderlineCase(sortingField.getField())); + if (wrapper instanceof QueryWrapper) { + QueryWrapper query = (QueryWrapper) wrapper; + for (SortingField sortingField : sortingFields) { + query.orderBy(true, + SortingField.ORDER_ASC.equals(sortingField.getOrder()), + StrUtil.toUnderlineCase(sortingField.getField())); + } + } else if (wrapper instanceof LambdaQueryWrapper) { + // LambdaQueryWrapper 不直接支持字符串字段排序,使用 last 方法拼接 ORDER BY + LambdaQueryWrapper lambdaQuery = (LambdaQueryWrapper) wrapper; + StringBuilder orderBy = new StringBuilder(); + for (SortingField sortingField : sortingFields) { + if (StrUtil.isNotEmpty(orderBy)) { + orderBy.append(", "); + } + orderBy.append(StrUtil.toUnderlineCase(sortingField.getField())) + .append(" ") + .append(SortingField.ORDER_ASC.equals(sortingField.getOrder()) ? "ASC" : "DESC"); + } + lambdaQuery.last("ORDER BY " + orderBy); + // 另外个思路:https://blog.csdn.net/m0_59084856/article/details/138450913 + } else { + throw new IllegalArgumentException("Unsupported wrapper type: " + wrapper.getClass().getName()); } + } /** From dac0c278bf69402c1a1ef3d1633cd8b2fde7c4ad Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 11:35:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat=EF=BC=9A=E3=80=90framework=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91ApiEncryptFilter=20=E7=9A=84=20getApiEncrypt?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=88=90=20jdk8=20=E5=86=99=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E5=A5=BD=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/framework/encrypt/core/filter/ApiEncryptFilter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java index e6d03ba32b..1216ffeb60 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/encrypt/core/filter/ApiEncryptFilter.java @@ -128,6 +128,7 @@ public class ApiEncryptFilter extends ApiRequestFilter { * * @param request 请求 */ + @SuppressWarnings("PatternVariableCanBeUsed") private ApiEncrypt getApiEncrypt(HttpServletRequest request) { try { HandlerExecutionChain mappingHandler = requestMappingHandlerMapping.getHandler(request); @@ -135,7 +136,8 @@ public class ApiEncryptFilter extends ApiRequestFilter { return null; } Object handler = mappingHandler.getHandler(); - if (handler instanceof HandlerMethod handlerMethod) { + if (handler instanceof HandlerMethod) { + HandlerMethod handlerMethod = (HandlerMethod) handler; ApiEncrypt annotation = handlerMethod.getMethodAnnotation(ApiEncrypt.class); if (annotation == null) { annotation = handlerMethod.getBeanType().getAnnotation(ApiEncrypt.class); From 3adfeb372959f43d791579757395422b08c2de5d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 14:58:34 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix=EF=BC=9A=E3=80=90framework=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91YudaoTracerAutoConfiguration=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BF=85=E9=A1=BB=E5=AD=98=E5=9C=A8=20Filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/tracer/config/YudaoTracerAutoConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java index 7876742620..14a8a974f2 100644 --- a/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-monitor/src/main/java/cn/iocoder/yudao/framework/tracer/config/YudaoTracerAutoConfiguration.java @@ -21,7 +21,8 @@ import org.springframework.context.annotation.Bean; @AutoConfiguration @ConditionalOnClass(name = { "org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer", - "io.opentracing.Tracer" + "io.opentracing.Tracer", + "jakarta.servlet.Filter" }) @EnableConfigurationProperties(TracerProperties.class) @ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true) From 5b6723fc3c7fd7813acd324b23ce66d4e52546b8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 17 Aug 2025 15:24:04 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix=EF=BC=9A=E3=80=90framework=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E3=80=91GlobalExceptionHandler=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=20ServiceException=20=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/core/handler/GlobalExceptionHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java index 43f4c1cfdf..3f3a871a13 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java @@ -115,9 +115,6 @@ public class GlobalExceptionHandler { if (ex instanceof AccessDeniedException) { return accessDeniedExceptionHandler(request, (AccessDeniedException) ex); } - if (ex instanceof UncheckedExecutionException && ex.getCause() != ex) { - return allExceptionHandler(request, ex.getCause()); - } return defaultExceptionHandler(request, ex); } @@ -321,6 +318,12 @@ public class GlobalExceptionHandler { */ @ExceptionHandler(value = Exception.class) public CommonResult defaultExceptionHandler(HttpServletRequest req, Throwable ex) { + // 特殊:如果是 ServiceException 的异常,则直接返回 + // 例如说:https://gitee.com/zhijiantianya/yudao-cloud/issues/ICSSRM、https://gitee.com/zhijiantianya/yudao-cloud/issues/ICT6FM + if (ex.getCause() != null && ex.getCause() instanceof ServiceException) { + return serviceExceptionHandler((ServiceException) ex.getCause()); + } + // 情况一:处理表不存在的异常 CommonResult tableNotExistsResult = handleTableNotExists(ex); if (tableNotExistsResult != null) {