|
@@ -270,6 +270,9 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
|
|
|
@Value("${config.smbRefinancingPlanUpdate.url}")
|
|
|
private String smbRefinancingPlanUpdateUrl;
|
|
|
|
|
|
+ @Value("${config.smbBeforeRepayPlanUpdate.url}")
|
|
|
+ private String smbBeforeRepayPlanUpdateUrl;
|
|
|
+
|
|
|
@Override
|
|
|
public LedgerAccountBasicInfo get(Long id) {
|
|
|
return ledgerAccountBasicInfoMapper.getListInfo(id);
|
|
@@ -525,7 +528,24 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void repayApplyBySMB(LedgerFundGoodsAssign ledgerFundGoodsAssign) {
|
|
|
+
|
|
|
FinancingLoanInfo financingLoanInfo = getFinancingLoanInfoByAccountsReceivableId(ledgerFundGoodsAssign.getSopAccountsReceivableId());
|
|
|
+
|
|
|
+ //还款前计划查询和更新、防止因自动批扣导致计划发生过变更
|
|
|
+ RepayPlanResp repayPlanResp = smbApiService.repayPlanQuery(financingLoanInfo.getOpenId(), financingLoanInfo.getDueBillNo());
|
|
|
+ if (repayPlanResp != null) {
|
|
|
+ SmbRefinancingInfo smbRefinancingInfo = new SmbRefinancingInfo();
|
|
|
+ smbRefinancingInfo.setContractNo(financingLoanInfo.getContractNo());
|
|
|
+ smbRefinancingInfo.setQuotaDisburseBatch(financingLoanInfo.getQuotaDisburseBatch());
|
|
|
+ smbRefinancingInfo.setRepayPlanResp(repayPlanResp);
|
|
|
+
|
|
|
+ ResponseEntity<String> responseEntity = restTemplate.postForEntity(smbBeforeRepayPlanUpdateUrl, smbRefinancingInfo, String.class);
|
|
|
+ ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
|
|
|
+ if (responseEntity.getStatusCode().value() != HttpStatus.OK.value() || !responseJson.isSuccess()) {
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "苏商还款计划更新推送sop失败:" + responseJson.getMsg().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
RepayApply repayApply = new RepayApply();
|
|
|
if (financingLoanInfo != null) {
|
|
|
repayApply.setDuebillNo(financingLoanInfo.getDueBillNo());
|
|
@@ -545,20 +565,23 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
|
|
|
bizNo = bizNo.substring(0, 32);
|
|
|
}
|
|
|
repayApply.setBizNo(bizNo);
|
|
|
+ //提交还款申请
|
|
|
RepayStatusResp repayStatusResp = smbApiService.repayApply(repayApply, financingLoanInfo.getOpenId());
|
|
|
if (repayStatusResp != null) {
|
|
|
//保存资方还款信息
|
|
|
- saveFinancingLoanInfo(financingLoanInfo, repayStatusResp, bizNo);
|
|
|
+ saveFinancingPaymentInfo(financingLoanInfo, repayStatusResp, bizNo);
|
|
|
if ("01".equals(repayStatusResp.getRepayStatus())) {
|
|
|
//如果状态为还款成功
|
|
|
//如果还款状态由还款中->还款成功 查询最新的还款计划,同步更新到sop中
|
|
|
- RepayPlanResp repayPlanResp = smbApiService.repayPlanQuery(financingLoanInfo.getOpenId(), financingLoanInfo.getDueBillNo());
|
|
|
+ repayPlanResp = smbApiService.repayPlanQuery(financingLoanInfo.getOpenId(), financingLoanInfo.getDueBillNo());
|
|
|
if (repayPlanResp != null) {
|
|
|
SmbRefinancingInfo smbRefinancingInfo = new SmbRefinancingInfo();
|
|
|
smbRefinancingInfo.setContractNo(financingLoanInfo.getContractNo());
|
|
|
smbRefinancingInfo.setQuotaDisburseBatch(financingLoanInfo.getQuotaDisburseBatch());
|
|
|
smbRefinancingInfo.setRepayPlanResp(repayPlanResp);
|
|
|
smbRefinancingInfo.setRepaymentMethod(SmbRepaymentMethodEnum.PROACTIVE_REPAYMENT.getCode());
|
|
|
+ smbRefinancingInfo.setRepayPrincipal(new BigDecimal(repayStatusResp.getHxCapi()));
|
|
|
+ smbRefinancingInfo.setRepayInterest(new BigDecimal(repayStatusResp.getHxInte()));
|
|
|
|
|
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(smbRefinancingPlanUpdateUrl, smbRefinancingInfo, String.class);
|
|
|
ResponseJson responseJson = JSONUtil.toBean(responseEntity.getBody(), ResponseJson.class);
|
|
@@ -576,7 +599,7 @@ public class LedgerManagementServiceImpl implements LedgerManagementService {
|
|
|
* @param financingLoanInfo
|
|
|
* @param repayStatusResp
|
|
|
*/
|
|
|
- private void saveFinancingLoanInfo(FinancingLoanInfo financingLoanInfo, RepayStatusResp repayStatusResp, String bizNo) {
|
|
|
+ private void saveFinancingPaymentInfo(FinancingLoanInfo financingLoanInfo, RepayStatusResp repayStatusResp, String bizNo) {
|
|
|
FinancingPaymentInfo financingPaymentInfo = new FinancingPaymentInfo(financingLoanInfo);
|
|
|
//bizNo
|
|
|
financingPaymentInfo.setBizNo(bizNo);
|