Commit 693c1d6b by zhangxingmin

Merge remote-tracking branch 'origin/test' into test

parents 66cddc96 48a7df98
...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.yd.auth.core.dto.AuthUserDto; import com.yd.auth.core.dto.AuthUserDto;
import com.yd.auth.core.utils.SecurityUtil; import com.yd.auth.core.utils.SecurityUtil;
import com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient; import com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient;
...@@ -526,19 +527,19 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -526,19 +527,19 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result executeSync(List<QueryPolicyAndBrokerDto> queryPolicyAndBrokerDtoList, public Result executeSync(List<QueryPolicyAndBrokerDto> queryPolicyAndBrokerDtoList,
String policyNo, List<ApiAnnouncementCommissionRatioListResponse> announcementRatioList,Integer paymentTerm) { String policyNo, List<ApiAnnouncementCommissionRatioListResponse> announcementRatioList, Integer paymentTerm) {
log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->入参queryPolicyAndBrokerDtoList:{}",JSON.toJSONString(queryPolicyAndBrokerDtoList)); log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->入参queryPolicyAndBrokerDtoList:{}", JSON.toJSONString(queryPolicyAndBrokerDtoList));
log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->入参policyNo:{}",policyNo); log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->入参policyNo:{}", policyNo);
HttpServletRequest request1 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request1 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token = request1.getHeader("Authorization"); String token = request1.getHeader("Authorization");
log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表 token==============,{}",token); log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表 token==============,{}", token);
// 使用编程式事务,确保方法内的事务一致性 // 使用编程式事务,确保方法内的事务一致性
return transactionTemplate.execute(status -> { return transactionTemplate.execute(status -> {
try { try {
HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token2 = request2.getHeader("Authorization"); String token2 = request2.getHeader("Authorization");
log.info("使用编程式事务,确保方法内的事务一致性 token==============,{}",token2); log.info("使用编程式事务,确保方法内的事务一致性 token==============,{}", token2);
//保单币种->港币的汇率 //保单币种->港币的汇率
BigDecimal exchangeRate = BigDecimal.ZERO; BigDecimal exchangeRate = BigDecimal.ZERO;
...@@ -563,7 +564,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -563,7 +564,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
.toLocalDateTime(); .toLocalDateTime();
List<CommissionRuleBinding> commissionRuleBindingList = brokerRelUserIdList(brokerDto); List<CommissionRuleBinding> commissionRuleBindingList = brokerRelUserIdList(brokerDto);
log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->commissionRuleBindingList:{}",JSON.toJSONString(commissionRuleBindingList)); log.info("同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->commissionRuleBindingList:{}", JSON.toJSONString(commissionRuleBindingList));
for (int i = 1; i <= paymentTerm; i++) { for (int i = 1; i <= paymentTerm; i++) {
Result<List<AlgorithmResDto>> result = executeBilling(ExecuteBillingDto.builder() Result<List<AlgorithmResDto>> result = executeBilling(ExecuteBillingDto.builder()
.name(brokerDto.getBrokerName()) .name(brokerDto.getBrokerName())
...@@ -619,7 +620,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -619,7 +620,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//默认结算汇率、港币金额 //默认结算汇率、港币金额
String policyCurrency = queryPolicyAndBrokerDtoList.get(0).getCurrency(); String policyCurrency = queryPolicyAndBrokerDtoList.get(0).getCurrency();
updateHkdAmountBatch(expectedFortuneList, policyCurrency, announcementRatioList);; updateHkdAmountBatch(expectedFortuneList, policyCurrency, announcementRatioList);
;
//执行成功完毕,也要销毁redis缓存 //执行成功完毕,也要销毁redis缓存
redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo); redisUtil.deleteObject(RedisConstants.EXPECTED_FORTUNE + policyNo);
...@@ -655,6 +657,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -655,6 +657,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/** /**
* 查询和当前转介人相关关系(推荐,一级管理,二级管理,辅导)的客户端用户ID列表数据 * 查询和当前转介人相关关系(推荐,一级管理,二级管理,辅导)的客户端用户ID列表数据
*
* @param brokerDto * @param brokerDto
* @return * @return
*/ */
...@@ -708,7 +711,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -708,7 +711,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//构造销售佣金基本法项目的顺序下标值执行 //构造销售佣金基本法项目的顺序下标值执行
List<Integer> executionOrderList = new ArrayList<>(); List<Integer> executionOrderList = new ArrayList<>();
executionOrderList.add(1); executionOrderList.add(1);
log.info("执行获得积分用户的非销售佣金基本法项目->入参:{}",JSON.toJSONString(dto)); log.info("执行获得积分用户的非销售佣金基本法项目->入参:{}", JSON.toJSONString(dto));
//执行获得积分用户的非销售佣金基本法项目 //执行获得积分用户的非销售佣金基本法项目
Result<List<AlgorithmResDto>> result = apiBasicLawCalculateService.policyBrokerAlgorithm(AlgorithmDto.builder() Result<List<AlgorithmResDto>> result = apiBasicLawCalculateService.policyBrokerAlgorithm(AlgorithmDto.builder()
.brokerBizId(brokerDto.getBrokerBizId()) .brokerBizId(brokerDto.getBrokerBizId())
...@@ -725,7 +728,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -725,7 +728,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
.executionOrderList(executionOrderList) .executionOrderList(executionOrderList)
.isNegateExecutionOrderList(true) .isNegateExecutionOrderList(true)
.build()); .build());
log.info("执行获得积分用户的非销售佣金基本法项目->出参:{}",JSON.toJSONString(result)); log.info("执行获得积分用户的非销售佣金基本法项目->出参:{}", JSON.toJSONString(result));
//生成保单预计发佣表记录 (非销售佣金基本法) //生成保单预计发佣表记录 (非销售佣金基本法)
generateExpectedFortune(GenerateExpectedFortuneDto.builder() generateExpectedFortune(GenerateExpectedFortuneDto.builder()
...@@ -1152,6 +1155,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1152,6 +1155,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
/** /**
* 保单币种对预计来佣的结算币种的默认汇率 * 保单币种对预计来佣的结算币种的默认汇率
*
* @param policyCurrency 保单币种 * @param policyCurrency 保单币种
* @param currency 预计来佣的结算币种 * @param currency 预计来佣的结算币种
* @return 汇率 * @return 汇率
...@@ -1159,7 +1163,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1159,7 +1163,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) { private BigDecimal queryExchangeRateByFeign(String policyCurrency, String currency) {
HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); HttpServletRequest request2 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String token2 = request2.getHeader("Authorization"); String token2 = request2.getHeader("Authorization");
log.info("保单币种对预计来佣的结算币种的默认汇率 token==============,{}",token2); log.info("保单币种对预计来佣的结算币种的默认汇率 token==============,{}", token2);
if (policyCurrency.equalsIgnoreCase(currency)) { if (policyCurrency.equalsIgnoreCase(currency)) {
return BigDecimal.ONE; return BigDecimal.ONE;
} }
...@@ -1331,6 +1335,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1331,6 +1335,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
List<String> brokerBizIdList = request.getBrokerBizIdList(); List<String> brokerBizIdList = request.getBrokerBizIdList();
List<String> signerBizIdList = request.getSignerBizIdList(); List<String> signerBizIdList = request.getSignerBizIdList();
String fortuneBizType = request.getFortuneBizType(); String fortuneBizType = request.getFortuneBizType();
String policyHolder = request.getPolicyHolder();
// 按保单号模糊查询 // 按保单号模糊查询
queryWrapper.eq(ObjectUtils.isNotEmpty(payableNo), "payable_no", payableNo); queryWrapper.eq(ObjectUtils.isNotEmpty(payableNo), "payable_no", payableNo);
...@@ -1344,9 +1349,21 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService ...@@ -1344,9 +1349,21 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
queryWrapper.in(ObjectUtils.isNotEmpty(teamBizIdList), "team_biz_id", teamBizIdList); queryWrapper.in(ObjectUtils.isNotEmpty(teamBizIdList), "team_biz_id", teamBizIdList);
queryWrapper.in(ObjectUtils.isNotEmpty(insuranceCompanyBizIdList), "insurance_company_biz_id", insuranceCompanyBizIdList); queryWrapper.in(ObjectUtils.isNotEmpty(insuranceCompanyBizIdList), "insurance_company_biz_id", insuranceCompanyBizIdList);
queryWrapper.in(ObjectUtils.isNotEmpty(productLaunchBizIdList), "product_launch_biz_id", productLaunchBizIdList); queryWrapper.in(ObjectUtils.isNotEmpty(productLaunchBizIdList), "product_launch_biz_id", productLaunchBizIdList);
queryWrapper.in(ObjectUtils.isNotEmpty(brokerBizIdList), "broker_biz_id", brokerBizIdList); // 根据转介人(主)查询
if (!CollectionUtils.isEmpty(brokerBizIdList)) {
// 构建带引号的参数列表
String brokerIds = brokerBizIdList.stream()
.map(id -> "'" + id + "'")
.collect(Collectors.joining(","));
queryWrapper.apply("EXISTS (SELECT 1 FROM policy_follow f WHERE f.policy_no = expected_fortune.policy_no AND f.first_broker_biz_id in (" + brokerIds + "))");
}
queryWrapper.in(ObjectUtils.isNotEmpty(signerBizIdList), "signer_biz_id", signerBizIdList); queryWrapper.in(ObjectUtils.isNotEmpty(signerBizIdList), "signer_biz_id", signerBizIdList);
queryWrapper.eq(StringUtils.isNotBlank(fortuneBizType), "fortune_biz_type", fortuneBizType); queryWrapper.eq(StringUtils.isNotBlank(fortuneBizType), "fortune_biz_type", fortuneBizType);
// 根据投保人名称查询
if (StringUtils.isNotBlank(policyHolder)) {
queryWrapper.apply("EXISTS (SELECT 1 FROM policy_follow f WHERE f.policy_no = expected_fortune.policy_no AND (f.policy_holder like concat('%', ?, '%') or f.policy_holder_en like concat('%', ?, '%')))",
policyHolder, policyHolder);
}
queryWrapper.in(ObjectUtils.isNotEmpty(request.getPolicyNoList()), "policy_no", request.getPolicyNoList()); queryWrapper.in(ObjectUtils.isNotEmpty(request.getPolicyNoList()), "policy_no", request.getPolicyNoList());
// 按id升序排序 // 按id升序排序
......
...@@ -51,7 +51,7 @@ public class ApiExpectedFortunePageRequest extends PageDto { ...@@ -51,7 +51,7 @@ public class ApiExpectedFortunePageRequest extends PageDto {
@Schema(description = "产品计划业务ID列表") @Schema(description = "产品计划业务ID列表")
private List<String> productLaunchBizIdList; private List<String> productLaunchBizIdList;
@Schema(description = "转介人业务ID列表") @Schema(description = "转介人(主)业务ID列表")
private List<String> brokerBizIdList; private List<String> brokerBizIdList;
@Schema(description = "签单员业务ID列表") @Schema(description = "签单员业务ID列表")
......
...@@ -35,6 +35,16 @@ public class PolicyFollow implements Serializable { ...@@ -35,6 +35,16 @@ public class PolicyFollow implements Serializable {
private String policyNo; private String policyNo;
/** /**
* 转介人(主)
*/
private String firstBroker;
/**
* 转介人(主)业务ID
*/
private String firstBrokerBizId;
/**
* FNA 业务ID * FNA 业务ID
*/ */
private String fnaBizId; private String fnaBizId;
......
...@@ -1220,6 +1220,8 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -1220,6 +1220,8 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// 更新 fortune 的字段, 已设置的不更新,记录更新成功及跳过的条数 // 更新 fortune 的字段, 已设置的不更新,记录更新成功及跳过的条数
int updateCount = 0; int updateCount = 0;
int skipCount = 0; int skipCount = 0;
List<Fortune> updateFortuneList = new ArrayList<>();
List<String> expectedFortuneBizIdList = new ArrayList<>();
for (Fortune fortune : fortuneList) { for (Fortune fortune : fortuneList) {
if (ObjectUtils.isEmpty(fortune.getActualPayoutDate())) { if (ObjectUtils.isEmpty(fortune.getActualPayoutDate())) {
updateCount++; updateCount++;
...@@ -1227,12 +1229,24 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune> ...@@ -1227,12 +1229,24 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
skipCount++; skipCount++;
continue; continue;
} }
this.lambdaUpdate()
.set(Fortune::getActualPayoutDate, actualPayoutDate) Fortune updateFortune = new Fortune();
.eq(Fortune::getId, fortune.getId()) updateFortune.setId(fortune.getId());
.update(); updateFortune.setActualPayoutDate(actualPayoutDate);
updateFortuneList.add(updateFortune);
expectedFortuneBizIdList.add(fortune.getExpectedFortuneBizId());
} }
// 更新 fortune 的字段
this.updateBatchById(updateFortuneList);
// 更新预计 fortune 的字段
expectedFortuneService.lambdaUpdate()
.set(ExpectedFortune::getActualPayoutDate, actualPayoutDate)
.in(ExpectedFortune::getExpectedFortuneBizId, expectedFortuneBizIdList)
.update();
return String.format("设置成功。已更新 %d 条数据,跳过 %d 条(已有实际出账年月)", updateCount, skipCount); return String.format("设置成功。已更新 %d 条数据,跳过 %d 条(已有实际出账年月)", updateCount, skipCount);
} }
......
...@@ -1081,7 +1081,19 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol ...@@ -1081,7 +1081,19 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
brokerList.add(policyBroker); brokerList.add(policyBroker);
} }
return policyBrokerService.saveBatch(brokerList); policyBrokerService.saveBatch(brokerList);
// brokerList 根据 id 升序
brokerList.sort(Comparator.comparing(PolicyBroker::getId));
// policyFollow 表更新 first_broker_biz_id 字段
policyFollowService.lambdaUpdate()
.eq(PolicyFollow::getPolicyBizId, policyBizId)
.set(PolicyFollow::getFirstBroker, brokerList.get(0).getBrokerName())
.set(PolicyFollow::getFirstBrokerBizId, brokerList.get(0).getBrokerBizId())
.update();
return true;
} }
@Override @Override
......
...@@ -79,11 +79,12 @@ ...@@ -79,11 +79,12 @@
then round(100 - (ifnull(sum(ef.paid_amount), 0) / ifnull(sum(ef.hkd_amount), 0) * 100), 2) then round(100 - (ifnull(sum(ef.paid_amount), 0) / ifnull(sum(ef.hkd_amount), 0) * 100), 2)
else 100 else 100
end as unpaidRatio, end as unpaidRatio,
MAX(ef.broker) as broker, pf.first_broker as broker,
MAX(ef.broker_biz_id) as brokerBizId, pf.first_broker_biz_id as brokerBizId,
DATE_ADD(DATE_ADD(MAX(p.effective_date), INTERVAL 2 MONTH), INTERVAL (ef.fortune_period - 1) YEAR) as payoutDate DATE_ADD(DATE_ADD(MAX(p.effective_date), INTERVAL 2 MONTH), INTERVAL (ef.fortune_period - 1) YEAR) as payoutDate
from expected_fortune ef from expected_fortune ef
left join policy p on ef.policy_no = p.policy_no left join policy p on ef.policy_no = p.policy_no
left join policy_follow pf on ef.policy_no = pf.policy_no
<where> <where>
ef.fortune_biz_type = 'R' ef.fortune_biz_type = 'R'
<if test="expectedFortuneIds != null and expectedFortuneIds.size > 0"> <if test="expectedFortuneIds != null and expectedFortuneIds.size > 0">
...@@ -122,8 +123,8 @@ ...@@ -122,8 +123,8 @@
then round(100 - (ifnull(ef.paid_amount, 0) / ifnull(ef.hkd_amount, 0) * 100), 2) then round(100 - (ifnull(ef.paid_amount, 0) / ifnull(ef.hkd_amount, 0) * 100), 2)
else 100 else 100
end as unpaidRatio, end as unpaidRatio,
ef.broker as broker, NULL as broker,
ef.broker_biz_id as brokerBizId, NULL as brokerBizId,
ef.payout_date as payoutDate ef.payout_date as payoutDate
from expected_fortune ef from expected_fortune ef
left join policy p on ef.policy_no = p.policy_no left join policy p on ef.policy_no = p.policy_no
...@@ -265,7 +266,7 @@ ...@@ -265,7 +266,7 @@
</if> </if>
</where> </where>
ORDER BY id ASC ORDER BY type ASC, create_time ASC
LIMIT #{pageSize} OFFSET #{offset} LIMIT #{pageSize} OFFSET #{offset}
</select> </select>
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
<id property="id" column="id" /> <id property="id" column="id" />
<result property="policyBizId" column="policy_biz_id" /> <result property="policyBizId" column="policy_biz_id" />
<result property="policyNo" column="policy_no" /> <result property="policyNo" column="policy_no" />
<result property="firstBroker" column="first_broker" />
<result property="firstBrokerBizId" column="first_broker_biz_id" />
<result property="fnaBizId" column="fna_biz_id" /> <result property="fnaBizId" column="fna_biz_id" />
<result property="appointmentBizId" column="appointment_biz_id" /> <result property="appointmentBizId" column="appointment_biz_id" />
<result property="appointmentNo" column="appointment_no" /> <result property="appointmentNo" column="appointment_no" />
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,policy_biz_id,policy_no,fna_biz_id,appointment_biz_id,appointment_no,customer_biz_id, id,policy_biz_id,policy_no,first_broker,first_broker_biz_id,fna_biz_id,appointment_biz_id,appointment_no,customer_biz_id,
submit_date,customer_name,sign_date,signer,signer_biz_id, submit_date,customer_name,sign_date,signer,signer_biz_id,
practice_code,sign_location,issue_date,cooling_off_end_date,cooling_off_days, practice_code,sign_location,issue_date,cooling_off_end_date,cooling_off_days,
underwriting_date,effective_date,renewal_date,receipt_date,receipt_status, underwriting_date,effective_date,renewal_date,receipt_date,receipt_status,
......
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