|
|
@ -198,6 +198,97 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService<BusSale |
|
|
|
return entity; |
|
|
|
} |
|
|
|
|
|
|
|
public List<LoanRepaymentPlanDetailsExportVo> exportExcel(BusLoancontractForRepayQuery pagerQuery) { |
|
|
|
QueryWrapper<BusSalesOrderLoancontract> qw = new QueryWrapper<>(); |
|
|
|
//=======================
|
|
|
|
PrivilegeQuery privilegeQuery = new PrivilegeQuery(); |
|
|
|
privilegeQuery.setOrgPath(pagerQuery.getOrgPath()); |
|
|
|
privilegeQuery.setMenuSid(pagerQuery.getMenuSid()); |
|
|
|
privilegeQuery.setMenuUrl(pagerQuery.getMenuUrl()); |
|
|
|
privilegeQuery.setUserSid(pagerQuery.getUserSid()); |
|
|
|
ResultBean<String> defaultIdReltBean = sysUserFeign.selectPrivilegeLevel(privilegeQuery); |
|
|
|
if (StringUtils.isNotBlank(defaultIdReltBean.getData())) { |
|
|
|
//数据权限ID(1集团、2事业部、3分公司、4部门、5个人)
|
|
|
|
String orgSidPath = pagerQuery.getOrgPath(); |
|
|
|
orgSidPath = orgSidPath + "/"; |
|
|
|
int i1 = orgSidPath.indexOf("/"); |
|
|
|
int i2 = orgSidPath.indexOf("/", i1 + 1); |
|
|
|
int i3 = orgSidPath.indexOf("/", i2 + 1); |
|
|
|
int i4 = orgSidPath.indexOf("/", i3 + 1); |
|
|
|
String orgLevelKey = defaultIdReltBean.getData(); |
|
|
|
if ("1".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i1); |
|
|
|
qw.like("bs.orgSidPath", orgSidPath); |
|
|
|
} else if ("2".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i2); |
|
|
|
qw.like("bs.orgSidPath", orgSidPath); |
|
|
|
} else if ("3".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i3); |
|
|
|
qw.like("bs.orgSidPath", orgSidPath); |
|
|
|
} else if ("4".equals(orgLevelKey)) { |
|
|
|
orgSidPath = orgSidPath.substring(0, i4); |
|
|
|
qw.like("bs.orgSidPath", orgSidPath); |
|
|
|
} else if ("5".equals(orgLevelKey)) { |
|
|
|
qw.eq("bs.createBySid", pagerQuery.getUserSid()); |
|
|
|
} else { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
//=======================
|
|
|
|
//分公司
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getUseOrgName())) { |
|
|
|
qw.like("bs.useOrgName", pagerQuery.getUseOrgName()); |
|
|
|
} |
|
|
|
//销售部门
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getOrgName())) { |
|
|
|
qw.like("bs.orgName", pagerQuery.getOrgName()); |
|
|
|
} |
|
|
|
//销售专员
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getStaffName())) { |
|
|
|
qw.like("bs.staffName", pagerQuery.getStaffName()); |
|
|
|
} |
|
|
|
//消贷合同编号
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getLoanContractNo())) { |
|
|
|
qw.like("co.loanContractNo", pagerQuery.getLoanContractNo()); |
|
|
|
} |
|
|
|
//贷款人
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBorrowerName())) { |
|
|
|
qw.like("co.borrowerName", pagerQuery.getBorrowerName()); |
|
|
|
} |
|
|
|
//资方
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBankName())) { |
|
|
|
qw.like("co.bankName", pagerQuery.getBankName()); |
|
|
|
} |
|
|
|
//金融产品
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getPolicyName())) { |
|
|
|
qw.like("co.policyName", pagerQuery.getPolicyName()); |
|
|
|
} |
|
|
|
//金融产品
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBuilded())) { |
|
|
|
qw.like("co.repaymentState", pagerQuery.getBuilded()); |
|
|
|
} |
|
|
|
String createStartTime = pagerQuery.getCreateStartDate(); |
|
|
|
String createEndTime = pagerQuery.getCreateEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createStartTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createEndTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.ne("co.state", 0); |
|
|
|
qw.eq("co.isDelete", 0); |
|
|
|
qw.eq("co.busNo", "305"); |
|
|
|
qw.orderByDesc("co.createTime"); |
|
|
|
List<BusLoancontractForRepayVo> loancontracts = baseMapper.selLoancontractsForExport(qw); |
|
|
|
if (!loancontracts.isEmpty()) { |
|
|
|
List<String> sids = loancontracts.stream().map(BusLoancontractForRepayVo::getSalesOrderSid).collect(Collectors.toList()); |
|
|
|
List<LoanRepaymentPlanDetailsExportVo> exportVos = repaymentScheduleFeign.exportExcel(sids).getData(); |
|
|
|
if (!exportVos.isEmpty()) { |
|
|
|
return exportVos; |
|
|
|
} |
|
|
|
} |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 消贷合同生成还款计划表列表 |
|
|
|
* |
|
|
@ -256,8 +347,8 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService<BusSale |
|
|
|
qw.like("bs.orgName", pagerQuery.getOrgName()); |
|
|
|
} |
|
|
|
//销售专员
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getUseOrgName())) { |
|
|
|
qw.like("bs.useOrgName", pagerQuery.getUseOrgName()); |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getStaffName())) { |
|
|
|
qw.like("bs.staffName", pagerQuery.getStaffName()); |
|
|
|
} |
|
|
|
//消贷合同编号
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getLoanContractNo())) { |
|
|
@ -275,8 +366,18 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService<BusSale |
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getPolicyName())) { |
|
|
|
qw.like("co.policyName", pagerQuery.getPolicyName()); |
|
|
|
} |
|
|
|
qw.eq("co.state", 1); |
|
|
|
//金融产品
|
|
|
|
if (StringUtils.isNotBlank(pagerQuery.getBuilded())) { |
|
|
|
qw.like("co.repaymentState", pagerQuery.getBuilded()); |
|
|
|
} |
|
|
|
String createStartTime = pagerQuery.getCreateStartDate(); |
|
|
|
String createEndTime = pagerQuery.getCreateEndDate(); |
|
|
|
qw.apply(StringUtils.isNotEmpty(createStartTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') >= date_format('" + createStartTime + "','%Y-%m-%d')"). |
|
|
|
apply(StringUtils.isNotEmpty(createEndTime), "date_format (co.repaymentCreateTime,'%Y-%m-%d') <= date_format('" + createEndTime + "','%Y-%m-%d')" |
|
|
|
); |
|
|
|
qw.ne("co.state", 0); |
|
|
|
qw.eq("co.isDelete", 0); |
|
|
|
qw.eq("co.busNo", "305"); |
|
|
|
qw.orderByDesc("co.createTime"); |
|
|
|
IPage<BusLoancontractForRepayVo> pagging = baseMapper.listPageForRepay(page, qw); |
|
|
|
List<BusLoancontractForRepayVo> records = pagging.getRecords(); |
|
|
@ -293,14 +394,88 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService<BusSale |
|
|
|
record.setVinNo(String.join(",", stringVinNos)); |
|
|
|
} |
|
|
|
} |
|
|
|
// ResultBean<LoanRepaymentSchedule> repaymentSchedule = repaymentScheduleFeign.selByLoanContractSid(record.getSalesOrderSid());
|
|
|
|
// if (repaymentSchedule.getData() != null) {
|
|
|
|
ResultBean<LoanRepaymentSchedule> repaymentSchedule = repaymentScheduleFeign.selByLoanContractSid(record.getSalesOrderSid()); |
|
|
|
if (repaymentSchedule.getData() != null) { |
|
|
|
LoanRepaymentSchedule schedule = repaymentSchedule.getData(); |
|
|
|
if (StringUtils.isNotBlank(schedule.getCwDeptNo())) { |
|
|
|
record.setCwDeptNo(schedule.getCwDeptNo()); |
|
|
|
} |
|
|
|
BigDecimal mainAmount; //主产品还款总金额
|
|
|
|
BigDecimal otherAmount; //其他融还款总金额
|
|
|
|
BigDecimal amountAll; // 总金额
|
|
|
|
//车辆数
|
|
|
|
BigDecimal vehCount = new BigDecimal(schedule.getVehCount()); |
|
|
|
if (StringUtils.isNotBlank(schedule.getIsDifferent())) { |
|
|
|
if (schedule.getIsDifferent().equals("是")) { |
|
|
|
//判断是否有一台车不同月还金额
|
|
|
|
//主产品期数
|
|
|
|
BigDecimal mainPeriod = new BigDecimal(schedule.getMainPeriod()); |
|
|
|
//主产品首期月还
|
|
|
|
BigDecimal mainFirstRepay = schedule.getMainFirstRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleMainFirstRepay()); |
|
|
|
//主产品期间月还
|
|
|
|
BigDecimal mainMidRepay = schedule.getMainMidRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleMainMidRepay()).multiply(mainPeriod.subtract(new BigDecimal("2"))); |
|
|
|
//主产品末期月还
|
|
|
|
BigDecimal mainLastRepay = schedule.getMainLastRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleMainLastRepay()); |
|
|
|
mainAmount = mainFirstRepay.add(mainMidRepay).add(mainLastRepay); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
//有其他融
|
|
|
|
//其他融期数
|
|
|
|
BigDecimal otherPeriod = new BigDecimal(schedule.getOtherPeriod()); |
|
|
|
//其他融首期月还
|
|
|
|
BigDecimal otherFirstRepay = schedule.getOtherFirstRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleOtherFirstRepay()); |
|
|
|
//其他融期间月还
|
|
|
|
BigDecimal otherMidRepay = schedule.getOtherMidRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleOtherMidRepay()).multiply(mainPeriod.subtract(new BigDecimal("2"))); |
|
|
|
//其他融末期月还
|
|
|
|
BigDecimal otherLastRepay = schedule.getOtherLastRepay().multiply(vehCount.subtract(new BigDecimal("1"))).add(schedule.getSingleOtherLastRepay()); |
|
|
|
otherAmount = otherFirstRepay.add(otherMidRepay).add(otherLastRepay); |
|
|
|
amountAll = mainAmount.add(otherAmount); |
|
|
|
record.setMainAmount(mainAmount.toString()); |
|
|
|
record.setOtherAmount(otherAmount.toString()); |
|
|
|
record.setAmountAll(amountAll.toString()); |
|
|
|
} else if (schedule.getIsOtherPolicy().equals("0")) { |
|
|
|
//没有其他融
|
|
|
|
record.setMainAmount(mainAmount.toString()); |
|
|
|
record.setAmountAll(mainAmount.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
//主产品期数
|
|
|
|
BigDecimal mainPeriod = new BigDecimal(schedule.getMainPeriod()); |
|
|
|
//主产品首期月还
|
|
|
|
BigDecimal mainFirstRepay = schedule.getMainFirstRepay().multiply(vehCount); |
|
|
|
//主产品期间月还
|
|
|
|
BigDecimal mainMidRepay = mainPeriod.subtract(new BigDecimal("2")).multiply(schedule.getMainMidRepay()).multiply(vehCount); |
|
|
|
//主产品末期月还
|
|
|
|
BigDecimal mainLastRepay = schedule.getMainLastRepay().multiply(vehCount); |
|
|
|
mainAmount = mainFirstRepay.add(mainMidRepay).add(mainLastRepay); |
|
|
|
if (schedule.getIsOtherPolicy().equals("1")) { |
|
|
|
//有其他融
|
|
|
|
//其他融期数
|
|
|
|
BigDecimal otherPeriod = new BigDecimal(schedule.getOtherPeriod()); |
|
|
|
//其他融首期月还
|
|
|
|
BigDecimal otherFirstRepay = schedule.getOtherFirstRepay().multiply(vehCount); |
|
|
|
//其他融期间月还
|
|
|
|
BigDecimal otherMidRepay = otherPeriod.subtract(new BigDecimal("2")).multiply(schedule.getOtherMidRepay()).multiply(vehCount); |
|
|
|
//其他融末期月还
|
|
|
|
BigDecimal otherLastRepay = schedule.getOtherLastRepay().multiply(vehCount); |
|
|
|
otherAmount = otherFirstRepay.add(otherMidRepay).add(otherLastRepay); |
|
|
|
amountAll = mainAmount.add(otherAmount); |
|
|
|
record.setMainAmount(mainAmount.toString()); |
|
|
|
record.setOtherAmount(otherAmount.toString()); |
|
|
|
record.setAmountAll(amountAll.toString()); |
|
|
|
} else if (schedule.getIsOtherPolicy().equals("0")) { |
|
|
|
//没有其他融
|
|
|
|
record.setMainAmount(mainAmount.toString()); |
|
|
|
record.setAmountAll(mainAmount.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
// record.setBuilded("是");
|
|
|
|
// List<LoanRepaymentHistory> histories = repaymentScheduleFeign.selHistoryBySid(repaymentSchedule.getData().getSid()).getData();
|
|
|
|
// if (histories.isEmpty() || histories == null) {
|
|
|
|
// record.setHandleBtn(true);
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
} |
|
|
|
// else {
|
|
|
|
// record.setBuilded("否");
|
|
|
|
// if (StringUtils.isNotBlank(record.getBankContractNo())) {
|
|
|
|
// record.setHandleBtn(true);
|
|
|
@ -1095,7 +1270,7 @@ public class BusSalesOrderLoancontractService extends MybatisBaseService<BusSale |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public int setRepaymentState(String sid,String createTime) { |
|
|
|
return baseMapper.setRepaymentState(sid,createTime); |
|
|
|
public int setRepaymentState(String sid, String createTime) { |
|
|
|
return baseMapper.setRepaymentState(sid, createTime); |
|
|
|
} |
|
|
|
} |
|
|
|