bug
This commit is contained in:
parent
c591aa3200
commit
5e82848c2d
@ -70,4 +70,12 @@ public interface CacheNames {
|
||||
*/
|
||||
String ONLINE_TOKEN = "online_tokens";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 首页查询(成交金额)
|
||||
*/
|
||||
String HOME_A = "home_queryA#60s";
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.TimeZone;
|
||||
@ -39,12 +40,15 @@ public class JacksonConfig {
|
||||
javaTimeModule.addSerializer(Long.TYPE, BigNumberSerializer.INSTANCE);
|
||||
javaTimeModule.addSerializer(BigInteger.class, BigNumberSerializer.INSTANCE);
|
||||
// javaTimeModule.addSerializer(BigDecimal.class, ToStringSerializer.instance);
|
||||
//去掉最后面的0并转为字符串
|
||||
|
||||
javaTimeModule.addSerializer(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
||||
@Override
|
||||
public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
if (value != null) {
|
||||
gen.writeString(value.stripTrailingZeros().toPlainString());
|
||||
//去掉最后面的0并转为字符串
|
||||
// gen.writeString(value.stripTrailingZeros().toPlainString());
|
||||
//保留两位小数
|
||||
gen.writeString(value.setScale(2, RoundingMode.HALF_UP).toPlainString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.pusong.business.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
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.service.HomeService;
|
||||
import com.pusong.business.service.IPsSalaryService;
|
||||
import com.pusong.common.core.domain.R;
|
||||
import com.pusong.common.mybatis.core.page.PageQuery;
|
||||
import com.pusong.common.mybatis.core.page.TableDataInfo;
|
||||
import com.pusong.common.web.core.BaseController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 员工提成提成
|
||||
*
|
||||
* @author wls
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/business/home")
|
||||
@SaIgnore
|
||||
public class HomeController extends BaseController {
|
||||
|
||||
private final HomeService homeService;
|
||||
|
||||
/**
|
||||
* 首页大盘数据
|
||||
* @param type 1本月 2上月 3本季度 4本年 5所有
|
||||
* @return
|
||||
*/
|
||||
@SaCheckPermission("business:salary:list")
|
||||
@GetMapping("/selectMakeAmount")
|
||||
public R<MakeAmountVo> selectMakeAmount(@RequestParam() Integer type) {
|
||||
return R.ok(homeService.selectMakeAmount(type));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -71,4 +71,8 @@ public class PsCustomRecordQueryBo {
|
||||
* 服务项目(可多选)
|
||||
*/
|
||||
private List<String> serviceProjects;
|
||||
/**
|
||||
* 介绍人姓名
|
||||
*/
|
||||
private String customIntroducerName;
|
||||
}
|
||||
|
@ -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 MakeAmountVo {
|
||||
|
||||
/**
|
||||
* 当前时间
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.pusong.business.service;
|
||||
|
||||
import com.pusong.business.domain.vo.home.MakeAmountVo;
|
||||
|
||||
/**
|
||||
* 首页相关接口
|
||||
*/
|
||||
public interface HomeService {
|
||||
|
||||
MakeAmountVo selectMakeAmount(Integer type);
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.pusong.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
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.enums.CommonStatusEnum;
|
||||
import com.pusong.business.enums.PayStatusEnum;
|
||||
import com.pusong.business.mapper.PsContractInfoMapper;
|
||||
import com.pusong.business.mapper.PsContractPayMapper;
|
||||
import com.pusong.business.service.HomeService;
|
||||
import com.pusong.common.core.constant.CacheNames;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class HomeServiceImpl implements HomeService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HomeServiceImpl.class);
|
||||
|
||||
private final PsContractInfoMapper psContractInfoMapper;
|
||||
private final PsContractPayMapper payMapper;
|
||||
|
||||
/**
|
||||
* 查询成交总金额
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
log.info("查询日期:{}到{}",startDate,endDate);
|
||||
List<PsContractInfo> list = psContractInfoMapper.selectList(Wrappers.<PsContractInfo>lambdaQuery()
|
||||
.select(PsContractInfo::getContractCode, PsContractInfo::getIsDue, PsContractInfo::getContractAmount)
|
||||
.ne(PsContractInfo::getIsCancel, CommonStatusEnum.SUCCESS.getCode())
|
||||
.ge(startDate != null,PsContractInfo::getApplyDate,startDate)
|
||||
.le(endDate != null,PsContractInfo::getApplyDate,endDate));
|
||||
|
||||
Map<String, List<PsContractInfo>> map = list.stream().collect(Collectors.groupingBy(PsContractInfo::getIsDue, Collectors.toList()));
|
||||
//续期合同
|
||||
List<PsContractInfo> renewList = Optional.ofNullable(map.get(CommonStatusEnum.Y.getCode())).orElse(new ArrayList<>());
|
||||
//新签的合同
|
||||
List<PsContractInfo> newList = Optional.ofNullable(map.get(CommonStatusEnum.N.getCode())).orElse(new ArrayList<>());
|
||||
|
||||
//装填dto
|
||||
MakeAmountVo makeAmountVo = new MakeAmountVo();
|
||||
makeAmountVo.setDateStr(date);
|
||||
//总金额
|
||||
makeAmountVo.setAll(list.stream().map(PsContractInfo::getContractAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
//续期合同
|
||||
makeAmountVo.getRenewInfo().setNum(renewList.size()+"单");
|
||||
makeAmountVo.getRenewInfo().setMoney(renewList.stream().map(PsContractInfo::getContractAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
fillPay(renewList,makeAmountVo.getRenewInfo());
|
||||
//新签合同
|
||||
makeAmountVo.getNewInfo().setNum(newList.size()+"单");
|
||||
makeAmountVo.getNewInfo().setMoney(newList.stream().map(PsContractInfo::getContractAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
fillPay(newList,makeAmountVo.getNewInfo());
|
||||
//计算比例
|
||||
makeAmountVo.cellPer();
|
||||
return makeAmountVo;
|
||||
}
|
||||
|
||||
private void fillPay(List<PsContractInfo> list, MakeAmountVo.TypeAmountVo typeAmountVo){
|
||||
//续费/新签的合同编码集合
|
||||
List<String> renewCodes = list.stream().map(PsContractInfo::getContractCode).toList();
|
||||
//续费/新签的合同已付金额
|
||||
if(CollectionUtils.isNotEmpty(renewCodes)){
|
||||
List<PsContractPay> payList = payMapper.selectList(Wrappers.<PsContractPay>query().select("business_type", "sum(money) money").lambda()
|
||||
.in(PsContractPay::getContractCode, renewCodes).eq(PsContractPay::getPayStatus, PayStatusEnum.SUCCESS.getCode())
|
||||
.groupBy(PsContractPay::getBusinessType));
|
||||
BigDecimal payMoney = BigDecimal.ZERO;
|
||||
for (PsContractPay pay : payList) {
|
||||
if(pay.getBusinessType().equals("1")){payMoney = payMoney.add(pay.getMoney());}else{ payMoney = payMoney.subtract(pay.getMoney());}
|
||||
}
|
||||
typeAmountVo.setPayMoney(payMoney);
|
||||
}else{
|
||||
typeAmountVo.setPayMoney(BigDecimal.ZERO);
|
||||
}
|
||||
//续费/新签的合同未付金额
|
||||
typeAmountVo.setUnPayMoney(typeAmountVo.getMoney().subtract(typeAmountVo.getPayMoney()));
|
||||
}
|
||||
|
||||
}
|
@ -663,23 +663,24 @@ public class PsContractInfoServiceImpl implements IPsContractInfoService {
|
||||
vo.setReturnMoney(payList.stream().filter(item->StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.RETURN.getCode()))
|
||||
.map(PsContractPayVo::getMoney).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
//收款金额
|
||||
BigDecimal netPay = payList.stream().filter(item -> StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.PAY.getCode()))
|
||||
.map(PsContractPayVo::getMoney).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
List<PsContractPayVo> returnList = payList.stream().filter(item -> StringUtils.equals(item.getBusinessType(), PayBuinessStatusEnum.PAY.getCode())).toList();
|
||||
BigDecimal netPay = returnList.stream().map(PsContractPayVo::getMoney).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal pay = netPay.subtract(vo.getReturnMoney());
|
||||
//已付金额(收款-退款)
|
||||
vo.setPayMoney(pay.compareTo(BigDecimal.ZERO)>=0?pay:BigDecimal.ZERO);
|
||||
//未付金额(合同金额-已付金额)
|
||||
vo.setResidualMoney((vo.getContractAmount() == null ? BigDecimal.ZERO:vo.getContractAmount()).subtract(vo.getPayMoney()));
|
||||
//付款周期
|
||||
if(payList.size() == 0){
|
||||
if(returnList.isEmpty()){
|
||||
vo.setPeriod(null);
|
||||
}else if(payList.size() == 1){
|
||||
}else if(returnList.size() == 1){
|
||||
vo.setPeriod(1);
|
||||
}else{
|
||||
//包含最后一天
|
||||
vo.setPeriod(DateUtils.calWorkDate(payList.get(0).getPayDate(),payList.get(payList.size()-1).getPayDate()));
|
||||
vo.setPeriod(DateUtils.calWorkDate(returnList.get(0).getPayDate(),returnList.get(returnList.size()-1).getPayDate()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据校验并返回
|
||||
* isAdd:是否为增加/修改校验
|
||||
|
@ -174,7 +174,7 @@ public class PsContractPayServiceImpl implements IPsContractPayService {
|
||||
.exists(StringUtils.isNotBlank(customManageName),"select 1 from sys_user su where su.user_id = cus.custom_manager and su.nick_name like %"+customManageName+"%")
|
||||
.like(StringUtils.isNotBlank(companyName),"com.company_name",companyName)
|
||||
.like(StringUtils.isNotBlank(mobile),"cus.custom_mobile",mobile)
|
||||
.eq(StringUtils.isNotBlank(name),"cus.custom_name",name)
|
||||
.like(StringUtils.isNotBlank(name),"cus.custom_name",name)
|
||||
.in("pay.pay_status",List.of(PayStatusEnum.SUCCESS.getCode(),PayStatusEnum.PAYING.getCode()))
|
||||
.eq("pay.business_type","2");
|
||||
Page<PsRefundVo> list = baseMapper.queryRefundList(pageQuery.build(), qw);
|
||||
|
@ -367,7 +367,7 @@ public class PsCustomInfoServiceImpl implements IPsCustomInfoService {
|
||||
qw.like(StringUtils.isNotBlank(queryBo.getMobile()), "custom.custom_mobile", queryBo.getMobile());
|
||||
qw.eq(StringUtils.isNotBlank(queryBo.getCustomSource()), "custom.custom_source", queryBo.getCustomSource());
|
||||
qw.notIn("con.contract_status", ContractStatusEnum.isValid());
|
||||
|
||||
qw.exists(StringUtils.isNotBlank(queryBo.getCustomIntroducerName()),"select 1 from ps_custom_info pc where pc.id = custom.custom_introducer and pc.custom_name like '%"+queryBo.getCustomIntroducerName()+"%'");
|
||||
qw.exists(StringUtils.isNotBlank(queryBo.getCustomManagerName()),"select 1 from sys_user su where su.user_id = custom.custom_manager and su.nick_name like '%"+queryBo.getCustomManagerName()+"%'");
|
||||
if(queryBo.getType() !=null && queryBo.getType() == 2){
|
||||
qw.eq("con.contract_status", ContractStatusEnum.SUCCESS.getCode());
|
||||
|
Loading…
Reference in New Issue
Block a user