回款周期

This commit is contained in:
1073413548 2024-09-09 10:42:00 +08:00
parent 52f3b5fd38
commit ff80866acf
5 changed files with 158 additions and 43 deletions

View File

@ -6,6 +6,7 @@ import com.pusong.business.domain.bo.PsSalaryBo;
import com.pusong.business.domain.vo.PsSalaryContractVo;
import com.pusong.business.domain.vo.PsSalaryVo;
import com.pusong.business.domain.vo.home.MakeAmountVo;
import com.pusong.business.domain.vo.home.ReturnAmountVo;
import com.pusong.business.service.HomeService;
import com.pusong.business.service.IPsSalaryService;
import com.pusong.common.core.domain.R;
@ -36,7 +37,7 @@ public class HomeController extends BaseController {
private final HomeService homeService;
/**
* 首页大盘数据本月成交总金额
* 首页大盘数据成交总金额
* @param type 1本月 2上月 3本季度 4本年 5所有
* @return
*/
@ -46,16 +47,17 @@ public class HomeController extends BaseController {
return R.ok(homeService.selectMakeAmount(type));
}
// /**
// * 首页大盘数据本月回款情况
// * @param type 1本月 2上月 3本季度 4本年 5所有
// * @return
// */
// @SaCheckPermission("business:salary:list")
// @GetMapping("/returnMoney")
// public R<MakeAmountVo> selectMakeAmount(@RequestParam() Integer type) {
// return R.ok(homeService.selectMakeAmount(type));
// }
/**
* 首页大盘数据回款情况
* @param type 1本月 2上月 3本季度 4本年 5所有
* @return
*/
@SaCheckPermission("business:salary:list")
@GetMapping("/returnMoney")
public R<ReturnAmountVo> returnMoney(@RequestParam() Integer type) {
return R.ok(homeService.returnMoney(type));
}
}

View File

@ -0,0 +1,68 @@
package com.pusong.business.domain.vo.home;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
@Data
public class ReturnAmountVo {
/**
* 当前时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm")
private Date currentDate = new Date();
/**
* 统计范围
*/
private String dateStr;
/**
* 成交总金额
*/
private BigDecimal all;
/**
* 新签合同信息
*/
private TypeAmountVo newInfo = new TypeAmountVo();
/**
* 续签合同信息
*/
private TypeAmountVo renewInfo = new TypeAmountVo();
public void cellPer(){
if(0 == this.all.compareTo(BigDecimal.ZERO)) {
this.newInfo.setPer("0%");
this.renewInfo.setPer("0%");
}else {
this.newInfo.setPer(this.newInfo.getMoney().multiply(new BigDecimal("100.0")).divide(this.all,2, RoundingMode.HALF_UP).toPlainString()+"%");
this.renewInfo.setPer(this.renewInfo.getMoney().multiply(new BigDecimal("100.0")).divide(this.all,2, RoundingMode.HALF_UP).toPlainString()+"%");
}
}
@Data
public static class TypeAmountVo{
/**
* 占比
*/
private String per;
/**
* 合同数量
*/
private String num;
/**
* 合同金额
*/
private BigDecimal money;
/**
* 已回款金额
*/
private BigDecimal payMoney;
/**
* 未回款金额
*/
private BigDecimal unPayMoney;
}
}

View File

