Commit 546708fa by zhangxingmin

push

parent 2dc97703
...@@ -17,6 +17,7 @@ import com.yd.csf.service.model.*; ...@@ -17,6 +17,7 @@ import com.yd.csf.service.model.*;
import com.yd.csf.service.service.*; import com.yd.csf.service.service.*;
import com.yd.feign.config.FeignTokenInterceptor; import com.yd.feign.config.FeignTokenInterceptor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
...@@ -26,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes; ...@@ -26,6 +27,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.*;
...@@ -157,7 +159,24 @@ public class ApiExpectedFortuneAsyncService { ...@@ -157,7 +159,24 @@ public class ApiExpectedFortuneAsyncService {
//积分解冻时间 //积分解冻时间
LocalDateTime thawingTime = resDto.getThawingTime(); LocalDateTime thawingTime = resDto.getThawingTime();
// 介绍费占比
String brokerRatio = resDto.getBrokerRatio();
// 将 brokerRatio 转为小数乘数,如 "30" -> 0.3, "60" -> 0.6
BigDecimal ratioFactor = BigDecimal.ZERO;
try {
BigDecimal ratioNum = new BigDecimal(brokerRatio);
ratioFactor = ratioNum.divide(new BigDecimal("100"), 6, RoundingMode.HALF_UP); // 保留足够精度
} catch (Exception e) {
log.warn("brokerRatio 转换失败,使用 0,policyNo: {}, brokerRatio: {}", policyNo, brokerRatio);
}
for (AlgorithmResDto algorithmResDto : resDto.getAlgorithmResDtoList()) { for (AlgorithmResDto algorithmResDto : resDto.getAlgorithmResDtoList()) {
// 原始佣金值
BigDecimal originalFyc = algorithmResDto.getCalculatedValue();
// 折后佣金值(乘以介绍费占比)
BigDecimal effectiveFyc = originalFyc.multiply(ratioFactor);
if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) <= 0) { if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) <= 0) {
//判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否小于等于当前时间(年月日时分秒) //判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否小于等于当前时间(年月日时分秒)
//如果小于等于当前时间,不用走定时任务来解冻积分,应该及时生效积分 //如果小于等于当前时间,不用走定时任务来解冻积分,应该及时生效积分
...@@ -166,7 +185,7 @@ public class ApiExpectedFortuneAsyncService { ...@@ -166,7 +185,7 @@ public class ApiExpectedFortuneAsyncService {
String detailFycBizId = RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_AGENT_DETAIL_FYC.getCode()); String detailFycBizId = RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_AGENT_DETAIL_FYC.getCode());
//新增积分明细 //新增积分明细
//status 定时任务0-冻结。非定时任务1-生效 //status 定时任务0-冻结。非定时任务1-生效
addAgentDetailFyc(resDto,policyNo,algorithmResDto,detailFycBizId,agentAccumulatedFyc,1,exchangeRate); addAgentDetailFyc(resDto,policyNo,algorithmResDto,detailFycBizId,agentAccumulatedFyc,1,exchangeRate,effectiveFyc);
}else if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) > 0){ }else if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) > 0){
//判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否大于当前时间(年月日时分秒) //判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否大于当前时间(年月日时分秒)
...@@ -194,7 +213,7 @@ public class ApiExpectedFortuneAsyncService { ...@@ -194,7 +213,7 @@ public class ApiExpectedFortuneAsyncService {
//发佣期数 //发佣期数
calmTask.setFortunePeriod(resDto.getFortunePeriod()); calmTask.setFortunePeriod(resDto.getFortunePeriod());
//汇率转换前佣金值(积分值) //汇率转换前佣金值(积分值)
calmTask.setFyc(algorithmResDto.getCalculatedValue()); calmTask.setFyc(effectiveFyc);
//汇率(保单币种->港币的汇率) //汇率(保单币种->港币的汇率)
calmTask.setExchangeRate(exchangeRate); calmTask.setExchangeRate(exchangeRate);
//汇率转换后佣金值(积分值) //汇率转换后佣金值(积分值)
...@@ -210,7 +229,7 @@ public class ApiExpectedFortuneAsyncService { ...@@ -210,7 +229,7 @@ public class ApiExpectedFortuneAsyncService {
//新增积分明细 //新增积分明细
//status 定时任务0-冻结。非定时任务1-生效 //status 定时任务0-冻结。非定时任务1-生效
addAgentDetailFyc(resDto,policyNo,algorithmResDto,detailFycBizId,agentAccumulatedFyc,0,exchangeRate); addAgentDetailFyc(resDto,policyNo,algorithmResDto,detailFycBizId,agentAccumulatedFyc,0,exchangeRate,effectiveFyc);
//创建XXL-Job定时任务 //创建XXL-Job定时任务
xxlJobService.addScheduleJob(calmTask.getCalmTaskBizId(),"冷静期定时发送任务-","calmSendJobHandler",Date.from(resDto.getThawingTime().atZone(ZoneId.systemDefault()).toInstant())); xxlJobService.addScheduleJob(calmTask.getCalmTaskBizId(),"冷静期定时发送任务-","calmSendJobHandler",Date.from(resDto.getThawingTime().atZone(ZoneId.systemDefault()).toInstant()));
...@@ -231,6 +250,7 @@ public class ApiExpectedFortuneAsyncService { ...@@ -231,6 +250,7 @@ public class ApiExpectedFortuneAsyncService {
* @param detailFycBizId * @param detailFycBizId
* @param agentAccumulatedFyc * @param agentAccumulatedFyc
* @param status 定时任务0-冻结。非定时任务1-生效 * @param status 定时任务0-冻结。非定时任务1-生效
* @param effectiveFyc 折后佣金值(乘以介绍费占比)
*/ */
public void addAgentDetailFyc(AlgorithmCollectResDto resDto, public void addAgentDetailFyc(AlgorithmCollectResDto resDto,
String policyNo, String policyNo,
...@@ -238,7 +258,8 @@ public class ApiExpectedFortuneAsyncService { ...@@ -238,7 +258,8 @@ public class ApiExpectedFortuneAsyncService {
String detailFycBizId, String detailFycBizId,
AgentAccumulatedFyc agentAccumulatedFyc, AgentAccumulatedFyc agentAccumulatedFyc,
Integer status, Integer status,
BigDecimal exchangeRate) { BigDecimal exchangeRate,
BigDecimal effectiveFyc) {
//新增积分明细 //新增积分明细
AgentDetailFyc agentDetailFyc = new AgentDetailFyc(); AgentDetailFyc agentDetailFyc = new AgentDetailFyc();
//积分来源类型 //积分来源类型
...@@ -269,9 +290,9 @@ public class ApiExpectedFortuneAsyncService { ...@@ -269,9 +290,9 @@ public class ApiExpectedFortuneAsyncService {
//变化前的业务员总FYC积分(已生效+未生效) //变化前的业务员总FYC积分(已生效+未生效)
agentDetailFyc.setBeforeFyc(agentAccumulatedFyc != null ? agentAccumulatedFyc.getTotalFyc() : BigDecimal.ZERO); agentDetailFyc.setBeforeFyc(agentAccumulatedFyc != null ? agentAccumulatedFyc.getTotalFyc() : BigDecimal.ZERO);
//汇率转化前积分值(变化值(-代表减少)) //汇率转化前积分值(变化值(-代表减少))
agentDetailFyc.setChangeFyc(algorithmResDto.getCalculatedValue()); agentDetailFyc.setChangeFyc(effectiveFyc);
//变化后的业务员总FYC积分 //变化后的业务员总FYC积分
agentDetailFyc.setAfterFyc(agentDetailFyc.getBeforeFyc().add(algorithmResDto.getCalculatedValue())); agentDetailFyc.setAfterFyc(agentDetailFyc.getBeforeFyc().add(effectiveFyc));
//汇率(保单币种->港币的汇率) //汇率(保单币种->港币的汇率)
agentDetailFyc.setExchangeRate(exchangeRate); agentDetailFyc.setExchangeRate(exchangeRate);
//汇率转化后积分值(变化值(-代表减少)) = 汇率转化前积分值 * 汇率 //汇率转化后积分值(变化值(-代表减少)) = 汇率转化前积分值 * 汇率
...@@ -328,52 +349,66 @@ public class ApiExpectedFortuneAsyncService { ...@@ -328,52 +349,66 @@ public class ApiExpectedFortuneAsyncService {
hashSet.add(agentId); hashSet.add(agentId);
// 介绍费占比
String brokerRatio = resDto.getBrokerRatio();
// 将 brokerRatio 转为小数乘数,如 "30" -> 0.3, "60" -> 0.6
BigDecimal ratioFactor = BigDecimal.ZERO;
try {
BigDecimal ratioNum = new BigDecimal(brokerRatio);
ratioFactor = ratioNum.divide(new BigDecimal("100"), 6, RoundingMode.HALF_UP); // 保留足够精度
} catch (Exception e) {
log.warn("brokerRatio 转换失败, brokerRatio: {}", brokerRatio);
}
//积分解冻时间 //积分解冻时间
LocalDateTime thawingTime = resDto.getThawingTime(); LocalDateTime thawingTime = resDto.getThawingTime();
for (AlgorithmResDto algorithmResDto : resDto.getAlgorithmResDtoList()) { for (AlgorithmResDto algorithmResDto : resDto.getAlgorithmResDtoList()) {
BigDecimal val = algorithmResDto.getCalculatedValue(); // 原始佣金值
if (val == null) continue; BigDecimal originalFyc = algorithmResDto.getCalculatedValue();
//val汇率转换后的值 if (originalFyc == null) continue;
val = val.multiply(exchangeRate); // 折后佣金值(乘以介绍费占比)
BigDecimal effectiveFyc = originalFyc.multiply(ratioFactor);
//effectiveFyc汇率转换后的值
effectiveFyc = effectiveFyc.multiply(exchangeRate);
if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) <= 0) { if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) <= 0) {
//判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否小于等于当前时间(年月日时分秒) //判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否小于等于当前时间(年月日时分秒)
//如果小于等于当前时间,不用走定时任务来解冻积分,应该及时生效积分 //如果小于等于当前时间,不用走定时任务来解冻积分,应该及时生效积分
// 已生效个人累计积分增量(非定时(生效)) // 已生效个人累计积分增量(非定时(生效))
deltaMap.merge(agentId, val, BigDecimal::add); deltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
// 根据期数判断佣金类型 // 根据期数判断佣金类型
if (fortunePeriod != null && fortunePeriod == 1) { if (fortunePeriod != null && fortunePeriod == 1) {
//已生效首期佣金增量(非定时(生效)) //已生效首期佣金增量(非定时(生效))
firstCommissionDeltaMap.merge(agentId, val, BigDecimal::add); firstCommissionDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
if (RuleItemEnum.SALES.getRuleItemBizId().equals(algorithmResDto.getRuleItemBizId())) { if (RuleItemEnum.SALES.getRuleItemBizId().equals(algorithmResDto.getRuleItemBizId())) {
//销售佣金项目 //销售佣金项目
//已生效累计首期销售佣金积分值(销售佣金场景(佣金场景的其中一个))增量(非定时(生效)) //已生效累计首期销售佣金积分值(销售佣金场景(佣金场景的其中一个))增量(非定时(生效))
firstSalesCommissionDeltaMap.merge(agentId, val, BigDecimal::add); firstSalesCommissionDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
} }
} else { } else {
//已生效非首期佣金增量(非定时(生效)) //已生效非首期佣金增量(非定时(生效))
rycDeltaMap.merge(agentId, val, BigDecimal::add); rycDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
} }
}else if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) > 0){ }else if (thawingTime != null && thawingTime.compareTo(LocalDateTime.now()) > 0){
//判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否大于当前时间(年月日时分秒) //判断积分解冻时间(年月日 + 00:00:00)(冷静期时间 + 期数)是否大于当前时间(年月日时分秒)
//如果大于当前时间,走定时任务来解冻积分。 //如果大于当前时间,走定时任务来解冻积分。
// 未生效个人累计积分增量(定时(冻结)) // 未生效个人累计积分增量(定时(冻结))
noDeltaMap.merge(agentId, val, BigDecimal::add); noDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
// 根据期数判断佣金类型 // 根据期数判断佣金类型
if (fortunePeriod != null && fortunePeriod == 1) { if (fortunePeriod != null && fortunePeriod == 1) {
//未生效首期佣金增量(定时(冻结)) //未生效首期佣金增量(定时(冻结))
noFirstCommissionDeltaMap.merge(agentId, val, BigDecimal::add); noFirstCommissionDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
if (RuleItemEnum.SALES.getRuleItemBizId().equals(algorithmResDto.getRuleItemBizId())) { if (RuleItemEnum.SALES.getRuleItemBizId().equals(algorithmResDto.getRuleItemBizId())) {
//销售佣金项目 //销售佣金项目
//未生效累计首期销售佣金积分值(销售佣金场景(佣金场景的其中一个))增量(定时(冻结)) //未生效累计首期销售佣金积分值(销售佣金场景(佣金场景的其中一个))增量(定时(冻结))
noFirstSalesCommissionDeltaMap.merge(agentId, val, BigDecimal::add); noFirstSalesCommissionDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
} }
} else { } else {
//未生效非首期佣金增量(定时(冻结)) //未生效非首期佣金增量(定时(冻结))
noRycDeltaMap.merge(agentId, val, BigDecimal::add); noRycDeltaMap.merge(agentId, effectiveFyc, BigDecimal::add);
} }
} }
} }
......
...@@ -21,6 +21,11 @@ public class AlgorithmCollectResDto { ...@@ -21,6 +21,11 @@ public class AlgorithmCollectResDto {
private String clientUserName; private String clientUserName;
/** /**
* 介绍费占比
*/
private String brokerRatio;
/**
* 发佣期数(1=第一年; 2=第二年; 3=第三年; 4=第四年; 5=第五年) * 发佣期数(1=第一年; 2=第二年; 3=第三年; 4=第四年; 5=第五年)
*/ */
private Integer fortunePeriod; private Integer fortunePeriod;
......
...@@ -570,6 +570,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -570,6 +570,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
LocalDateTime actualThawingTime = baseThawingTime.plusYears(resDto.getFortunePeriod() - 1); LocalDateTime actualThawingTime = baseThawingTime.plusYears(resDto.getFortunePeriod() - 1);
//积分解冻时间(受发佣期数影响,第一年就是冷静期结束日期,第二年冷静期结束日期+1年,以此类推) //积分解冻时间(受发佣期数影响,第一年就是冷静期结束日期,第二年冷静期结束日期+1年,以此类推)
resDto.setThawingTime(actualThawingTime); resDto.setThawingTime(actualThawingTime);
//介绍费占比
resDto.setBrokerRatio(brokerDto.getBrokerRatio());
resDto.setAlgorithmResDtoList(result.getData()); resDto.setAlgorithmResDtoList(result.getData());
collectResDtos.add(resDto); collectResDtos.add(resDto);
......
...@@ -86,5 +86,10 @@ public class QueryPolicyAndBrokerDto { ...@@ -86,5 +86,10 @@ public class QueryPolicyAndBrokerDto {
* 所属团队业务id * 所属团队业务id
*/ */
private String teamBizId; private String teamBizId;
/**
* 介绍费占比
*/
private String brokerRatio;
//======保单转介人信息end======= //======保单转介人信息end=======
} }
...@@ -88,7 +88,7 @@ public class CalmTask implements Serializable { ...@@ -88,7 +88,7 @@ public class CalmTask implements Serializable {
private String brokerName; private String brokerName;
/** /**
* 汇率转换前佣金值(积分值) * 汇率转换前佣金值(积分值)(增量积分值)
*/ */
@TableField("fyc") @TableField("fyc")
private BigDecimal fyc; private BigDecimal fyc;
...@@ -100,7 +100,7 @@ public class CalmTask implements Serializable { ...@@ -100,7 +100,7 @@ public class CalmTask implements Serializable {
private BigDecimal exchangeRate; private BigDecimal exchangeRate;
/** /**
* 汇率转换后佣金值(积分值) * 汇率转换后佣金值(积分值)(增量积分值)
*/ */
@TableField("after_fyc") @TableField("after_fyc")
private BigDecimal afterFyc; private BigDecimal afterFyc;
......
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