Commit c1843c04 authored by fangxinjiang's avatar fangxinjiang

见费出单逻辑-fxj

parent 79506681
......@@ -87,6 +87,27 @@ public class BigDecimalUtils {
return isZero ? (r.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : r) : r;
}
/**
* BigDecimal的减法运算,允许返回负数值
* @author : Lingma
* 2026年1月26日
* @param b1 被减数
* @param bn 需要减的减数数组
* @return 返回实际减法结果,如果结果为负数也会返回
*/
public static BigDecimal subtractAllowNegative(BigDecimal b1, BigDecimal... bn) {
if (null == b1) {
b1 = BigDecimal.ZERO;
}
BigDecimal r = b1;
if (null != bn) {
for (BigDecimal b : bn) {
r = r.subtract((null == b ? BigDecimal.ZERO : b));
}
}
return r;
}
/**
* 整型的减法运算,小于0时返回0
* @author : shijing
......
......@@ -356,6 +356,50 @@ public class LocalDateUtil {
}
return dif;
}
/**
* 计算两个日期之间的月数(Excel DATEDIF逻辑)
* @param startDateStr 开始日期,格式:yyyy/MM/dd
* @param endDateStr 结束日期,格式:yyyy/MM/dd
* @return 月数(整月数 + 1)
*/
public static int calculateMonths(String startDateStr, String endDateStr) {
// 定义日期格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 解析日期
LocalDate startDate = LocalDate.parse(startDateStr, formatter);
LocalDate endDate = LocalDate.parse(endDateStr, formatter);
// 计算整月数(Excel DATEDIF的"m"参数逻辑)
int monthsBetween = calculateFullMonths(startDate, endDate);
// 加1(根据Excel公式要求)
return monthsBetween + 1;
}
/**
* 计算两个日期之间的整月数(模仿Excel DATEDIF的"m"参数)
*/
private static int calculateFullMonths(LocalDate startDate, LocalDate endDate) {
// 如果开始日期晚于结束日期,返回0
if (startDate.isAfter(endDate)) {
return 0;
}
// 计算年份和月份的差值
int years = endDate.getYear() - startDate.getYear();
int months = endDate.getMonthValue() - startDate.getMonthValue();
int totalMonths = years * 12 + months;
// 如果结束日的日份小于开始日的日份,减1个月
// 这是Excel DATEDIF的规则:不足整月的不计入
if (endDate.getDayOfMonth() < startDate.getDayOfMonth()) {
totalMonths--;
}
return totalMonths;
}
/**
* 判断两个时间段是否有交集
*
......
......@@ -89,4 +89,8 @@ public interface EkpSettleMapper {
void deleteEkpInsuranceDetailAsso(@Param("id")String id);
void callBackBalance(@Param("id")String id);
void deleteEkpManagerInfo(@Param("id")String id);
void deleteEkpEkpRiskInfo(@Param("id")String id);
}
......@@ -77,6 +77,10 @@ public interface EkpSettleService extends IService<TInsuranceTypeRate> {
void deleteEkpInsuranceDetail(String id);
void deleteEkpManagerInfo(String id);
void deleteEkpEkpRiskInfo(String id);
List<EkpSettleStatusVo> getBalanceByInsuranceId(String id);
void deleteEkpInsuranceDetailAsso(String id);
......
......@@ -136,9 +136,22 @@ public class EkpSettleServiceImpl implements EkpSettleService {
@Override
public void deleteEkpInsuranceDetail(String id) {
//删除商险明细数据
ekpSettleMapper.deleteEkpInsuranceDetail(id);
}
@Override
public void deleteEkpManagerInfo(String id) {
//删除管理费明细数据
ekpSettleMapper.deleteEkpManagerInfo(id);
}
@Override
public void deleteEkpEkpRiskInfo(String id) {
//删除风险金明细数据
ekpSettleMapper.deleteEkpEkpRiskInfo(id);
}
@Override
public List<EkpSettleStatusVo> getBalanceByInsuranceId(String id) {
return ekpSettleMapper.getBalanceByInsuranceId(id);
......
......@@ -516,7 +516,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
private void initJfcdInfo(Date preDispatchDate, TInsuranceDetail detail,List<TInsuranceSettle> settleList) {
//购买周期
String purchaseCycle = "0";
String purchaseCycle = detail.getPurchaseCycle();
LocalDate buyStartDate;
if (CommonConstants.ZERO_STRING.equals(detail.getIsJfcd())){
//计算预计办理日期:若派单当日为工作日3点20之前,则预计办理日期为派单日期,若为3点20之后或派单日为非工作日,则预计办理日期为派单日后最近的一个工作日
......@@ -530,7 +530,6 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
//计算购买周期:购买周期=保单结束日期-参保开始日期+1(天数);购买周期=保单结束日期-参保开始日期+1(天数)推算出月数;
//按天计费方式
if (null != detail.getBillingType() && CommonConstants.ZERO_INT == detail.getBillingType().intValue()){
purchaseCycle = String.valueOf(LocalDateUtil.betweenDay(buyStartDate.toString(), detail.getPolicyEnd().toString())+1);
//计算预计保费:根据计费方式、购买标准、购买天数/月数等计算:
//“计费方式”为“按天”的,预估保费=购买周期天数/365*购买标准+5元;
//“计费方式”为“按月”的,预估保费=购买周期月数对应的费率*购买标准+5元
......@@ -541,15 +540,14 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
.add(new BigDecimal("5.00")));
//按月计费方式
}else if (null != detail.getBillingType() && CommonConstants.ONE_INT == detail.getBillingType().intValue()){
purchaseCycle = String.valueOf(LocalDateUtil.betweenMonthTwo(buyStartDate.toString(), detail.getPolicyEnd().toString())+1);
detail.setEstimatePremium(new BigDecimal(detail.getBuyStandard())
.multiply(new BigDecimal(purchaseCycle))
.multiply(null== detail.getRate()?BigDecimal.ZERO: detail.getRate())
.add(new BigDecimal("5.00")));
}
long day = LocalDateUtil.betweenDay(buyStartDate.toString().toString(),detail.getPolicyEnd().toString());
//购买周期
detail.setPurchaseCycle(purchaseCycle);
detail.setPurchaseCycle(purchaseCycle+"个月|"+day+"天");
//预估缴费状态 0待缴费、1已缴费
detail.setPaymentStatus(CommonConstants.ZERO_STRING);
detail.setBuyHandleStatus(CommonConstants.SIX_INT);
......@@ -1747,6 +1745,8 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
detail.setPolicyEffect(null);
detail.setIsEffect(null);
detail.setIsOverdue(null);
detail.setPaymentTime(CommonConstants.EMPTY_STRING);
detail.setPaymentStatus(CommonConstants.EMPTY_STRING);
}
detail.setUpdateBy(user.getId());
detail.setUpdateTime(LocalDateTime.now());
......@@ -2490,7 +2490,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
if (StringUtils.isNotBlank(success.getActualPremium())){
bigDecimalAct = new BigDecimal(success.getActualPremium());
//如果当前保单为合并结算
if (detail.getSettleType() == CommonConstants.ZERO_INT &&
if ((detail.getSettleType() == CommonConstants.ZERO_INT || CommonConstants.ZERO_STRING.equals(detail.getIsJfcd()) ) &&
StringUtils.isNotBlank(detail.getDefaultSettleId())) {
settle = tInsuranceSettleService.getById(detail.getDefaultSettleId());
if (Optional.ofNullable(settle).isPresent()) {
......@@ -3397,6 +3397,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
param.setPurchaseCycle(month+CommonConstants.EMPTY_STRING);
if (!Optional.ofNullable(typeRate).isPresent()) {
param.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
listResult.add(param);
......@@ -4006,6 +4007,7 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
.eq(TInsuranceTypeRate::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL)
);
param.setPurchaseCycle(month+CommonConstants.EMPTY_STRING);
if (!Optional.ofNullable(typeRate).isPresent()){
param.setErrorMessage(InsurancesConstants.INSURANCE_TYPE_RATE_NOT_EXIST);
listResult.add(param);
......@@ -9726,6 +9728,10 @@ public class TInsuranceDetailServiceImpl extends ServiceImpl<TInsuranceDetailMap
BigDecimal sumMoney = BigDecimal.ZERO;
for (TIncomeDetail income : incomeDetailList) {
socialDaprUtils.deleteById(income);
//删除管理费
ekpSettleService.deleteEkpManagerInfo(income.getId());
//删除风险金
ekpSettleService.deleteEkpEkpRiskInfo(income.getId());
}
}
//未结算更新自动化测的状态为待派单 temployeeinsurancepre
......
......@@ -578,8 +578,9 @@ public class DoJointInsuranceTask {
public void pushEstime(List<TInsuranceDetail> successList) {
//根据结算类型是合并结算,推送预估保费到ekp(上面已经算好,这里直接判断有预估保费的就推送)
for (TInsuranceDetail tInsuranceDetail : successList) {
//如果是合并计算则推送至EKP
if (CommonConstants.ZERO_INT == tInsuranceDetail.getSettleType()) {
//如果是合并计算或见费出单则推送至EKP
if (CommonConstants.ZERO_INT == tInsuranceDetail.getSettleType()
|| CommonConstants.ZERO_STRING.equals(tInsuranceDetail.getIsJfcd())) {
//存储成功后发送给EKP
String s = pushEstimate(tInsuranceDetail, CommonConstants.ONE_INT);
if (StringUtils.isNotBlank(s)) {
......@@ -669,6 +670,10 @@ public class DoJointInsuranceTask {
ys = null==param.getEstimatePremium()? 0.00:param.getEstimatePremium().doubleValue();
//应支=0
pushParam.setFd_3adfe6e3911ffe(0.00);
pushParam.setFd_3adfe6af71a1cc("预估");
//见费出单 是否全部结算 都是 是
pushParam.setFd_3b13b2ecc164aa("是");
}
if (InsurancesConstants.ACTUAL_SETTLE_BILL.equals(param.getSettleType())){
ys = 0L;
......@@ -676,16 +681,18 @@ public class DoJointInsuranceTask {
//差额
if (InsurancesConstants.BALANCE_SETTLE_BILL.equals(param.getSettleType())){
//应收=实缴的应支-预估的应收
ys = BigDecimalUtils.safeSubtract(param.getActualPremium(),param.getEstimatePremium()).doubleValue();
ys = BigDecimalUtils.subtractAllowNegative(param.getActualPremium(),param.getEstimatePremium()).doubleValue();
//应支=0
pushParam.setFd_3adfe6e3911ffe(0.00);
//是否全部结算
pushParam.setFd_3b13b2ecc164aa("是");
//实际保费设置为0.0
pushParam.setFd_3adfe6610c0d2c(0.00);
pushParam.setFd_3adfe6610c0d2c(null == param.getActualPremium()?0.00:param.getActualPremium().doubleValue());
//见费出单 是否全部结算 都是 是
pushParam.setFd_3b13b2ecc164aa("是");
}
}
}
/*if (!"是".equals(deptInfoVo.getIsBpo())) {
......
......@@ -113,6 +113,13 @@
<delete id="callBackBalance">
delete from ekp_insurances_info where fd_3b0a5743acab7e like CONCAT(#{id},'%') and fd_jfcd='是' and fd_3adfe6af71a1cc = '差额'
</delete>
<delete id="deleteEkpManagerInfo">
delete from ekp_manager_info where fd_3b13dc864a3052 = #{id}
</delete>
<delete id="deleteEkpEkpRiskInfo">
delete from ekp_risk_info where fd_3b13db120a8224 = #{id}
</delete>
<select id="getDeptSettle" resultMap="BaseDeptResultMap">
select
<include refid="Base_Column_Dept"></include>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment