|
@@ -24,12 +24,13 @@ import com.sunxung.factoring.entity.financing.apply.CFinancingBasicInfo;
|
|
|
import com.sunxung.factoring.entity.financing.apply.CFinancingGoodsInfo;
|
|
|
import com.sunxung.factoring.entity.financing.review.*;
|
|
|
import com.sunxung.factoring.entity.project.ProjectInformation;
|
|
|
+import com.sunxung.factoring.entity.smb.FinancingFromInvestors;
|
|
|
+import com.sunxung.factoring.entity.smb.FinancingFromInvestorsHistory;
|
|
|
import com.sunxung.factoring.entity.smb.FinancingFromInvestorsNotice;
|
|
|
import com.sunxung.factoring.entity.smb.FinancingFromInvestorsPerson;
|
|
|
import com.sunxung.factoring.entity.supplier.SupplierInfo;
|
|
|
import com.sunxung.factoring.entity.sys.Dictionary;
|
|
|
import com.sunxung.factoring.entity.sys.FileStorage;
|
|
|
-import com.sunxung.factoring.entity.sys.FileStorageDO;
|
|
|
import com.sunxung.factoring.mapper.financing.review.ReviewQuotaDisburseMapper;
|
|
|
import com.sunxung.factoring.service.creditresolution.ICreditResolutionService;
|
|
|
import com.sunxung.factoring.service.entprise.IEnterpriseService;
|
|
@@ -47,7 +48,6 @@ import com.sunxung.factoring.service.smbApi.api.SMBApiService;
|
|
|
import com.sunxung.factoring.service.smbApi.resp.RepayPlanTrialResp;
|
|
|
import com.sunxung.factoring.service.supplier.ISupplierInfoService;
|
|
|
import com.sunxung.factoring.service.sys.DictionaryService;
|
|
|
-import com.sunxung.factoring.service.sys.FileService;
|
|
|
import com.sunxung.factoring.service.sys.FileStorageService;
|
|
|
import com.sunxung.factoring.service.sys.SerialNumberGenerator;
|
|
|
import com.sunxung.factoring.service.sys.flowable.FlowableService;
|
|
@@ -189,8 +189,6 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
private IFinancingFromInvestorsPersonService financingFromInvestorsPersonService;
|
|
|
@Autowired
|
|
|
private SMBApiService smbApiService;
|
|
|
- @Autowired
|
|
|
- private FileService fileService;
|
|
|
|
|
|
@Override
|
|
|
public List<ReviewIncomeExpenditurePlan> generateIncomeExpenditurePlan(ReviewFinancingInfo reviewFinancingInfo) {
|
|
@@ -204,14 +202,11 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
|
|
|
//回款方式为前收息或者后收息、20240626 add 苏商银行逻辑
|
|
|
List<ReviewIncomeExpenditurePlan> planList = new ArrayList<>();
|
|
|
-
|
|
|
- preOrAfterInterest(reviewFinancingInfo, planList, dict);
|
|
|
-
|
|
|
-// if (ConstantUtil.JIANGSU_SUSHANG_BANK.equals(reviewFinancingInfo.getInstitutionName())) {
|
|
|
-// generateSMBPlan(reviewFinancingInfo, planList);
|
|
|
-// } else {
|
|
|
-// preOrAfterInterest(reviewFinancingInfo, planList, dict);
|
|
|
-// }
|
|
|
+ if (ConstantUtil.JIANGSU_SUSHANG_BANK.equals(reviewFinancingInfo.getInstitutionName())) {
|
|
|
+ generateSMBPlan(reviewFinancingInfo, planList);
|
|
|
+ } else {
|
|
|
+ preOrAfterInterest(reviewFinancingInfo, planList, dict);
|
|
|
+ }
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(planList)) {
|
|
|
planList.sort(Comparator.comparing(ReviewIncomeExpenditurePlan::getIncomeExpenditureDate));
|
|
@@ -373,27 +368,21 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
if (financingBasicInfo != null) {
|
|
|
|
|
|
SupplierInfo supplierInfo = supplierInfoService.getByEnterpriseId(financingBasicInfo.getMainEnterpriseId());
|
|
|
- FinancingFromInvestorsNotice notice = new FinancingFromInvestorsNotice();
|
|
|
- notice.setApprovedInterestRate(new BigDecimal("0.1"));
|
|
|
-
|
|
|
- return notice;
|
|
|
-
|
|
|
-// if (supplierInfo != null) {
|
|
|
-// //todo 添加按状态筛选
|
|
|
-// FinancingFromInvestors financingFromInvestors = financingFromInvestorsService.lambdaQuery().eq(FinancingFromInvestors::getSupplierInfoId, supplierInfo.getId()).one();
|
|
|
-// if (financingFromInvestors != null) {
|
|
|
-// List<FinancingFromInvestorsHistory> list = financingFromInvestorsHistoryService.lambdaQuery().eq(FinancingFromInvestorsHistory::getFinancingFromInvestorsId, financingFromInvestors.getId())
|
|
|
-// .orderByDesc(FinancingFromInvestorsHistory::getId).list();
|
|
|
-// if (CollectionUtil.isNotEmpty(list)) {
|
|
|
-// FinancingFromInvestorsHistory fromInvestorsHistory = list.get(0);
|
|
|
-// FinancingFromInvestorsNotice notice = financingFromInvestorsNoticeService.lambdaQuery().eq(FinancingFromInvestorsNotice::getFinancingFromInvestorsHistoryId, fromInvestorsHistory.getId()).one();
|
|
|
-// if (notice != null) {
|
|
|
-// //todo 判断notice状态
|
|
|
-// return notice;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if (supplierInfo != null) {
|
|
|
+ FinancingFromInvestors financingFromInvestors = financingFromInvestorsService.lambdaQuery().eq(FinancingFromInvestors::getSupplierInfoId, supplierInfo.getId())
|
|
|
+ .orderByDesc(FinancingFromInvestors::getId).list().get(0);
|
|
|
+ if (financingFromInvestors != null && financingFromInvestors.getCreditStatus().equals("审批通过")) {
|
|
|
+ List<FinancingFromInvestorsHistory> list = financingFromInvestorsHistoryService.lambdaQuery().eq(FinancingFromInvestorsHistory::getFinancingFromInvestorsId, financingFromInvestors.getId())
|
|
|
+ .orderByDesc(FinancingFromInvestorsHistory::getId).list();
|
|
|
+ if (CollectionUtil.isNotEmpty(list)) {
|
|
|
+ FinancingFromInvestorsHistory fromInvestorsHistory = list.get(0);
|
|
|
+ FinancingFromInvestorsNotice notice = financingFromInvestorsNoticeService.lambdaQuery().eq(FinancingFromInvestorsNotice::getFinancingFromInvestorsHistoryId, fromInvestorsHistory.getId()).one();
|
|
|
+ if (notice != null && notice.getApplyStatus().equals("审批通过")) {
|
|
|
+ return notice;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -1883,16 +1872,14 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
if (reviewFinancingInfo.getFinancingInterest() != null && reviewFinancingInfo.getFinancingInterest().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
ReviewIncomeExpenditurePlan plan = new ReviewIncomeExpenditurePlan();
|
|
|
plan.setReceivables(reviewFinancingInfo.getFinancingInterest());
|
|
|
-// if (dict.getCode().equals("paymentMethodForInterestManagementFee_A")) {
|
|
|
-// //如果是前收息
|
|
|
-// plan.setIncomeExpenditureDate(reviewFinancingInfo.getStartingDate());
|
|
|
-// } else if (dict.getCode().equals("paymentMethodForInterestManagementFee_B")
|
|
|
-// || dict.getCode().equals("paymentMethodForInterestManagementFee_C")) {
|
|
|
-// //如果是后收息或者是管理费前收利息后收
|
|
|
-// plan.setIncomeExpenditureDate(endDate);
|
|
|
-// }
|
|
|
- plan.setIncomeExpenditureDate(endDate);
|
|
|
-
|
|
|
+ if (dict.getCode().equals("paymentMethodForInterestManagementFee_A")) {
|
|
|
+ //如果是前收息
|
|
|
+ plan.setIncomeExpenditureDate(reviewFinancingInfo.getStartingDate());
|
|
|
+ } else if (dict.getCode().equals("paymentMethodForInterestManagementFee_B")
|
|
|
+ || dict.getCode().equals("paymentMethodForInterestManagementFee_C")) {
|
|
|
+ //如果是后收息或者是管理费前收利息后收
|
|
|
+ plan.setIncomeExpenditureDate(endDate);
|
|
|
+ }
|
|
|
plan.setIncomeExpenditureType(IncomeExpenditureTypeDict.ChildEnum.INTEREST.getCode());
|
|
|
plan.setFinalCashFlow(reviewFinancingInfo.getFinancingInterest());
|
|
|
//收款主体默认为债权人
|
|
@@ -1904,15 +1891,13 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
if (reviewFinancingInfo.getManagementFeeAmount() != null && reviewFinancingInfo.getManagementFeeAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
ReviewIncomeExpenditurePlan plan = new ReviewIncomeExpenditurePlan();
|
|
|
plan.setReceivables(reviewFinancingInfo.getManagementFeeAmount());
|
|
|
-// if (dict.getCode().equals("paymentMethodForInterestManagementFee_A") || dict.getCode().equals("paymentMethodForInterestManagementFee_C")) {
|
|
|
-// //如果是前收息或者是管理费前收利息后收
|
|
|
-// plan.setIncomeExpenditureDate(reviewFinancingInfo.getStartingDate());
|
|
|
-// } else if (dict.getCode().equals("paymentMethodForInterestManagementFee_B")) {
|
|
|
-// //如果是后收息
|
|
|
-// plan.setIncomeExpenditureDate(endDate);
|
|
|
-// }
|
|
|
- plan.setIncomeExpenditureDate(endDate);
|
|
|
-
|
|
|
+ if (dict.getCode().equals("paymentMethodForInterestManagementFee_A") || dict.getCode().equals("paymentMethodForInterestManagementFee_C")) {
|
|
|
+ //如果是前收息或者是管理费前收利息后收
|
|
|
+ plan.setIncomeExpenditureDate(reviewFinancingInfo.getStartingDate());
|
|
|
+ } else if (dict.getCode().equals("paymentMethodForInterestManagementFee_B")) {
|
|
|
+ //如果是后收息
|
|
|
+ plan.setIncomeExpenditureDate(endDate);
|
|
|
+ }
|
|
|
plan.setIncomeExpenditureType(IncomeExpenditureTypeDict.ChildEnum.MANAGEMENT_FEE.getCode());
|
|
|
plan.setFinalCashFlow(reviewFinancingInfo.getManagementFeeAmount());
|
|
|
//收款主体默认为债权人
|
|
@@ -2073,19 +2058,19 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 调用苏商银行还款试算接口获取还款计划
|
|
|
+ * 调用苏商银行还款计划试算接口获取还款计划
|
|
|
*
|
|
|
* @param reviewFinancingInfo
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
*/
|
|
|
private RepayPlanTrialResp getRepayPlanTrialRespBySmb(ReviewFinancingInfo reviewFinancingInfo, DateTime endDate) {
|
|
|
- //调用苏商银行还款试算接口
|
|
|
+ //调用苏商银行还款计划试算接口
|
|
|
RepayPlanTrial repayPlanTrial = new RepayPlanTrial();
|
|
|
//贷款金额
|
|
|
repayPlanTrial.setLnAmt(reviewFinancingInfo.getFinancingAmount().toString());
|
|
|
//利率值
|
|
|
- BigDecimal financingRate = reviewFinancingInfo.getFinancingRate().multiply(new BigDecimal("100")).setScale(6, RoundingMode.HALF_UP);
|
|
|
+ BigDecimal financingRate = reviewFinancingInfo.getFinancingRate().setScale(6, RoundingMode.HALF_UP);
|
|
|
repayPlanTrial.setActRate(financingRate.toString());
|
|
|
//利率标志-年
|
|
|
repayPlanTrial.setRateFlag("Y");
|
|
@@ -2101,9 +2086,36 @@ public class ReviewQuotaDisburseServiceImpl extends ServiceImpl<ReviewQuotaDisbu
|
|
|
repayPlanTrial.setMatuDate(matuDateStr);
|
|
|
//还款方式
|
|
|
repayPlanTrial.setRepayMtd("2");
|
|
|
- //todo 查询授信完成后客户的openId
|
|
|
- String openId = "";
|
|
|
+ //todo 还款周期
|
|
|
+ repayPlanTrial.setRepayCycl("1MA20");
|
|
|
+ //查询授信完成后客户的openId
|
|
|
+ FinancingFromInvestors financingFromInvestors = getFinancingFromInvestors(reviewFinancingInfo);
|
|
|
+ if (financingFromInvestors == null || financingFromInvestors.getOpenId() == null) {
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "获取不到对应的openId");
|
|
|
+ }
|
|
|
+ String openId = financingFromInvestors.getOpenId();
|
|
|
RepayPlanTrialResp repayPlanTrialResp = smbApiService.repayPlanTrial(repayPlanTrial, openId);
|
|
|
return repayPlanTrialResp;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取资方融资信息
|
|
|
+ *
|
|
|
+ * @param reviewFinancingInfo
|
|
|
+ */
|
|
|
+ private FinancingFromInvestors getFinancingFromInvestors(ReviewFinancingInfo reviewFinancingInfo) {
|
|
|
+ ReviewQuotaDisburse reviewQuotaDisburse = getById(reviewFinancingInfo.getReviewQuotaDisburseId());
|
|
|
+ if (reviewQuotaDisburse != null && reviewQuotaDisburse.getFinancingBasicInfoId() != null) {
|
|
|
+ CFinancingBasicInfo financingBasicInfo = financingBasicInfoService.getById(reviewQuotaDisburse.getFinancingBasicInfoId());
|
|
|
+ if (financingBasicInfo != null) {
|
|
|
+ SupplierInfo supplierInfo = supplierInfoService.getByEnterpriseId(financingBasicInfo.getMainEnterpriseId());
|
|
|
+ if (supplierInfo != null) {
|
|
|
+ FinancingFromInvestors financingFromInvestors = financingFromInvestorsService.lambdaQuery().eq(FinancingFromInvestors::getSupplierInfoId, supplierInfo.getId())
|
|
|
+ .orderByDesc(FinancingFromInvestors::getId).list().get(0);
|
|
|
+ return financingFromInvestors;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|