|
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.deepoove.poi.XWPFTemplate;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.snb.fsos.bean.AccountInfoQuery;
|
|
|
+import com.snb.fsos.bean.BalanceQuery;
|
|
|
import com.snb.fsos.bean.ProductCreditApplyV2;
|
|
|
import com.snb.fsos.bean.SMBFileUpload;
|
|
|
import com.sunxung.factoring.component.aspect.OperationLogAspect;
|
|
@@ -35,11 +37,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.sunxung.factoring.service.smbApi.api.SMBApiService;
|
|
|
import com.sunxung.factoring.service.smbApi.dto.CreditApplyRiskMsgDto;
|
|
|
import com.sunxung.factoring.service.smbApi.dto.LoanCreditRiskMsgDto;
|
|
|
+import com.sunxung.factoring.service.smbApi.resp.AccountInfoQueryResp;
|
|
|
+import com.sunxung.factoring.service.smbApi.resp.BalanceQueryResp;
|
|
|
import com.sunxung.factoring.service.smbApi.resp.CreditApplyResp;
|
|
|
import com.sunxung.factoring.service.smbApi.resp.CreditProcessQueryResp;
|
|
|
import com.sunxung.factoring.service.supplier.*;
|
|
|
import com.sunxung.factoring.service.sys.*;
|
|
|
import com.sunxung.factoring.service.sys.dto.AttachmentDto;
|
|
|
+import org.apache.bcel.classfile.Code;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
@@ -48,7 +53,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.io.File;
|
|
|
+import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -138,6 +143,26 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addInfo(FinancingFromInvestors financingFromInvestors) {
|
|
|
+ //续授信
|
|
|
+ if(financingFromInvestors.getCredit()){
|
|
|
+ //判断数据的状态是否支持续授信
|
|
|
+ List<FinancingFromInvestorsHistory> financingFromInvestorsHistories = financingFromInvestorsHistoryService.lambdaQuery().eq(FinancingFromInvestorsHistory::getFinancingFromInvestorsId, financingFromInvestors.getId()).orderByDesc(FinancingFromInvestorsHistory::getId).list();
|
|
|
+ FinancingFromInvestorsNotice financingFromInvestorsNotice = null;
|
|
|
+ if (CollectionUtil.isNotEmpty(financingFromInvestorsHistories)) {
|
|
|
+ FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistories.get(0);
|
|
|
+ financingFromInvestorsNotice = financingFromInvestorsNoticeService.lambdaQuery().eq(FinancingFromInvestorsNotice::getFinancingFromInvestorsHistoryId, financingFromInvestorsHistory.getId()).one();
|
|
|
+ }
|
|
|
+ if(financingFromInvestorsNotice == null){
|
|
|
+ throw new BusinessException(CodeUtil.FAIL,"无法续授信!请联系开发人员!");
|
|
|
+ }
|
|
|
+ if (financingFromInvestorsNotice.getExpiringDate().compareTo(new Date()) == 1) {
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "授信生效中,无法续授信!");
|
|
|
+ }
|
|
|
+ if (financingFromInvestorsNotice.getNextApplyDate().compareTo(new Date()) == 1) {
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "未到可再次申请日期,无法续授信!");
|
|
|
+ }
|
|
|
+ financingFromInvestors.setId(null);
|
|
|
+ }
|
|
|
List<SMBFileUpload> fileList = new ArrayList<>();
|
|
|
List<Long> registeredAddressCodeList = financingFromInvestors.getRegisteredAddressCodeList();
|
|
|
if(CollectionUtil.isNotEmpty(registeredAddressCodeList)){
|
|
@@ -819,31 +844,14 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
|
|
|
return financingFromInvestorsNotice;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void credit(FinancingFromInvestors financingFromInvestors) {
|
|
|
- //判断数据的状态是否支持续授信
|
|
|
- List<FinancingFromInvestorsHistory> financingFromInvestorsHistories = financingFromInvestorsHistoryService.lambdaQuery().eq(FinancingFromInvestorsHistory::getFinancingFromInvestorsId, financingFromInvestors.getId()).orderByDesc(FinancingFromInvestorsHistory::getId).list();
|
|
|
- FinancingFromInvestorsNotice financingFromInvestorsNotice = null;
|
|
|
- if (CollectionUtil.isNotEmpty(financingFromInvestorsHistories)) {
|
|
|
- FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistories.get(0);
|
|
|
- financingFromInvestorsNotice = financingFromInvestorsNoticeService.lambdaQuery().eq(FinancingFromInvestorsNotice::getFinancingFromInvestorsHistoryId, financingFromInvestorsHistory.getId()).one();
|
|
|
- }
|
|
|
- if (financingFromInvestorsNotice.getExpiringDate().compareTo(new Date()) == 1) {
|
|
|
- throw new BusinessException(CodeUtil.FAIL, "授信生效中,无法续授信!");
|
|
|
- }
|
|
|
- if (financingFromInvestorsNotice.getNextApplyDate().compareTo(new Date()) == 1) {
|
|
|
- throw new BusinessException(CodeUtil.FAIL, "未到可再次申请日期,无法续授信!");
|
|
|
- }
|
|
|
- financingFromInvestors.setId(null);
|
|
|
- this.addInfo(financingFromInvestors);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public FinancingFromInvestorsNotice findCreditDetail(Long id) {
|
|
|
FinancingFromInvestors financingFromInvestors = this.getById(id);
|
|
|
List<FinancingFromInvestorsHistory> financingFromInvestorsHistories =
|
|
|
financingFromInvestorsHistoryService.lambdaQuery().eq(FinancingFromInvestorsHistory::getFinancingFromInvestorsId, id).orderByDesc(FinancingFromInvestorsHistory::getId).list();
|
|
|
+ if(CollectionUtil.isEmpty(financingFromInvestorsHistories)){
|
|
|
+ throw new BusinessException(CodeUtil.FAIL,"未查询到授信信息");
|
|
|
+ }
|
|
|
FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistories.get(0);
|
|
|
CreditProcessQueryResp creditProcessQueryResp = smbApiService.creditProcessQuery(financingFromInvestors.getOpenId(), financingFromInvestorsHistory.getBizNo());
|
|
|
//删除之前的回调
|
|
@@ -893,15 +901,91 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
|
|
|
financingFromInvestorsNotice.setPendingLoanReceipt("否");
|
|
|
}
|
|
|
financingFromInvestorsNotice.setGuaranteeMethod(creditProcessQueryResp.getGuaranteeFlag());
|
|
|
- //todo 待核实字段
|
|
|
-// financingFromInvestorsNotice.setRepaymentAccount();
|
|
|
-// financingFromInvestorsNotice.setRepaymentAccountName();
|
|
|
-// financingFromInvestorsNotice.setRepaymentAccountType();
|
|
|
financingFromInvestorsNotice.setLimitNumber(creditProcessQueryResp.getProductLimitNo());
|
|
|
+ if(StringUtil.isNotEmpty(creditProcessQueryResp.getType301SdossId())){
|
|
|
+ financingFromInvestorsNotice.setType301SdossId(creditProcessQueryResp.getType301SdossId());
|
|
|
+ FileStorage fileStorage = downloadFile(creditProcessQueryResp.getType301SdossId());
|
|
|
+ fileStorageService.saveAttachmentRefByFileStorage(fileStorage,
|
|
|
+ FileModuleDict.ChildEnum.SMB_TYPE_301,
|
|
|
+ financingFromInvestorsNotice.getId());
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(creditProcessQueryResp.getType302SdossId())){
|
|
|
+
|
|
|
+ financingFromInvestorsNotice.setType302SdossId(creditProcessQueryResp.getType302SdossId());
|
|
|
+ FileStorage fileStorage = downloadFile(creditProcessQueryResp.getType302SdossId());
|
|
|
+ fileStorageService.saveAttachmentRefByFileStorage(fileStorage,
|
|
|
+ FileModuleDict.ChildEnum.SMB_TYPE_302,
|
|
|
+ financingFromInvestorsNotice.getId());
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(creditProcessQueryResp.getType303SdossId())){
|
|
|
+
|
|
|
+ financingFromInvestorsNotice.setType303SdossId(creditProcessQueryResp.getType303SdossId());
|
|
|
+ FileStorage fileStorage = downloadFile(creditProcessQueryResp.getType303SdossId());
|
|
|
+ fileStorageService.saveAttachmentRefByFileStorage(fileStorage,
|
|
|
+ FileModuleDict.ChildEnum.SMB_TYPE_303,
|
|
|
+ financingFromInvestorsNotice.getId());
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(creditProcessQueryResp.getType327SdossId())){
|
|
|
+ financingFromInvestorsNotice.setType327SdossId(creditProcessQueryResp.getType327SdossId());
|
|
|
+ FileStorage fileStorage = downloadFile(creditProcessQueryResp.getType327SdossId());
|
|
|
+ fileStorageService.saveAttachmentRefByFileStorage(fileStorage,
|
|
|
+ FileModuleDict.ChildEnum.SMB_TYPE_327,
|
|
|
+ financingFromInvestorsNotice.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询账户信息
|
|
|
+ AccountInfoQuery accountInfoQuery = new AccountInfoQuery();
|
|
|
+ List<AccountInfoQueryResp> accountInfoQueryResps = smbApiService.accountInfoQuery(accountInfoQuery, financingFromInvestors.getOpenId());
|
|
|
+ AccountInfoQueryResp accountInfoQueryResp = accountInfoQueryResps.get(0);
|
|
|
+
|
|
|
+ financingFromInvestorsNotice.setRepaymentAccount(accountInfoQueryResp.getClientAcct());
|
|
|
+ financingFromInvestorsNotice.setRepaymentAccountName(accountInfoQueryResp.getAcctName());
|
|
|
+ financingFromInvestorsNotice.setRepaymentAccountType(accountInfoQueryResp.getAcctType());
|
|
|
financingFromInvestorsNoticeService.save(financingFromInvestorsNotice);
|
|
|
+
|
|
|
return financingFromInvestorsNotice;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private FileStorage downloadFile(String remoteFilePath){
|
|
|
+
|
|
|
+ FileStorage fileStorage = new FileStorage(null, FileModuleDict.ChildEnum.SMB_SING_FILE, UUID.randomUUID().toString(), ".pdf");
|
|
|
+
|
|
|
+ String absolutePath = fileStorage.getAbsolutePath();
|
|
|
+ File file = new File(absolutePath);
|
|
|
+ if (!file.getParentFile().exists()) {
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ DataOutputStream out = null ;
|
|
|
+ InputStream inputStream = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ inputStream = smbApiService.downloadFileStream(".pdf", remoteFilePath);
|
|
|
+ //读文件流
|
|
|
+ out = new DataOutputStream(new FileOutputStream(fileStorage.getAbsolutePath()));
|
|
|
+ byte[] buffer = new byte[2048];
|
|
|
+ int count = 0;
|
|
|
+ while ((count = inputStream.read(buffer)) > 0) {
|
|
|
+ out.write(buffer, 0, count);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }finally {
|
|
|
+ try {
|
|
|
+ if (out != null) {
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ if (inputStream != null) {
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fileStorageService.add(fileStorage);
|
|
|
+ }
|
|
|
+
|
|
|
private File creatCompanyFile(FileStorage fileStorage, Enterprise enterprise) {
|
|
|
try {
|
|
|
String absolutePath = fileStorage.getAbsolutePath();
|