123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792 |
- package com.huyi.service.creditLine.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.huyi.service.base.entity.*;
- import com.huyi.service.base.service.*;
- import com.huyi.service.creditLine.service.CreditLineService;
- import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
- import com.tianhu.common.core.constant.SalaryConstants;
- import com.tianhu.common.core.domain.R;
- import com.tianhu.common.core.utils.*;
- import com.tianhu.common.core.web.controller.BaseController;
- import com.tianhu.common.core.web.domain.AjaxResult;
- import com.tianhu.common.log.annotation.Log;
- import com.tianhu.common.log.enums.BusinessType;
- import com.tianhu.common.security.annotation.PreAuthorize;
- import com.tianhu.common.security.service.TokenService;
- import com.tianhu.system.api.domain.SysUser;
- import com.tianhu.system.api.model.LoginUser;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServletResponse;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.InputStream;
- import java.math.BigDecimal;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.net.URLEncoder;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.regex.Pattern;
- /**
- * 授信额度Controller
- *
- * @author pxh
- * @date 2021-02-04
- */
- @RestController
- @RequestMapping("/creditLine")
- public class CreditLineController extends BaseController {
- @Autowired
- private TokenService tokenService;
- @Autowired
- private CreditLineService creditLineService;
- @Autowired
- private IZcFinanceInfService zcFinanceInfService;
- @Autowired
- private IZcFinanceProComRelService iZcFinanceProComRelService;
- @Autowired
- private IZcFinanceQuotaConRelService iZcFinanceQuotaConRelService;
- @Autowired
- private IZcFinanceContractService iZcFinanceContractService;
- @Autowired
- private IZcFinanceSupplierQuotaService iZcFinanceSupplierQuotaService;
- @Autowired
- private IPubFileInfService iPubFileInfService;
- public final static String REGEX = "^\\d\\.([0-9]{1,2}|[0-9][0-9])$|^[0-9]\\d{0,1}(\\.\\d{1,2}){0,1}$|^100(\\.0{1,2}){0,1}$";
- /**
- * 查询授信额度列表
- */
- @PreAuthorize(hasPermi = "credit:line:list")
- @GetMapping("/list")
- public R list(//资金方名称
- @RequestParam(required=false) String rzScyName,
- //授信额度范围
- @RequestParam (required=false) String AmountA,
- //授信额度范围
- @RequestParam (required=false) String AmountB,
- //状态(00:有效 01:失效)
- @RequestParam (required=false) String zfpcrStatus,
- //开始日期
- @RequestParam (required = false) Map startTime,
- //结束日期
- @RequestParam (required = false) Map endTime,
- //授信类型(融资产品类型)
- @RequestParam (required = false) String zfpType,
- //融资产品
- @RequestParam (required = false) String zfpName,
- //类型
- @RequestParam (required = false) String zfpcrQuery,
- @RequestParam (required = false) String zfpcrValue,
- QueryRequest request) {
- //查询当前操作员
- LoginUser userInfo = tokenService.getLoginUser();
- SysUser user = userInfo.getSysUser();
- //获取企业
- String companyId = user.getCompanyId();
- //获取企业类型
- String companyType = user.getCompanyType();
- Map map = new HashMap();
- if (!SalaryConstants.OPEX.equals(companyId)) {
- map.put("companyId", companyId);
- }
- //企业类型
- map.put("companyType",companyType);
- //授信额度范围
- // if (CommonUtil.isNotEmpty(AmountA)) {
- // map.put("AmountA", CommonUtil.objToBigDecimal(AmountA));
- // }
- // if (CommonUtil.isNotEmpty(AmountB)) {
- // map.put("AmountB", CommonUtil.objToBigDecimal(AmountB));
- // }
- //类型
- if ("00".equals(zfpcrQuery)){
- //资金方
- map.put("rzScyName",zfpcrValue);
- }else if ("01".equals(zfpcrQuery)){
- //融资产品名称
- map.put("zfpName",zfpcrValue);
- }else if ("02".equals(zfpcrQuery)){
- //企业名称
- map.put("scyName",zfpcrValue);
- }
- //状态状态(00:有效 01:失效)
- if (!"02".equals(zfpcrStatus)) {
- map.put("zfpcrStatus", zfpcrStatus);
- }
- //开始日期区间
- map.put("startTimeA",startTime.get("startTime[0]"));
- map.put("startTimeB",startTime.get("startTime[1]"));
- //结束日期区间
- map.put("endTimeA",endTime.get("endTime[0]"));
- map.put("endTimeB",endTime.get("endTime[1]"));
- //授信类型(融资产品类型)
- if (!"2".equals(zfpType)) {
- map.put("zfpType", zfpType);
- }
- //供应商
- if ("02".equals(companyType)){
- IPage<Map> list = creditLineService.selectSupplierCreditList(map, request);
- List listAll = list.getRecords();
- for (int j = 0; j < listAll.size(); j++) {
- Map<String, String> m = (Map<String, String>) listAll.get(j);
- //授信额度
- String zfsqAmount = m.get("zfsqAmount");
- //授信id
- String zfsqId = m.get("zfsqId");
- //通过融资产品查询融信表申请金额
- QueryWrapper<ZcFinanceInf> queryWrapper = new QueryWrapper<>();
- //授信id
- queryWrapper.in("zfi_supplier_quota_id", zfsqId);
- //状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回 07:已失效(到期失效)08:已失效(还款成功失效)99:删除)
- //queryWrapper.and(i -> i.ne("zfi_status", "00").or().ne("zfi_status", "03"));
- queryWrapper.notIn("zfi_status","00","03","07","08");
- queryWrapper.select("IFNULL(CAST(ROUND(SUM(zfi_amount),2)AS CHAR),'0.00') AS zfiAmount");
- ZcFinanceInf zcFinanceInf = zcFinanceInfService.getOne(queryWrapper);
- //申请金额(已用)
- String zfiAmount = "0.00";
- if (zcFinanceInf != null) {
- zfiAmount = zcFinanceInf.getZfiAmount();
- }
- //可用额度(授信额度 - 申请金额)
- String usableAmount = AmtUtil.subtract(zfsqAmount, zfiAmount, 2);
- //已使用额度
- m.put("zfiAmount", zfiAmount);
- //可用额度
- m.put("usableAmount", usableAmount);
- //企业类型
- m.put("companyType", companyType);
- }
- return R.ok(list);
- }else {
- IPage<Map> list = creditLineService.selectCreditLineList(map, request);
- List listAll = list.getRecords();
- for (int j = 0; j < listAll.size(); j++) {
- Map<String, String> m = (Map<String, String>) listAll.get(j);
- //授信额度
- String zfpcrAmount = m.get("zfpcrAmount");
- //授信id
- String zfpcrId = m.get("zfpcrId");
- //融资产品
- String zfpcrProductId = m.get("zfpcrProductId");
- //融资产品方向(0:正向,1反向)
- String zfpTypes = m.get("zfpType");
- //通过融资产品查询融信表申请金额
- QueryWrapper<ZcFinanceInf> queryWrapper = new QueryWrapper<>();
- //授信id
- queryWrapper.in("zfi_core_quota_id", zfpcrId);
- //状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回 07:已失效(到期失效)08:已失效(还款成功失效)99:删除)
- //queryWrapper.and(i -> i.ne("zfi_status", "00").or().ne("zfi_status", "03"));
- queryWrapper.notIn("zfi_status","00","03","07","08");
- queryWrapper.select("IFNULL(CAST(ROUND(SUM(zfi_amount),2)AS CHAR),'0.00') AS zfiAmount");
- ZcFinanceInf zcFinanceInf = zcFinanceInfService.getOne(queryWrapper);
- //申请金额(已用)
- String zfiAmount = "0.00";
- if (zcFinanceInf != null) {
- zfiAmount = zcFinanceInf.getZfiAmount();
- }
- //可用额度(反向保理:授信额度 - 申请金额;正向保理:授信额度 - 已分配额度)
- String usableAmount = "0.00";
- //查询核心企业授信额度ID下的供应商授信额度总和
- QueryWrapper<ZcFinanceSupplierQuota> supplierQueryWrapper = new QueryWrapper<>();
- supplierQueryWrapper.eq("zfsq_core_quota_id", zfpcrId);
- supplierQueryWrapper.eq("zfsq_status","00");
- supplierQueryWrapper.select("IFNULL(CAST(ROUND(SUM(zfsq_amount),2)AS CHAR),'0.00') AS zfsqAmount");
- ZcFinanceSupplierQuota supplierQuota = iZcFinanceSupplierQuotaService.getOne(supplierQueryWrapper);
- //供应商已使用额度总和
- String totalAmount = supplierQuota.getZfsqAmount();
- //已使用额度
- m.put("zfiAmount", zfiAmount);
- //可用额度(正向保理:授信额度 - 已分配额度)
- if ("0".equals(zfpTypes)){
- usableAmount = AmtUtil.subtract(zfpcrAmount, totalAmount, 2);
- }
- //可用额度(反向保理:授信额度 - 申请金额)
- else if ("1".equals(zfpTypes)){
- usableAmount = AmtUtil.subtract(zfpcrAmount, zfiAmount, 2);
- }
- m.put("usableAmount", usableAmount);
- //企业类型
- m.put("companyType", companyType);
- //供应商授信额度
- m.put("supplierAmount", totalAmount);
- }
- return R.ok(list);
- }
- }
- /**
- * 授信额度信息详情
- */
- @PreAuthorize(hasPermi = "credit:line:query")
- @GetMapping(value = "/{zfpcrId}")
- public AjaxResult getInfo(@PathVariable("zfpcrId") String zfpcrId)
- {
- Map result = new HashMap();
- //授信信息
- Map map = new HashMap();
- map.put("zfpcrId",zfpcrId);
- List<Map> list = creditLineService.selectCreditLineDetail(map);
- //授信合同信息关联表
- LambdaQueryWrapper<ZcFinanceQuotaConRel> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ZcFinanceQuotaConRel::getZfqcrCreditId,zfpcrId);
- List<ZcFinanceQuotaConRel> quotaConRelList = iZcFinanceQuotaConRelService.findZcFinanceQuotaConRels(queryWrapper);
- List id = new ArrayList();
- for (int i = 0; i < quotaConRelList.size(); i++) {
- String contractId = quotaConRelList.get(i).getZfqcrContractId();
- id.add(contractId);
- }
- //通过主键查询合同表
- if (id.size() > 0) {
- Map map1 = new HashMap();
- map1.put("id",CommonUtil.listToStr4InSql(id));
- List<Map> contractList = creditLineService.selectContractList(map1);
- // LambdaQueryWrapper<ZcFinanceContract> contractWrapper = new LambdaQueryWrapper<>();
- // contractWrapper.in(ZcFinanceContract::getZfcId, id);
- // List<ZcFinanceContract> contractList = iZcFinanceContractService.findZcFinanceContracts(contractWrapper);
- // for (int i = 0; i < contractList.size(); i++) {
- // String zfcFile = contractList.get(i).getZfcFile();
- // PubFileInf pubFileInf = iPubFileInfService.getById(zfcFile);
- // String pfiUrl = pubFileInf.getPfiUrl();
- //
- // }
- result.put("ticketList",contractList);
- }
- result.put("list",list);
- return AjaxResult.success(result);
- }
- /**
- * 新增授信管理
- * @param map
- * @return
- * @throws Exception
- */
- @PreAuthorize(hasPermi = "credit:line:add")
- @Log(title = "授信管理", businessType = BusinessType.INSERT)
- @Transactional(rollbackFor = Exception.class)
- @PostMapping
- public AjaxResult add(@RequestBody Map<String,Object> map)throws Exception
- {
- //获取此操作员
- LoginUser userInfo = tokenService.getLoginUser();
- SysUser user = userInfo.getSysUser();
- String userId = user.getUserId() + "";
- //融资产品
- String zfpcrProductId = CommonUtil.objToString(map.get("zfpcrProductId"));
- //授信企业名称
- String zfpcrCompanyId = CommonUtil.objToString(map.get("zfpcrCompanyId"));
- //授信额度
- String zfpcrAmount = CommonUtil.objToString(map.get("zfpcrAmount"));
- //利率
- String zfpcrRate = CommonUtil.objToString(map.get("zfpcrRate"));
- //有效期
- String zfpcrDateType = CommonUtil.objToString(map.get("zfpcrDateType"));
- //日期范围
- List<String> dateTime = (List<String>) map.get("dateTime");
- //开始日期
- String zfpcrStartDate = "";
- //结束日期
- String zfpcrEndDate = "";
- if ("1".equals(zfpcrDateType)) {
- if (dateTime != null && !dateTime.isEmpty()) {
- //开始日期
- zfpcrStartDate = dateTime.get(0);
- //结束日期
- zfpcrEndDate = dateTime.get(1);
- }
- }
- //融资网点
- String zfpcrAddress = CommonUtil.objToString(map.get("zfpcrAddress"));
- //是否收取手续费(0:不收取, 1收取)
- String zfpcrCharge = CommonUtil.objToString(map.get("zfpcrCharge"));
- //平台服务费收取费率
- String zfpcrChargeRate = CommonUtil.objToString(map.get("zfpcrChargeRate"));
- //核心企业还款账户账号
- String zfpcrAccount = CommonUtil.objToString(map.get("zfpcrAccount"));
- //核心企业还款账户开户行
- String zfpcrAccountBank = CommonUtil.objToString(map.get("zfpcrAccountBank"));
- //融资放款方式
- String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
- //记账簿托管方式
- String zfpcrBookkeepingType = CommonUtil.objToString(map.get("zfpcrLoanType"));
- //校验百分百
- Pattern pattern = Pattern.compile(REGEX);
- //融资产品
- if(CommonUtil.isEmpty(zfpcrProductId)){
- return AjaxResult.error("融资产品不能为空");
- }
- LambdaQueryWrapper<ZcFinanceProComRel> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ZcFinanceProComRel::getZfpcrProductId,zfpcrProductId);
- queryWrapper.eq(ZcFinanceProComRel::getZfpcrCompanyId,zfpcrCompanyId);
- int count = iZcFinanceProComRelService.count(queryWrapper);
- if (count > 0){
- return AjaxResult.error("此企业已授信该融资产品");
- }
- //授信企业名称
- if(CommonUtil.isEmpty(zfpcrCompanyId)){
- return AjaxResult.error("授信企业名称不能为空");
- }
- //授信额度
- if(CommonUtil.isNotEmpty(zfpcrAmount)) {
- if(AmtUtil.isMoney(zfpcrAmount) == false) {
- return AjaxResult.error("请输入正确的授信额度");
- }
- }else {
- return AjaxResult.error("授信额度不能为空");
- }
- //利率
- if(CommonUtil.isNotEmpty(zfpcrRate)) {
- if(!pattern.matcher(zfpcrRate).matches()) {
- return AjaxResult.error("请输入正确的利率");
- }
- }else {
- return AjaxResult.error("利率不能为空");
- }
- //有效期
- if(CommonUtil.isEmpty(zfpcrDateType)){
- return AjaxResult.error("有效期不能为空");
- }
- //时间范围
- if ("1".equals(zfpcrDateType)){
- //时间范围
- if(dateTime.size() == 0){
- return AjaxResult.error("时间范围不能为空");
- }
- }
- //是否收取手续费(0:不收取, 1收取)
- if(CommonUtil.isEmpty(zfpcrCharge)){
- return AjaxResult.error("是否收取手续费不能为空");
- }
- //平台服务费收取费率
- if("1".equals(zfpcrCharge)){
- if(CommonUtil.isNotEmpty(zfpcrChargeRate)) {
- if(!pattern.matcher(zfpcrChargeRate).matches()) {
- return AjaxResult.error("请输入正确的平台服务费收取费率");
- }
- }else {
- return AjaxResult.error("平台服务费收取费率不能为空");
- }
- }
- //核心企业还款账户账号
- if(CommonUtil.isEmpty(zfpcrAccount)){
- return AjaxResult.error("核心企业还款账户账号不能为空");
- }
- //核心企业还款账户账号
- if(CommonUtil.isEmpty(zfpcrAccountBank)){
- return AjaxResult.error("核心企业还款账户开户行不能为空");
- }
- if (zfpcrAccountBank.length() > 30){
- return AjaxResult.error("核心企业还款账户开户行长度过长");
- }
- //融资放款方式
- if(CommonUtil.isEmpty(zfpcrLoanType)){
- return AjaxResult.error("融资放款方式不能为空");
- }
- //记账簿托管方式
- if(CommonUtil.isEmpty(zfpcrBookkeepingType)){
- return AjaxResult.error("记账簿托管方式不能为空");
- }
- //合同信息
- List<Map<String, String>> tableData = (List<Map<String, String>>) map.get("ticketList");
- // if (tableData.size() == 0 ){
- // return AjaxResult.error("请选择合同信息");
- // }
- //执行新增
- ZcFinanceProComRel zcFinanceProComRel = new ZcFinanceProComRel();
- //主键
- String zfpcrId = IdUtils.fastSimpleUUID();
- zcFinanceProComRel.setZfpcrId(zfpcrId);
- //融资产品
- zcFinanceProComRel.setZfpcrProductId(zfpcrProductId);
- //授信企业名称
- zcFinanceProComRel.setZfpcrCompanyId(zfpcrCompanyId);
- //授信额度
- zcFinanceProComRel.setZfpcrAmount(zfpcrAmount);
- //原授信额度(如果授信额度没做修改,原授信额度不变
- zcFinanceProComRel.setZfpcrOldAmount(zfpcrAmount);
- //利率
- zcFinanceProComRel.setZfpcrRate(zfpcrRate);
- //有效期
- zcFinanceProComRel.setZfpcrDateType(zfpcrDateType);
- //开始日期
- zcFinanceProComRel.setZfpcrStartDate(zfpcrStartDate);
- //结束日期
- zcFinanceProComRel.setZfpcrEndDate(zfpcrEndDate);
- //融资网点
- zcFinanceProComRel.setZfpcrAddress(zfpcrAddress);
- //是否收取手续费(0:不收取, 1收取)
- zcFinanceProComRel.setZfpcrCharge(zfpcrCharge);
- //收取服务费
- if("1".equals(zfpcrCharge)){
- //平台服务费收取费率
- zcFinanceProComRel.setZfpcrChargeRate(zfpcrChargeRate);
- }else{
- zcFinanceProComRel.setZfpcrChargeRate("0.00");
- }
- //核心企业还款账户账号
- zcFinanceProComRel.setZfpcrAccount(zfpcrAccount);
- //核心企业还款账户开户行
- zcFinanceProComRel.setZfpcrAccountBank(zfpcrAccountBank);
- //融资放款方式
- zcFinanceProComRel.setZfpcrLoanType(zfpcrLoanType);
- //记账簿托管方式
- zcFinanceProComRel.setZfpcrBookkeepingType(zfpcrBookkeepingType);
- //状态(00:有效 01:失效)
- zcFinanceProComRel.setZfpcrStatus("00");
- //创建人
- zcFinanceProComRel.setCreateBy(userId);
- //创建时间
- zcFinanceProComRel.setCreateTime(DateUtils.getNowDate());
- iZcFinanceProComRelService.createZcFinanceProComRel(zcFinanceProComRel);
- //新增授信合同关联表
- for (int i = 0; i < tableData.size(); i++) {
- if (tableData != null) {
- String zfcId = tableData.get(i).get("zfcId");
- ZcFinanceQuotaConRel zcFinanceQuotaConRel = new ZcFinanceQuotaConRel();
- //合同id
- zcFinanceQuotaConRel.setZfqcrContractId(zfcId);
- //授信id
- zcFinanceQuotaConRel.setZfqcrCreditId(zfpcrId);
- iZcFinanceQuotaConRelService.createZcFinanceQuotaConRel(zcFinanceQuotaConRel);
- }
- }
- return AjaxResult.success();
- }
- /**
- * 修改授信管理
- * @param map
- * @return
- * @throws Exception
- */
- @PreAuthorize(hasPermi = "credit:line:edit")
- @Log(title = "授信管理", businessType = BusinessType.UPDATE)
- @Transactional(rollbackFor = Exception.class)
- @PutMapping
- public AjaxResult update(@RequestBody Map<String,Object> map)throws Exception
- {
- //主键
- String zfpcrId = CommonUtil.objToString(map.get("zfpcrId"));
- //获取此操作员
- LoginUser userInfo = tokenService.getLoginUser();
- SysUser user = userInfo.getSysUser();
- String userId = user.getUserId() + "";
- //融资产品
- String zfpcrProductId = CommonUtil.objToString(map.get("zfpcrProductId"));
- //授信企业名称
- String zfpcrCompanyId = CommonUtil.objToString(map.get("zfpcrCompanyId"));
- //授信额度
- String zfpcrAmount = CommonUtil.objToString(map.get("zfpcrAmount"));
- //原授信额度
- String zfpcrOldAmount = CommonUtil.objToString(map.get("zfpcrOldAmount"));
- //利率
- String zfpcrRate = CommonUtil.objToString(map.get("zfpcrRate"));
- //有效期
- String zfpcrDateType = CommonUtil.objToString(map.get("zfpcrDateType"));
- //日期范围
- List<String> dateTime = (List<String>) map.get("dateTime");
- //开始日期
- String zfpcrStartDate = "";
- //结束日期
- String zfpcrEndDate = "";
- if (dateTime != null) {
- //开始日期
- zfpcrStartDate = dateTime.get(0);
- //结束日期
- zfpcrEndDate = dateTime.get(1);
- }
- //融资网点
- String zfpcrAddress = CommonUtil.objToString(map.get("zfpcrAddress"));
- //是否收取手续费(0:不收取, 1收取)
- String zfpcrCharge = CommonUtil.objToString(map.get("zfpcrCharge"));
- //平台服务费收取费率
- String zfpcrChargeRate = CommonUtil.objToString(map.get("zfpcrChargeRate"));
- //核心企业还款账户账号
- String zfpcrAccount = CommonUtil.objToString(map.get("zfpcrAccount"));
- //核心企业还款账户开户行
- String zfpcrAccountBank = CommonUtil.objToString(map.get("zfpcrAccountBank"));
- //融资放款方式
- String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
- //记账簿托管方式
- String zfpcrBookkeepingType = CommonUtil.objToString(map.get("zfpcrLoanType"));
- //校验百分百
- Pattern pattern = Pattern.compile(REGEX);
- //融资产品
- if(CommonUtil.isEmpty(zfpcrProductId)){
- return AjaxResult.error("融资产品不能为空");
- }
- LambdaQueryWrapper<ZcFinanceProComRel> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(ZcFinanceProComRel::getZfpcrProductId,zfpcrProductId);
- wrapper.eq(ZcFinanceProComRel::getZfpcrCompanyId,zfpcrCompanyId);
- wrapper.ne(ZcFinanceProComRel::getZfpcrId,zfpcrId);
- int count = iZcFinanceProComRelService.count(wrapper);
- if (count > 0){
- return AjaxResult.error("此企业已授信盖融资产品");
- }
- //授信企业名称
- if(CommonUtil.isEmpty(zfpcrCompanyId)){
- return AjaxResult.error("授信企业名称不能为空");
- }
- //授信额度
- if(CommonUtil.isNotEmpty(zfpcrAmount)) {
- if(AmtUtil.isMoney(zfpcrAmount) == false) {
- return AjaxResult.error("请输入正确的授信额度");
- }
- }else {
- return AjaxResult.error("授信额度不能为空");
- }
- //利率
- if(CommonUtil.isNotEmpty(zfpcrRate)) {
- if(!pattern.matcher(zfpcrRate).matches()) {
- return AjaxResult.error("请输入正确的利率");
- }
- }else {
- return AjaxResult.error("利率不能为空");
- }
- //有效期
- if(CommonUtil.isEmpty(zfpcrDateType)){
- return AjaxResult.error("有效期不能为空");
- }
- //时间范围
- if ("1".equals(zfpcrDateType)){
- //时间范围
- if(dateTime.size() == 0){
- return AjaxResult.error("时间范围不能为空");
- }
- }
- //是否收取手续费(0:不收取, 1收取)
- if(CommonUtil.isEmpty(zfpcrCharge)){
- return AjaxResult.error("是否收取手续费不能为空");
- }
- //平台服务费收取费率
- if("1".equals(zfpcrCharge)){
- if(CommonUtil.isNotEmpty(zfpcrChargeRate)) {
- if(!pattern.matcher(zfpcrChargeRate).matches()) {
- return AjaxResult.error("请输入正确的平台服务费收取费率");
- }
- }else {
- return AjaxResult.error("平台服务费收取费率不能为空");
- }
- }
- //核心企业还款账户账号
- if(CommonUtil.isEmpty(zfpcrAccount)){
- return AjaxResult.error("核心企业还款账户账号不能为空");
- }
- //核心企业还款账户账号
- if(CommonUtil.isEmpty(zfpcrAccountBank)){
- return AjaxResult.error("核心企业还款账户开户行不能为空");
- }
- if (zfpcrAccountBank.length() > 30){
- return AjaxResult.error("核心企业还款账户开户行长度过长");
- }
- //融资放款方式
- if(CommonUtil.isEmpty(zfpcrLoanType)){
- return AjaxResult.error("融资放款方式不能为空");
- }
- //记账簿托管方式
- if(CommonUtil.isEmpty(zfpcrBookkeepingType)){
- return AjaxResult.error("记账簿托管方式不能为空");
- }
- //合同信息
- List<Map<String, String>> tableData = (List<Map<String, String>>) map.get("ticketList");
- // if (tableData.size() == 0 ){
- // return AjaxResult.error("请选择合同信息");
- // }
- //执行修改
- ZcFinanceProComRel zcFinanceProComRel = new ZcFinanceProComRel();
- //主键
- zcFinanceProComRel.setZfpcrId(zfpcrId);
- //融资产品
- zcFinanceProComRel.setZfpcrProductId(zfpcrProductId);
- //授信企业名称
- zcFinanceProComRel.setZfpcrCompanyId(zfpcrCompanyId);
- //授信额度
- zcFinanceProComRel.setZfpcrAmount(zfpcrAmount);
- //原授信额度(如果授信额度没做修改,原授信额度不变
- if (!zfpcrAmount.equals(zfpcrOldAmount)) {
- zcFinanceProComRel.setZfpcrOldAmount(zfpcrOldAmount);
- }
- //利率
- zcFinanceProComRel.setZfpcrRate(zfpcrRate);
- //有效期
- zcFinanceProComRel.setZfpcrDateType(zfpcrDateType);
- if ("1".equals(zfpcrDateType)) {
- //开始日期
- zcFinanceProComRel.setZfpcrStartDate(zfpcrStartDate);
- //结束日期
- zcFinanceProComRel.setZfpcrEndDate(zfpcrEndDate);
- }else{
- //开始日期
- zcFinanceProComRel.setZfpcrStartDate("");
- //结束日期
- zcFinanceProComRel.setZfpcrEndDate("");
- }
- //融资网点
- zcFinanceProComRel.setZfpcrAddress(zfpcrAddress);
- //是否收取手续费(0:不收取, 1收取)
- zcFinanceProComRel.setZfpcrCharge(zfpcrCharge);
- //收取服务费
- if("1".equals(zfpcrCharge)){
- //平台服务费收取费率
- zcFinanceProComRel.setZfpcrChargeRate(zfpcrChargeRate);
- }else{
- zcFinanceProComRel.setZfpcrChargeRate("0.00");
- }
- //核心企业还款账户账号
- zcFinanceProComRel.setZfpcrAccount(zfpcrAccount);
- //核心企业还款账户开户行
- zcFinanceProComRel.setZfpcrAccountBank(zfpcrAccountBank);
- //融资放款方式
- zcFinanceProComRel.setZfpcrLoanType(zfpcrLoanType);
- //记账簿托管方式
- zcFinanceProComRel.setZfpcrBookkeepingType(zfpcrBookkeepingType);
- //修改人
- zcFinanceProComRel.setUpdateBy(userId);
- //修改时间
- zcFinanceProComRel.setUpdateTime(DateUtils.getNowDate());
- iZcFinanceProComRelService.updateZcFinanceProComRel(zcFinanceProComRel);
- //查询原合同信息详情并删除
- LambdaQueryWrapper<ZcFinanceQuotaConRel> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ZcFinanceQuotaConRel::getZfqcrCreditId,zfpcrId);
- List<ZcFinanceQuotaConRel> list = iZcFinanceQuotaConRelService.findZcFinanceQuotaConRels(queryWrapper);
- for (int i = 0; i < list.size(); i++) {
- LambdaQueryWrapper<ZcFinanceQuotaConRel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
- lambdaQueryWrapper.eq(ZcFinanceQuotaConRel::getZfqcrCreditId,list.get(i).getZfqcrCreditId());
- iZcFinanceQuotaConRelService.deleteZcFinanceQuotaConRel(lambdaQueryWrapper);
- }
- //新增授信合同
- // 关联表
- if (tableData != null && !tableData.isEmpty()) {
- for (int i = 0; i < tableData.size(); i++) {
- String zfcId = tableData.get(i).get("zfcId");
- ZcFinanceQuotaConRel zcFinanceQuotaConRel = new ZcFinanceQuotaConRel();
- //合同id
- zcFinanceQuotaConRel.setZfqcrContractId(zfcId);
- //授信id
- zcFinanceQuotaConRel.setZfqcrCreditId(zfpcrId);
- iZcFinanceQuotaConRelService.createZcFinanceQuotaConRel(zcFinanceQuotaConRel);
- }
- }
- return AjaxResult.success();
- }
- /**
- * 状态修改
- */
- @PreAuthorize(hasPermi = "credit:line:update")
- @Log(title = "授信管理", businessType = BusinessType.UPDATE)
- @Transactional(rollbackFor = Exception.class)
- @PutMapping("/changeStatus")
- public AjaxResult changeStatus(@RequestBody Map<String, String> map) throws Exception
- {
- //授信id
- String zfpcrId = map.get("zfpcrId");
- //已使用金额
- String zfiAmount = map.get("zfiAmount");
- //授信状态
- String zfpcrStatus = map.get("zfpcrStatus");
- ZcFinanceProComRel proComRel = iZcFinanceProComRelService.getById(zfpcrId);
- //到期时间
- String zfpcrEndDate = proComRel.getZfpcrEndDate();
- //开始日期
- String zfpcrStartDate = proComRel.getZfpcrStartDate();
- ZcFinanceProComRel zcFinanceProComRel = new ZcFinanceProComRel();
- //授信id
- zcFinanceProComRel.setZfpcrId(zfpcrId);
- //判断状态(如果是冻结操作判断是否符合冻结条件
- if ("00".equals(zfpcrStatus)) {
- if ("0.00".equals(zfiAmount)) {
- zcFinanceProComRel.setZfpcrStatus("01");
- iZcFinanceProComRelService.updateZcFinanceProComRel(zcFinanceProComRel);
- }else {
- return AjaxResult.error("此授信正在使用无法冻结");
- }
- }else {
- if (CommonUtil.isNotEmpty(zfpcrEndDate) && CommonUtil.isNotEmpty(zfpcrStartDate)){
- Date EndDate = DateUtils.parseDate(zfpcrEndDate,"yyyy-MM-dd");
- zfpcrEndDate = DateUtils.parseDateToStr("yyyyMMdd",EndDate);
- //当前时间
- String currentDate = DateUtils.dateTimeNow("yyyyMMdd");
- int result = CommonUtil.compare(zfpcrEndDate,currentDate);
- Date beginDate = DateUtils.parseDate(zfpcrStartDate,"yyyy-MM-dd");
- zfpcrStartDate = DateUtils.parseDateToStr("yyyyMMdd",beginDate);
- //当前日期和开始日期比较
- int ending = CommonUtil.compare(zfpcrStartDate,currentDate);
- //小于开始日期或者大于结束日期
- if (ending == 1 || result == -1 ){
- return AjaxResult.error("请先修改授信的有效期范围,只有在有效期范围内才可以解冻");
- }
- }
- zcFinanceProComRel.setZfpcrStatus("00");
- iZcFinanceProComRelService.updateZcFinanceProComRel(zcFinanceProComRel);
- }
- return AjaxResult.success();
- }
- public static void main(String args[]){
- //到期时间
- String zfpcrEndDate = "2021-11-02";
- Date EndDate = DateUtils.dateTime("yyyy-MM-dd",zfpcrEndDate);
- zfpcrEndDate = DateUtils.parseDateToStr("yyyyMMdd",EndDate);
- //当前时间
- String currentDate = DateUtils.dateTimeNow("yyyyMMdd");
- int a = CommonUtil.compare(zfpcrEndDate,currentDate);
- System.out.println(a);
- }
- /**
- * 文件下载
- * @param pfiFileUrl 文件url
- * @param resp
- * @throws MalformedURLException
- */
- @PostMapping("/jpgAuthorization")
- public void jpgAuthorization(@RequestParam(required=false) String pfiFileUrl, HttpServletResponse resp) throws MalformedURLException {
- // 下载网络文件
- int bytesum = 0;
- int byteread = 0;
- URL url = new URL(pfiFileUrl);
- try {
- URLConnection conn = url.openConnection();
- InputStream fis = conn.getInputStream();
- //1、得到文件的绝对路径,并且通过该路径得到一个字节输入流
- //2、创建字节输出流
- ServletOutputStream sos = resp.getOutputStream();
- //4、设置文件编码
- String filename = URLEncoder.encode("file.png", "UTF-8");//编码为UTF-8
- //5、告知客户端(浏览器)要下载文件
- resp.setHeader("content-disposition", "attachment;filename="+filename);
- resp.setHeader("content-type", "image/png/pdf/doc/docx");//文件类型
- //6、输出
- byte[] b = new byte[1024];
- int len = 0;
- while((len=fis.read(b)) != -1){
- sos.write(b, 0, len);
- }
- sos.close();
- fis.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
|