回款周期
This commit is contained in:
parent
52f3b5fd38
commit
ff80866acf
@ -6,6 +6,7 @@ import com.pusong.business.domain.bo.PsSalaryBo;
|
|||||||
import com.pusong.business.domain.vo.PsSalaryContractVo;
|
import com.pusong.business.domain.vo.PsSalaryContractVo;
|
||||||
import com.pusong.business.domain.vo.PsSalaryVo;
|
import com.pusong.business.domain.vo.PsSalaryVo;
|
||||||
import com.pusong.business.domain.vo.home.MakeAmountVo;
|
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.HomeService;
|
||||||
import com.pusong.business.service.IPsSalaryService;
|
import com.pusong.business.service.IPsSalaryService;
|
||||||
import com.pusong.common.core.domain.R;
|
import com.pusong.common.core.domain.R;
|
||||||
@ -36,7 +37,7 @@ public class HomeController extends BaseController {
|
|||||||
private final HomeService homeService;
|
private final HomeService homeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页大盘数据:本月成交总金额
|
* 首页大盘数据:成交总金额
|
||||||
* @param type 1本月 2上月 3本季度 4本年 5所有
|
* @param type 1本月 2上月 3本季度 4本年 5所有
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -46,16 +47,17 @@ public class HomeController extends BaseController {
|
|||||||
return R.ok(homeService.selectMakeAmount(type));
|
return R.ok(homeService.selectMakeAmount(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 首页大盘数据:本月回款情况
|
* 首页大盘数据:回款情况
|
||||||
// * @param type 1本月 2上月 3本季度 4本年 5所有
|
* @param type 1本月 2上月 3本季度 4本年 5所有
|
||||||
// * @return
|
* @return
|
||||||
// */
|
*/
|
||||||
// @SaCheckPermission("business:salary:list")
|
@SaCheckPermission("business:salary:list")
|
||||||
// @GetMapping("/returnMoney")
|
@GetMapping("/returnMoney")
|
||||||
// public R<MakeAmountVo> selectMakeAmount(@RequestParam() Integer type) {
|
public R<ReturnAmountVo> returnMoney(@RequestParam() Integer type) {
|
||||||
// return R.ok(homeService.selectMakeAmount(type));
|
return R.ok(homeService.returnMoney(type));
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.pusong.business.service;
|
package com.pusong.business.service;
|
||||||
|
|
||||||
import com.pusong.business.domain.vo.home.MakeAmountVo;
|
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 {
|
public interface HomeService {
|
||||||
|
|
||||||
MakeAmountVo selectMakeAmount(Integer type);
|
MakeAmountVo selectMakeAmount(Integer type);
|
||||||
|
|
||||||
|
ReturnAmountVo returnMoney(Integer type);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.pusong.business.domain.PsContractInfo;
|
import com.pusong.business.domain.PsContractInfo;
|
||||||
import com.pusong.business.domain.PsContractPay;
|
import com.pusong.business.domain.PsContractPay;
|
||||||
import com.pusong.business.domain.vo.home.MakeAmountVo;
|
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.CommonStatusEnum;
|
||||||
import com.pusong.business.enums.PayStatusEnum;
|
import com.pusong.business.enums.PayStatusEnum;
|
||||||
import com.pusong.business.mapper.PsContractInfoMapper;
|
import com.pusong.business.mapper.PsContractInfoMapper;
|
||||||
@ -40,34 +41,11 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
*/
|
*/
|
||||||
@Cacheable(cacheNames = CacheNames.HOME_A, key = "#type")
|
@Cacheable(cacheNames = CacheNames.HOME_A, key = "#type")
|
||||||
public MakeAmountVo selectMakeAmount(Integer type){
|
public MakeAmountVo selectMakeAmount(Integer type){
|
||||||
LocalDate startDate = null;
|
Map<String, Object> mapParam = this.getDate(type);
|
||||||
LocalDate endDate = null;
|
LocalDate startDate = (LocalDate)mapParam.get("startDate");
|
||||||
LocalDate now = LocalDate.now();
|
LocalDate endDate = (LocalDate)mapParam.get("endDate");
|
||||||
String date = "";
|
String date = (String)mapParam.get("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;
|
|
||||||
}
|
|
||||||
log.info("查询日期:{}到{}",startDate,endDate);
|
log.info("查询日期:{}到{}",startDate,endDate);
|
||||||
List<PsContractInfo> list = psContractInfoMapper.selectList(Wrappers.<PsContractInfo>lambdaQuery()
|
List<PsContractInfo> list = psContractInfoMapper.selectList(Wrappers.<PsContractInfo>lambdaQuery()
|
||||||
.select(PsContractInfo::getContractCode, PsContractInfo::getIsDue, PsContractInfo::getContractAmount)
|
.select(PsContractInfo::getContractCode, PsContractInfo::getIsDue, PsContractInfo::getContractAmount)
|
||||||
@ -119,4 +97,49 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
typeAmountVo.setUnPayMoney(typeAmountVo.getMoney().subtract(typeAmountVo.getPayMoney()));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -671,14 +671,33 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
|
|||||||
vo.setPayMoney(pay.compareTo(BigDecimal.ZERO)>=0?pay:BigDecimal.ZERO);
|
vo.setPayMoney(pay.compareTo(BigDecimal.ZERO)>=0?pay:BigDecimal.ZERO);
|
||||||
//未付金额(合同金额-已付金额)
|
//未付金额(合同金额-已付金额)
|
||||||
vo.setResidualMoney((vo.getContractAmount() == null ? BigDecimal.ZERO:vo.getContractAmount()).subtract(vo.getPayMoney()));
|
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()){
|
if(startDate == null){
|
||||||
vo.setPeriod(null);
|
vo.setPeriod(0);
|
||||||
}else if(returnList.size() == 1){
|
}else if(endDate == null){
|
||||||
vo.setPeriod(1);
|
vo.setPeriod(1);
|
||||||
}else{
|
}else{
|
||||||
//包含最后一天
|
//包含最后一天
|
||||||
vo.setPeriod(DateUtils.calWorkDate(returnList.get(0).getPayDate(),returnList.get(returnList.size()-1).getPayDate()));
|
vo.setPeriod(DateUtils.calWorkDate(startDate,endDate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user