|
@@ -218,183 +218,193 @@ public class FinanceRecordController extends BaseController {
|
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody Map<String,Object> map)throws Exception
|
|
|
{
|
|
|
- //获取此操作员
|
|
|
- LoginUser userInfo = tokenService.getLoginUser();
|
|
|
- SysUser user = userInfo.getSysUser();
|
|
|
- String userId = user.getUserId() + "";
|
|
|
- String companyId = user.getCompanyId();
|
|
|
- //查询当前用户是否是经办人
|
|
|
- LambdaQueryWrapper<SysUserCompanyRel> companyRelWrapper = new LambdaQueryWrapper<>();
|
|
|
- companyRelWrapper.eq(SysUserCompanyRel::getSucrUserId,userId);
|
|
|
- companyRelWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
- companyRelWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
- List<SysUserCompanyRel> list = iSysUserCompanyRelService.findSysUserCompanyRels(companyRelWrapper);
|
|
|
- if (list.size() == 0) {
|
|
|
- return AjaxResult.error("此操作需经办人权限,请确认您是否是经办人");
|
|
|
- }
|
|
|
- //融信id
|
|
|
- String zfrFinanceId = CommonUtil.objToString(map.get("zfrFinanceId"));
|
|
|
- //获取融信信息
|
|
|
- ZcFinanceInf financeInf = iZcFinanceInfService.getById(zfrFinanceId);
|
|
|
- if(financeInf == null){
|
|
|
- throw new Exception("获取融信信息失败");
|
|
|
- }
|
|
|
- //获取接收方
|
|
|
- String zfiSupplierId = financeInf.getZfiSupplierId();
|
|
|
- //授信id
|
|
|
- String zfiCoreQuotaId = financeInf.getZfiCoreQuotaId();
|
|
|
- //查询授信信息
|
|
|
- ZcFinanceProComRel zcFinanceProComRel = iZcFinanceProComRelService.getById(zfiCoreQuotaId);
|
|
|
- //是否收取手续费(0:不收取, 1收取)
|
|
|
- String zfpcrCharge = zcFinanceProComRel.getZfpcrCharge();
|
|
|
- //放入map中
|
|
|
- map.put("zfiSupplierId",zfiSupplierId);
|
|
|
- //融资金额
|
|
|
- String zfrAmount = CommonUtil.objToString(map.get("zfrAmount"));
|
|
|
- map.put("zfrAmountCN", com.keao.tianhu.core.util.AmtUtil.convert(zfrAmount));
|
|
|
- //融资收款账号
|
|
|
- String zfrCollectionAccount = CommonUtil.objToString(map.get("zfrCollectionAccount"));
|
|
|
- //融资利率
|
|
|
- String zfrRate = CommonUtil.objToString(map.get("zfrRate"));
|
|
|
- String zfpcrChargeRate = CommonUtil.objToString(map.get("zfpcrChargeRate"));
|
|
|
- //融资放款方式(0:平台电子记账簿 1:供应商指定账户 2:供应商线下面签)
|
|
|
- String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
|
|
|
- //融资产品
|
|
|
- String zfiProductId = CommonUtil.objToString(map.get("zfiProductId"));
|
|
|
- //承诺还款时间
|
|
|
- String zfrRepaymentDate = CommonUtil.objToString(map.get("zfrRepaymentDate"));
|
|
|
- //获取创建时间
|
|
|
- Date createTime = DateUtils.getNowDate();
|
|
|
- //获取当前时间
|
|
|
- String currentTime = DateUtils.parseDateToStr("yyyyMMddHHmmss",createTime);
|
|
|
- if (CommonUtil.isEmpty(zfrFinanceId)) {
|
|
|
- return AjaxResult.error("融信编号不能为空");
|
|
|
- }
|
|
|
- if (CommonUtil.isEmpty(zfrAmount)){
|
|
|
- return AjaxResult.error("融资金额不能为空");
|
|
|
- }
|
|
|
- //融资编号
|
|
|
- String zfrNumber = "MB";
|
|
|
- //查询融资产品编号
|
|
|
- ZcFinanceProduct zcFinanceProduct = iZcFinanceProductService.getById(zfiProductId);
|
|
|
- //融资产品编号
|
|
|
- String zfpNumber = zcFinanceProduct.getZfpNumber();
|
|
|
- zfpNumber = StringUtils.substring(zfpNumber,0,2);
|
|
|
- zfrNumber += zfpNumber;
|
|
|
- zfrNumber += currentTime;
|
|
|
- //融资放款方式为:平台电子记账簿=>融资收款账号为资方电子账户,供应商指定账户=>融资收款账号为必输,供应商线下面签=>融资收款账号为非必输
|
|
|
- Pattern pattern = Pattern.compile(REGEX);
|
|
|
- if ("1".equals(zfpcrLoanType)){
|
|
|
- if (CommonUtil.isEmpty(zfrCollectionAccount)){
|
|
|
- return AjaxResult.error("融资收款账号不能为空");
|
|
|
- }else {
|
|
|
- if(!pattern.matcher(zfrCollectionAccount).matches()) {
|
|
|
- return AjaxResult.error("请输入正确的融资收款账号");
|
|
|
+ //获取融资编号
|
|
|
+ String recordId = CommonUtil.objToString(map.get("zfrId"));
|
|
|
+ //融资编号为空
|
|
|
+ if(CommonUtil.isEmpty(recordId)){
|
|
|
+ //获取此操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ String userId = user.getUserId() + "";
|
|
|
+ String companyId = user.getCompanyId();
|
|
|
+ //查询当前用户是否是经办人
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> companyRelWrapper = new LambdaQueryWrapper<>();
|
|
|
+ companyRelWrapper.eq(SysUserCompanyRel::getSucrUserId,userId);
|
|
|
+ companyRelWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
+ companyRelWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
+ List<SysUserCompanyRel> list = iSysUserCompanyRelService.findSysUserCompanyRels(companyRelWrapper);
|
|
|
+ if (list.size() == 0) {
|
|
|
+ return AjaxResult.error("此操作需经办人权限,请确认您是否是经办人");
|
|
|
+ }
|
|
|
+ //融信id
|
|
|
+ String zfrFinanceId = CommonUtil.objToString(map.get("zfrFinanceId"));
|
|
|
+ //获取融信信息
|
|
|
+ ZcFinanceInf financeInf = iZcFinanceInfService.getById(zfrFinanceId);
|
|
|
+ if(financeInf == null){
|
|
|
+ throw new Exception("获取融信信息失败");
|
|
|
+ }
|
|
|
+ //获取接收方
|
|
|
+ String zfiSupplierId = financeInf.getZfiSupplierId();
|
|
|
+ //授信id
|
|
|
+ String zfiCoreQuotaId = financeInf.getZfiCoreQuotaId();
|
|
|
+ //查询授信信息
|
|
|
+ ZcFinanceProComRel zcFinanceProComRel = iZcFinanceProComRelService.getById(zfiCoreQuotaId);
|
|
|
+ //是否收取手续费(0:不收取, 1收取)
|
|
|
+ String zfpcrCharge = zcFinanceProComRel.getZfpcrCharge();
|
|
|
+ //放入map中
|
|
|
+ map.put("zfiSupplierId",zfiSupplierId);
|
|
|
+ //融资金额
|
|
|
+ String zfrAmount = CommonUtil.objToString(map.get("zfrAmount"));
|
|
|
+ map.put("zfrAmountCN", com.keao.tianhu.core.util.AmtUtil.convert(com.keao.tianhu.core.util.AmtUtil.moneyFormat(zfrAmount)));
|
|
|
+ //融资收款账号
|
|
|
+ String zfrCollectionAccount = CommonUtil.objToString(map.get("zfrCollectionAccount"));
|
|
|
+ //融资利率
|
|
|
+ String zfrRate = CommonUtil.objToString(map.get("zfrRate"));
|
|
|
+ String zfpcrChargeRate = CommonUtil.objToString(map.get("zfpcrChargeRate"));
|
|
|
+ //融资放款方式(0:平台电子记账簿 1:供应商指定账户 2:供应商线下面签)
|
|
|
+ String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
|
|
|
+ //融资产品
|
|
|
+ String zfiProductId = CommonUtil.objToString(map.get("zfiProductId"));
|
|
|
+ //承诺还款时间
|
|
|
+ String zfrRepaymentDate = CommonUtil.objToString(map.get("zfrRepaymentDate"));
|
|
|
+ //获取创建时间
|
|
|
+ Date createTime = DateUtils.getNowDate();
|
|
|
+ //获取当前时间
|
|
|
+ String currentTime = DateUtils.parseDateToStr("yyyyMMddHHmmss",createTime);
|
|
|
+ if (CommonUtil.isEmpty(zfrFinanceId)) {
|
|
|
+ return AjaxResult.error("融信编号不能为空");
|
|
|
+ }
|
|
|
+ if (CommonUtil.isEmpty(zfrAmount)){
|
|
|
+ return AjaxResult.error("融资金额不能为空");
|
|
|
+ }
|
|
|
+ //融资编号
|
|
|
+ String zfrNumber = "MB";
|
|
|
+ //查询融资产品编号
|
|
|
+ ZcFinanceProduct zcFinanceProduct = iZcFinanceProductService.getById(zfiProductId);
|
|
|
+ //融资产品编号
|
|
|
+ String zfpNumber = zcFinanceProduct.getZfpNumber();
|
|
|
+ zfpNumber = StringUtils.substring(zfpNumber,0,2);
|
|
|
+ zfrNumber += zfpNumber;
|
|
|
+ zfrNumber += currentTime;
|
|
|
+ //融资放款方式为:平台电子记账簿=>融资收款账号为资方电子账户,供应商指定账户=>融资收款账号为必输,供应商线下面签=>融资收款账号为非必输
|
|
|
+ Pattern pattern = Pattern.compile(REGEX);
|
|
|
+ if ("1".equals(zfpcrLoanType)){
|
|
|
+ if (CommonUtil.isEmpty(zfrCollectionAccount)){
|
|
|
+ return AjaxResult.error("融资收款账号不能为空");
|
|
|
+ }else {
|
|
|
+ if(!pattern.matcher(zfrCollectionAccount).matches()) {
|
|
|
+ return AjaxResult.error("请输入正确的融资收款账号");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else if ("2".equals(zfpcrLoanType)){
|
|
|
- if(CommonUtil.isNotEmpty(zfrCollectionAccount)) {
|
|
|
- if(!pattern.matcher(zfrCollectionAccount).matches()) {
|
|
|
- return AjaxResult.error("请输入正确的融资收款账号");
|
|
|
+ else if ("2".equals(zfpcrLoanType)){
|
|
|
+ if(CommonUtil.isNotEmpty(zfrCollectionAccount)) {
|
|
|
+ if(!pattern.matcher(zfrCollectionAccount).matches()) {
|
|
|
+ return AjaxResult.error("请输入正确的融资收款账号");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- /*---------------新增融资表----------*/
|
|
|
- ZcFinanceRecord zcFinanceRecord = new ZcFinanceRecord();
|
|
|
- //主键
|
|
|
- String zfrId = IdUtils.fastSimpleUUID();
|
|
|
- zcFinanceRecord.setZfrId(zfrId);
|
|
|
- //融资编号
|
|
|
- zcFinanceRecord.setZfrNumber(zfrNumber);
|
|
|
- //融信id
|
|
|
- zcFinanceRecord.setZfrFinanceId(zfrFinanceId);
|
|
|
- //融资金额
|
|
|
- zcFinanceRecord.setZfrAmount(zfrAmount);
|
|
|
- //融资利率
|
|
|
- zcFinanceRecord.setZfrRate(zfrRate);
|
|
|
- //融资收款账号
|
|
|
- zcFinanceRecord.setZfrCollectionAccount(zfrCollectionAccount);
|
|
|
- //承诺还款时间
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
|
|
|
- zcFinanceRecord.setZfrRepaymentDate(simpleDateFormat.parse(zfrRepaymentDate));
|
|
|
- //融资申请日期
|
|
|
- zcFinanceRecord.setZfrApplyDate(createTime);
|
|
|
- //TODO 经办人
|
|
|
- zcFinanceRecord.setZfrHandler(userId);
|
|
|
- //审批状态
|
|
|
- //TODO
|
|
|
- //融资状态
|
|
|
- zcFinanceRecord.setZfrStatus("04");
|
|
|
- //审批状态(00:审核中 01:审批通过, 02:审批拒绝, 03:暂存)
|
|
|
+ /*---------------新增融资表----------*/
|
|
|
+ ZcFinanceRecord zcFinanceRecord = new ZcFinanceRecord();
|
|
|
+ //主键
|
|
|
+ String zfrId = IdUtils.fastSimpleUUID();
|
|
|
+ zcFinanceRecord.setZfrId(zfrId);
|
|
|
+ //融资编号
|
|
|
+ zcFinanceRecord.setZfrNumber(zfrNumber);
|
|
|
+ //融信id
|
|
|
+ zcFinanceRecord.setZfrFinanceId(zfrFinanceId);
|
|
|
+ //融资金额
|
|
|
+ zcFinanceRecord.setZfrAmount(zfrAmount);
|
|
|
+ //融资利率
|
|
|
+ zcFinanceRecord.setZfrRate(zfrRate);
|
|
|
+ //融资收款账号
|
|
|
+ zcFinanceRecord.setZfrCollectionAccount(zfrCollectionAccount);
|
|
|
+ //承诺还款时间
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");//注意月份是MM
|
|
|
+ zcFinanceRecord.setZfrRepaymentDate(simpleDateFormat.parse(zfrRepaymentDate));
|
|
|
+ //融资申请日期
|
|
|
+ zcFinanceRecord.setZfrApplyDate(createTime);
|
|
|
+ //TODO 经办人
|
|
|
+ zcFinanceRecord.setZfrHandler(userId);
|
|
|
+ //审批状态
|
|
|
+ //TODO
|
|
|
+ //融资状态
|
|
|
+ zcFinanceRecord.setZfrStatus("04");
|
|
|
+ //审批状态(00:审核中 01:审批通过, 02:审批拒绝, 03:暂存)
|
|
|
// zcFinanceRecord.setZfrApproveStt("03");
|
|
|
- //创建者
|
|
|
- zcFinanceRecord.setCreateBy(userId);
|
|
|
- //创建时间
|
|
|
- zcFinanceRecord.setCreateTime(createTime);
|
|
|
- /*-------------新增费用表--------*/
|
|
|
- //查询此融资是否已存在
|
|
|
+ //创建者
|
|
|
+ zcFinanceRecord.setCreateBy(userId);
|
|
|
+ //创建时间
|
|
|
+ zcFinanceRecord.setCreateTime(createTime);
|
|
|
+ /*-------------新增费用表--------*/
|
|
|
+ //查询此融资是否已存在
|
|
|
// LambdaQueryWrapper<ZcChargeInf> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
// queryWrapper.eq(ZcChargeInf::getZciFinanceId,zfrFinanceId);
|
|
|
// int count = iZcChargeInfService.count(queryWrapper);
|
|
|
- //平台收取手续费则添加费用信息
|
|
|
- if ("1".equals(zfpcrCharge)) {
|
|
|
- ZcChargeInf zcChargeInf = new ZcChargeInf();
|
|
|
- //主键
|
|
|
- zcChargeInf.setZciId(IdUtils.fastSimpleUUID());
|
|
|
- //融资id
|
|
|
- zcChargeInf.setZciFinanceId(zfrId);
|
|
|
- //费用状态 待缴费
|
|
|
- zcChargeInf.setZciStatus("00");
|
|
|
- //发票状态 未开票
|
|
|
- zcChargeInf.setZciInvoiceStatus("0");
|
|
|
- //手续费
|
|
|
- String zciAmount = AmtUtil.divide(zfpcrChargeRate, "100", 4);
|
|
|
- zciAmount = AmtUtil.multiply(zfrAmount, zciAmount, 2);
|
|
|
- zcChargeInf.setZciAmount(zciAmount);
|
|
|
- //创建人
|
|
|
- zcChargeInf.setCreateBy(userId);
|
|
|
- //创建时间
|
|
|
- zcChargeInf.setCreateTime(DateUtils.getNowDate());
|
|
|
- iZcChargeInfService.createZcChargeInf(zcChargeInf);
|
|
|
+ //平台收取手续费则添加费用信息
|
|
|
+ if ("1".equals(zfpcrCharge)) {
|
|
|
+ ZcChargeInf zcChargeInf = new ZcChargeInf();
|
|
|
+ //主键
|
|
|
+ zcChargeInf.setZciId(IdUtils.fastSimpleUUID());
|
|
|
+ //融资id
|
|
|
+ zcChargeInf.setZciFinanceId(zfrId);
|
|
|
+ //费用状态 待缴费
|
|
|
+ zcChargeInf.setZciStatus("00");
|
|
|
+ //发票状态 未开票
|
|
|
+ zcChargeInf.setZciInvoiceStatus("0");
|
|
|
+ //手续费
|
|
|
+ String zciAmount = AmtUtil.divide(zfpcrChargeRate, "100", 4);
|
|
|
+ zciAmount = AmtUtil.multiply(zfrAmount, zciAmount, 2);
|
|
|
+ zcChargeInf.setZciAmount(zciAmount);
|
|
|
+ //创建人
|
|
|
+ zcChargeInf.setCreateBy(userId);
|
|
|
+ //创建时间
|
|
|
+ zcChargeInf.setCreateTime(DateUtils.getNowDate());
|
|
|
+ iZcChargeInfService.createZcChargeInf(zcChargeInf);
|
|
|
+ }
|
|
|
+ /*----------修改融信表状态---------------*/
|
|
|
+ ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
+ //融信id
|
|
|
+ zcFinanceInf.setZfiId(zfrFinanceId);
|
|
|
+ //融信状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回)
|
|
|
+ zcFinanceInf.setZfiStatus("04");
|
|
|
+ //修改人
|
|
|
+ zcFinanceInf.setUpdateBy(userId);
|
|
|
+ //修改时间
|
|
|
+ zcFinanceInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ iZcFinanceInfService.updateZcFinanceInf(zcFinanceInf);
|
|
|
+ iZcFinanceRecordService.createZcFinanceRecord(zcFinanceRecord);
|
|
|
+ //调用融资审批
|
|
|
+ //融信id
|
|
|
+ map.put("zfrId",zfrId);
|
|
|
+ //企业id
|
|
|
+ map.put("companyId",companyId);
|
|
|
+ //融资编号
|
|
|
+ map.put("zfrNumber",zfrNumber);
|
|
|
+ approvalService.addFinancingApproval(map);
|
|
|
+ //待办改为已办
|
|
|
+ LambdaQueryWrapper<SysNotice> noticeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //待办
|
|
|
+ noticeLambdaQueryWrapper.eq(SysNotice::getStatus,"0");
|
|
|
+ //融信编号
|
|
|
+ noticeLambdaQueryWrapper.eq(SysNotice::getTableId,zfrFinanceId);
|
|
|
+ //待融资
|
|
|
+ noticeLambdaQueryWrapper.eq(SysNotice::getWorkType,"05");
|
|
|
+ //待办
|
|
|
+ noticeLambdaQueryWrapper.eq(SysNotice::getType,"00");
|
|
|
+ SysNotice notice = new SysNotice();
|
|
|
+ //已办
|
|
|
+ notice.setStatus("1");
|
|
|
+ sysNoticeService.update(notice,noticeLambdaQueryWrapper);
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("zfrId",zfrId);
|
|
|
+ return AjaxResult.success(result);
|
|
|
+ }else{
|
|
|
+ Map result = new HashMap();
|
|
|
+ result.put("zfrId",recordId);
|
|
|
+ return AjaxResult.success(result);
|
|
|
}
|
|
|
- /*----------修改融信表状态---------------*/
|
|
|
- ZcFinanceInf zcFinanceInf = new ZcFinanceInf();
|
|
|
- //融信id
|
|
|
- zcFinanceInf.setZfiId(zfrFinanceId);
|
|
|
- //融信状态(00:待确权 01:待签收 02:已生效 03:已失效 04:融资中 05:已融资 06:平台退回)
|
|
|
- zcFinanceInf.setZfiStatus("04");
|
|
|
- //修改人
|
|
|
- zcFinanceInf.setUpdateBy(userId);
|
|
|
- //修改时间
|
|
|
- zcFinanceInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
- iZcFinanceInfService.updateZcFinanceInf(zcFinanceInf);
|
|
|
- iZcFinanceRecordService.createZcFinanceRecord(zcFinanceRecord);
|
|
|
- //调用融资审批
|
|
|
- //融信id
|
|
|
- map.put("zfrId",zfrId);
|
|
|
- //企业id
|
|
|
- map.put("companyId",companyId);
|
|
|
- //融资编号
|
|
|
- map.put("zfrNumber",zfrNumber);
|
|
|
- approvalService.addFinancingApproval(map);
|
|
|
- //待办改为已办
|
|
|
- LambdaQueryWrapper<SysNotice> noticeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- //待办
|
|
|
- noticeLambdaQueryWrapper.eq(SysNotice::getStatus,"0");
|
|
|
- //融信编号
|
|
|
- noticeLambdaQueryWrapper.eq(SysNotice::getTableId,zfrFinanceId);
|
|
|
- //待融资
|
|
|
- noticeLambdaQueryWrapper.eq(SysNotice::getWorkType,"05");
|
|
|
- //待办
|
|
|
- noticeLambdaQueryWrapper.eq(SysNotice::getType,"00");
|
|
|
- SysNotice notice = new SysNotice();
|
|
|
- //已办
|
|
|
- notice.setStatus("1");
|
|
|
- sysNoticeService.update(notice,noticeLambdaQueryWrapper);
|
|
|
- Map result = new HashMap();
|
|
|
- result.put("zfrId",zfrId);
|
|
|
- return AjaxResult.success(result);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|