Commit 546708fa by zhangxingmin

push

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