diff --git a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/exception/enums/GlobalErrorCodeConstants.java b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/exception/enums/GlobalErrorCodeConstants.java index 2d31a3eeb..1d5fe67c9 100644 --- a/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/exception/enums/GlobalErrorCodeConstants.java +++ b/cf-framework/cf-common/src/main/java/com/cf/imes/framework/common/exception/enums/GlobalErrorCodeConstants.java @@ -26,6 +26,7 @@ public class GlobalErrorCodeConstants { public static final ErrorCode LOCKED = new ErrorCode(423, "请求失败,请稍后重试"); // 并发请求,不允许 public static final ErrorCode TOO_MANY_REQUESTS = new ErrorCode(429, "请求过于频繁,请稍后重试"); public static final ErrorCode ORG_PRODUCT_EXPIRED = new ErrorCode(410, "组织产品套餐已过期,请续费后继续使用"); + public static final ErrorCode USER_PRODUCTID_NOT_EXIST = new ErrorCode(411, "账号登录异常,套餐信息不存在,请重新登陆"); // ========== 服务端错误段 ========== diff --git a/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/security/OrganSecurityWebFilter.java b/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/security/OrganSecurityWebFilter.java index 5b79fe483..b6356b9ab 100644 --- a/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/security/OrganSecurityWebFilter.java +++ b/cf-framework/cf-spring-boot-starter-biz-organ/src/main/java/com/cf/imes/framework/organ/core/security/OrganSecurityWebFilter.java @@ -128,9 +128,16 @@ public class OrganSecurityWebFilter extends ApiRequestFilter { * @param request */ private void validOrgnProduct(LoginUser user, HttpServletRequest request) { + Long productId = user.getProductId(); + boolean isManageEndPoint = Objects.equals(user.getUserType(), UserTypeEnum.ADMIN.getValue()); // 非管理端校验产品的有效性 - if (!Objects.equals(user.getUserType(), UserTypeEnum.ADMIN.getValue()) && !isProductIgnoreUrl(request)) { - organFrameworkService.validOrgProduct(user.getOrganId(), user.getProductId()); + if (!isManageEndPoint) { + if (ObjectUtil.isNull(productId)) { + throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED.getCode(), GlobalErrorCodeConstants.USER_PRODUCTID_NOT_EXIST.getMsg()); + } + if (!isProductIgnoreUrl(request)) { + organFrameworkService.validOrgProduct(user.getOrganId(), productId); + } } } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/OrganController.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/OrganController.java index ad9bd0b2a..fc3d2805c 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/OrganController.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/OrganController.java @@ -25,6 +25,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import jakarta.annotation.Resource; @@ -81,7 +82,7 @@ public class OrganController { @PostMapping("/create") @Operation(summary = "创建组织") @PreAuthorize("@ss.hasPermission('organizationLIst:create')") - public CommonResult createOrgan(@Valid @RequestBody OrganSaveReqVO createReqVO) { + public CommonResult createOrgan(@Validated(OrganSaveCreateGroup.class) @RequestBody OrganSaveReqVO createReqVO) { return success(organService.createOrgan(createReqVO)); } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganCreateProductPurchaseReqVO.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganCreateProductPurchaseReqVO.java index ff757e8e2..1c43f4b67 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganCreateProductPurchaseReqVO.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganCreateProductPurchaseReqVO.java @@ -13,22 +13,22 @@ import java.time.LocalDate; @Schema(description = "管理后台 - 组织创建购买产品 Request VO") @Data public class OrganCreateProductPurchaseReqVO { - @Schema(description = "产品编号",example = "1") - @NotNull(message = "产品编号不能为空") + @Schema(description = "产品编号", example = "1") + @NotNull(message = "产品编号不能为空", groups = {OrganSaveCreateGroup.class}) private Long productId; - @Schema(description = "定价规则编号",example = "1") - @NotNull(message = "定价规则编号不能为空") + @Schema(description = "定价规则编号", example = "1") + @NotNull(message = "定价规则编号不能为空", groups = {OrganSaveCreateGroup.class}) private Long productDetailsId; @Schema(description = "产品购买金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - @NotNull(message = "产品购买金额不能为空") + @NotNull(message = "产品购买金额不能为空", groups = {OrganSaveCreateGroup.class}) @DecimalMin(value = "0.01", message = "产品购买金额必须大于零") @DecimalMax(value = "100000", message = "产品购买金额不能超过十万") @Digits(integer = 6, fraction = 2, message = "产品购买金额格式不正确") private BigDecimal price; @Schema(description = "产品有效时间") - @NotNull(message = "产品有效时间不能为空") + @NotNull(message = "产品有效时间不能为空", groups = {OrganSaveCreateGroup.class}) private LocalDate productExpireDate; } diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganSaveCreateGroup.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganSaveCreateGroup.java new file mode 100644 index 000000000..fdc26b44a --- /dev/null +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/controller/admin/organ/vo/organ/OrganSaveCreateGroup.java @@ -0,0 +1,10 @@ +package com.cf.imes.module.system.controller.admin.organ.vo.organ; + +/** + * 组织新增请求校验组 + * + * @author Gqr + * @since 2025/9/24 16:28 + */ +public interface OrganSaveCreateGroup { +} diff --git a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/funds/purchase/PurchaseServiceImpl.java b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/funds/purchase/PurchaseServiceImpl.java index 402018a0b..b9b16d9d9 100644 --- a/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/funds/purchase/PurchaseServiceImpl.java +++ b/cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/funds/purchase/PurchaseServiceImpl.java @@ -10,6 +10,7 @@ import com.cf.imes.framework.common.pojo.PageParam; import com.cf.imes.framework.common.pojo.PageResult; import com.cf.imes.framework.common.util.date.LocalDateTimeUtils; import com.cf.imes.framework.common.util.object.BeanUtils; +import com.cf.imes.module.system.controller.admin.funds.delay.vo.ProductDelayRespVO; import com.cf.imes.module.system.controller.admin.funds.organamount.vo.TotalSalesAmountRespVO; import com.cf.imes.module.system.controller.admin.funds.products.vo.productDetails.ProductDetailsPageReqVO; import com.cf.imes.module.system.controller.admin.funds.purchase.vo.OrgEarliestPurchaseProductRespVO; @@ -30,6 +31,7 @@ import com.cf.imes.module.system.enums.pay.ProductDurationUnitEnum; import com.cf.imes.module.system.enums.pay.PurchaseRecordStatusEnum; import com.cf.imes.module.system.enums.pay.TradeTypeEnum; import com.cf.imes.module.system.framework.snowflake.config.MybatisIdProperties; +import com.cf.imes.module.system.service.funds.delay.ProductDelayService; import com.cf.imes.module.system.service.funds.products.ProductsDetailService; import com.cf.imes.module.system.service.organ.OrganService; import jakarta.annotation.Resource; @@ -70,6 +72,10 @@ public class PurchaseServiceImpl implements PurchaseService { @Lazy private OrganService organService; + @Resource + @Lazy + private ProductDelayService productDelayService; + @Override public PurchaseRecordDO getRecord(Long id) { return purchaseRecordMapper.selectById(id); @@ -119,12 +125,17 @@ public class PurchaseServiceImpl implements PurchaseService { // 查询购买记录中还有效的最晚一条 PurchaseRecordDO purchaseRecordDO = purchaseRecordMapper.selectOne(new LambdaQueryWrapper() .eq(PurchaseRecordDO::getOrganId, organId) - .gt(PurchaseRecordDO::getEndTime, LocalDateTime.now()) .eq(PurchaseRecordDO::getDeleted, false) .eq(PurchaseRecordDO::getStatus, PurchaseRecordStatusEnum.ACTIVE.getStatus()) .orderByDesc(PurchaseRecordDO::getCreateTime) .last("limit 1")); if (ObjectUtil.isNotNull(purchaseRecordDO)) { + // 查询延期记录 + List recordsByPurchaseId = productDelayService.getRecordsByPurchaseId(purchaseRecordDO.getId(), organId); + if(CollUtil.isNotEmpty(recordsByPurchaseId)) { + // 延期记录是按自增id逆序的,第一条的延期后时间作为产品到期时间 + purchaseRecordDO.setEndTime(recordsByPurchaseId.get(0).getDelayTime()); + } return new OrgEarliestPurchaseProductRespVO(purchaseRecordDO, productsDetailMapper.selectById(purchaseRecordDO.getProductDetailsId())); } return null; diff --git a/cf-module-system/cf-module-system-biz/src/main/resources/application-dev.yaml b/cf-module-system/cf-module-system-biz/src/main/resources/application-dev.yaml index c415c5668..4b97c3f98 100644 --- a/cf-module-system/cf-module-system-biz/src/main/resources/application-dev.yaml +++ b/cf-module-system/cf-module-system-biz/src/main/resources/application-dev.yaml @@ -199,6 +199,12 @@ chenfeng: ignore-product-urls: - /admin-api/system/auth/get-permission-info - /admin-api/system/dict-data/list-all-simple + - /admin-api/system/amount + - /admin-api/system/organ/get + - /admin-api/system/products/available + - /admin-api/system/product-details/organ/purchase + - /admin-api/system/purchase + - /admin-api/system/pay/product ignore-tables: - system_organization - system_tenant_package diff --git a/cf-module-system/cf-module-system-biz/src/main/resources/application-local.yaml b/cf-module-system/cf-module-system-biz/src/main/resources/application-local.yaml index 056e9ee6e..1b9b6d150 100644 --- a/cf-module-system/cf-module-system-biz/src/main/resources/application-local.yaml +++ b/cf-module-system/cf-module-system-biz/src/main/resources/application-local.yaml @@ -215,6 +215,12 @@ chenfeng: ignore-product-urls: - /admin-api/system/auth/get-permission-info - /admin-api/system/dict-data/list-all-simple + - /admin-api/system/amount + - /admin-api/system/organ/get + - /admin-api/system/products/available + - /admin-api/system/product-details/organ/purchase + - /admin-api/system/purchase + - /admin-api/system/pay/product ignore-tables: - system_organization - system_tenant_package