1、完善组织产品有效性的检查能力:增加延期记录的范围检查;2、购买记录查询/导出字段修正;

This commit is contained in:
gaoqr
2025-09-24 11:36:24 +08:00
parent c070584159
commit 89179c2c80
8 changed files with 141 additions and 70 deletions
@@ -30,8 +30,4 @@ public class DictTypeConstants {
public static final String PLATE_TEXTURE_TYPE = "plate_texture_type";// 板材纹路:0有 1无
public static final String ADVERTISEMENT_POSITION = "advertisement_position";
public static final String PURCHASE_PAYMENT_METHOD = "diffPayStyle"; // 产品购买方式
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.system.api.organ;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.OrderStatisticsUnit;
import com.cf.imes.framework.common.pojo.CommonResult;
@@ -7,9 +8,11 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsIsLapseRespDTO;
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
import com.cf.imes.module.system.api.organ.dto.OrganizationDTO;
import com.cf.imes.module.system.controller.admin.funds.delay.vo.PreviouProductDelayRespVO;
import com.cf.imes.module.system.controller.admin.funds.delay.vo.ProductDelayRespVO;
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganRespVO;
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;
import com.cf.imes.module.system.service.funds.purchase.PurchaseService;
import com.cf.imes.module.system.service.funds.delay.ProductDelayService;
import com.cf.imes.module.system.service.organ.OrganService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -34,8 +37,7 @@ public class OrganApiImpl implements OrganApi {
private OrganService organService;
@Resource
private PurchaseService purchaseService;
private ProductDelayService productDelayService;
@Override
public CommonResult<List<Long>> getOrganIdList() {
@@ -144,12 +146,23 @@ public class OrganApiImpl implements OrganApi {
@Override
public CommonResult<Boolean> validOrganProduct(Long organId, Long productId) {
List<PurchaseRecordDO> purchaseList = purchaseService.getOrgProductPurchaseList(organId, productId);
// 如果购买记录存在大于等于当前时间的记录,则是有效期内
boolean anyMatch = purchaseList.stream().anyMatch(p -> p.getEndTime().isAfter(LocalDate.now()) || p.getEndTime().isEqual(LocalDate.now()));
if (!anyMatch) {
PreviouProductDelayRespVO recordsByProductId = productDelayService.getActiveRecordsByProductId(productId, organId);
PurchaseRecordDO previouPurchaseRecord = recordsByProductId.getPreviouPurchaseRecord();
List<ProductDelayRespVO> delayRespVOList = recordsByProductId.getDelayRespVOList();
// 当前产品购买记录有效期是否超过当前时间
boolean productMatch = false;
if (ObjectUtil.isNotNull(previouPurchaseRecord)) {
productMatch = previouPurchaseRecord.getEndTime().isAfter(LocalDate.now());
}
// 延期记录中是否有超过当前时间的记录
boolean delayMatch = false;
if (CollUtil.isNotEmpty(delayRespVOList)) {
delayMatch = delayRespVOList.stream().anyMatch(item -> item.getDelayTime().isAfter(LocalDate.now()));
}
// 产品过期且没有有效的延期记录时,提示产品已过期
if (!productMatch && !delayMatch) {
throw exception(ORG_PRODUCT_EXPIRED);
}
return success(anyMatch);
return success(true);
}
}
@@ -1,10 +1,13 @@
package com.cf.imes.module.system.controller.admin.funds.purchase;
import cn.hutool.core.bean.BeanUtil;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.excel.core.util.ExcelUtils;
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.ManagePurchaseRecordRespVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordPageReqVO;
import com.cf.imes.module.system.controller.admin.funds.purchase.vo.PurchaseRecordRespVO;
import com.cf.imes.module.system.service.funds.purchase.PurchaseService;
@@ -52,7 +55,13 @@ public class PurchaseController {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PurchaseRecordRespVO> list = purchaseService.getPurchaseRecord(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "软件购买记录表.xls", "数据", PurchaseRecordRespVO.class, list);
if (SecurityFrameworkUtils.isManageEndPoint()) {
// 导出 Excel
List<ManagePurchaseRecordRespVO> managePurchaseRecordRespVOS = BeanUtil.copyToList(list, ManagePurchaseRecordRespVO.class);
ExcelUtils.write(response, "软件购买记录表.xls", "数据", ManagePurchaseRecordRespVO.class, managePurchaseRecordRespVOS);
} else {
// 导出 Excel
ExcelUtils.write(response, "软件购买记录表.xls", "数据", PurchaseRecordRespVO.class, list);
}
}
}
@@ -0,0 +1,76 @@
package com.cf.imes.module.system.controller.admin.funds.purchase.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cf.imes.framework.excel.core.annotations.EnumFormat;
import com.cf.imes.framework.excel.core.convert.EnumConvert;
import com.cf.imes.module.system.enums.pay.PayProductChannelCodeEnum;
import com.cf.imes.module.system.enums.pay.ProductDurationUnitEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class ManagePurchaseRecordRespVO {
@Schema(description = "组织名称")
@ExcelProperty("组织名称")
private String organName;
@Schema(description = "产品名称")
@ExcelProperty("产品名称")
private String productName;
@Schema(description = "购买时长", example = "1")
@ExcelProperty("购买时长")
private Integer purchaseDuration;
@Schema(description = "购买时长单位,0:年、1:月", example = "1")
@ExcelProperty(value = "购买时长单位", converter = EnumConvert.class)
@EnumFormat(value = ProductDurationUnitEnum.class)
private Integer purchaseDurationUnit;
@Schema(description = "赠送时长", example = "1")
@ExcelProperty("赠送时长")
private Integer giftDuration;
@Schema(description = "赠送时长单位,0:年、1:月", example = "1")
@ExcelProperty(value = "赠送时长单位", converter = EnumConvert.class)
@EnumFormat(value = ProductDurationUnitEnum.class)
private Integer giftDurationUnit;
@Schema(description = "支付方式")
@ExcelProperty(value = "支付方式", converter = EnumConvert.class)
@EnumFormat(value = PayProductChannelCodeEnum.class)
private Integer paymentMethod;
@Schema(description = "订单总额")
@ExcelProperty("订单总额")
private BigDecimal totalAmount;
@Schema(description = "现金余额支出")
@ExcelProperty("现金余额支出")
private BigDecimal accountBalanceSpent;
@Schema(description = "支付宝支出")
@ExcelProperty("支付宝支出")
private BigDecimal alipaySpent;
@Schema(description = "微信支出")
@ExcelProperty("微信支出")
private BigDecimal wechatSpent;
@Schema(description = "赠送金")
@ExcelProperty("赠送金")
private BigDecimal giftMoneySpent;
@Schema(description = "购买时间")
@ExcelProperty("购买时间")
private LocalDateTime createTime;
@Schema(description = "操作人")
@ExcelProperty("操作人")
private String creator;
}
@@ -1,54 +1,38 @@
package com.cf.imes.module.system.controller.admin.funds.purchase.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cf.imes.framework.excel.core.annotations.DictFormat;
import com.cf.imes.framework.excel.core.annotations.EnumFormat;
import com.cf.imes.framework.excel.core.convert.DictConvert;
import com.cf.imes.framework.excel.core.convert.EnumConvert;
import com.cf.imes.module.system.enums.DictTypeConstants;
import com.cf.imes.module.system.enums.pay.InvoiceStatusEnum;
import com.cf.imes.module.system.enums.pay.PayProductChannelCodeEnum;
import com.cf.imes.module.system.enums.pay.ProductDurationUnitEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
@Data
public class PurchaseRecordRespVO {
@Schema(description = "购买记录ID")
@ExcelProperty("购买记录编码")
@Schema(description = "订单号")
@ExcelProperty("订单号")
private Long id;
@Schema(description = "组织ID")
@ExcelProperty("组织编号")
@ExcelIgnore
private Long organId;
@Schema(description = "产品ID")
@ExcelProperty("产品编号")
private Long productId;
@Schema(description = "产品明细ID")
@ExcelProperty("产品明细编号")
private Long productDetailsId;
@Schema(description = "组织名称")
@ExcelIgnore
private String organName;
@Schema(description = "产品名称")
@ExcelProperty("产品名称")
private String productName;
@Schema(description = "购买时长", example = "1")
@ExcelProperty("购买时长")
private Integer purchaseDuration;
@@ -68,52 +52,35 @@ public class PurchaseRecordRespVO {
private Integer giftDurationUnit;
@Schema(description = "支付方式")
@ExcelProperty(value = "支付方式", converter = DictConvert.class)
@DictFormat(DictTypeConstants.PURCHASE_PAYMENT_METHOD)
@ExcelProperty(value = "支付方式", converter = EnumConvert.class)
@EnumFormat(value = PayProductChannelCodeEnum.class)
private Integer paymentMethod;
@Schema(description = "订单总额")
@ExcelProperty("订单总额")
private BigDecimal totalAmount;
@Schema(description = "现金余额支出")
@ExcelProperty("现金余额支出")
private BigDecimal accountBalanceSpent;
@Schema(description = "支付宝支出")
@ExcelProperty("支付宝支出")
private BigDecimal alipaySpent;
@Schema(description = "微信支出")
@ExcelProperty("微信支出")
private BigDecimal wechatSpent;
@Schema(description = "赠送金")
@ExcelProperty("赠送金")
private BigDecimal giftMoneySpent;
@Schema(description = "是否开票")
@ExcelProperty(value = "是否开票", converter = EnumConvert.class)
@EnumFormat(value = InvoiceStatusEnum.class)
private Integer isInvocing;
@Schema(description = "购买时间")
@ExcelProperty("购买时间")
private LocalDateTime createTime;
@Schema(description = "失效时间")
@ExcelProperty("失效时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private LocalDate endTime;
@Schema(description = "操作人")
@ExcelProperty("操作人")
private String creator;
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.system.enums.pay;
import com.cf.imes.framework.excel.core.convert.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -11,68 +12,70 @@ import lombok.Getter;
*/
@Getter
@AllArgsConstructor
public enum PayProductChannelCodeEnum {
public enum PayProductChannelCodeEnum implements BaseEnum {
/**
* 账户余额
*/
BALANCE_ONLY(0),
BALANCE_ONLY(0, "现金"),
/**
* 赠送金
*/
GIFT_ONLY(1),
GIFT_ONLY(1, "赠送金"),
/**
* 支付宝
*/
ALIPAY_PC(2),
ALIPAY_PC(2, "支付宝"),
/**
* 微信
*/
WECHAT_NATIVE(3),
WECHAT_NATIVE(3, "微信"),
/**
* 现金+赠送金
*/
BALANCE_AND_GIFT(4),
BALANCE_AND_GIFT(4, "现金+赠送金"),
/**
* 现金+支付宝
*/
BALANCE_AND_ALIPAY(5),
BALANCE_AND_ALIPAY(5, "现金+支付宝"),
/**
* 现金+微信
*/
BALANCE_AND_WECHAT(6),
BALANCE_AND_WECHAT(6, "现金+微信"),
/**
* 赠送金+支付宝
*/
GIFT_AND_ALIPAY(7),
GIFT_AND_ALIPAY(7, "赠送金+支付宝"),
/**
* 赠送金+微信
*/
GIFT_AND_WECHAT(8),
GIFT_AND_WECHAT(8, "赠送金+微信"),
/**
* 现金+赠送金+支付宝
*/
BALANCE_AND_GIFT_AND_ALIPAY(9),
BALANCE_AND_GIFT_AND_ALIPAY(9, "现金+赠送金+支付宝"),
/**
* 现金+赠送金+微信
*/
BALANCE_AND_GIFT_AND_WECHAT(10),
BALANCE_AND_GIFT_AND_WECHAT(10, "现金+赠送金+微信"),
/**
* 组织创建首次购买
*/
ORGAN_CREATE(11);
ORGAN_CREATE(11, "首次订购");
private final Integer code;
private final String desc;
public static PayProductChannelCodeEnum fromType(Integer type) {
for (PayProductChannelCodeEnum value : values()) {
if (value.getCode().equals(type)) {
@@ -164,6 +164,7 @@ public class ProductDelayServiceImpl implements ProductDelayService {
.eq(PurchaseRecordDO::getOrganId, organId)
.eq(PurchaseRecordDO::getProductId, productId)
.eq(PurchaseRecordDO::getStatus, PurchaseRecordStatusEnum.ACTIVE.getStatus())
.eq(PurchaseRecordDO::getDeleted, false)
);
List<ProductDelayRespVO> resultList;
if(ObjectUtil.isNotNull(purchaseRecordDO)) {
@@ -92,6 +92,12 @@ public class PurchaseServiceImpl implements PurchaseService {
return new PageResult<>();
}
List<PurchaseRecordRespVO> respVOS = BeanUtils.toBean(resultList, PurchaseRecordRespVO.class);
respVOS.forEach(respVO -> {
OrganizationDO organ = organService.getOrgan(respVO.getOrganId());
if (ObjectUtil.isNotNull(organ)) {
respVO.setOrganName(organ.getName());
}
});
return new PageResult<>(respVOS, pageResult.getTotal());
}