@ -1,6 +1,7 @@
package com.pusong.business.service;
import com.pusong.business.domain.vo.home.MakeAmountVo;
import com.pusong.business.domain.vo.home.ReturnAmountVo;
/**
* 首页相关接口
@ -8,4 +9,6 @@ import com.pusong.business.domain.vo.home.MakeAmountVo;
public interface HomeService {
MakeAmountVo selectMakeAmount(Integer type);
ReturnAmountVo returnMoney(Integer type);
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pusong.business.domain.PsContractInfo;
import com.pusong.business.domain.PsContractPay;
import com.pusong.business.domain.vo.home.MakeAmountVo;
import com.pusong.business.domain.vo.home.ReturnAmountVo;
import com.pusong.business.enums.CommonStatusEnum;
import com.pusong.business.enums.PayStatusEnum;
import com.pusong.business.mapper.PsContractInfoMapper;
@ -40,34 +41,11 @@ public class HomeServiceImpl implements HomeService {
*/
@Cacheable(cacheNames = CacheNames.HOME_A, key = "#type")
public MakeAmountVo selectMakeAmount(Integer type){
LocalDate startDate = null;
LocalDate endDate = null;
LocalDate now = LocalDate.now();
String date = "";
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM");
switch (type){
case 1://本月
startDate = now.withDayOfMonth(1);
date =startDate.format(df);
break;
case 2: //上月
startDate = now.minusMonths(1).withDayOfMonth(1);
endDate = now.withDayOfMonth(1);
date =startDate.format(df);
break;
case 3: //本季度
int month = (now.getMonthValue()-1) / 3 * 3 + 1;
startDate = now.withMonth(month).withDayOfMonth(1);
date =startDate.format(df) + "至今";
break;
case 4: //本年
startDate = now.withMonth(1).withDayOfMonth(1);
date =startDate.getYear()+"";
break;
case 5: //所有
date = "全部";
break;
}
Map<String, Object> mapParam = this.getDate(type);
LocalDate startDate = (LocalDate)mapParam.get("startDate");
LocalDate endDate = (LocalDate)mapParam.get("endDate");
String date = (String)mapParam.get("date");
log.info("查询日期:{}到{}",startDate,endDate);
List<PsContractInfo> list = psContractInfoMapper.selectList(Wrappers.<PsContractInfo>lambdaQuery()
.select(PsContractInfo::getContractCode, PsContractInfo::getIsDue, PsContractInfo::getContractAmount)
@ -119,4 +97,49 @@ public class HomeServiceImpl implements HomeService {
typeAmountVo.setUnPayMoney(typeAmountVo.getMoney().subtract(typeAmountVo.getPayMoney()));
}
private Map<String, Object> getDate(Integer type){
LocalDate startDate = null;
LocalDate endDate = null;
String date = "";
LocalDate now = LocalDate.now();
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM");
switch (type){
case 1://本月
startDate = now.withDayOfMonth(1);
date =startDate.format(df);
break;
case 2: //上月
startDate = now.minusMonths(1).withDayOfMonth(1);
endDate = now.withDayOfMonth(1);
date =startDate.format(df);
break;
case 3: //本季度
int month = (now.getMonthValue()-1) / 3 * 3 + 1;
startDate = now.withMonth(month).withDayOfMonth(1);
date =startDate.format(df) + "至今";
break;
case 4: //本年
startDate = now.withMonth(1).withDayOfMonth(1);
date =startDate.getYear()+"";
break;
case 5: //所有
date = "全部";
break;
}
Map<String,Object> map = new HashMap<>();
map.put("startDate",startDate);
map.put("endDate",endDate);
map.put("date",date);
return map;
}
public ReturnAmountVo returnMoney(Integer type){
Map<String, Object> mapParam = this.getDate(type);
LocalDate startDate = (LocalDate)mapParam.get("startDate");
LocalDate endDate = (LocalDate)mapParam.get("endDate");
String date = (String)mapParam.get("date");
// payMapper.selectList(Wrappers.<PsContractPay>query().select("business_type", "sum(money) money").lambda())
return null;
}
}

View File

@ -671,14 +671,33 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
vo.setPayMoney(pay.compareTo(BigDecimal.ZERO)>=0?pay:BigDecimal.ZERO);
//未付金额(合同金额-已付金额)
vo.setResidualMoney((vo.getContractAmount() == null ? BigDecimal.ZERO:vo.getContractAmount()).subtract(vo.getPayMoney()));
//回款日期 = 第一次回款若有全部退款过则需要从全部退款开始算到最后一次回款的时间
BigDecimal big = BigDecimal.ZERO;
Date startDate = null;
Date endDate = null;
for (PsContractPayVo pcp:payList){
big = StringUtils.equals(pcp.getBusinessType(),"1")?big.add(pcp.getMoney()):big.subtract(pcp.getMoney());
if(big.compareTo(BigDecimal.ZERO)>0){
if( startDate == null){
startDate = pcp.getPayDate();
}else{
endDate = pcp.getPayDate();
}
}else{
startDate = null;
endDate = null;
}
}
//付款周期
if(returnList.isEmpty()){
vo.setPeriod(null);
}else if(returnList.size() == 1){
if(startDate == null){
vo.setPeriod(0);
}else if(endDate == null){
vo.setPeriod(1);
}else{
//包含最后一天
vo.setPeriod(DateUtils.calWorkDate(returnList.get(0).getPayDate(),returnList.get(returnList.size()-1).getPayDate()));
vo.setPeriod(DateUtils.calWorkDate(startDate,endDate));
}
}