|
@@ -1,6 +1,7 @@
|
|
package com.inkasso.factoring.financingmanagement.service.impl;
|
|
package com.inkasso.factoring.financingmanagement.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -20,6 +21,7 @@ import com.inkasso.factoring.creditmanagement.entity.Enterprise;
|
|
import com.inkasso.factoring.creditmanagement.entity.ProjectInformation;
|
|
import com.inkasso.factoring.creditmanagement.entity.ProjectInformation;
|
|
import com.inkasso.factoring.creditmanagement.service.IEnterpriseService;
|
|
import com.inkasso.factoring.creditmanagement.service.IEnterpriseService;
|
|
import com.inkasso.factoring.creditmanagement.service.IProjectInformationService;
|
|
import com.inkasso.factoring.creditmanagement.service.IProjectInformationService;
|
|
|
|
+import com.inkasso.factoring.dict.entity.Dictionary;
|
|
import com.inkasso.factoring.dict.service.DictionaryService;
|
|
import com.inkasso.factoring.dict.service.DictionaryService;
|
|
import com.inkasso.factoring.file.entity.FileStorageDO;
|
|
import com.inkasso.factoring.file.entity.FileStorageDO;
|
|
import com.inkasso.factoring.file.enums.FileTypeEnum;
|
|
import com.inkasso.factoring.file.enums.FileTypeEnum;
|
|
@@ -57,6 +59,7 @@ import org.springframework.web.client.RestTemplate;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -108,6 +111,10 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
private String financingApplyUrl;
|
|
private String financingApplyUrl;
|
|
@Value("${sop.viewLatestPlanUrl}")
|
|
@Value("${sop.viewLatestPlanUrl}")
|
|
private String viewLatestPlanUrl;
|
|
private String viewLatestPlanUrl;
|
|
|
|
+ @Value("${sop.judgeCustomerGradeUrl}")
|
|
|
|
+ private String judgeCustomerGradeUrl;
|
|
|
|
+ @Value("${sop.judgeCustomerExemptionMattersUrl}")
|
|
|
|
+ private String judgeCustomerExemptionMattersUrl;
|
|
@Autowired
|
|
@Autowired
|
|
private FinancingApplyMapper financingApplyMapper;
|
|
private FinancingApplyMapper financingApplyMapper;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -335,10 +342,16 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
|
|
|
|
List<CFinancingGoodsInfo> financingGoodsInfoList = financingApplyVo.getFinancingGoodsInfoList();
|
|
List<CFinancingGoodsInfo> financingGoodsInfoList = financingApplyVo.getFinancingGoodsInfoList();
|
|
if (visible) {
|
|
if (visible) {
|
|
- //检验验收单货物是否已经融资
|
|
|
|
|
|
+ //校验验收单货物是否已经融资
|
|
checkAcceptanceGoods(financingGoodsInfoList);
|
|
checkAcceptanceGoods(financingGoodsInfoList);
|
|
- //校验项目授信决议是否通过
|
|
|
|
- //123
|
|
|
|
|
|
+ //校验供应商五级分类是否正常用户
|
|
|
|
+ checkEnterpriseGrade(financingBasicInfo.getMainEnterpriseId());
|
|
|
|
+ //校验供应商名下是否存在豁免事项跟进未完成的数据
|
|
|
|
+ checkEnterpriseExemptionMatters(financingBasicInfo.getMainEnterpriseId());
|
|
|
|
+ //校验是否存在超过预计结算日期且未结算的验收单
|
|
|
|
+ checkAcceptance(financingBasicInfo.getBusinessNumber());
|
|
|
|
+ //校验是否存在已逾期的融资申请
|
|
|
|
+ checkOverdue(financingBasicInfo.getBusinessNumber());
|
|
//状态为处理中
|
|
//状态为处理中
|
|
financingBasicInfo.setFinancingStatus(ProjectInitiationStatusEnum.PROCESSING.getCode());
|
|
financingBasicInfo.setFinancingStatus(ProjectInitiationStatusEnum.PROCESSING.getCode());
|
|
//当前阶段为额度支用
|
|
//当前阶段为额度支用
|
|
@@ -407,7 +420,6 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
financingBasicInfo.setRiskManagerId(userDO.getRiskManager());
|
|
financingBasicInfo.setRiskManagerId(userDO.getRiskManager());
|
|
}
|
|
}
|
|
financingBasicInfo.setFinancingHisInfoId(financingHisInfo.getId());
|
|
financingBasicInfo.setFinancingHisInfoId(financingHisInfo.getId());
|
|
- //todo 添加应收账款净额
|
|
|
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(financingApplyUrl, financingBasicInfo, String.class);
|
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(financingApplyUrl, financingBasicInfo, String.class);
|
|
ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
|
|
ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
|
|
if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || !responseJson.isSuccess()) {
|
|
if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || !responseJson.isSuccess()) {
|
|
@@ -416,6 +428,92 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 校验是否存在已逾期的融资申请
|
|
|
|
+ *
|
|
|
|
+ * @param businessNumber
|
|
|
|
+ */
|
|
|
|
+ private void checkOverdue(String businessNumber) {
|
|
|
|
+ List<CFinancingBasicInfo> financingBasicInfoList = financingBasicInfoService.list(new QueryWrapper<CFinancingBasicInfo>().eq("business_number", businessNumber));
|
|
|
|
+ if (CollectionUtil.isNotEmpty(financingBasicInfoList)) {
|
|
|
|
+ for (CFinancingBasicInfo financingBasicInfo : financingBasicInfoList) {
|
|
|
|
+ PaymentCollectionBasic basic = getViewLatestPlan(financingBasicInfo.getId());
|
|
|
|
+ if (basic != null && CollectionUtil.isNotEmpty(basic.getPlanFactoringList())) {
|
|
|
|
+ for (PaymentCollectionPlanFactoring planFactoring : basic.getPlanFactoringList()) {
|
|
|
|
+ if ("pay_coll_collection".equals(planFactoring.getPaymentCollectionType()) && planFactoring.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
+ Dictionary statusDict = planFactoring.getStatus();
|
|
|
|
+ if (statusDict != null && "pay_coll_plan_overdue".equals(statusDict.getCode())) {
|
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "存在已逾期的融资申请,请结清后操作");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验是否存在超过预计结算日期且未结算的验收单
|
|
|
|
+ *
|
|
|
|
+ * @param businessNumber
|
|
|
|
+ */
|
|
|
|
+ private void checkAcceptance(String businessNumber) {
|
|
|
|
+ List<CAcceptanceBasicInfo> acceptanceBasicInfoList = acceptanceBasicInfoService.list(new QueryWrapper<CAcceptanceBasicInfo>().eq("business_number", businessNumber));
|
|
|
|
+ if (CollectionUtil.isNotEmpty(acceptanceBasicInfoList)) {
|
|
|
|
+ for (CAcceptanceBasicInfo acceptanceBasicInfo : acceptanceBasicInfoList) {
|
|
|
|
+ if (acceptanceBasicInfo.getSettlement() != null && !acceptanceBasicInfo.getSettlement()) {
|
|
|
|
+ //未结算
|
|
|
|
+ if (acceptanceBasicInfo.getExpectedSettlementDate() != null
|
|
|
|
+ && DateUtil.beginOfDay(new Date()).compareTo(acceptanceBasicInfo.getExpectedSettlementDate()) > 0) {
|
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "存在到期未结算的验收单,请联系业务经理");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验供应商五级分类是否正常
|
|
|
|
+ *
|
|
|
|
+ * @param mainEnterpriseId
|
|
|
|
+ */
|
|
|
|
+ private void checkEnterpriseGrade(Long mainEnterpriseId) {
|
|
|
|
+ Enterprise enterprise = enterpriseService.getById(mainEnterpriseId);
|
|
|
|
+ if (enterprise != null && enterprise.getSocialCreditCode() != null) {
|
|
|
|
+ JSONObject jsonObject = restTemplate.getForObject(judgeCustomerGradeUrl + "?socialCreditCode=" + enterprise.getSocialCreditCode(), JSONObject.class);
|
|
|
|
+ Integer code = jsonObject.getInt("code");
|
|
|
|
+ Boolean success = jsonObject.getBool("success");
|
|
|
|
+ if (code != HttpStatus.OK.value() || !success) {
|
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "获取客户五级分类失败:" + jsonObject.getStr("msg"));
|
|
|
|
+ }
|
|
|
|
+ Boolean bool = jsonObject.getBool("data");
|
|
|
|
+ if (!bool) {
|
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "五级分类异常,请联系业务经理");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验供应商下是否存在豁免事项跟进未完成的数据
|
|
|
|
+ *
|
|
|
|
+ * @param mainEnterpriseId
|
|
|
|
+ */
|
|
|
|
+ private void checkEnterpriseExemptionMatters(Long mainEnterpriseId) {
|
|
|
|
+ Enterprise enterprise = enterpriseService.getById(mainEnterpriseId);
|
|
|
|
+ if (enterprise != null && enterprise.getSocialCreditCode() != null) {
|
|
|
|
+ JSONObject jsonObject = restTemplate.getForObject(judgeCustomerExemptionMattersUrl + "?socialCreditCode=" + enterprise.getSocialCreditCode(), JSONObject.class);
|
|
|
|
+ Integer code = jsonObject.getInt("code");
|
|
|
|
+ Boolean success = jsonObject.getBool("success");
|
|
|
|
+ if (code != HttpStatus.OK.value() || !success) {
|
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "获取客户豁免事项待办失败:" + jsonObject.getStr("msg"));
|
|
|
|
+ }
|
|
|
|
+ Boolean bool = jsonObject.getBool("data");
|
|
|
|
+ if (!bool) {
|
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "存在豁免事项待办,请联系业务经理");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 校验验收单货物是否已融资
|
|
* 校验验收单货物是否已融资
|
|
*
|
|
*
|