mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 21:52:07 +08:00
1、新增BaseEnum、EnumConvert、EnumFormat:支持excel导出从枚举获取描述;2、购买记录、组织余额excel导出文件内容修正;
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.cf.imes.framework.excel.core.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典格式化注解
|
||||||
|
*
|
||||||
|
* 实现将枚举的魔值,格式化成枚举的描述
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2025/8/27 15:02
|
||||||
|
*/
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EnumFormat {
|
||||||
|
/**
|
||||||
|
* 对应的枚举类型
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Class<? extends Enum> value();
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.cf.imes.framework.excel.core.convert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础枚举接口
|
||||||
|
* <p>
|
||||||
|
* 用于easyexcel convert
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2025/8/27 11:51
|
||||||
|
*/
|
||||||
|
public interface BaseEnum {
|
||||||
|
/**
|
||||||
|
* 魔值
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer getCode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getDesc();
|
||||||
|
}
|
||||||
+73
@@ -0,0 +1,73 @@
|
|||||||
|
package com.cf.imes.framework.excel.core.convert;
|
||||||
|
|
||||||
|
import com.alibaba.excel.converters.Converter;
|
||||||
|
import com.alibaba.excel.converters.ReadConverterContext;
|
||||||
|
import com.alibaba.excel.converters.WriteConverterContext;
|
||||||
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||||
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||||
|
import com.cf.imes.framework.excel.core.annotations.EnumFormat;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel 枚举转换器
|
||||||
|
*
|
||||||
|
* @author Gqr
|
||||||
|
* @since 2025/8/27 11:02
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class EnumConvert implements Converter<Integer> {
|
||||||
|
@Override
|
||||||
|
public Class<?> supportJavaTypeKey() {
|
||||||
|
return Integer.class; // 泛型接口
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CellDataTypeEnum supportExcelTypeKey() {
|
||||||
|
return CellDataTypeEnum.STRING; // Excel 存字符串
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写出:Integer -> 枚举描述
|
||||||
|
@Override
|
||||||
|
public WriteCellData<String> convertToExcelData(WriteConverterContext<Integer> context) {
|
||||||
|
Integer code = context.getValue();
|
||||||
|
if (code == null) {
|
||||||
|
return new WriteCellData<>("");
|
||||||
|
}
|
||||||
|
Class<? extends Enum<?>> enumClass = getEnumClass(context.getContentProperty().getField());
|
||||||
|
if (enumClass != null) {
|
||||||
|
for (Object e : enumClass.getEnumConstants()) {
|
||||||
|
BaseEnum baseEnum = (BaseEnum) e;
|
||||||
|
if (baseEnum.getCode().equals(code)) {
|
||||||
|
return new WriteCellData<>(baseEnum.getDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new WriteCellData<>("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读入:枚举描述 -> Integer code
|
||||||
|
@Override
|
||||||
|
public Integer convertToJavaData(ReadConverterContext<?> context) {
|
||||||
|
String desc = context.getReadCellData().getStringValue();
|
||||||
|
if (desc == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Class<? extends Enum<?>> enumClass = getEnumClass(context.getContentProperty().getField());
|
||||||
|
if (enumClass != null) {
|
||||||
|
for (Object e : enumClass.getEnumConstants()) {
|
||||||
|
BaseEnum baseEnum = (BaseEnum) e;
|
||||||
|
if (baseEnum.getDesc().equals(desc)) {
|
||||||
|
return baseEnum.getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Class<? extends Enum<?>> getEnumClass(Field field) {
|
||||||
|
EnumFormat annotation = field.getAnnotation(EnumFormat.class);
|
||||||
|
return annotation != null ? annotation.value() : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -32,5 +32,6 @@ public class DictTypeConstants {
|
|||||||
|
|
||||||
|
|
||||||
public static final String ADVERTISEMENT_POSITION = "advertisement_position";
|
public static final String ADVERTISEMENT_POSITION = "advertisement_position";
|
||||||
|
public static final String PURCHASE_PAYMENT_METHOD = "diffPayStyle"; // 产品购买方式
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -1,6 +1,11 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.funds.balancedetails.vo;
|
package com.cf.imes.module.system.controller.admin.funds.balancedetails.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
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.IncomeExpenseTypeEnum;
|
||||||
|
import com.cf.imes.module.system.enums.pay.TradeTypeEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -17,11 +22,14 @@ public class BalanceDetailsRespVO {
|
|||||||
|
|
||||||
|
|
||||||
@Schema(description = "交易类型,0充值 1软件购买")
|
@Schema(description = "交易类型,0充值 1软件购买")
|
||||||
@ExcelProperty("交易类型")
|
@ExcelProperty(value = "交易类型",converter = EnumConvert.class)
|
||||||
|
@EnumFormat(value = TradeTypeEnum.class)
|
||||||
private Integer tradeType;
|
private Integer tradeType;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "收支类型,0收入 1支出")
|
@Schema(description = "收支类型,0收入 1支出")
|
||||||
|
@ExcelProperty(value = "收支类型",converter = EnumConvert.class)
|
||||||
|
@EnumFormat(value = IncomeExpenseTypeEnum.class)
|
||||||
private Integer incomeExpenseType;
|
private Integer incomeExpenseType;
|
||||||
|
|
||||||
|
|
||||||
@@ -71,11 +79,13 @@ public class BalanceDetailsRespVO {
|
|||||||
|
|
||||||
|
|
||||||
@Schema(description = "支出/入账现金金额")
|
@Schema(description = "支出/入账现金金额")
|
||||||
|
@ExcelIgnore
|
||||||
private BigDecimal cashAmountChange;
|
private BigDecimal cashAmountChange;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "支出/入账赠送金金额")
|
@Schema(description = "支出/入账赠送金金额")
|
||||||
|
@ExcelIgnore
|
||||||
private BigDecimal giftAmountChange;
|
private BigDecimal giftAmountChange;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+33
-10
@@ -1,6 +1,14 @@
|
|||||||
package com.cf.imes.module.system.controller.admin.funds.purchase.vo;
|
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.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.DurationUnitEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -13,78 +21,93 @@ public class PurchaseRecordRespVO {
|
|||||||
|
|
||||||
|
|
||||||
@Schema(description = "购买记录ID")
|
@Schema(description = "购买记录ID")
|
||||||
|
@ExcelProperty("购买记录编码")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "组织ID")
|
@Schema(description = "组织ID")
|
||||||
|
@ExcelProperty("组织编号")
|
||||||
private Long organId;
|
private Long organId;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "产品ID")
|
@Schema(description = "产品ID")
|
||||||
|
@ExcelProperty("产品编号")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "产品明细ID")
|
@Schema(description = "产品明细ID")
|
||||||
|
@ExcelProperty("产品明细编号")
|
||||||
private Long productDetailsId;
|
private Long productDetailsId;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "产品名称")
|
@Schema(description = "产品名称")
|
||||||
|
@ExcelProperty("产品名称")
|
||||||
private String productName;
|
private String productName;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "购买时长", example = "1")
|
@Schema(description = "购买时长", example = "1")
|
||||||
|
@ExcelProperty("购买时长")
|
||||||
private Integer purchaseDuration;
|
private Integer purchaseDuration;
|
||||||
|
|
||||||
@Schema(description = "购买时长单位,0:年、1:月、2:日", example = "1")
|
@Schema(description = "购买时长单位,0:年、1:月、2:日", example = "1")
|
||||||
|
@ExcelProperty(value = "购买时长单位", converter = EnumConvert.class)
|
||||||
|
@EnumFormat(value = DurationUnitEnum.class)
|
||||||
private Integer purchaseDurationUnit;
|
private Integer purchaseDurationUnit;
|
||||||
|
|
||||||
@Schema(description = "赠送时长", example = "1")
|
@Schema(description = "赠送时长", example = "1")
|
||||||
|
@ExcelProperty("赠送时长")
|
||||||
private Integer giftDuration;
|
private Integer giftDuration;
|
||||||
|
|
||||||
@Schema(description = "赠送时长单位,0:年、1:月、2:日", example = "1")
|
@Schema(description = "赠送时长单位,0:年、1:月、2:日", example = "1")
|
||||||
|
@ExcelProperty(value = "赠送时长单位", converter = EnumConvert.class)
|
||||||
|
@EnumFormat(value = DurationUnitEnum.class)
|
||||||
private Integer giftDurationUnit;
|
private Integer giftDurationUnit;
|
||||||
|
|
||||||
@Schema(description = "支付方式")
|
@Schema(description = "支付方式")
|
||||||
|
@ExcelProperty(value = "支付方式", converter = DictConvert.class)
|
||||||
|
@DictFormat(DictTypeConstants.PURCHASE_PAYMENT_METHOD)
|
||||||
private Integer paymentMethod;
|
private Integer paymentMethod;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "订单总额")
|
@Schema(description = "订单总额")
|
||||||
|
@ExcelProperty("订单总额")
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "现金余额支出")
|
@Schema(description = "现金余额支出")
|
||||||
|
@ExcelProperty("现金余额支出")
|
||||||
private BigDecimal accountBalanceSpent;
|
private BigDecimal accountBalanceSpent;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "支付宝支出")
|
@Schema(description = "支付宝支出")
|
||||||
|
@ExcelProperty("支付宝支出")
|
||||||
private BigDecimal alipaySpent;
|
private BigDecimal alipaySpent;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "微信支出")
|
@Schema(description = "微信支出")
|
||||||
|
@ExcelProperty("微信支出")
|
||||||
private BigDecimal wechatSpent;
|
private BigDecimal wechatSpent;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "赠送金")
|
@Schema(description = "赠送金")
|
||||||
|
@ExcelProperty("赠送金")
|
||||||
private BigDecimal giftMoneySpent;
|
private BigDecimal giftMoneySpent;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "货币类型")
|
|
||||||
private Integer currency;
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "货币单位")
|
|
||||||
private String currencyUnit;
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "是否开票")
|
@Schema(description = "是否开票")
|
||||||
|
@ExcelProperty(value = "是否开票", converter = EnumConvert.class)
|
||||||
|
@EnumFormat(value = InvoiceStatusEnum.class)
|
||||||
private Integer isInvocing;
|
private Integer isInvocing;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "购买时间")
|
@Schema(description = "购买时间")
|
||||||
|
@ExcelProperty("购买时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "失效时间")
|
||||||
|
@ExcelProperty("失效时间")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
@Schema(description = "操作人")
|
@Schema(description = "操作人")
|
||||||
|
@ExcelProperty("操作人")
|
||||||
private String creator;
|
private String creator;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public interface PurchaseRecordMapper extends BaseMapperX<PurchaseRecordDO> {
|
|||||||
.leIfPresent(PurchaseRecordDO::getTotalAmount, ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[1] : null)
|
.leIfPresent(PurchaseRecordDO::getTotalAmount, ObjectUtil.isNotNull(pageReqVO.getInvoiceAmount()) ? pageReqVO.getInvoiceAmount()[1] : null)
|
||||||
.eq(PurchaseRecordDO::getOrganId, SecurityFrameworkUtils.getUserOrganId())
|
.eq(PurchaseRecordDO::getOrganId, SecurityFrameworkUtils.getUserOrganId())
|
||||||
.eq(PurchaseRecordDO::getDeleted, false)
|
.eq(PurchaseRecordDO::getDeleted, false)
|
||||||
.in(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.INVOICABLE.getStatus(), InvoiceStatusEnum.INVOICINGFAILED.getStatus())
|
.in(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.INVOICABLE.getCode(), InvoiceStatusEnum.INVOICINGFAILED.getCode())
|
||||||
.orderByDesc(PurchaseRecordDO::getCreateTime)
|
.orderByDesc(PurchaseRecordDO::getCreateTime)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+10
-9
@@ -1,6 +1,7 @@
|
|||||||
package com.cf.imes.module.system.enums.products;
|
package com.cf.imes.module.system.enums.pay;
|
||||||
|
|
||||||
import com.cf.imes.framework.common.core.IntArrayValuable;
|
import com.cf.imes.framework.common.core.IntArrayValuable;
|
||||||
|
import com.cf.imes.framework.excel.core.convert.BaseEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -14,22 +15,22 @@ import java.util.Objects;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum DurationUnitEnum implements IntArrayValuable {
|
public enum DurationUnitEnum implements IntArrayValuable, BaseEnum {
|
||||||
|
|
||||||
YEAR(0, "年"),
|
YEAR(0, "年"),
|
||||||
MONTH(1, "月"),
|
MONTH(1, "月"),
|
||||||
DAY(2, "日");
|
DAY(2, "日");
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DurationUnitEnum::getStatus).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DurationUnitEnum::getCode).toArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态值
|
* 状态值
|
||||||
*/
|
*/
|
||||||
private final Integer status;
|
private final Integer code;
|
||||||
/**
|
/**
|
||||||
* 状态名
|
* 状态名
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String desc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] array() {
|
public int[] array() {
|
||||||
@@ -37,20 +38,20 @@ public enum DurationUnitEnum implements IntArrayValuable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isYear(String name) {
|
public static boolean isYear(String name) {
|
||||||
return Objects.equals(YEAR.name, name);
|
return Objects.equals(YEAR.code, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMonth(String name) {
|
public static boolean isMonth(String name) {
|
||||||
return Objects.equals(MONTH.name, name);
|
return Objects.equals(MONTH.code, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDay(String name) {
|
public static boolean isDay(String name) {
|
||||||
return Objects.equals(DAY.name, name);
|
return Objects.equals(DAY.code, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DurationUnitEnum fromStatus(Integer status) {
|
public static DurationUnitEnum fromStatus(Integer status) {
|
||||||
return Arrays.stream(values())
|
return Arrays.stream(values())
|
||||||
.filter(bean -> Objects.equals(bean.status, status))
|
.filter(bean -> Objects.equals(bean.code, status))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
+5
-4
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.enums.pay;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.cf.imes.framework.excel.core.convert.BaseEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum IncomeExpenseTypeEnum {
|
public enum IncomeExpenseTypeEnum implements BaseEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 收入
|
* 收入
|
||||||
@@ -27,12 +28,12 @@ public enum IncomeExpenseTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
private final Integer type;
|
private final Integer code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String desc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ public enum IncomeExpenseTypeEnum {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (IncomeExpenseTypeEnum value : values()) {
|
for (IncomeExpenseTypeEnum value : values()) {
|
||||||
if (ObjectUtil.equal(value.getType(), type)) {
|
if (ObjectUtil.equal(value.code, type)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.enums.pay;
|
|||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.cf.imes.framework.excel.core.convert.BaseEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum InvoiceStatusEnum {
|
public enum InvoiceStatusEnum implements BaseEnum {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,13 +37,12 @@ public enum InvoiceStatusEnum {
|
|||||||
/**
|
/**
|
||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private final Integer status;
|
private final Integer code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 名称
|
* 名称
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String desc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static InvoiceStatusEnum fromType(Integer status) {
|
public static InvoiceStatusEnum fromType(Integer status) {
|
||||||
@@ -50,7 +50,7 @@ public enum InvoiceStatusEnum {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (InvoiceStatusEnum value : values()) {
|
for (InvoiceStatusEnum value : values()) {
|
||||||
if (ObjectUtil.equal(value.getStatus(), status)) {
|
if (ObjectUtil.equal(value.code, status)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.module.system.enums.pay;
|
package com.cf.imes.module.system.enums.pay;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.excel.core.convert.BaseEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -10,19 +11,21 @@ import lombok.Getter;
|
|||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum TradeTypeEnum {
|
public enum TradeTypeEnum implements BaseEnum {
|
||||||
/**
|
/**
|
||||||
* 充值
|
* 充值
|
||||||
*/
|
*/
|
||||||
RECHARGE(0),
|
RECHARGE(0, "充值"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品购买
|
* 产品购买
|
||||||
*/
|
*/
|
||||||
PRODUCT(1);
|
PRODUCT(1, "产品购买");
|
||||||
|
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
public static TradeTypeEnum fromCode(Integer code) {
|
public static TradeTypeEnum fromCode(Integer code) {
|
||||||
for (TradeTypeEnum value : TradeTypeEnum.values()) {
|
for (TradeTypeEnum value : TradeTypeEnum.values()) {
|
||||||
if (value.code.equals(code)) {
|
if (value.code.equals(code)) {
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ public class IncomeExpenseServiceImpl implements IncomeExpenseService {
|
|||||||
|
|
||||||
// 根据收支类型赋值对应的 支出/收入字段
|
// 根据收支类型赋值对应的 支出/收入字段
|
||||||
result.getList().forEach(f -> {
|
result.getList().forEach(f -> {
|
||||||
if (IncomeExpenseTypeEnum.INCOME.getType().equals(f.getIncomeExpenseType())) {
|
if (IncomeExpenseTypeEnum.INCOME.getCode().equals(f.getIncomeExpenseType())) {
|
||||||
f.setEntryAmount(f.getCashAmountChange());
|
f.setEntryAmount(f.getCashAmountChange());
|
||||||
f.setEntryGiftAmount(f.getGiftAmountChange());
|
f.setEntryGiftAmount(f.getGiftAmountChange());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+8
-8
@@ -159,7 +159,7 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||||||
.eq(PurchaseRecordDO::getOrganId, organId)
|
.eq(PurchaseRecordDO::getOrganId, organId)
|
||||||
.eq(PurchaseRecordDO::getDeleted, false)
|
.eq(PurchaseRecordDO::getDeleted, false)
|
||||||
.in(PurchaseRecordDO::getId, purchaseRecordId)
|
.in(PurchaseRecordDO::getId, purchaseRecordId)
|
||||||
.set(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.PENDINGINVOICING.getStatus()));
|
.set(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.PENDINGINVOICING.getCode()));
|
||||||
if (update != purchaseRecordId.size()) {
|
if (update != purchaseRecordId.size()) {
|
||||||
throw new ServiceException(ORG_INVOICE_PURCHASE_RECORD_UPDATE_NUM_NOT_MATCH_ERROR);
|
throw new ServiceException(ORG_INVOICE_PURCHASE_RECORD_UPDATE_NUM_NOT_MATCH_ERROR);
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||||||
.invoiceAmount(invoicableAmount)
|
.invoiceAmount(invoicableAmount)
|
||||||
.invoiceTitleId(invoiceTitleInfoDO.getId())
|
.invoiceTitleId(invoiceTitleInfoDO.getId())
|
||||||
.invoiceTitleInfo(zipString(toJsonString(invoiceTitleInfoDO)))
|
.invoiceTitleInfo(zipString(toJsonString(invoiceTitleInfoDO)))
|
||||||
.status(InvoiceStatusEnum.PENDINGINVOICING.getStatus())
|
.status(InvoiceStatusEnum.PENDINGINVOICING.getCode())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,8 +241,8 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||||||
// 校验发票申请记录是否存在
|
// 校验发票申请记录是否存在
|
||||||
InvoiceRecordsDO invoiceRecordsDO = validateInvoiceExists(reqVO.getId());
|
InvoiceRecordsDO invoiceRecordsDO = validateInvoiceExists(reqVO.getId());
|
||||||
|
|
||||||
if (invoiceRecordsDO.getStatus().equals(InvoiceStatusEnum.INVOICINGFAILED.getStatus())
|
if (invoiceRecordsDO.getStatus().equals(InvoiceStatusEnum.INVOICINGFAILED.getCode())
|
||||||
|| invoiceRecordsDO.getStatus().equals(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getStatus())) {
|
|| invoiceRecordsDO.getStatus().equals(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getCode())) {
|
||||||
throw exception(THIS_INVOICE_IS_FAIL);
|
throw exception(THIS_INVOICE_IS_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,10 +254,10 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||||||
if (reqVO.isAgree()) {
|
if (reqVO.isAgree()) {
|
||||||
// 同意开票
|
// 同意开票
|
||||||
// 更新发票申请记录状态
|
// 更新发票申请记录状态
|
||||||
invoiceRecordsDO.setStatus(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getStatus());
|
invoiceRecordsDO.setStatus(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getCode());
|
||||||
invoiceRecordsDO.setRemark(reqVO.getRemark());
|
invoiceRecordsDO.setRemark(reqVO.getRemark());
|
||||||
// 更新购买记录状态
|
// 更新购买记录状态
|
||||||
purchaseRecordDOS.forEach(f -> f.setIsInvocing(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getStatus()));
|
purchaseRecordDOS.forEach(f -> f.setIsInvocing(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getCode()));
|
||||||
|
|
||||||
// 发票文件入库
|
// 发票文件入库
|
||||||
if (ObjectUtil.isNull(file) || file.isEmpty()) {
|
if (ObjectUtil.isNull(file) || file.isEmpty()) {
|
||||||
@@ -269,12 +269,12 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|||||||
} else {
|
} else {
|
||||||
// 拒绝开票
|
// 拒绝开票
|
||||||
// 更新发票申请记录状态
|
// 更新发票申请记录状态
|
||||||
invoiceRecordsDO.setStatus(InvoiceStatusEnum.INVOICINGFAILED.getStatus());
|
invoiceRecordsDO.setStatus(InvoiceStatusEnum.INVOICINGFAILED.getCode());
|
||||||
String remark = Optional.ofNullable(reqVO.getRemark()).orElseThrow(() -> new ServiceException(INVOICING_REJECT_REASON));
|
String remark = Optional.ofNullable(reqVO.getRemark()).orElseThrow(() -> new ServiceException(INVOICING_REJECT_REASON));
|
||||||
invoiceRecordsDO.setRemark(remark);
|
invoiceRecordsDO.setRemark(remark);
|
||||||
|
|
||||||
// 更新购买记录状态
|
// 更新购买记录状态
|
||||||
purchaseRecordDOS.forEach(f -> f.setIsInvocing(InvoiceStatusEnum.INVOICABLE.getStatus()));
|
purchaseRecordDOS.forEach(f -> f.setIsInvocing(InvoiceStatusEnum.INVOICABLE.getCode()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public class PurchaseServiceImpl implements PurchaseService {
|
|||||||
purchaseRecordMapper.update(new LambdaUpdateWrapper<PurchaseRecordDO>()
|
purchaseRecordMapper.update(new LambdaUpdateWrapper<PurchaseRecordDO>()
|
||||||
.eq(PurchaseRecordDO::getId, purchaseRecordId)
|
.eq(PurchaseRecordDO::getId, purchaseRecordId)
|
||||||
.eq(PurchaseRecordDO::getOrganId, organId)
|
.eq(PurchaseRecordDO::getOrganId, organId)
|
||||||
.set(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.INVOICABLE.getStatus()));
|
.set(PurchaseRecordDO::getIsInvocing, InvoiceStatusEnum.INVOICABLE.getCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-2
@@ -513,7 +513,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.businessNo(payNo)
|
.businessNo(payNo)
|
||||||
.tradeType(TradeTypeEnum.RECHARGE.getCode())
|
.tradeType(TradeTypeEnum.RECHARGE.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.INCOME.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.INCOME.getCode())
|
||||||
.cashAmountChange(price)
|
.cashAmountChange(price)
|
||||||
.giftAmountChange(giftAmount)
|
.giftAmountChange(giftAmount)
|
||||||
.availableAmount(rechargeAmountRespVO.getAvailableAmount())
|
.availableAmount(rechargeAmountRespVO.getAvailableAmount())
|
||||||
@@ -629,7 +629,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
IncomeExpenseDetailsDO incomeExpenseDetailsDO = IncomeExpenseDetailsDO.builder()
|
IncomeExpenseDetailsDO incomeExpenseDetailsDO = IncomeExpenseDetailsDO.builder()
|
||||||
.organId(organId)
|
.organId(organId)
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.INCOME.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.INCOME.getCode())
|
||||||
.cashAmountChange(accountBalanceSpent)
|
.cashAmountChange(accountBalanceSpent)
|
||||||
.giftAmountChange(giftMoneySpent)
|
.giftAmountChange(giftMoneySpent)
|
||||||
.availableAmount(organRefundProductRespVO.getAvailableAmount())
|
.availableAmount(organRefundProductRespVO.getAvailableAmount())
|
||||||
|
|||||||
+10
-10
@@ -21,7 +21,7 @@ import com.cf.imes.module.system.enums.pay.PayConstants;
|
|||||||
import com.cf.imes.module.system.enums.pay.PayOrderStatusEnum;
|
import com.cf.imes.module.system.enums.pay.PayOrderStatusEnum;
|
||||||
import com.cf.imes.module.system.enums.pay.PayProductChannelCodeEnum;
|
import com.cf.imes.module.system.enums.pay.PayProductChannelCodeEnum;
|
||||||
import com.cf.imes.module.system.enums.pay.TradeTypeEnum;
|
import com.cf.imes.module.system.enums.pay.TradeTypeEnum;
|
||||||
import com.cf.imes.module.system.enums.products.DurationUnitEnum;
|
import com.cf.imes.module.system.enums.pay.DurationUnitEnum;
|
||||||
import com.cf.imes.module.system.framework.snowflake.config.MybatisIdProperties;
|
import com.cf.imes.module.system.framework.snowflake.config.MybatisIdProperties;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ public class PayProductProcessor {
|
|||||||
.paymentMethod(PayProductChannelCodeEnum.BALANCE_ONLY.getCode())
|
.paymentMethod(PayProductChannelCodeEnum.BALANCE_ONLY.getCode())
|
||||||
.totalAmount(price)
|
.totalAmount(price)
|
||||||
.accountBalanceSpent(price)
|
.accountBalanceSpent(price)
|
||||||
.isInvocing(InvoiceStatusEnum.INVOICABLE.getStatus())
|
.isInvocing(InvoiceStatusEnum.INVOICABLE.getCode())
|
||||||
.build();
|
.build();
|
||||||
purchaseRecordDO.setEndTime(calculateEndTime(purchaseRecordDO.getStartTime(),
|
purchaseRecordDO.setEndTime(calculateEndTime(purchaseRecordDO.getStartTime(),
|
||||||
purchaseRecordDO.getPurchaseDuration(), purchaseRecordDO.getPurchaseDurationUnit(),
|
purchaseRecordDO.getPurchaseDuration(), purchaseRecordDO.getPurchaseDurationUnit(),
|
||||||
@@ -145,7 +145,7 @@ public class PayProductProcessor {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.purchaseId(purchaseRecordDO.getId())
|
.purchaseId(purchaseRecordDO.getId())
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getCode())
|
||||||
.cashAmountChange(price)
|
.cashAmountChange(price)
|
||||||
.availableAmount(newBalance.add(giftAmount))
|
.availableAmount(newBalance.add(giftAmount))
|
||||||
.amount(newBalance)
|
.amount(newBalance)
|
||||||
@@ -183,7 +183,7 @@ public class PayProductProcessor {
|
|||||||
.paymentMethod(PayProductChannelCodeEnum.BALANCE_ONLY.getCode())
|
.paymentMethod(PayProductChannelCodeEnum.BALANCE_ONLY.getCode())
|
||||||
.totalAmount(price)
|
.totalAmount(price)
|
||||||
.accountBalanceSpent(price)
|
.accountBalanceSpent(price)
|
||||||
.isInvocing(InvoiceStatusEnum.INVOICABLE.getStatus())
|
.isInvocing(InvoiceStatusEnum.INVOICABLE.getCode())
|
||||||
.build();
|
.build();
|
||||||
purchaseRecordDO.setEndTime(calculateEndTime(purchaseRecordDO.getStartTime(),
|
purchaseRecordDO.setEndTime(calculateEndTime(purchaseRecordDO.getStartTime(),
|
||||||
purchaseRecordDO.getPurchaseDuration(), purchaseRecordDO.getPurchaseDurationUnit(),
|
purchaseRecordDO.getPurchaseDuration(), purchaseRecordDO.getPurchaseDurationUnit(),
|
||||||
@@ -196,7 +196,7 @@ public class PayProductProcessor {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.purchaseId(purchaseRecordDO.getId())
|
.purchaseId(purchaseRecordDO.getId())
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getCode())
|
||||||
.giftAmountChange(price)
|
.giftAmountChange(price)
|
||||||
.availableAmount(amount.add(newGift))
|
.availableAmount(amount.add(newGift))
|
||||||
.amount(amount)
|
.amount(amount)
|
||||||
@@ -300,7 +300,7 @@ public class PayProductProcessor {
|
|||||||
.startTime(LocalDateTime.now())
|
.startTime(LocalDateTime.now())
|
||||||
.paymentMethod(PayProductChannelCodeEnum.BALANCE_AND_GIFT.getCode())
|
.paymentMethod(PayProductChannelCodeEnum.BALANCE_AND_GIFT.getCode())
|
||||||
.totalAmount(price)
|
.totalAmount(price)
|
||||||
.isInvocing(InvoiceStatusEnum.INVOICABLE.getStatus())
|
.isInvocing(InvoiceStatusEnum.INVOICABLE.getCode())
|
||||||
.build();
|
.build();
|
||||||
purchaseRecordDO.setEndTime(calculateEndTime(purchaseRecordDO.getStartTime(),
|
purchaseRecordDO.setEndTime(calculateEndTime(purchaseRecordDO.getStartTime(),
|
||||||
purchaseRecordDO.getPurchaseDuration(), purchaseRecordDO.getPurchaseDurationUnit(),
|
purchaseRecordDO.getPurchaseDuration(), purchaseRecordDO.getPurchaseDurationUnit(),
|
||||||
@@ -333,7 +333,7 @@ public class PayProductProcessor {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.purchaseId(purchaseRecordDO.getId())
|
.purchaseId(purchaseRecordDO.getId())
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getCode())
|
||||||
.cashAmountChange(usedBalance)
|
.cashAmountChange(usedBalance)
|
||||||
.giftAmountChange(usedGift)
|
.giftAmountChange(usedGift)
|
||||||
.availableAmount(newAmounta.add(newGift))
|
.availableAmount(newAmounta.add(newGift))
|
||||||
@@ -391,7 +391,7 @@ public class PayProductProcessor {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.purchaseId(purchaseRecordDO.getId())
|
.purchaseId(purchaseRecordDO.getId())
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getCode())
|
||||||
.cashAmountChange(usedBalance)
|
.cashAmountChange(usedBalance)
|
||||||
.availableAmount(newAmounta.add(giftAmount))
|
.availableAmount(newAmounta.add(giftAmount))
|
||||||
.amount(newAmounta)
|
.amount(newAmounta)
|
||||||
@@ -461,7 +461,7 @@ public class PayProductProcessor {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.purchaseId(purchaseRecordDO.getId())
|
.purchaseId(purchaseRecordDO.getId())
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getCode())
|
||||||
.giftAmountChange(usedGift)
|
.giftAmountChange(usedGift)
|
||||||
.availableAmount(amount.add(newGift))
|
.availableAmount(amount.add(newGift))
|
||||||
.amount(amount)
|
.amount(amount)
|
||||||
@@ -539,7 +539,7 @@ public class PayProductProcessor {
|
|||||||
.organId(organId)
|
.organId(organId)
|
||||||
.purchaseId(purchaseRecordDO.getId())
|
.purchaseId(purchaseRecordDO.getId())
|
||||||
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
.tradeType(TradeTypeEnum.PRODUCT.getCode())
|
||||||
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getType())
|
.incomeExpenseType(IncomeExpenseTypeEnum.EXPENSES.getCode())
|
||||||
.cashAmountChange(usedBalance)
|
.cashAmountChange(usedBalance)
|
||||||
.giftAmountChange(usedGift)
|
.giftAmountChange(usedGift)
|
||||||
.availableAmount(newAmounta.add(newGift))
|
.availableAmount(newAmounta.add(newGift))
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package com.cf.imes.module.system.validation.products;
|
package com.cf.imes.module.system.validation.products;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.cf.imes.module.system.enums.products.DurationUnitEnum;
|
import com.cf.imes.module.system.enums.pay.DurationUnitEnum;
|
||||||
import jakarta.validation.ConstraintValidator;
|
import jakarta.validation.ConstraintValidator;
|
||||||
import jakarta.validation.ConstraintValidatorContext;
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ public class TimeUnitValidator implements ConstraintValidator<TimeUnitValid, Int
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (DurationUnitEnum unitEnum : DurationUnitEnum.values()) {
|
for (DurationUnitEnum unitEnum : DurationUnitEnum.values()) {
|
||||||
if (Objects.equals(unitEnum.getStatus(), value)) {
|
if (Objects.equals(unitEnum.getCode(), value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user