This commit is contained in:
1073413548 2024-09-09 16:35:27 +08:00
parent 3afd28afa5
commit 2fa8673bb7
5 changed files with 32 additions and 13 deletions

View File

@ -80,15 +80,16 @@ public class CalSalaryBatch {
List<SysUser> list = sysUserMapper.selectList(Wrappers.<SysUser>lambdaQuery().select(SysUser::getUserId).eq(SysUser::getStatus, 0));
log.info("查询所有员工{}", list.size());
log.info("查询本月所有已完成的合同");
log.info("查询符合条件的合同");
//当月新签+当月之前未完成合同数 = 全部合同 - 完成时间在当月之前的
List<PsContractInfo> contractInfos = psContractInfoMapper.selectList(Wrappers.<PsContractInfo>lambdaQuery()
.ne(PsContractInfo::getIsCancel, CommonStatusEnum.SUCCESS.getCode())
.between(PsContractInfo::getFinishDate, firstDayOfLastMonth, lastDayOfLastMonth));
.and(wq->wq.lt(PsContractInfo::getFinishDate, firstDayOfLastMonth).or().isNull(PsContractInfo::getFinishDate)));
// List<PsContractInfo> contractInfos = psContractInfoMapper.selectList(Wrappers.<PsContractInfo>lambdaQuery()
// .ne(PsContractInfo::getIsCancel, CommonStatusEnum.SUCCESS.getCode())
// .between(PsContractInfo::getFinishDate, firstDayOfLastMonth, lastDayOfLastMonth));
log.info("查询本月所有的合同{}", contractInfos.size());
if(CollectionUtils.isEmpty(contractInfos)){
log.info("本月无已完成合同");
contractInfos = new ArrayList<>();
}
List<PsContractInfo> finists = contractInfos.stream().filter(item -> StringUtils.equals(item.getContractStatus(), ContractStatusEnum.SUCCESS.getCode())).toList();
List<PsContractInfo> unfinists = contractInfos.stream().filter(item -> !StringUtils.equals(item.getContractStatus(), ContractStatusEnum.SUCCESS.getCode())).toList();
log.info("本月已完成合同数量{},未完成数量{}", finists.size(),unfinists.size());
@ -110,18 +111,22 @@ public class CalSalaryBatch {
SysUserPost post = sysUserPostMapper.selectOne(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, userId).last("limit 1"));
if(post == null){continue;}
log.info("查询员工岗位{}",post.getPostId());
//服务列表
//已完成合同的合同编码
List<String> codeList = new ArrayList<>(finistMap.get(userId) == null ? new ArrayList<>() : finistMap.get(userId).stream().map(PsContractInfo::getContractCode).toList());
//服务列表
List<PsContractBusinessVo> busin = businessService.selectBusinessList(codeList);
//所有合同的退款列表
codeList.addAll(unfinistMap.get(userId) == null ? new ArrayList<>() : unfinistMap.get(userId).stream().map(PsContractInfo::getContractCode).toList());
// codeList.addAll(unfinistMap.get(userId) == null ? new ArrayList<>() : unfinistMap.get(userId).stream().map(PsContractInfo::getContractCode).toList());
log.info("进行计算提成计算");
BigDecimal salary = calSalary(busin, configMap.get(post.getPostId()),costMap.get(post.getPostId()));
List<PsContractPay> payList = new ArrayList<>();
//查询已完成合同的退款列表
if(CollectionUtils.isNotEmpty(codeList)){
payList = payMapper.selectList(Wrappers.<PsContractPay>lambdaQuery().in(PsContractPay::getContractCode, codeList).
eq(PsContractPay::getPayStatus, PayStatusEnum.SUCCESS.getCode()).eq(PsContractPay::getBusinessType,"2"));
payList = payMapper.getRefundList(Wrappers.<PsContractPay>query()
.in("pay.contract_code", codeList).isNotNull("info.finish_date")
.apply("pay.pay_date>info.finish_date")
.eq("pay.business_type","2").eq("pay.pay_status",PayStatusEnum.SUCCESS.getCode()));
}
//salary- 退费金额*服务项目最高提成
salary = salary.subtract(this.calReturnSalary(payList,configMap.get(post.getPostId())));
@ -149,15 +154,15 @@ public class CalSalaryBatch {
psSalary.setContractMoney(finishMoney.add(unFinishMoney));
psSalary.setFinistContractMoney(finishMoney);
psSalary.setUnfinistContractMoney(unFinishMoney);
//已完成合同编码
List<String> finCode = new ArrayList<>();
//未完成合同编码
List<String> unfinCode = new ArrayList<>();
if(CollectionUtils.isNotEmpty(finistMap.get(userId))){
finCode = finistMap.get(userId).stream().map(PsContractInfo::getContractCode).toList();
}
if(CollectionUtils.isNotEmpty(unfinistMap.get(userId))){
unfinCode = unfinistMap.get(userId).stream().map(PsContractInfo::getContractCode).toList();
psSalary.setUnfinishContractCode(finistMap.get(userId).stream().map(PsContractInfo::getContractCode).collect(Collectors.joining(",")));
}
// psSalary.setFinishContractCode(String.join(",",finCode));
// psSalary.setUnfinishContractCode(String.join(",",unfinCode));

View File

@ -20,4 +20,7 @@ import java.util.List;
*/
public interface PsContractPayMapper extends BaseMapperPlus<PsContractPay, PsContractPayVo> {
Page<PsRefundVo> queryRefundList(@Param("page") Page<PsContractPay> page, @Param(Constants.WRAPPER) Wrapper<PsContractPay> queryWrapper);
//查询所有合同完成之后的退款记录
List<PsContractPay> getRefundList( @Param(Constants.WRAPPER) Wrapper<PsContractPay> queryWrapper);
}

View File

@ -549,7 +549,7 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
});
}
//回传
serviceScheduleVo.setRollBack(StringUtils.equals(CommonStatusEnum.Y.getCode(),contractInfo.getRollBackStatus())?customer.getCustomManager():null);
serviceScheduleVo.setRollBack(StringUtils.equals(CommonStatusEnum.SUCCESS.getCode(),contractInfo.getRollBackStatus())?customer.getCustomManager():null);
if(vo.getResidualMoney().compareTo(BigDecimal.ZERO) <=0 && CollectionUtils.isNotEmpty(payVoList)){
PsContractPayVo pay = payVoList.get(payVoList.size() - 1);
//最后一笔回款收款者

View File

@ -16,4 +16,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ps_custom_info cus on cus.id = info.custom_id
${ew.getCustomSqlSegment}
</select>
<select id="getRefundList" resultType="com.pusong.business.domain.PsContractPay">
select
pay.*
from
ps_contract_pay pay
left join ps_contract_info info on
pay.contract_code = info.contract_code
${ew.getCustomSqlSegment}
</select>
</mapper>

View File

@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
main.contract_code,
main.invoice,
con.is_proxy con_is_proxy,
con.contract_amount con_contract_amount,
con.custom_scene con_custom_scene,
con.custom_manager con_custom_manager,
usr.nick_name con_custom_manager_name,