implementation "org.springframework.cloud:spring-cloud-starter-openfeign" | implementation "org.springframework.cloud:spring-cloud-starter-openfeign" | ||||
implementation group: 'redis.clients', name: 'jedis' | implementation group: 'redis.clients', name: 'jedis' | ||||
implementation group: 'org.springframework.kafka', name: 'spring-kafka' | implementation group: 'org.springframework.kafka', name: 'spring-kafka' | ||||
implementation 'com.alibaba:easyexcel:3.2.1' | |||||
//MYSQL | //MYSQL | ||||
/* | /* | ||||
runtimeOnly 'mysql:mysql-connector-java' | runtimeOnly 'mysql:mysql-connector-java' |
package cn.com.taiji.core.entity.dict.issue; | package cn.com.taiji.core.entity.dict.issue; | ||||
import cn.com.taiji.common.model.StringKeyValue; | |||||
import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||
import lombok.Getter; | import lombok.Getter; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
@AllArgsConstructor | @AllArgsConstructor | ||||
@Getter | @Getter | ||||
public enum ProcessingFeeType { | public enum ProcessingFeeType { | ||||
private final String name; | private final String name; | ||||
public List<StringKeyValue> assType() { | |||||
List<StringKeyValue> stringKeyValues = new ArrayList<>(); | |||||
for (ProcessingFeeType value : values()) { | |||||
StringKeyValue stringKeyValue = new StringKeyValue(value.name(), value.getName()); | |||||
stringKeyValues.add(stringKeyValue); | |||||
} | |||||
return stringKeyValues; | |||||
} | |||||
} | } |
package cn.com.taiji.core.entity.dict.issue; | |||||
import cn.com.taiji.common.model.StringKeyValue; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Getter; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/26 17:47 | |||||
* @Filename:ProductAfterType | |||||
* @description: 产品售后类型 | |||||
*/ | |||||
@AllArgsConstructor | |||||
@Getter | |||||
public enum ProductAfterType { | |||||
CHANGECARD("更换卡"), | |||||
CHANGEOBU("更换签"), | |||||
CHANGEALL("更换卡签"), | |||||
; | |||||
private String name; | |||||
public List<StringKeyValue> assType() { | |||||
List<StringKeyValue> stringKeyValues = new ArrayList<>(); | |||||
for (ProductAfterType value : values()) { | |||||
StringKeyValue stringKeyValue = new StringKeyValue(value.name(), value.getName()); | |||||
stringKeyValues.add(stringKeyValue); | |||||
} | |||||
return stringKeyValues; | |||||
} | |||||
} |
/** | /** | ||||
* | * | ||||
* | |||||
* 卡券详情表 | |||||
*/ | */ | ||||
@Getter | @Getter | ||||
@Setter | @Setter | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 32) | @Size(max = 32) | ||||
@Column(name = "COUPON_ID") | @Column(name = "COUPON_ID") | ||||
private String couponId;//卡券id(属于指定类型卡券) | |||||
private String couponId;//卡券id(属于指定的卡券) | |||||
@NotBlank | @NotBlank | ||||
@Size(max = 100) | @Size(max = 100) | ||||
@Column(name = "REDEEM_CODE") | @Column(name = "REDEEM_CODE") | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 50) | @Size(max = 50) | ||||
@Enumerated(EnumType.STRING) | @Enumerated(EnumType.STRING) | ||||
@Column(name = "STATUS") | |||||
@Column(name = "COUPON_STATUS") | |||||
private CouponStatus status;//状态(待领取、领取后待激活、已激活待使用、已使用、已过期) | private CouponStatus status;//状态(待领取、领取后待激活、已激活待使用、已使用、已过期) | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 32) | @Size(max = 32) | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 50) | @Size(max = 50) | ||||
@Column(name = "COUPON_AGENCY_TYPE") | @Column(name = "COUPON_AGENCY_TYPE") | ||||
private String couponAgencyType;//卡券权益所属渠道 | |||||
private String couponAgencyType;//卡券权益所属渠道 如支付宝 | |||||
@NotNull | @NotNull | ||||
@Column(name = "INSERT_TIME") | @Column(name = "INSERT_TIME") | ||||
private LocalDateTime insertTime = LocalDateTime.now(); | private LocalDateTime insertTime = LocalDateTime.now(); |
@Size(max = 50) | @Size(max = 50) | ||||
@Column(name = "COUPON_AGENCY_TYPE") | @Column(name = "COUPON_AGENCY_TYPE") | ||||
private String couponAgencyType;//卡券权益所属渠道 | |||||
private String couponAgencyType;//卡券权益所属渠道 如支付宝 | |||||
@NotBlank | @NotBlank | ||||
@Size(max = 255) | @Size(max = 255) | ||||
@Column(name = "COUPON_NAME") | @Column(name = "COUPON_NAME") |
@Getter | @Getter | ||||
@Setter | @Setter | ||||
@Entity | @Entity | ||||
@Table(name = "ISSUE_PRODUT") | |||||
@Table(name = "ISSUE_PRODUCT") | |||||
public class IssueProduct extends StringPropertyUUIDEntity { | public class IssueProduct extends StringPropertyUUIDEntity { | ||||
@NotBlank | @NotBlank | ||||
@Column(name = "EQUITY_SERVICES_ID") | @Column(name = "EQUITY_SERVICES_ID") | ||||
private String equityServicesId;//权益服务ID | private String equityServicesId;//权益服务ID | ||||
@Column(name = "TRIAL_OPERATION_CIRCULATION") | @Column(name = "TRIAL_OPERATION_CIRCULATION") | ||||
private Long trialOperationCirculation;//试运营发行量设置 | |||||
private Integer trialOperationCirculation;//试运营发行量设置 | |||||
@NotBlank | @NotBlank | ||||
@Size(max = 11) | @Size(max = 11) | ||||
@Column(name = "DEDUCTION_CHANNELS_ID") | @Column(name = "DEDUCTION_CHANNELS_ID") | ||||
@Enumerated(EnumType.STRING) | @Enumerated(EnumType.STRING) | ||||
private CardType cardType;//卡类型 1记账卡 2储值卡 3预付卡 | private CardType cardType;//卡类型 1记账卡 2储值卡 3预付卡 | ||||
@Column(name = "VAN_TYPE") | @Column(name = "VAN_TYPE") | ||||
private Integer vanType;//客货类型 1客车 2货车 3 专项作业车 | |||||
private String vanType;//客货类型 1客车 2货车 3 专项作业车 | |||||
@Size(max = 128) | @Size(max = 128) | ||||
@Column(name = "VEHICLE_TYPE") | @Column(name = "VEHICLE_TYPE") | ||||
private String vehicleType;//车型 | private String vehicleType;//车型 | ||||
private Long prestoreFee;//办理费——预存金费用 | private Long prestoreFee;//办理费——预存金费用 | ||||
@Column(name = "DEFAULT_FEE") | @Column(name = "DEFAULT_FEE") | ||||
private Long defaultFee;//违约费用 | private Long defaultFee;//违约费用 | ||||
@NotNull | |||||
@Column(name = "DATE_OF_DELIST") | |||||
private LocalDateTime dateOfDelist;//下架日期 | |||||
@NotNull | |||||
@Column(name = "DATE_OF_LISTING") | |||||
private LocalDateTime dateOfListing;//上架日期 | |||||
@Column(name = "IS_PAY") | @Column(name = "IS_PAY") | ||||
private Integer pay;//是否支付 1是0否 | |||||
private Integer isPay;//是否支付 1是0否 | |||||
@Column(name = "QT_SIGN") | @Column(name = "QT_SIGN") | ||||
private Integer qtSign;//是否黔通签约1是0否 | private Integer qtSign;//是否黔通签约1是0否 | ||||
@Size(max = 1000) | @Size(max = 1000) | ||||
private String channelUrl;//通知渠道接口地址 | private String channelUrl;//通知渠道接口地址 | ||||
@Size(max = 32) | @Size(max = 32) | ||||
@Column(name = "OPERATE_USER_ID") | @Column(name = "OPERATE_USER_ID") | ||||
private String operateUserId;//操作人id | |||||
private String operateUserId;//操作人Openid | |||||
@Size(max = 50) | @Size(max = 50) | ||||
@Column(name = "OPERATE_USER_NAME") | @Column(name = "OPERATE_USER_NAME") | ||||
private String operateUserName;//操作人姓名 | private String operateUserName;//操作人姓名 | ||||
@Column(name = "CHANGE_REASON") | @Column(name = "CHANGE_REASON") | ||||
private String changeReason;//变更原因 | private String changeReason;//变更原因 | ||||
@Column(name = "EXAMINE") | @Column(name = "EXAMINE") | ||||
private Integer examine;//审核是否通过(0--通过 1---不通过 2---待审核) | |||||
private Integer examine;//审核状态(0--通过 1---不通过 2---待审核) | |||||
@Size(max = 255) | @Size(max = 255) | ||||
@Column(name = "EXAMINE_DES") | @Column(name = "EXAMINE_DES") | ||||
private String examineDes;//审核原因 | private String examineDes;//审核原因 |
private String fileName;//文件名 | private String fileName;//文件名 | ||||
@Size(max = 32) | @Size(max = 32) | ||||
@Column(name = "TYPE_NAME") | @Column(name = "TYPE_NAME") | ||||
private String typeName;//业务类型 | |||||
private String typeName;//文件类型 | |||||
@Size(max = 512) | @Size(max = 512) | ||||
@Column(name = "FILE_URL") | @Column(name = "FILE_URL") | ||||
private String fileUrl;//文件地址 | private String fileUrl;//文件地址 |
@NotBlank | @NotBlank | ||||
@Size(max = 20) | @Size(max = 20) | ||||
@Column(name = "FEE_TYPE") | @Column(name = "FEE_TYPE") | ||||
private String feeType;//费用类型 HANDLE("办理费"),//办理费的收费类型从ProcessingFeeType枚举获取 ;使用费的收费类型从字典获取 | |||||
@NotNull | |||||
@Column(name = "FEE") | |||||
private Long fee;//金额 | |||||
private String feeType;//费用类型 办理费的收费类型从ProcessingFeeType枚举获取 ;使用费的收费类型从字典获取 | |||||
@NotNull | @NotNull | ||||
@Column(name = "CHARGE_METHOD") | @Column(name = "CHARGE_METHOD") | ||||
@Enumerated(EnumType.STRING) | @Enumerated(EnumType.STRING) |
private Integer validityFormat;//有效期格式 1日 2月 3季 4年 | private Integer validityFormat;//有效期格式 1日 2月 3季 4年 | ||||
@Column(name = "PRODUCT_VALIDITY") | @Column(name = "PRODUCT_VALIDITY") | ||||
private Integer productValidity;//产品有效期 | private Integer productValidity;//产品有效期 | ||||
@NotNull | |||||
@Column(name = "DATE_OF_DELIST") | |||||
private LocalDateTime dateOfDelist;//下架日期 | |||||
@NotNull | |||||
@Column(name = "DATE_OF_LISTING") | |||||
private LocalDateTime dateOfListing;//上架日期 | |||||
@Size(max = 50) | @Size(max = 50) | ||||
@Column(name = "OPERATE_USER_ID") | @Column(name = "OPERATE_USER_ID") | ||||
private String operateUserId;//操作人id | private String operateUserId;//操作人id | ||||
@Column(name = "OPERATE_USER_NAME") | @Column(name = "OPERATE_USER_NAME") | ||||
private String operateUserName;//操作人姓名 | private String operateUserName;//操作人姓名 | ||||
@Column(name = "EXAMINE") | @Column(name = "EXAMINE") | ||||
private Integer examine;//审核通过状态 0--通过 1---不通过 2---待审核 | |||||
private Integer examine;//审核通过状态 0-通过 1-不通过 2-待审核 | |||||
@Size(max = 300) | @Size(max = 300) | ||||
@Column(name = "EXAMINE_DES") | @Column(name = "EXAMINE_DES") | ||||
private String examineDes;//审核原因 | private String examineDes;//审核原因 |
@Column(name = "RELEASE_ID") | @Column(name = "RELEASE_ID") | ||||
private String releaseId;//产品编号 | private String releaseId;//产品编号 | ||||
@NotBlank | @NotBlank | ||||
@Size(max = 255) | |||||
@Size(max = 20) | |||||
@Column(name = "USE_FEE_TYPE") | @Column(name = "USE_FEE_TYPE") | ||||
private String useFeeType;//使用费类型 | private String useFeeType;//使用费类型 | ||||
@NotBlank | |||||
@Size(max = 255) | |||||
@NotNull | |||||
@Column(name = "BILLING_MODE") | @Column(name = "BILLING_MODE") | ||||
private String billingMode;//计费方式 | |||||
private Integer billingMode;//计费方式 0次数,1按月,2按年 | |||||
@NotNull | @NotNull | ||||
@Column(name = "FEE") | @Column(name = "FEE") | ||||
private Long fee;//金额 | private Long fee;//金额 |
@Size(max = 4000) | @Size(max = 4000) | ||||
@Column(name = "PRODUCT_INTRO") | @Column(name = "PRODUCT_INTRO") | ||||
private String productIntro;//权益类产品内容简介 | private String productIntro;//权益类产品内容简介 | ||||
@Digits(integer=0,fraction=-127) | |||||
@Column(name = "CUSTOMER_GROUP") | @Column(name = "CUSTOMER_GROUP") | ||||
private BigDecimal customerGroup;//客户群体 | |||||
private Integer customerGroup;//客户群体 | |||||
@Column(name = "CHARGE_TYPE") | @Column(name = "CHARGE_TYPE") | ||||
private Integer chargeType;//收费类型 字典取CHARGE_TYPE | private Integer chargeType;//收费类型 字典取CHARGE_TYPE | ||||
@Column(name = "DISCOUNT_PRICE") | @Column(name = "DISCOUNT_PRICE") | ||||
private EnableFlag status;//状态 | private EnableFlag status;//状态 | ||||
@NotNull | @NotNull | ||||
@Column(name = "EXAMINE") | @Column(name = "EXAMINE") | ||||
private Integer examine;//审核是否通过(0--通过 1---不通过 2--待审核) | |||||
private Integer examine;//审核状态(0--通过 1---不通过 2--待审核) | |||||
@Size(max = 255) | @Size(max = 255) | ||||
@Column(name = "EXAMINE_DES") | @Column(name = "EXAMINE_DES") | ||||
private String examineDes;//审核原因 | private String examineDes;//审核原因 |
package cn.com.taiji.core.manager.tools.excel; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||||
import cn.com.taiji.core.manager.tools.excel.annotations.ExcelFiledNotBlank; | |||||
import cn.com.taiji.core.manager.tools.excel.annotations.ExcelFiledNotNull; | |||||
import com.alibaba.excel.context.AnalysisContext; | |||||
import com.alibaba.excel.read.listener.ReadListener; | |||||
import com.alibaba.excel.util.ListUtils; | |||||
import com.alibaba.fastjson2.JSON; | |||||
import org.slf4j.Logger; | |||||
import org.slf4j.LoggerFactory; | |||||
import org.springframework.util.CollectionUtils; | |||||
import java.lang.reflect.Field; | |||||
import java.util.List; | |||||
/** | |||||
* excel阅读监听器抽象类 | |||||
* <p>实现数据读取缓存,以及抽象数据存储 | |||||
* @Author weicailin | |||||
* @Date 2023/4/4 14:57 | |||||
* @Email 13079168756@163.com | |||||
*/ | |||||
public abstract class AbstractListener<T> implements ReadListener<T> { | |||||
protected Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
/** | |||||
* 每隔100条存储数据库 | |||||
*/ | |||||
private static final int BATCH_COUNT = 100; | |||||
/** | |||||
* 缓存的数据 | |||||
*/ | |||||
private List<T> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); | |||||
/** | |||||
* 当前处理excel的第几行数 | |||||
*/ | |||||
private int currentLine; | |||||
@Override | |||||
public void invoke(T data, AnalysisContext context) { | |||||
T t = null; | |||||
//自定义的注解,进行非空校验 | |||||
try { | |||||
t = validFiled(data); | |||||
} catch (Exception e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
//业务校验处理 | |||||
try { | |||||
validData(data); | |||||
} catch (ManagerException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
currentLine++; | |||||
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM | |||||
if (currentLine > BATCH_COUNT){ | |||||
throw new RuntimeException("表格数据不可超出"+BATCH_COUNT+"行"); | |||||
} | |||||
// if (t != null) { | |||||
// logger.info("解析到一条数据:{}", JSON.toJSONString(data)); | |||||
// cachedDataList.add(data); | |||||
// currentLine++; | |||||
// // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM | |||||
// if (cachedDataList.size() >= BATCH_COUNT) { | |||||
// try { | |||||
// saveData(cachedDataList); | |||||
// } catch (ServiceHandleException e) { | |||||
// logger.error("保存表格数据失败!"); | |||||
// throw new RuntimeException("保存表格数据失败!"); | |||||
// } | |||||
// // 存储完成清理 list | |||||
// cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); | |||||
// } | |||||
// } | |||||
} | |||||
/*** | |||||
* | |||||
*/ | |||||
@Override | |||||
public void doAfterAllAnalysed(AnalysisContext context) { | |||||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库 | |||||
if (!CollectionUtils.isEmpty(cachedDataList)) { | |||||
try { | |||||
saveData(cachedDataList); | |||||
} catch (ServiceHandleException e) { | |||||
logger.error(e.getMessage()); | |||||
throw new RuntimeException(e.getMessage()); | |||||
} | |||||
logger.info("所有数据解析入库完成!"); | |||||
} | |||||
} | |||||
/*** | |||||
* 将扫excel数据入库的行为抽象出来 | |||||
*/ | |||||
protected abstract void saveData(List<T> dataList) throws ServiceHandleException; | |||||
//字段非空校验 | |||||
protected T validFiled(T data) throws Exception { | |||||
//1、获取该类型的所有属性字段 | |||||
Field[] declaredFields = data.getClass().getDeclaredFields(); | |||||
//2、遍历属性,对带有自定义注解ExcelFiledNotBlack,实现字段的非空校验 | |||||
for (int i = 0; i < declaredFields.length; i++) { | |||||
Field field = declaredFields[i]; | |||||
//对象非null校验 | |||||
ExcelFiledNotNull notNullAnnotation = field.getAnnotation(ExcelFiledNotNull.class); | |||||
if (notNullAnnotation != null) { | |||||
field.setAccessible(true); //暴力破解访问权限 | |||||
Object o = field.get(data); //获取字段的值 | |||||
if (o == null) { | |||||
throw new ManagerException("excel 解析失败,第" + currentLine + "行,第" + i+1 + "列,必要字段为空!"); | |||||
} | |||||
} | |||||
//字符串非空校验 | |||||
ExcelFiledNotBlank notBlankAnnotation = field.getAnnotation(ExcelFiledNotBlank.class); | |||||
if (notBlankAnnotation != null) { | |||||
field.setAccessible(true); //暴力破解访问权限 | |||||
String str = (String) field.get(data); //获取字段的值 | |||||
if (str == null || str.trim().isEmpty()) { | |||||
throw new ManagerException("excel 解析失败,第" + currentLine + "行,第" + i+1 + "列,必要字段为空!"); | |||||
} | |||||
} | |||||
} | |||||
return data; | |||||
} | |||||
//业务校验处理 | |||||
protected void validData(T data) throws ManagerException{ | |||||
} | |||||
} |
package cn.com.taiji.core.manager.tools.excel.annotations; | |||||
import java.lang.annotation.ElementType; | |||||
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
import java.lang.annotation.Target; | |||||
/*** | |||||
* 字符串非空校验 | |||||
*/ | |||||
@Target({ElementType.FIELD}) | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
public @interface ExcelFiledNotBlank { | |||||
} |
package cn.com.taiji.core.manager.tools.excel.annotations; | |||||
import java.lang.annotation.ElementType; | |||||
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
import java.lang.annotation.Target; | |||||
/*** | |||||
* 对象非空校验 | |||||
*/ | |||||
@Target({ElementType.FIELD}) | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
public @interface ExcelFiledNotNull { | |||||
} |
package cn.com.taiji.core.repo.jpa.issue; | package cn.com.taiji.core.repo.jpa.issue; | ||||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | ||||
import cn.com.taiji.core.entity.dict.issue.FeeCategory; | |||||
import cn.com.taiji.core.entity.issue.IssueProductPay; | import cn.com.taiji.core.entity.issue.IssueProductPay; | ||||
import org.springframework.data.jpa.repository.Modifying; | |||||
import org.springframework.data.jpa.repository.Query; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import java.util.List; | |||||
public interface IssueProductPayRepo extends AbstractJpaRepo<IssueProductPay, String>{ | public interface IssueProductPayRepo extends AbstractJpaRepo<IssueProductPay, String>{ | ||||
//通过费用类别删除 | |||||
@Transactional | |||||
@Modifying | |||||
@Query("delete from IssueProductPay where feeCategory=?1 and releaseId = ?2") | |||||
int deleteByfr(FeeCategory feeCategory,String releaseId); | |||||
//通过费用类别,费用类型删除 | |||||
@Transactional | |||||
@Modifying | |||||
@Query("delete from IssueProductPay where feeCategory=?1 and feeType = ?2 and releaseId = ?3") | |||||
int deleteByffr(FeeCategory feeCategory,String feeType,String releaseId); | |||||
List<IssueProductPay> findByFeeCategoryAndReleaseId(FeeCategory feeCategory,String releaseId); | |||||
} | } |
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | ||||
import cn.com.taiji.core.entity.issue.IssueProduct; | import cn.com.taiji.core.entity.issue.IssueProduct; | ||||
import org.springframework.data.jpa.repository.Query; | |||||
import java.util.List; | |||||
public interface IssueProductRepo extends AbstractJpaRepo<IssueProduct, String>{ | public interface IssueProductRepo extends AbstractJpaRepo<IssueProduct, String>{ | ||||
IssueProduct findByProductName(String productName); | |||||
IssueProduct findByReleaseId(String releaseId); | |||||
@Query("select releaseId from IssueProduct") | |||||
List<String> findAllReleaseId(); | |||||
} | } |
package cn.com.taiji.core.repo.jpa.issue; | package cn.com.taiji.core.repo.jpa.issue; | ||||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | ||||
import cn.com.taiji.core.entity.dict.issue.FeeCategory; | |||||
import cn.com.taiji.core.entity.issue.IssueProductUseFee; | import cn.com.taiji.core.entity.issue.IssueProductUseFee; | ||||
import org.springframework.data.jpa.repository.Modifying; | |||||
import org.springframework.data.jpa.repository.Query; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
public interface IssueProductUseFeeRepo extends AbstractJpaRepo<IssueProductUseFee, String>{ | public interface IssueProductUseFeeRepo extends AbstractJpaRepo<IssueProductUseFee, String>{ | ||||
//通过费用类别删除 | |||||
@Transactional | |||||
@Modifying | |||||
@Query("delete from IssueProductUseFee where releaseId = ?2") | |||||
int deleteByReleaseId( String releaseId); | |||||
} | } |
import cn.com.taiji.core.entity.dict.basic.*; | import cn.com.taiji.core.entity.dict.basic.*; | ||||
import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; | import cn.com.taiji.core.entity.dict.invw.InvApplyStatus; | ||||
import cn.com.taiji.core.entity.dict.invw.InventoryType; | import cn.com.taiji.core.entity.dict.invw.InventoryType; | ||||
import cn.com.taiji.core.entity.dict.issue.ChargeMethod; | |||||
import cn.com.taiji.core.entity.dict.issue.FeeCategory; | |||||
import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||
import org.junit.runner.RunWith; | import org.junit.runner.RunWith; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
GlobalConfigBuilder configBuilder = GlobalConfigBuilder.create(); | GlobalConfigBuilder configBuilder = GlobalConfigBuilder.create(); | ||||
configBuilder.setAppName("core"); | configBuilder.setAppName("core"); | ||||
configBuilder.setModule("issue"); | configBuilder.setModule("issue"); | ||||
configBuilder.setTableName("INVW_TRANSFER_DETAILS"); | |||||
String pak = "issue"; | |||||
configBuilder.setEntityPackage("cn/com/taiji/core/entity/"+pak); | |||||
configBuilder.setRepoPackage("cn/com/taiji/core/repo/jpa/"+pak); | |||||
configBuilder.setTableName("ISSUE_MULTIPLE_EQUITY"); | |||||
// 生成分页查询request | // 生成分页查询request | ||||
// configBuilder.setQueryField(List.of("intVal", "name", "mobile", "insertTime1", "insertTime2")); | // configBuilder.setQueryField(List.of("intVal", "name", "mobile", "insertTime1", "insertTime2")); | ||||
// configBuilder.setOrderBy("orderIndex"); | // configBuilder.setOrderBy("orderIndex"); | ||||
// configBuilder.setRequestMapping("/demo/datatype"); | // configBuilder.setRequestMapping("/demo/datatype"); | ||||
GlobalConfig globalConfig = configBuilder.build(); | GlobalConfig globalConfig = configBuilder.build(); | ||||
/* 给字段映射枚举类型、实体(manyToOne),如果是字符串,自动生成枚举 */ | /* 给字段映射枚举类型、实体(manyToOne),如果是字符串,自动生成枚举 */ | ||||
HashMap<String, Object> typeNameMap = new HashMap<>(); | HashMap<String, Object> typeNameMap = new HashMap<>(); | ||||
typeNameMap.put("INVENTORY_TYPE", InventoryType.class); | |||||
typeNameMap.put("VERSION", DeviceVersion.class); | |||||
typeNameMap.put("CARD_TYPE", CardType.class); | |||||
typeNameMap.put("OBU_TYPE", ObuType.class); | |||||
typeNameMap.put("APPLY_STATUS", InvApplyStatus.class); | |||||
typeNameMap.put("STATUS", EnableFlag.class); | |||||
// typeNameMap.put("CHARGE_METHOD", ChargeMethod.class); | |||||
// typeNameMap.put("CARD_TYPE", CardType.class); | |||||
// typeNameMap.put("OBU_TYPE", ObuType.class); | |||||
// typeNameMap.put("APPLY_STATUS", InvApplyStatus.class); | |||||
/*typeNameMap.put("CARD_TYPE_NEW", CardType.class); | /*typeNameMap.put("CARD_TYPE_NEW", CardType.class); | ||||
typeNameMap.put("CARD_STATUS", CardStatus.class); | typeNameMap.put("CARD_STATUS", CardStatus.class); | ||||
typeNameMap.put("OBU_STATUS", ObuStatus.class); | typeNameMap.put("OBU_STATUS", ObuStatus.class); |
package cn.com.taiji.managew.api.product; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.common.web.ApiResponse; | |||||
import cn.com.taiji.managew.api.MyValidController; | |||||
import cn.com.taiji.managew.dto.product.GetReleaseIdRequestDTO; | |||||
import cn.com.taiji.managew.dto.product.ProductAddRequestDto; | |||||
import cn.com.taiji.managew.dto.product.ProductUpdateRequestDTO; | |||||
import cn.com.taiji.managew.manager.product.ProductManager; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.web.bind.annotation.PostMapping; | |||||
import org.springframework.web.bind.annotation.RequestBody; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | |||||
import org.springframework.web.bind.annotation.RestController; | |||||
import javax.validation.Valid; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/26 16:33 | |||||
* @Filename:ProductController | |||||
* @description: 发行产品管理 | |||||
*/ | |||||
@Api(tags = {"105.发行产品管理"}) | |||||
@RestController | |||||
@RequestMapping("/api/product/releaseProductStandards") | |||||
public class ProductController extends MyValidController { | |||||
@Autowired | |||||
private ProductManager productManager; | |||||
@ApiOperation("新增发行产品") | |||||
@PostMapping("/add") | |||||
public ApiResponse<?> add(@Valid @RequestBody ProductAddRequestDto req) throws ManagerException { | |||||
productManager.add(req); | |||||
return ApiResponse.success().setMessage("新增成功"); | |||||
} | |||||
@ApiOperation("获取产品编号") | |||||
@PostMapping("/getReleaseId") | |||||
public ApiResponse<String> getReleaseId(@Valid @RequestBody GetReleaseIdRequestDTO req) throws ManagerException { | |||||
String id = productManager.getReleaseId(req); | |||||
return ApiResponse.of(id); | |||||
} | |||||
@ApiOperation("更新发行产品") | |||||
@PostMapping("/update") | |||||
public ApiResponse<?> update(@Valid @RequestBody ProductUpdateRequestDTO req) throws ManagerException { | |||||
productManager.update(req); | |||||
return ApiResponse.success().setMessage("更新成功"); | |||||
} | |||||
} |
package cn.com.taiji.managew.dto.product; | |||||
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | |||||
/** | |||||
* @Author ChenChao | |||||
* @Date 2024/11/6 21:27 | |||||
* @Description | |||||
*/ | |||||
public class GetReleaseIdRequestDTO extends AbstractStaffBizRequestDTO { | |||||
} |
package cn.com.taiji.managew.dto.product; | |||||
import cn.com.taiji.common.pub.StringTools; | |||||
import cn.com.taiji.common.valid.ViolationValidator; | |||||
import cn.com.taiji.core.dto.AbstractStaffBizRequestDTO; | |||||
import cn.com.taiji.core.entity.dict.basic.CardType; | |||||
import cn.com.taiji.core.entity.dict.basic.SecretKeyType; | |||||
import cn.com.taiji.core.entity.issue.IssueProductUseFee; | |||||
import cn.com.taiji.core.model.comm.protocol.constraint.FixedLength; | |||||
import cn.com.taiji.core.model.comm.protocol.constraint.IntegerConstant; | |||||
import cn.com.taiji.managew.model.product.AfterSaleFee; | |||||
import cn.com.taiji.managew.model.product.ProcessingFee; | |||||
import cn.hutool.core.util.ObjectUtil; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.validation.Valid; | |||||
import javax.validation.constraints.NotBlank; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.time.LocalDateTime; | |||||
import java.util.List; | |||||
/** | |||||
* @author shake | |||||
* @projectName ReleaseProductStandardsAddRequest | |||||
* @date 2023/4/13 18:34 | |||||
* @description 发行产品管理新增请求 | |||||
*/ | |||||
@Getter | |||||
@Setter | |||||
@ApiModel(description = "新增产品请求") | |||||
public class ProductAddRequestDto extends AbstractStaffBizRequestDTO { | |||||
@ApiModelProperty(name = "产品类型(0:自营产品,1:非自营产品)",required = true) | |||||
@NotNull | |||||
@IntegerConstant(values="0,1") | |||||
private Integer productType; | |||||
@ApiModelProperty(name = "产品名称",required = true) | |||||
@NotBlank | |||||
private String productName; | |||||
@ApiModelProperty(name = "产品编号",required = true) | |||||
@NotBlank | |||||
@FixedLength(length = 3) | |||||
private String releaseId; | |||||
// @ApiModelProperty(name = "下架日期",required = true) | |||||
// @NotNull | |||||
// private LocalDateTime dateOfDelist; | |||||
@ApiModelProperty(name = "备注") | |||||
private String remarks; | |||||
@ApiModelProperty(name = "权益服务",required = true) | |||||
@NotNull | |||||
private List<String> equityServicesId; | |||||
// @ApiModelProperty(name = "上架日期",required = true) | |||||
// @NotNull | |||||
// private LocalDateTime dateOfListing; | |||||
@ApiModelProperty(name = "试运营发行量设置") | |||||
private Integer trialOperationCirculation; | |||||
@ApiModelProperty(name = "推广模式(1:线上,2:线下,3:线上和线下)",required = true) | |||||
@NotNull | |||||
@IntegerConstant(values="1,2,3") | |||||
private Integer promotionMode; | |||||
@ApiModelProperty(name = "推广工具",required = true) | |||||
@NotNull | |||||
private List<String> extensionTool; | |||||
@ApiModelProperty(name = "用户类型 1个人 2单位 3个人+单位-车辆所属性质",required = true) | |||||
@NotNull | |||||
@IntegerConstant(values="1,2,3") | |||||
private Integer customerType; | |||||
@ApiModelProperty(name = "卡类型",required = true) | |||||
@NotNull | |||||
private CardType cardType; | |||||
@ApiModelProperty(name = "车辆类型 1客车 2货车 3 专项作业车",required = true) | |||||
@NotNull | |||||
private List<String> vanType; | |||||
@ApiModelProperty(name = "支持车型",required = true) | |||||
@NotNull | |||||
private List<String> vehicleType; | |||||
@ApiModelProperty(name = "合作渠道是否支持售后1-是,0-否",required = true) | |||||
@IntegerConstant(values="0,1") | |||||
@NotNull | |||||
private Integer supAfterSales; | |||||
@ApiModelProperty(name = "办理费 信息列表") | |||||
@Valid | |||||
private List<ProcessingFee> processingFeeList; | |||||
@ApiModelProperty(name = "使用费 信息列表") | |||||
@Valid | |||||
private List<IssueProductUseFee> useFeeList; | |||||
/** 售后费 信息 */ | |||||
@ApiModelProperty(name = "质保期",required = true) | |||||
@NotNull | |||||
private Integer warrantyPeriod; | |||||
/** 违约金 信息 */ | |||||
@ApiModelProperty(name = "注销违约金",required = true) | |||||
@NotNull | |||||
private Long defaultFee;//monthlyRate; | |||||
/** 注销费 信息列表 */ | |||||
@ApiModelProperty(name = "注销年限") | |||||
private Integer cancelAgeLimit; | |||||
@ApiModelProperty(name = "注销费金额") | |||||
private Long cancelAmount; | |||||
@ApiModelProperty(name = "是否是通用秘钥设备(9901,5201,选装)",required = true) | |||||
@NotNull | |||||
private SecretKeyType deviceType; | |||||
@ApiModelProperty(name = "部中心编号") | |||||
private String centerNo; | |||||
@ApiModelProperty(name = "扣费渠道编号",required = true) | |||||
@NotBlank | |||||
private String deductionChannelsId; | |||||
@ApiModelProperty(name = "车辆性质 1营运 2非营运 3营运和非营运",required = true) | |||||
@NotNull | |||||
private Integer useCharacter; | |||||
@ApiModelProperty(name = "其他注销条件") | |||||
private String otherCancelCondition; | |||||
@ApiModelProperty(name = "售后费用") | |||||
@Valid | |||||
private List<AfterSaleFee> afterSaleFees; | |||||
@ApiModelProperty(name = "合作机构",required = true) | |||||
@NotBlank | |||||
private String agencyId; | |||||
@NotNull | |||||
@IntegerConstant(values="0,1") | |||||
@ApiModelProperty(name = "1需要支付0不需要支付",required = true) | |||||
private Integer isPay; | |||||
@NotNull | |||||
@IntegerConstant(values="0,1") | |||||
@ApiModelProperty(name = "1是黔通签约0否黔通签约",required = true) | |||||
private Integer qtSign; | |||||
@ApiModelProperty(name = "渠道签约地址") | |||||
private String qdSignUrl; | |||||
@ApiModelProperty(name = "渠道签约小程序appId") | |||||
private String qdSignAppId; | |||||
@ApiModelProperty(name = "支持车籍") | |||||
private List<String> vehiclePalce; | |||||
@Override | |||||
protected void validate(ViolationValidator validator) { | |||||
if (SecretKeyType.TYMY9901.equals(deviceType)){ | |||||
validator.validFieldNotNull("centerNo", centerNo); | |||||
} | |||||
validator.validField("qdSignUrl",qtSign == 0 && StringTools.isEmpty(qdSignUrl),"请输入渠道签约地址"); | |||||
validator.validField("", | |||||
(ObjectUtil.isNotEmpty(processingFeeList) && ObjectUtil.isNotEmpty(useFeeList)) || | |||||
(ObjectUtil.isEmpty(processingFeeList) && ObjectUtil.isEmpty(useFeeList)), | |||||
"使用费或办理费必填,并且只能填写一种"); | |||||
validator.validField("releaseId",!releaseId.matches("\\d+"),"请输入数字类型"); | |||||
validator.validField("",promotionMode==2 && isPay ==0,"线下推广模式需要支付"); | |||||
} | |||||
} |
package cn.com.taiji.managew.dto.product; | |||||
import cn.com.taiji.common.valid.ViolationValidator; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.validation.constraints.NotBlank; | |||||
@Getter | |||||
@Setter | |||||
@ApiModel(description = "更新产品请求") | |||||
public class ProductUpdateRequestDTO extends ProductAddRequestDto { | |||||
@ApiModelProperty(value = "产品id",required = true) | |||||
@NotBlank | |||||
private String id; | |||||
// @Override | |||||
// protected void validate(ViolationValidator validator) { | |||||
// super.validate(); | |||||
// } | |||||
} |
import cn.com.taiji.common.manager.ManagerException; | import cn.com.taiji.common.manager.ManagerException; | ||||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | import cn.com.taiji.common.manager.net.http.ServiceHandleException; | ||||
import cn.com.taiji.common.model.dao.Pagination; | import cn.com.taiji.common.model.dao.Pagination; | ||||
import cn.com.taiji.core.entity.dict.basic.EnableFlag; | |||||
import cn.com.taiji.core.entity.issue.IssueCouponDetail; | import cn.com.taiji.core.entity.issue.IssueCouponDetail; | ||||
import cn.com.taiji.core.entity.issue.IssueCouponInfo; | import cn.com.taiji.core.entity.issue.IssueCouponInfo; | ||||
import cn.com.taiji.core.manager.cache.RedisCacheManager; | import cn.com.taiji.core.manager.cache.RedisCacheManager; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | |||||
import java.io.FileNotFoundException; | |||||
import java.io.InputStream; | |||||
import java.util.List; | import java.util.List; | ||||
/** | /** | ||||
@Override | @Override | ||||
public List<IssueCouponInfo> enableList(CouponEnableListRequestDTO req) { | public List<IssueCouponInfo> enableList(CouponEnableListRequestDTO req) { | ||||
return issueCouponInfoRepo.findByStatus(1); | |||||
return issueCouponInfoRepo.findByStatus(EnableFlag.ENABLE); | |||||
} | } | ||||
IssueCouponInfo couponInfo = issueCouponInfoRepo.findById(req.getCouponId()).orElse(null); | IssueCouponInfo couponInfo = issueCouponInfoRepo.findById(req.getCouponId()).orElse(null); | ||||
if (couponInfo == null) throw new ManagerException("请勿传入无效的卡券类型id!"); | if (couponInfo == null) throw new ManagerException("请勿传入无效的卡券类型id!"); | ||||
File fileByUrl = minioUtile.getFileByUrl(req.getExcelFileUrl()); | |||||
//todo | |||||
File tempFile = minioUtile.getFileByUrl(req.getExcelFileUrl()); | |||||
//获取文件流 | |||||
InputStream fileInputStream = null; | |||||
try { | |||||
fileInputStream = new FileInputStream(tempFile); | |||||
} catch (FileNotFoundException e) { | |||||
throw new ManagerException("读取文件流失败!"); | |||||
} | |||||
} | } | ||||
} | } |
package cn.com.taiji.managew.manager.product; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.managew.dto.product.GetReleaseIdRequestDTO; | |||||
import cn.com.taiji.managew.dto.product.ProductAddRequestDto; | |||||
import cn.com.taiji.managew.dto.product.ProductUpdateRequestDTO; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/26 17:07 | |||||
* @Filename:ProductManager | |||||
* @description: 发行产品管理 | |||||
*/ | |||||
public interface ProductManager { | |||||
void add(ProductAddRequestDto req) throws ManagerException; | |||||
String getReleaseId(GetReleaseIdRequestDTO req) throws ManagerException; | |||||
void update(ProductUpdateRequestDTO req) throws ManagerException; | |||||
} |
package cn.com.taiji.managew.manager.product; | |||||
import cn.com.taiji.common.manager.ManagerException; | |||||
import cn.com.taiji.core.entity.dict.basic.EnableFlag; | |||||
import cn.com.taiji.core.entity.dict.issue.FeeCategory; | |||||
import cn.com.taiji.core.entity.issue.IssueProduct; | |||||
import cn.com.taiji.core.entity.issue.IssueProductPay; | |||||
import cn.com.taiji.core.entity.user.Staff; | |||||
import cn.com.taiji.core.manager.cache.RedisCacheManager; | |||||
import cn.com.taiji.core.repo.jpa.issue.IssueProductPayRepo; | |||||
import cn.com.taiji.core.repo.jpa.issue.IssueProductRepo; | |||||
import cn.com.taiji.core.repo.jpa.issue.IssueProductUseFeeRepo; | |||||
import cn.com.taiji.core.repo.jpa.user.StaffRepo; | |||||
import cn.com.taiji.managew.dto.product.GetReleaseIdRequestDTO; | |||||
import cn.com.taiji.managew.dto.product.ProductAddRequestDto; | |||||
import cn.com.taiji.managew.dto.product.ProductUpdateRequestDTO; | |||||
import cn.com.taiji.managew.model.product.ProcessingFee; | |||||
import cn.hutool.core.collection.CollectionUtil; | |||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.context.ApplicationContext; | |||||
import org.springframework.stereotype.Service; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import java.util.List; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/26 17:07 | |||||
* @Filename:ProductManagerImpl | |||||
* @description: 产品管理实现类 | |||||
*/ | |||||
@Service | |||||
public class ProductManagerImpl extends RedisCacheManager implements ProductManager{ | |||||
@Autowired | |||||
private IssueProductRepo issueProductRepo; | |||||
@Autowired | |||||
private IssueProductUseFeeRepo issueProductUseFeeRepo; | |||||
@Autowired | |||||
private StaffRepo staffRepo; | |||||
@Autowired | |||||
private IssueProductPayRepo issueProductPayRepo; | |||||
@Autowired | |||||
private ApplicationContext applicationContext; | |||||
@Override | |||||
public void add(ProductAddRequestDto req) throws ManagerException { | |||||
//格式校验 | |||||
req.validate(); | |||||
//业务校验 | |||||
businessValid(req); | |||||
//处理业务 | |||||
ProductManagerImpl proxy = applicationContext.getBean(ProductManagerImpl.class); | |||||
proxy.businessHandle(req); | |||||
} | |||||
private void businessValid(ProductAddRequestDto req) throws ManagerException { | |||||
IssueProduct byProductName = issueProductRepo.findByProductName(req.getProductName()); | |||||
if (byProductName != null) { | |||||
throw new ManagerException("当前产品名称重复,请修改"); | |||||
} | |||||
IssueProduct byReleaseId = issueProductRepo.findByReleaseId(req.getReleaseId()); | |||||
if (byReleaseId != null){ | |||||
throw new ManagerException("当前产品编号重复,请修改"); | |||||
} | |||||
} | |||||
@Transactional(rollbackFor = Exception.class) | |||||
private void businessHandle(ProductAddRequestDto req) throws ManagerException { | |||||
//保存使用费 | |||||
if (CollectionUtil.isNotEmpty(req.getUseFeeList())){ | |||||
if (req.getUseFeeList().stream().anyMatch(useFee -> !useFee.getReleaseId().equals(req.getReleaseId()))) { | |||||
throw new ManagerException("使用费编号与产品编号不一致"); | |||||
} | |||||
issueProductUseFeeRepo.persistAll(req.getUseFeeList()); | |||||
} | |||||
IssueProduct issueProduct = copyProperties(req, new IssueProduct()); | |||||
//售后费 | |||||
if (CollectionUtil.isNotEmpty(req.getAfterSaleFees())) { | |||||
req.getAfterSaleFees().forEach(afterSaleFee -> { | |||||
switch (afterSaleFee.getProductAfterType()){ | |||||
case CHANGECARD: | |||||
issueProduct.setChangeCardFee(afterSaleFee.getAmount()); | |||||
break; | |||||
case CHANGEOBU: | |||||
issueProduct.setChangeObuFee(afterSaleFee.getAmount()); | |||||
break; | |||||
case CHANGEALL: | |||||
issueProduct.setChangeAllFee(afterSaleFee.getAmount()); | |||||
} | |||||
}); | |||||
} | |||||
//办理费 | |||||
if (CollectionUtil.isNotEmpty(req.getProcessingFeeList())) { | |||||
Long amount = 0l; | |||||
for (ProcessingFee processingFee : req.getProcessingFeeList()) { | |||||
switch (processingFee.getProcessingFeeType()){ | |||||
case HANDLE: | |||||
issueProduct.setEquityFee(processingFee.getAmount()); | |||||
break; | |||||
case MARGIN: | |||||
issueProduct.setEnsureFee(processingFee.getAmount()); | |||||
break; | |||||
case PRESTORE: | |||||
issueProduct.setPrestoreFee(processingFee.getAmount()); | |||||
} | |||||
amount += processingFee.getAmount(); | |||||
} | |||||
issueProduct.setAmount(amount); | |||||
} | |||||
issueProduct.setEquityServicesId(String.join(",", req.getEquityServicesId())); | |||||
issueProduct.setExtensionTool(String.join(",",req.getExtensionTool())); | |||||
issueProduct.setVanType(String.join(",",req.getVanType())); | |||||
issueProduct.setVehiclePalce(String.join(",",req.getVehiclePalce())); | |||||
Staff staff = staffRepo.findByStaffId(req.getStaffId()); | |||||
issueProduct.setOperateUserId(staff.getOpenId()); | |||||
issueProduct.setOperateUserName(staff.getStaffName()); | |||||
issueProduct.setExamine(2);//待审核 | |||||
issueProduct.setStatus(EnableFlag.DISABLE); | |||||
issueProductRepo.persist(issueProduct); | |||||
} | |||||
@Override | |||||
public String getReleaseId(GetReleaseIdRequestDTO req) throws ManagerException { | |||||
List<String> allreleaseId = issueProductRepo.findAllReleaseId(); | |||||
String releaseId = null; | |||||
for (int i= 1;i<=999;i++){ | |||||
releaseId = String.format("%03d", i); | |||||
boolean b = allreleaseId.stream().anyMatch(releaseId::contains); | |||||
if (!b){ | |||||
break; | |||||
} | |||||
} | |||||
if (releaseId==null){ | |||||
throw new ManagerException("数据库产品数量已达最大限制999"); | |||||
} | |||||
return releaseId; | |||||
} | |||||
@Override | |||||
public void update(ProductUpdateRequestDTO req) throws ManagerException { | |||||
//格式校验 | |||||
req.validate(); | |||||
//业务校验 | |||||
IssueProduct issueProduct = updateBusinessValid(req); | |||||
//处理业务 | |||||
ProductManagerImpl proxy = applicationContext.getBean(ProductManagerImpl.class); | |||||
proxy.updateBusinessHandle(req,issueProduct); | |||||
} | |||||
private IssueProduct updateBusinessValid(ProductUpdateRequestDTO req) throws ManagerException { | |||||
IssueProduct issueProduct = issueProductRepo.findById(req.getId()).orElse(null); | |||||
if (issueProduct == null){ | |||||
throw new ManagerException("产品不存在"); | |||||
} | |||||
if (!req.getId().equals(issueProduct.getId())){ | |||||
//产品编号被修改,要验证数据库是否已存在此编号 | |||||
IssueProduct byReleaseId = issueProductRepo.findByReleaseId(req.getReleaseId()); | |||||
if (byReleaseId != null) throw new ManagerException("产品编号已存在,请修改"); | |||||
} | |||||
if (!req.getProductName().equals(issueProduct.getProductName())){ | |||||
//产品名称被修改,要验证数据库是否已存在此名称 | |||||
IssueProduct byProductName = issueProductRepo.findByProductName(req.getProductName()); | |||||
if (byProductName != null) throw new ManagerException("产品名称已存在,请修改"); | |||||
} | |||||
return issueProduct; | |||||
} | |||||
@Transactional(rollbackFor = Exception.class) | |||||
private void updateBusinessHandle(ProductUpdateRequestDTO req, IssueProduct issueProduct) throws ManagerException { | |||||
//办理费和使用费不可同时存在 | |||||
//使用费 | |||||
if (CollectionUtil.isNotEmpty(req.getUseFeeList())) { | |||||
if (req.getUseFeeList().stream().anyMatch(useFee -> !useFee.getReleaseId().equals(req.getReleaseId()))) { | |||||
throw new ManagerException("使用费编号与产品编号不一致"); | |||||
} | |||||
//支付方式表去除多余的使用费类型(比如之前配置了三个使用费类型,现在只配置了一个,那么就要把多余的删除) | |||||
List<IssueProductPay> issueProductPayList = | |||||
issueProductPayRepo.findByFeeCategoryAndReleaseId(FeeCategory.USE, issueProduct.getReleaseId()); | |||||
List<IssueProductPay> collect = issueProductPayList.stream().filter(t -> | |||||
req.getUseFeeList().stream().noneMatch(useFee -> useFee.getUseFeeType().equals(t.getFeeType())) | |||||
).collect(Collectors.toList()); | |||||
issueProductPayRepo.deleteAll(collect); | |||||
//清空办理费 | |||||
issueProduct.setEquityFee(null); | |||||
issueProduct.setEnsureFee(null); | |||||
issueProduct.setPrestoreFee(null); | |||||
issueProduct.setAmount(null); | |||||
//清空支付方式表的办理费数据(此时产品编号还没有修改,所以可以用issueProduct.getReleaseId(),删除以前的数据) | |||||
issueProductPayRepo.deleteByfr(FeeCategory.HANDLE,issueProduct.getReleaseId()); | |||||
//更新使用费 | |||||
issueProductUseFeeRepo.deleteByReleaseId(issueProduct.getReleaseId()); | |||||
issueProductUseFeeRepo.persistAll(req.getUseFeeList()); | |||||
} | |||||
//办理费 | |||||
if (CollectionUtil.isNotEmpty(req.getProcessingFeeList())){ | |||||
//支付方式表去除多余的办理费类型(比如之前配置了三个办理费类型,现在只配置了一个,那么就要把多余的删除) | |||||
List<IssueProductPay> issueProductPayList = | |||||
issueProductPayRepo.findByFeeCategoryAndReleaseId(FeeCategory.HANDLE, issueProduct.getReleaseId()); | |||||
List<IssueProductPay> collect = issueProductPayList.stream().filter(t -> | |||||
req.getProcessingFeeList().stream().noneMatch(e -> e.getProcessingFeeType().name().equals(t.getFeeType())) | |||||
).collect(Collectors.toList()); | |||||
issueProductPayRepo.deleteAll(collect); | |||||
//清空使用费 | |||||
issueProductUseFeeRepo.deleteByReleaseId(issueProduct.getReleaseId()); | |||||
//清空支付方式表的使用费数据(此时产品编号还没有修改,所以可以用issueProduct.getReleaseId(),删除以前的数据) | |||||
issueProductPayRepo.deleteByfr(FeeCategory.USE,issueProduct.getReleaseId()); | |||||
//更新办理费 | |||||
Long amount = 0l; | |||||
for (ProcessingFee processingFee : req.getProcessingFeeList()) { | |||||
switch (processingFee.getProcessingFeeType()){ | |||||
case HANDLE: | |||||
issueProduct.setEquityFee(processingFee.getAmount()); | |||||
break; | |||||
case MARGIN: | |||||
issueProduct.setEnsureFee(processingFee.getAmount()); | |||||
break; | |||||
case PRESTORE: | |||||
issueProduct.setPrestoreFee(processingFee.getAmount()); | |||||
} | |||||
amount += processingFee.getAmount(); | |||||
} | |||||
issueProduct.setAmount(amount); | |||||
} | |||||
copyProperties(req,issueProduct); | |||||
issueProduct.setEquityServicesId(String.join(",", req.getEquityServicesId())); | |||||
issueProduct.setExtensionTool(String.join(",",req.getExtensionTool())); | |||||
issueProduct.setVanType(String.join(",",req.getVanType())); | |||||
issueProduct.setVehiclePalce(String.join(",",req.getVehiclePalce())); | |||||
Staff staff = staffRepo.findByStaffId(req.getStaffId()); | |||||
issueProduct.setOperateUserId(staff.getOpenId()); | |||||
issueProduct.setOperateUserName(staff.getStaffName()); | |||||
issueProduct.setExamine(2);//待审核 | |||||
issueProduct.setStatus(EnableFlag.DISABLE); | |||||
issueProductRepo.merge(issueProduct); | |||||
} | |||||
} |
package cn.com.taiji.managew.model.product; | |||||
import cn.com.taiji.core.entity.dict.issue.ProductAfterType; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotNull; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/26 17:37 | |||||
* @Filename:AfterSaleFee | |||||
* @description: 售后费用 | |||||
*/ | |||||
@Data | |||||
public class AfterSaleFee { | |||||
@ApiModelProperty(name = "售后类型") | |||||
@NotNull | |||||
private ProductAfterType productAfterType; | |||||
@ApiModelProperty(name = "金额") | |||||
@NotNull | |||||
private Long amount; | |||||
} |
package cn.com.taiji.managew.model.product; | |||||
import cn.com.taiji.core.entity.dict.issue.ProcessingFeeType; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotNull; | |||||
/** | |||||
* @Author:ChenChao | |||||
* @Date:2025/5/26 17:19 | |||||
* @Filename:ProcessingFee | |||||
* @description: 办理费 | |||||
*/ | |||||
@Data | |||||
public class ProcessingFee { | |||||
@ApiModelProperty(name = "办理费类型") | |||||
@NotNull | |||||
private ProcessingFeeType processingFeeType; | |||||
@ApiModelProperty(name = "金额") | |||||
@NotNull | |||||
private Long amount; | |||||
} |