|
|
@@ -1,6 +1,14 @@
|
|
|
package com.huyi.service.common.report.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.huyi.service.base.entity.ZcFinanceInf;
|
|
|
+import com.huyi.service.base.entity.ZcFinanceProComRel;
|
|
|
+import com.huyi.service.base.entity.ZcFinanceSupplierQuota;
|
|
|
+import com.huyi.service.base.service.IZcFinanceInfService;
|
|
|
+import com.huyi.service.base.service.IZcFinanceProComRelService;
|
|
|
import com.huyi.service.common.report.service.ReportCreditService;
|
|
|
import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
|
|
|
import com.tianhu.common.core.utils.AmtUtil;
|
|
|
@@ -33,6 +41,10 @@ public class ReportCreditController extends BaseController {
|
|
|
private TokenService tokenService;
|
|
|
@Autowired
|
|
|
private ReportCreditService reportCreditService;
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceProComRelService iZcFinanceProComRelService;
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceInfService iZcFinanceInfService;
|
|
|
|
|
|
/**
|
|
|
* 企业类型 00平台
|
|
|
@@ -387,11 +399,11 @@ public class ReportCreditController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 企业融信30天到期数据
|
|
|
+ * 核心企业融信30天到期数据(30天待还款)
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/getExpiredList")
|
|
|
- public AjaxResult getExpiredList(String zfpType, QueryRequest request)
|
|
|
+ public AjaxResult getExpiredList(String zfpType, QueryRequest request) throws Exception
|
|
|
{
|
|
|
//获取当前企业的编号
|
|
|
LoginUser userInfo = tokenService.getLoginUser();
|
|
|
@@ -405,30 +417,56 @@ public class ReportCreditController extends BaseController {
|
|
|
String startDate = DateUtils.dateTimeNow("yyyy-MM-dd");
|
|
|
//结束时间 30后
|
|
|
String endDate = DateUtils.getFetureDate(30);
|
|
|
- map.put("startDate",startDate);
|
|
|
- map.put("endDate",endDate);
|
|
|
//默认反向
|
|
|
if(CommonUtil.isEmpty(zfpType)){
|
|
|
zfpType = "1";
|
|
|
}
|
|
|
if(COMPANYTYPE_CORE.equals(type)){
|
|
|
//核心企业
|
|
|
- map.put("zfpType",zfpType);
|
|
|
+ map.put("startDate",startDate);
|
|
|
+ map.put("endDate",endDate);
|
|
|
+ //map.put("zfpType",zfpType);
|
|
|
map.put("coreCompanyId", companyId);
|
|
|
+ //即将到期融信
|
|
|
+ IPage<Map> list = reportCreditService.getExpiredList(map,request);
|
|
|
+ return AjaxResult.success(list);
|
|
|
}else if(COMPANYTYPE_SUPPLIER.equals(type)){
|
|
|
//供应商
|
|
|
- map.put("zfpType",zfpType);
|
|
|
- map.put("supplierCompanyId", companyId);
|
|
|
- }else if(COMPANYTYPE_MANAGEMENT.equals(type)){
|
|
|
- //资金方
|
|
|
- map.put("zfpType",zfpType);
|
|
|
- map.put("managementCompanyId", companyId);
|
|
|
+ Map map1 = new HashMap();
|
|
|
+ map1.put("supplierCompanyId", companyId);
|
|
|
+ List<Map> dateInf = reportCreditService.listCreditDate(map1);
|
|
|
+ List<String> idList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < dateInf.size(); i++) {
|
|
|
+ //融信id
|
|
|
+ String zfiId = dateInf.get(i).get("zfiId")+"";
|
|
|
+ //承诺付款日
|
|
|
+ String zfiExpireDate = dateInf.get(i).get("zfiExpireDate")+"";
|
|
|
+ //最短账期
|
|
|
+ int zfpShortestPeriod = Integer.parseInt(dateInf.get(i).get("zfpShortestPeriod")+"");
|
|
|
+ //String 转 Date
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
|
|
|
+ Date date = simpleDateFormat.parse(zfiExpireDate);
|
|
|
+ //承诺还款日 - 最短账期(天数) = 失效日期
|
|
|
+ GregorianCalendar cal = new GregorianCalendar();
|
|
|
+ cal.setTime(date);
|
|
|
+ cal.add(Calendar.DATE, -zfpShortestPeriod);
|
|
|
+ //失效日期
|
|
|
+ String expirationDate = DateUtils.parseDateToStr("yyyy-MM-dd",cal.getTime());
|
|
|
+ //当前日期向后推30天
|
|
|
+ String day = DateUtils.getFetureDate(30);
|
|
|
+ if (expirationDate.equals(day)){
|
|
|
+ idList.add(zfiId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (idList.size() > 0) {
|
|
|
+ LambdaQueryWrapper<ZcFinanceInf> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(ZcFinanceInf::getZfiId, idList);
|
|
|
+ IPage<ZcFinanceInf> list = iZcFinanceInfService.findZcFinanceInfs(request, queryWrapper);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
}
|
|
|
- //即将到期融信
|
|
|
- IPage<Map> list = reportCreditService.getExpiredList(map,request);
|
|
|
- return AjaxResult.success(list);
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 查询平台资金 -- 饼图
|
|
|
* @return
|
|
|
@@ -814,4 +852,256 @@ public class ReportCreditController extends BaseController {
|
|
|
}
|
|
|
return daysStrList;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询核心企业总授信额度
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listCreditLineAll")
|
|
|
+ public AjaxResult listCreditLineAll(String zfpType)
|
|
|
+ {
|
|
|
+ //获取当前企业的编号
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //获取企业类型
|
|
|
+ String type = use.getCompanyType();
|
|
|
+ //默认反向
|
|
|
+ if(CommonUtil.isEmpty(zfpType)){
|
|
|
+ zfpType = "1";
|
|
|
+ }
|
|
|
+ //反向总授信额度
|
|
|
+ String allAmount = "0";
|
|
|
+ //反向可用额度{总授信 减去 (已生效+空+融资中+已融资+待签收)(融信状态)}
|
|
|
+ String usableAmount = "0";
|
|
|
+ //正向总授信额度
|
|
|
+ String allAmountForward = "0";
|
|
|
+ //正向可用额度{总授信额度 -已分配额度}
|
|
|
+ String usableAmountForward = "0";
|
|
|
+ //核心企业反向总授信额度
|
|
|
+ if(COMPANYTYPE_CORE.equals(type) && "1".equals(zfpType)){
|
|
|
+ //查询本企业反向总授信额度
|
|
|
+ QueryWrapper<ZcFinanceProComRel> queryWrapper = new QueryWrapper<>();
|
|
|
+ //企业id
|
|
|
+ queryWrapper.in("zfpcr_company_id", companyId);
|
|
|
+ //状态(00:有效 01:失效)
|
|
|
+ queryWrapper.eq("zfpcr_status","00");
|
|
|
+ queryWrapper.select("CAST(ROUND(IFNULL(SUM(zfpcr_amount), 0), 2) AS CHAR) AS zfpcrAmount");
|
|
|
+ ZcFinanceProComRel zcFinanceProComRel = iZcFinanceProComRelService.getOne(queryWrapper);
|
|
|
+ //查询本企业融信表总申请金额
|
|
|
+ QueryWrapper<ZcFinanceInf> wrapper = new QueryWrapper<>();
|
|
|
+ //核心企业id
|
|
|
+ wrapper.in("zfi_core_id", companyId);
|
|
|
+ //状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回 07:已失效(到期失效)08:已失效(还款成功失效)99:删除)
|
|
|
+ wrapper.notIn("zfi_status","00","03","06","07","08","99");
|
|
|
+ wrapper.select("IFNULL(CAST(ROUND(SUM(zfi_amount),2)AS CHAR),'0.00') AS zfiAmount");
|
|
|
+ ZcFinanceInf zcFinanceInf = iZcFinanceInfService.getOne(wrapper);
|
|
|
+ if (zcFinanceProComRel != null) {
|
|
|
+ allAmount = zcFinanceProComRel.getZfpcrAmount();
|
|
|
+ }
|
|
|
+ if (zcFinanceInf != null){
|
|
|
+ //申请金额
|
|
|
+ String zfiAmount = zcFinanceInf.getZfiAmount();
|
|
|
+ usableAmount = AmtUtil.subtract(allAmount,zfiAmount,2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //核心企业正向总授信额度
|
|
|
+ else if (COMPANYTYPE_CORE.equals(type) && "0".equals(zfpType)){
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("companyId",companyId);
|
|
|
+ List<Map> list = reportCreditService.listCreditLineAll(map);
|
|
|
+ allAmountForward = list.get(0).get("allAmount")+"";
|
|
|
+ //已分配额度
|
|
|
+ String zfsqAmount = list.get(0).get("zfsqAmount")+"";
|
|
|
+ //可用授信额度
|
|
|
+ usableAmountForward = AmtUtil.subtract(allAmountForward,zfsqAmount,2);
|
|
|
+ }
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("allAmount",allAmount);
|
|
|
+ result.put("usableAmount",usableAmount);
|
|
|
+ result.put("allAmountForward",allAmountForward);
|
|
|
+ result.put("usableAmountForward",usableAmountForward);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询核心企业我开立的融信金额/我确权的
|
|
|
+ * @param hxDateType 00:实时 01:年度 02:历史
|
|
|
+ * @param zfpType 融资产品 0:正向 1:反向
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listCreditAll")
|
|
|
+ public AjaxResult listCreditAll(String hxDateType,String zfpType)
|
|
|
+ {
|
|
|
+ //获取当前企业的编号
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ //获取企业类型
|
|
|
+ String type = use.getCompanyType();
|
|
|
+ //默认反向
|
|
|
+ if(CommonUtil.isEmpty(zfpType)){
|
|
|
+ zfpType = "1";
|
|
|
+ }
|
|
|
+ //总额度
|
|
|
+ String allAmount = "0";
|
|
|
+ //核心企业我开立的融信额度
|
|
|
+ if(COMPANYTYPE_CORE.equals(type)){
|
|
|
+ map.put("coreCompanyId",companyId);
|
|
|
+ map.put("hxDateType",hxDateType);
|
|
|
+ map.put("zfpType",zfpType);
|
|
|
+ //年度
|
|
|
+ if ("01".equals(hxDateType)){
|
|
|
+ String startDate = getYearStart();
|
|
|
+ String endDate = getYearEnd();
|
|
|
+ map.put("startDate",startDate);
|
|
|
+ map.put("endDate",endDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allAmount = reportCreditService.listCreditAll(map);
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("allAmount",allAmount);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询核心企业已融资金额
|
|
|
+ * @param zfpType 融资产品 0:正向 1:反向
|
|
|
+ * @param hxDateType 00:实时 01:年度 02:历史
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listHasRaised")
|
|
|
+ public AjaxResult listHasRaised(String zfpType,String hxDateType)
|
|
|
+ {
|
|
|
+ //获取当前企业的编号
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //获取企业类型
|
|
|
+ String type = use.getCompanyType();
|
|
|
+ //默认反向
|
|
|
+ if(CommonUtil.isEmpty(zfpType)){
|
|
|
+ zfpType = "1";
|
|
|
+ }
|
|
|
+ //总额度
|
|
|
+ String allAmount = "0";
|
|
|
+ //核心企业已融资额度
|
|
|
+ if(COMPANYTYPE_CORE.equals(type)){
|
|
|
+ map.put("coreCompanyId",companyId);
|
|
|
+ map.put("zfpType", zfpType);
|
|
|
+ map.put("hxDateType",hxDateType);
|
|
|
+ //年度
|
|
|
+ if ("01".equals(hxDateType)) {
|
|
|
+ String startDate = getYearStart();
|
|
|
+ String endDate = getYearEnd();
|
|
|
+ map.put("startDate",startDate);
|
|
|
+ map.put("endDate",endDate);
|
|
|
+ }
|
|
|
+ allAmount = reportCreditService.listHasRaised(map);
|
|
|
+ }
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("allAmount",allAmount);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 核心企业30天内待还款
|
|
|
+ * @param zfpType 融资产品 0:正向 1:反向
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listPendingRepayment")
|
|
|
+ public AjaxResult listPendingRepayment(String zfpType)
|
|
|
+ {
|
|
|
+ //获取当前企业的编号
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //获取企业类型
|
|
|
+ String type = use.getCompanyType();
|
|
|
+ //开始时间 当天
|
|
|
+ String startDate = DateUtils.dateTimeNow("yyyy-MM-dd");
|
|
|
+ //结束时间 30后
|
|
|
+ String endDate = DateUtils.getFetureDate(30);
|
|
|
+ //总额度
|
|
|
+ String allAmount = "0";
|
|
|
+ map.put("startDate",startDate);
|
|
|
+ map.put("endDate",endDate);
|
|
|
+ //默认反向
|
|
|
+ if(CommonUtil.isEmpty(zfpType)){
|
|
|
+ zfpType = "1";
|
|
|
+ }
|
|
|
+ if(COMPANYTYPE_CORE.equals(type)){
|
|
|
+ //核心企业
|
|
|
+ map.put("zfpType",zfpType);
|
|
|
+ map.put("coreCompanyId", companyId);
|
|
|
+ }
|
|
|
+ allAmount = reportCreditService.listPendingRepayment(map);
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("allAmount",allAmount);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询核心企业还款金额
|
|
|
+ * @param hxDateType 00:实时 01:年度 02:历史
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/listRepayment")
|
|
|
+ public AjaxResult listRepayment(String hxDateType)
|
|
|
+ {
|
|
|
+ //获取当前企业的编号
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //获取企业类型
|
|
|
+ String type = use.getCompanyType();
|
|
|
+ //总额度
|
|
|
+ String allAmount = "0";
|
|
|
+ //核心企业已融资额度
|
|
|
+ if(COMPANYTYPE_CORE.equals(type)){
|
|
|
+ map.put("coreCompanyId",companyId);
|
|
|
+ map.put("hxDateType",hxDateType);
|
|
|
+ //年度
|
|
|
+ if ("01".equals(hxDateType)) {
|
|
|
+ String startDate = getYearStart();
|
|
|
+ String endDate = getYearEnd();
|
|
|
+ map.put("startDate",startDate);
|
|
|
+ map.put("endDate",endDate);
|
|
|
+ }
|
|
|
+ allAmount = reportCreditService.listRepayment(map);
|
|
|
+ }
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("allAmount",allAmount);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取本年的第一天
|
|
|
+ * @return String
|
|
|
+ * **/
|
|
|
+ public static String getYearStart(){
|
|
|
+ return new SimpleDateFormat("yyyy").format(new Date())+"-01-01";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取本年的最后一天
|
|
|
+ * @return String
|
|
|
+ * **/
|
|
|
+ public static String getYearEnd(){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.set(Calendar.MONTH,calendar.getActualMaximum(Calendar.MONTH));
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ Date currYearLast = calendar.getTime();
|
|
|
+ return new SimpleDateFormat("yyyy-MM-dd").format(currYearLast)+" 23:59:59";
|
|
|
+ }
|
|
|
}
|