This commit is contained in:
mx 2024-11-19 14:05:07 +08:00
parent 6bae31876c
commit 7c57a19800
6 changed files with 103 additions and 35 deletions

View File

@ -95,7 +95,7 @@ public class PsContractInfoController extends BaseController {
/**
* 使用客户id 查询分页查询合同列表
*/
@SaCheckPermission("business:contractInfo:LIST")
@SaCheckPermission("business:contractInfo:listByCustomId")
@GetMapping("/queryPageListByCustomId")
public TableDataInfo<PsContractInfoVo> queryPageListByCustomId(@RequestParam Long customId, PageQuery pageQuery) {
return psContractInfoService.queryPageListByCustomId(customId, pageQuery);

View File

@ -4,7 +4,9 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@Data
public class UserAmountVo {
@ -43,4 +45,48 @@ public class UserAmountVo {
*/
private Collection<UserContractAmountVo> zjsList;
public void cellPer(){
if (userAmountList != null && !userAmountList.isEmpty()){
UserAmountInfoVo sum = new UserAmountInfoVo();
sum.setTuoGuanAmount(new BigDecimal(0));
sum.setSumAmount(new BigDecimal(0));
sum.setXuFeiAmount(new BigDecimal(0));
sum.setSoftwareDevAmount(new BigDecimal(0));
sum.setOtherAmount(new BigDecimal(0));
for (UserAmountInfoVo userAmountInfoVo : userAmountList) {
sum.setNickName("总计");
sum.setDateStr(userAmountInfoVo.getDateStr());
sum.setTuoGuanAmount(sum.getTuoGuanAmount().add(userAmountInfoVo.getTuoGuanAmount()));
sum.setSumAmount(sum.getSumAmount().add(userAmountInfoVo.getSumAmount()));
sum.setXuFeiAmount(sum.getXuFeiAmount().add(userAmountInfoVo.getXuFeiAmount()));
sum.setSoftwareDevAmount(sum.getSoftwareDevAmount().add(userAmountInfoVo.getSoftwareDevAmount()));
sum.setOtherAmount(sum.getOtherAmount().add(userAmountInfoVo.getOtherAmount()));
sum.setAmountPer("100%");
}
userAmountList.add(sum);
}
if (zjsList != null && !zjsList.isEmpty()){
UserContractAmountVo sum = new UserContractAmountVo();
sum.setSumAmount(new BigDecimal(0));
sum.setJieShaoAmount(new BigDecimal(0));;
sum.setOtherAmount(new BigDecimal(0));;
sum.setJieShaoContractNum(0);
for (UserContractAmountVo userAmountInfoVo : zjsList) {
sum.setNickName("总计");
sum.setDateStr(userAmountInfoVo.getDateStr());
sum.setSumAmount(sum.getSumAmount().add(userAmountInfoVo.getSumAmount()));
sum.setJieShaoAmount(sum.getJieShaoAmount().add(userAmountInfoVo.getJieShaoAmount()));
sum.setOtherAmount(sum.getOtherAmount().add(userAmountInfoVo.getOtherAmount()));
sum.setJieShaoContractNum(sum.getJieShaoContractNum() + userAmountInfoVo.getJieShaoContractNum());
}
if (sum.getSumAmount().doubleValue() == 0d){
sum.setJieShaoPer("0%");
}else{
sum.setJieShaoPer(sum.getJieShaoAmount().multiply(new BigDecimal("100.0")).divide(sum.getSumAmount(), 2, RoundingMode.HALF_UP).toPlainString() + "%");
}
zjsList.add(sum);
}
}
}

View File

@ -22,6 +22,11 @@ public class UserContractAmountInfo {
* 是否为续签合同 0 1
*/
private String isDue;
/**
* 服务项id用来去重
*/
private Long busId;
/**
* 合同类型
*/

View File

@ -129,6 +129,7 @@ public class HomeServiceImpl implements HomeService {
case 1://本月
startDate = now.withDayOfMonth(1);
endDate = now.plusMonths(1).withDayOfMonth(1);
// endDate = now;
date = startDate.format(df);
break;
case 2: //上月
@ -139,11 +140,22 @@ public class HomeServiceImpl implements HomeService {
case 3: //本季度
int month = (now.getMonthValue()-1) / 3 * 3 + 1;
startDate = now.withMonth(month).withDayOfMonth(1);
date =startDate.format(df) + "至今";
int endMonth = ((now.getMonthValue() - 1) / 3 + 1) * 3 + 1;
int addYear = 0;
if (endMonth > 12){
addYear = endMonth / 12;
endMonth = endMonth % 12;
}
endDate = now.plusYears(addYear).withMonth(endMonth).withDayOfMonth(1);
// endDate = now;
date = startDate.format(df) + "至今";
break;
case 4: //本年
startDate = now.withMonth(1).withDayOfMonth(1);
date =startDate.getYear()+"";
endDate = now.plusYears(1).withMonth(1);
date = startDate.getYear()+"";
break;
case 5: //所有
date = "全部";
@ -269,7 +281,8 @@ public class HomeServiceImpl implements HomeService {
.lt(endDate != null,"apply_date", endDate)
.eq("con.is_due", 1)
.in("cc.company_id", companyIds)
.notIn("cc.contract_code", contractCodeList);
// .notIn("cc.contract_code", contractCodeList)
;
//已续费的合同
List<PsContractBusinessVo> renewalContact = psHomeMapper.selectRenewalContract(contractWrapper);
//总已续费金额
@ -299,7 +312,7 @@ public class HomeServiceImpl implements HomeService {
* @param isCaiwu
* @return
*/
@Cacheable(cacheNames = CacheNames.HOME_E, key = "#type")
@Cacheable(cacheNames = CacheNames.HOME_E, key = "#type+'_' + #tabType")
public UserAmountVo getUserContractSourceAmountsByDeptId(Integer type, int tabType){
Map<String, Object> mapParam = this.getDate(type);
LocalDate startDate = (LocalDate)mapParam.get("startDate");
@ -324,9 +337,9 @@ public class HomeServiceImpl implements HomeService {
Map<String,String> repeatContractCode = new HashMap<>();
UserContractAmountVo daPan = new UserContractAmountVo();
BigDecimal all = new BigDecimal(0);
for(UserContractAmountInfo obj : list){
UserContractAmountVo vo=res.get(obj.getUserId());
UserContractAmountVo vo = res.get(obj.getUserId());
if(vo==null){
vo=new UserContractAmountVo();
vo.setUserId(obj.getUserId());
@ -334,7 +347,7 @@ public class HomeServiceImpl implements HomeService {
vo.setDateStr(date);
res.put(obj.getUserId(),vo);
}
if(repeatContractCode.get(obj.getContractCode())==null){
if(repeatContractCode.get(obj.getContractCode()) == null){
repeatContractCode.put(obj.getContractCode(),obj.getContractCode());
vo.addSumAmount(obj.getContractAmount());
daPan.addSumAmount(obj.getContractAmount());
@ -349,6 +362,7 @@ public class HomeServiceImpl implements HomeService {
daPan.addOtherAmount(obj.getContractAmount());
daPan.addOtherContractNum();
}
all = all.add(obj.getContractAmount());
}
//判断是否为转介绍合同
if(contractSource.equals(obj.getCustomSource())){
@ -386,14 +400,12 @@ public class HomeServiceImpl implements HomeService {
}
BigDecimal sumAmount = list.stream().map(UserContractAmountInfo::getContractAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
UserAmountVo userAmountVo = new UserAmountVo();
userAmountVo.setZjsList(listData);
userAmountVo.setDateStr(date);
userAmountVo.setAll(sumAmount);
userAmountVo.setAll(all);
userAmountVo.setDaPan(daPan);
userAmountVo.cellPer();
return userAmountVo;
}
/**
@ -487,7 +499,7 @@ public class HomeServiceImpl implements HomeService {
* @param type
* @return
*/
@Cacheable(cacheNames = CacheNames.HOME_F, key = "#type")
// @Cacheable(cacheNames = CacheNames.HOME_F, key = "#type + '_' + #tabType")
public UserAmountVo getUserContractAndPayInfo(Integer type, int tabType){
Map<String, Object> mapParam = this.getDate(type);
LocalDate startDate = (LocalDate)mapParam.get("startDate");
@ -502,19 +514,15 @@ public class HomeServiceImpl implements HomeService {
queryParam.put("payStatus", PayStatusEnum.SUCCESS.getCode());
// LocalDateTime localDateTime2= LocalDateTime.parse("2024-11-07T14:04:00");
QueryWrapper<PsContractInfo> queryWrapper = new QueryWrapper<PsContractInfo>()
// .in(tabType == 1, "role.role_key", Arrays.asList(RoleEnum.caiwu.getCode(), RoleEnum.cwzg.getCode()))
// .in(tabType == 0, "role.role_key", Arrays.asList(RoleEnum.xiaoshou.getCode(), RoleEnum.xszg.getCode()) )
.exists(tabType == 1,"select 1 from sys_user_role ur inner join sys_role role on role.role_id = ur.role_id where ur.user_id = u.user_id and role.role_key in (" + RoleEnum.caiwu.getCode() + "," + RoleEnum.cwzg.getCode() + ")")
.exists(tabType == 1,"select 1 from sys_user_role ur inner join sys_role role on role.role_id = ur.role_id where ur.user_id = u.user_id and role.role_key in (" + RoleEnum.xiaoshou.getCode() + "," + RoleEnum.xszg.getCode() + ")")
.exists(tabType == 1,"select 1 from sys_user_role ur inner join sys_role role on role.role_id = ur.role_id where ur.user_id = u.user_id and role.role_key in ('" + RoleEnum.caiwu.getCode() + "','" + RoleEnum.cwzg.getCode() + "')")
.exists(tabType == 0,"select 1 from sys_user_role ur inner join sys_role role on role.role_id = ur.role_id where ur.user_id = u.user_id and role.role_key in ('" + RoleEnum.xiaoshou.getCode() + "','" + RoleEnum.xszg.getCode() + "')")
;
List<UserContractAmountInfo> list = psContractInfoMapper.getUserContractAndPayInfo(queryParam, queryWrapper);
Map<Long, UserAmountInfoVo> resMap = new HashMap<>();
//记录合同编码防止重复
Map<String, String> repeatContractCode = new HashMap<>();
Set< String> repeatContractCodeBusiness = new HashSet<>();
for (UserContractAmountInfo obj : list) {
Long userId = obj.getUserId();
UserAmountInfoVo vo = resMap.get(userId);
@ -541,23 +549,29 @@ public class HomeServiceImpl implements HomeService {
}
//托管合同金额累计
if("2".equals(obj.getBusinessType())){
vo.addTuoGuanAmount(obj.getBusinessAmount());
} else {
//软件开发合同金额累计
if (obj.getBusinessType() != null && obj.getBusinessType().equals("7")) {
if (obj.getBusinessAmount() != null) {
vo.addSoftwareDevAmount(obj.getBusinessAmount());
}
String contractBusiness = obj.getContractCode() + "_" + obj.getBusId();
if (!repeatContractCodeBusiness.contains(contractBusiness)){
if("2".equals(obj.getBusinessType())){
vo.addTuoGuanAmount(obj.getBusinessAmount());
} else {
//其他合同金额累计
if (obj.getIsDue() == null || obj.getIsDue().equals("0")) {
if (obj.getBusinessAmount() != null){
vo.addOtherAmount(obj.getBusinessAmount());
//软件开发合同金额累计
if (obj.getBusinessType() != null && obj.getBusinessType().equals("7")) {
if (obj.getBusinessAmount() != null) {
vo.addSoftwareDevAmount(obj.getBusinessAmount());
}
} else {
//其他合同金额累计
if (obj.getIsDue() == null || obj.getIsDue().equals("0")) {
if (obj.getBusinessAmount() != null){
vo.addOtherAmount(obj.getBusinessAmount());
}
}
}
}
repeatContractCodeBusiness.add(contractBusiness);
}
//续签合同金额累计
if(obj.getIsDue() != null && obj.getIsDue().equals("1")){
if (obj.getContractAmount() != null) {
@ -589,6 +603,7 @@ public class HomeServiceImpl implements HomeService {
userAmountVo.setUserAmountList(new ArrayList<>(resMap.values()));
userAmountVo.setDateStr(date);
userAmountVo.setAll(sumAmount);
userAmountVo.cellPer();
return userAmountVo;
}
@ -600,7 +615,7 @@ public class HomeServiceImpl implements HomeService {
* @return
*/
@Cacheable(cacheNames = CacheNames.HOME_C, key = "#type+'_'+#dateType")
public ChannelAmountVo byChannel(Integer type,Integer dateType){
public ChannelAmountVo byChannel(Integer type, Integer dateType){
Map<String, Object> mapParam = dateType == 1 ? this.getDate(type) : this.getDateByUser(type);
LocalDate startDate = (LocalDate)mapParam.get("startDate");
LocalDate endDate = (LocalDate)mapParam.get("endDate");

View File

@ -166,8 +166,9 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
PsCustomInfo psCustomInfo = customInfoService.listById(bo.getCustomId());
add.setCustomManager(psCustomInfo.getCustomManager());//所属销售经理id
// add.setCustomManager(psCustomInfo.getCustomManager());//所属销售经理id
LoginUser loginUser = LoginHelper.getLoginUser();
add.setCustomManager(loginUser.getUserId());//谁创建的就是谁的
if (type == 2){
psCustomInfo.setCustomLevel("3");
customInfoMapper.updateById(psCustomInfo);

View File

@ -130,6 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
info.contract_code as contractCode,
info.contract_amount as contractAmount,
pay.money as payedMoney,
bus.id as busId,
bus.business_type as businessType,
bus.business_amount as businessAmount
FROM sys_user u