ContractServiceImpl.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. package com.loan.system.service.Impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import com.loan.system.context.BaseContext;
  4. import com.loan.system.domain.dto.ContractDTO;
  5. import com.loan.system.domain.dto.ContractWrapperDTO;
  6. import com.loan.system.domain.dto.query.ContractQueryDTO;
  7. import com.loan.system.domain.entity.*;
  8. import com.loan.system.domain.enums.*;
  9. import com.loan.system.domain.pojo.ContractInformation;
  10. import com.loan.system.domain.pojo.Result;
  11. import com.loan.system.domain.pojo.TemplateMessage;
  12. import com.loan.system.domain.vo.*;
  13. import com.loan.system.exception.DescribeException;
  14. import com.loan.system.repository.ContractRepository;
  15. import com.loan.system.service.*;
  16. import com.loan.system.utils.NumberToChineseUtil;
  17. import com.loan.system.utils.PoiWordUtil;
  18. import com.loan.system.utils.ResultUtil;
  19. import lombok.RequiredArgsConstructor;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.beans.factory.annotation.Value;
  22. import org.springframework.context.annotation.Lazy;
  23. import org.springframework.data.domain.Page;
  24. import org.springframework.data.domain.PageRequest;
  25. import org.springframework.data.domain.Pageable;
  26. import org.springframework.stereotype.Service;
  27. import org.springframework.util.ObjectUtils;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.io.IOException;
  30. import java.nio.file.Files;
  31. import java.nio.file.Path;
  32. import java.nio.file.Paths;
  33. import java.time.LocalDateTime;
  34. import java.time.format.DateTimeFormatter;
  35. import java.util.*;
  36. import static com.loan.system.domain.enums.ExceptionEnum.FILE_DELETE_ERROR;
  37. @Service
  38. @RequiredArgsConstructor
  39. public class ContractServiceImpl implements ContractService {
  40. @Value("${upload.templatePath}")
  41. private String contractPath;
  42. @Autowired
  43. @Lazy
  44. private LoanService loanService;
  45. private final CustomerService customerService;
  46. private final ContractRepository contractRepository;
  47. private final DocumentService documentService;
  48. private final DictionaryService dictionaryService;
  49. private final StepService stepService;
  50. private final EsignService esignService;
  51. private final ContractBankInfoService contractBankInfoService;
  52. private final WxService wxService;
  53. private final UserService userService;
  54. private final CollateralService collateralService;
  55. private final ContractAndCollateralService contractAndCollateralService;
  56. @Override
  57. public Contract saveContract(ContractDTO contractDTO) {
  58. Map<String, String> contractMap = dictionaryService.contractMap();
  59. Contract contract = BeanUtil.copyProperties(contractDTO, Contract.class);
  60. String[] split = contractDTO.getCustomerIds().split(",");
  61. contract.setCustomerId(split.length>0?Long.valueOf(split[0]):null);
  62. contract.setCustomerId1(split.length>1?Long.valueOf(split[1]):null);
  63. contract.setCustomerId2(split.length>2?Long.valueOf(split[2]):null);
  64. contract.setId( null);
  65. contract.setContractName(contract.getBusinessAttr().equals(BusinessAttrEnum.ESTATE_MORTGAGE.getMsg())?"抵押合同":"质押合同");
  66. if(contract.getContractNo()==null)
  67. contract.setContractNo("临时编号:"+UUID.randomUUID().toString().replace("-",""));
  68. contract.setIsDelete(false);
  69. contract.setSignedByCustomer(false);
  70. contract.setIsPush( false);
  71. contract.setClearedStatus(DecisionEnum.CLEAR_NOT.getMsg());
  72. contract.setInterestAmount(0.0);
  73. contract.setActualAmount(0.0);
  74. contract.setIsDisbursementComplete(false);
  75. contract.setAmountRate(Double.valueOf(contractMap.get(ContractEnum.PAWN_INTEREST_RATE.getLabel())));
  76. contract.setServiceCost(Double.valueOf(contractMap.get(ContractEnum.MONTHLY_COMPREHENSIVE_FEE.getLabel())));
  77. contract.setLoanRate(Double.valueOf(contractMap.get(ContractEnum.LOAN_INTEREST_RATE.getLabel())));
  78. contract.setCreateTime(LocalDateTime.now()
  79. .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
  80. contract.setUpdateTime(LocalDateTime.now()
  81. .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
  82. return contractRepository.save(contract);
  83. }
  84. @Override
  85. public Contract findContractByCaseIdAndBusinessAttr(Long caseId, String businessAttr, boolean b) {
  86. return contractRepository.findByCaseIdAndBusinessAttrAndIsDelete(caseId,businessAttr,b);
  87. }
  88. @Override
  89. public void updateContractById(Long id, ContractDTO contractDTO, boolean isDelete) {
  90. Contract contract = BeanUtil.copyProperties(contractDTO, Contract.class);
  91. String[] split = contractDTO.getCustomerIds().split(",");
  92. contract.setCustomerId(split.length>0?Long.valueOf(split[0]):null);
  93. contract.setCustomerId1(split.length>1?Long.valueOf(split[1]):null);
  94. contract.setCustomerId2(split.length>2?Long.valueOf(split[2]):null);
  95. contract.setUpdateTime( LocalDateTime.now().format( DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm:ss" )));
  96. contractRepository.updateContractById(id,contract,isDelete);
  97. }
  98. @Override
  99. public List<ContractVO> findContractByCaseId(Long caseId) {
  100. List<Contract> contracts = contractRepository.findByCaseIdAndIsDelete(caseId, false);
  101. return convertContractsToContractVOS( contracts);
  102. }
  103. @Override
  104. public void updateContractById1(Long contractId, Long commitedId,Long signId) {
  105. Contract contract = new Contract();
  106. contract.setCommitedId(commitedId);
  107. contract.setSignedId(signId);
  108. contract.setSignedByCustomer(true);
  109. contract.setSignedTime( LocalDateTime.now().format( DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm:ss" )));
  110. contract.setUpdateTime( LocalDateTime.now().format( DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm:ss" )));
  111. contractRepository.updateContractById(contractId,contract,false);
  112. }
  113. @Override
  114. public void updateIsPushById(Long contractId) {
  115. contractRepository.updateIsPushById(contractId);
  116. }
  117. @Override
  118. public List<ContractVO> findContractByCaseIdAndIsPush(Long caseId, boolean isPush) {
  119. List<Contract> contracts = contractRepository.findByCaseIdAndIsPush(caseId, isPush, false);
  120. return convertContractsToContractVOS( contracts);
  121. }
  122. @Override
  123. public void deleteAllByCaseId(Long caseId) {
  124. contractRepository.deleteAllByCaseId(caseId);
  125. }
  126. @Override
  127. public void updateContractNoById(Long id, String contractNo) {
  128. contractRepository.updateContractNoById(id,contractNo);
  129. }
  130. @Override
  131. public Contract findContractById(Long contractId) {
  132. return contractRepository.findContractById(contractId);
  133. }
  134. @Override
  135. public void updateSignedCustomerById(Long contractId) {
  136. contractRepository.updateSignedCustomerById(contractId);
  137. }
  138. @Override
  139. public void deleteSigned(Long sifnedId) {
  140. contractRepository.deleteSigned(sifnedId);
  141. }
  142. @Override
  143. public void updateRepayById(String clearedStatus, Double interest, Long currentId, Long contractId, boolean isDelete) {
  144. contractRepository.updateRepayById(clearedStatus,interest,currentId,contractId,isDelete);
  145. }
  146. @Override
  147. public List<Double> findIntersetByCaseId(Long caseId) {
  148. return contractRepository.findIntersetByCaseIdAndIsDelete(caseId,false);
  149. }
  150. @Override
  151. public List<Contract> findContractByCaseId2(Long caseId) {
  152. return contractRepository.findByCaseIdAndIsDelete2(caseId,false);
  153. }
  154. @Override
  155. public boolean existsById(Long contractId) {
  156. return contractRepository.existsById(contractId);
  157. }
  158. @Override
  159. public void updateContractStatus(Contract contract, Long caseId) {
  160. Long contractId = contract.getId();
  161. updateSignedCustomerById(contractId);
  162. if(contract.getSignedId()!=null){
  163. Document document = documentService.findById(contract.getSignedId());
  164. String filePath = document.getFilePath();
  165. if (filePath!=null){
  166. try {
  167. Path path = Paths.get(filePath);
  168. boolean deleted = Files.deleteIfExists(path);
  169. if (deleted) {
  170. deleteSigned(contract.getSignedId());
  171. documentService.deleteFileById(contract.getSignedId());
  172. System.out.println("文件删除成功: " + filePath);
  173. } else {
  174. System.out.println("文件不存在或已被删除: " + filePath);
  175. }
  176. } catch (IOException e) {
  177. throw new DescribeException(FILE_DELETE_ERROR);
  178. }
  179. }
  180. }
  181. }
  182. @Override
  183. public void completeContract(LoanCaseSimpleVO loanCaseSimpleVO, ContractWrapperDTO contractWrapper) {
  184. Long caseId = loanCaseSimpleVO.getId();
  185. List<ContractDTO> contractDTOS = contractWrapper.getContractDTOS();
  186. for (ContractDTO contractDTO : contractDTOS) {
  187. contractBankInfoService.addInfo(contractDTO.getBankInfo(),contractDTO.getId());
  188. contractBankInfoService.addInfos(contractDTO.getEntrustBankInfos(),contractDTO.getId());
  189. contractRepository.updateLoanInfoById(contractDTO.getAmountRate(),contractDTO.getServiceCost(),contractDTO.getLoanRate(),contractDTO.getId());
  190. }
  191. //合同签约完成
  192. stepService.updateUserId1ByCaseIdAndStepCode(StepPropertyEnum.CONTRACT_SIGN.getCode(), BaseContext.getCurrentId(),caseId);
  193. stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(), StepPropertyEnum.CONTRACT_SIGN_PARENT.getCode(),caseId);
  194. stepService.updateStatusByCaseId(StepEnum.COMPLETED.getMsg(),StepPropertyEnum.CONTRACT_SIGN.getCode(),caseId);
  195. stepService.tryStartStep(StepPropertyEnum.CONTRACT_SIGN.getCode(),caseId);
  196. //TODO:微信消息推送至下一环节:业务员
  197. TemplateMessage message = new TemplateMessage();
  198. Map<String, Map<String, String>> data = new HashMap<>();
  199. data.put("character_string6", Collections.singletonMap("value", String.valueOf(caseId)));//caseId
  200. data.put("phrase7", Collections.singletonMap("value", StepPropertyEnum.PLAN_REPORT.getLabel()));//当前环节
  201. data.put("thing1", Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getBusinessType())));//业务类型
  202. Customer customer = customerService.findByIdAndIsDelete(loanCaseSimpleVO.getCustomerId());
  203. data.put("thing3", Collections.singletonMap("value", customer!=null ? customer.getName() : ""));//客户名称
  204. data.put("amount4",Collections.singletonMap("value", String.valueOf(loanCaseSimpleVO.getTotalLoanAmount())));//典当金额
  205. message.setData(data);
  206. List<User> users = userService.findByRoleAndIsDelete(Arrays.asList(RoleEnum.ASSIST_SALES.getMsg(),RoleEnum.LEAD_SALES.getMsg()), false);
  207. for (User user : users) {
  208. if (user.getId().equals(BaseContext.getCurrentId())) continue;
  209. if (user.getOpenid() != null) wxService.sendTemplateMessage(user.getOpenid(), message);
  210. }
  211. }
  212. @Override
  213. public void getContractInformation(HttpServletResponse response, Long caseId,Long contractId){
  214. Contract contract = contractRepository.findContractById(contractId);
  215. LoanCaseSimpleVO loancase = loanService.findLoanCaseSimpleByIdAndIsDelete(caseId, false);
  216. CustomerVO customer = customerService.findByCustomerIdAndIsDelete(loancase.getCustomerId(),false);
  217. ContractInformation contractInformation = BeanUtil.copyProperties(contract, ContractInformation.class);
  218. if (contract.getSignedId() != null){
  219. Document byId = documentService.findById(contract.getSignedId());
  220. contractInformation.setSignaturePath1(byId.getFilePath());
  221. }
  222. String names = "";
  223. String idNumbers = "";
  224. if (contract.getCustomerId()!=null){
  225. Customer customer1 = customerService.findByIdAndIsDelete(contract.getCustomerId());
  226. names = names == "" ? customer1.getName() : names + "、" + customer1.getName();
  227. idNumbers = idNumbers == "" ? customer1.getIdNumber() : idNumbers + "、" + customer1.getIdNumber();
  228. }
  229. if (contract.getCustomerId1()!=null){
  230. Customer customer2 = customerService.findByIdAndIsDelete(contract.getCustomerId1());
  231. names = names == "" ? customer2.getName() : names + "、" + customer2.getName();
  232. idNumbers = idNumbers == "" ? customer2.getIdNumber() : idNumbers + "、" + customer2.getIdNumber();
  233. }
  234. if (contract.getCustomerId2()!=null){
  235. Customer customer3 = customerService.findByIdAndIsDelete(contract.getCustomerId2());
  236. names = names == "" ? customer3.getName() : names + "、" + customer3.getName();
  237. idNumbers = idNumbers == "" ? customer3.getIdNumber() : idNumbers + "、" + customer3.getIdNumber();
  238. }
  239. contractInformation.setName(names);
  240. contractInformation.setIdNumber(idNumbers);
  241. contractInformation.setContractAmount(NumberToChineseUtil.convertToChinese(contract.getContractAmount())+"万元");
  242. contractInformation.setMobile(customer.getMobile());
  243. contractInformation.setContactAddress1(customer.getContactAddress());
  244. contractInformation.setContractAttr(loancase.getBusinessUsage());//改成借款用途了
  245. contractInformation.setContractType(loancase.getBusinessAttrs());//改成业务属性了
  246. Map<String, String> contractMap = dictionaryService.contractMap();
  247. contractInformation.setPages1(contractMap.get(ContractEnum.CONTRACT_COPIES.getLabel()));
  248. contractInformation.setContactAddress2(contractMap.get(ContractEnum.CONTACT_ADDRESS.getLabel()));
  249. contractInformation.setSignaturePath2(contractMap.get(ContractEnum.CONTRACT_PARTY_A.getLabel()));
  250. contractInformation.setSignLocation1(contractMap.get(ContractEnum.SIGNATURE_ADDRESS.getLabel()));
  251. contractInformation.setSignLocation2(contractMap.get(ContractEnum.SIGNATURE_ADDRESS.getLabel()));
  252. List<Long> collateralIdsByContractId = contractAndCollateralService.findCollateralIdsByContractId(contract.getId());
  253. if (collateralIdsByContractId != null){
  254. Collateral collateral = collateralService.findCollateralById(collateralIdsByContractId.get(0));
  255. contractInformation.setAddress(collateral.getAddress());
  256. contractInformation.setCollateralArea(collateral.getCollateralArea()+"平方米");
  257. contractInformation.setCollateralNumber(collateral.getCollateralNo());
  258. }
  259. String downloadName = contract.getContractName()+"-"+contract.getId();
  260. new PoiWordUtil().writeApprove(response,contractPath+"template1.docx",contractInformation,downloadName);
  261. }
  262. @Override
  263. public ContractInformation getContractInformationById(Long caseId, Long contractId) {
  264. Contract contract = contractRepository.findContractById(contractId);
  265. LoanCaseSimpleVO loancase = loanService.findLoanCaseSimpleByIdAndIsDelete(caseId, false);
  266. CustomerVO customer = customerService.findByCustomerIdAndIsDelete(loancase.getCustomerId(),false);
  267. ContractInformation contractInformation = BeanUtil.copyProperties(contract, ContractInformation.class);
  268. if (contract.getSignedId() != null){
  269. Document byId = documentService.findById(contract.getSignedId());
  270. contractInformation.setSignaturePath1(byId.getFilePath());
  271. }
  272. String names = "";
  273. String idNumbers = "";
  274. if (contract.getCustomerId()!=null){
  275. Customer customer1 = customerService.findByIdAndIsDelete(contract.getCustomerId());
  276. names = names == "" ? customer1.getName() : names + "、" + customer1.getName();
  277. idNumbers = idNumbers == "" ? customer1.getIdNumber() : idNumbers + "、" + customer1.getIdNumber();
  278. }
  279. if (contract.getCustomerId1()!=null){
  280. Customer customer2 = customerService.findByIdAndIsDelete(contract.getCustomerId1());
  281. names = names == "" ? customer2.getName() : names + "、" + customer2.getName();
  282. idNumbers = idNumbers == "" ? customer2.getIdNumber() : idNumbers + "、" + customer2.getIdNumber();
  283. }
  284. if (contract.getCustomerId2()!=null){
  285. Customer customer3 = customerService.findByIdAndIsDelete(contract.getCustomerId2());
  286. names = names == "" ? customer3.getName() : names + "、" + customer3.getName();
  287. idNumbers = idNumbers == "" ? customer3.getIdNumber() : idNumbers + "、" + customer3.getIdNumber();
  288. }
  289. contractInformation.setName(names);
  290. contractInformation.setIdNumber(idNumbers);
  291. contractInformation.setContractAmount(NumberToChineseUtil.convertToChinese(contract.getContractAmount()));
  292. contractInformation.setMobile(customer.getMobile());
  293. contractInformation.setContactAddress1(customer.getContactAddress());
  294. contractInformation.setContractAttr(loancase.getBusinessUsage());//改成借款用途了
  295. contractInformation.setContractType(loancase.getBusinessAttrs());//改成业务属性了
  296. Map<String, String> contractMap = dictionaryService.contractMap();
  297. contractInformation.setPages1(contractMap.get(ContractEnum.CONTRACT_COPIES.getLabel()));
  298. contractInformation.setContactAddress2(contractMap.get(ContractEnum.CONTACT_ADDRESS.getLabel()));
  299. contractInformation.setSignaturePath2(contractMap.get(ContractEnum.CONTRACT_PARTY_A.getLabel()));
  300. contractInformation.setSignLocation1(contractMap.get(ContractEnum.SIGNATURE_ADDRESS.getLabel()));
  301. contractInformation.setSignLocation2(contractMap.get(ContractEnum.SIGNATURE_ADDRESS.getLabel()));
  302. List<Long> collateralIdsByContractId = contractAndCollateralService.findCollateralIdsByContractId(contract.getId());
  303. if (collateralIdsByContractId != null){
  304. Collateral collateral = collateralService.findCollateralById(collateralIdsByContractId.get(0));
  305. contractInformation.setAddress(collateral.getAddress());
  306. contractInformation.setCollateralArea(collateral.getCollateralArea());
  307. contractInformation.setCollateralNumber(collateral.getCollateralNo());
  308. }
  309. return contractInformation;
  310. }
  311. @Override
  312. public void updateClearedStatusById(Long contractId, String msg) {
  313. contractRepository.updateClearedStatusById(contractId,msg,LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
  314. }
  315. @Override
  316. public List<Long> findIdsByCaseId(Long caseId) {
  317. return contractRepository.findIdsByCaseIdAndIsDelete(caseId, false);
  318. }
  319. @Override
  320. public void updateActualAmountAndIsCompleteByIds(Map<Long, Double> contractIdAndAmount,Boolean isComplete) {
  321. for (Map.Entry<Long, Double> entry : contractIdAndAmount.entrySet()){
  322. Contract contract = contractRepository.findContractById(entry.getKey());
  323. Double amount = entry.getValue();
  324. isComplete = contract.getIsDisbursementComplete();
  325. if(Math.abs(amount - contract.getContractAmount())<Double.MIN_VALUE && isComplete == false)//相同则自动更新
  326. isComplete = true;
  327. contractRepository.updateActualAmountAndIsCompleteById(entry.getKey(),amount,isComplete);
  328. }
  329. }
  330. @Override
  331. public Double getActualTotalAmount(Long caseId) {
  332. List<ContractVO> contracts = findContractByCaseId(caseId);
  333. return contracts.stream().reduce(0.0, (sum, contract) -> sum + contract.getActualAmount(), Double::sum);
  334. }
  335. @Override
  336. public void updateIsDisbursementById(Long contractId, boolean isDisbursement) {
  337. contractRepository.updateISCompleteById(contractId,isDisbursement);
  338. }
  339. @Override
  340. public Result findAllContract(Integer pageNum, Integer pageSize) {
  341. Pageable pageable = PageRequest.of(pageNum, pageSize);
  342. Page<Contract> data = contractRepository.findAllByIsDelete(false, pageable);
  343. List<ContractVO> contractVOS = convertContractsToContractVOS(data.getContent());
  344. return ResultUtil.success(data.getTotalElements(), contractVOS);
  345. }
  346. @Override
  347. public Result findAllContractByQuery(Integer pageNum, Integer pageSize, ContractQueryDTO contractQueryDTO) {
  348. Pageable pageable = PageRequest.of(pageNum-1, pageSize);
  349. Page<Contract> data = contractRepository.findAllByQuery(contractQueryDTO, pageable);
  350. return ResultUtil.success(data.getTotalElements(), convertContractsToContractVOS(data.getContent()));
  351. }
  352. @Override
  353. public void deleteContractById(Long id) {
  354. contractRepository.deleteByIdAndIsDelete(id, true);
  355. }
  356. @Override
  357. public void updateIsDisbursementByCaseId(Long caseId) {
  358. contractRepository.updateIsDisbursementByCaseIdAndIsDelete(caseId,false);
  359. }
  360. private List<ContractVO> convertContractsToContractVOS(List<Contract> contracts) {
  361. List<ContractVO> contractVOS = new ArrayList<>();
  362. for (Contract contract : contracts){
  363. ContractVO contractVO = BeanUtil.copyProperties(contract, ContractVO.class);
  364. contractVO.setEsignFlow(esignService.findByContractIdAndNormal(contract.getId()));
  365. Customer customer = customerService.findByIdAndIsDelete(contract.getCustomerId());
  366. contractVO.setCustomer(BeanUtil.copyProperties(customer, CustomerVO.class));
  367. Customer customer1 = customerService.findByIdAndIsDelete(contract.getCustomerId1());
  368. contractVO.setCustomer1(BeanUtil.copyProperties(customer1, CustomerVO.class));
  369. Customer customer2 = customerService.findByIdAndIsDelete(contract.getCustomerId2());
  370. contractVO.setCustomer2(BeanUtil.copyProperties(customer2, CustomerVO.class));
  371. String customerNames = "";
  372. if (!ObjectUtils.isEmpty(customer)) customerNames += customer.getName();
  373. if (!ObjectUtils.isEmpty(customer1)) customerNames += "," + customer1.getName();
  374. if (!ObjectUtils.isEmpty(customer2)) customerNames += "," + customer2.getName();
  375. contractVO.setCustomerNames(customerNames);
  376. List<ContractBankInfoVO> bankInfoVOS = contractBankInfoService.findByContractIdAndIsDelete(contract.getId(), false);
  377. ContractBankInfoVO bankInfo = null;
  378. List<ContractBankInfoVO> entrustBankInfoVOS = new ArrayList<>();
  379. for (ContractBankInfoVO bankInfoVO : bankInfoVOS){
  380. if (!bankInfoVO.getIsEntrust())
  381. bankInfo = bankInfoVO;
  382. else
  383. entrustBankInfoVOS.add(bankInfoVO);
  384. }
  385. if (bankInfo == null && customer != null){//如果还没填,默认是第一位客户的银行信息
  386. bankInfo = new ContractBankInfoVO();
  387. bankInfo.setPayee(customer.getName());
  388. bankInfo.setCustomerId(customer.getId());
  389. bankInfo.setMobile(customer.getMobile());
  390. bankInfo.setId(-1L);
  391. bankInfo.setDisburseBank(customer.getBankName());
  392. bankInfo.setDisburseAccount(customer.getBankAccount());
  393. }
  394. contractVO.setBankInfo(bankInfo);
  395. contractVO.setEntrustBankInfos(entrustBankInfoVOS);
  396. //contractVO.setCustomerName(customer.getName());
  397. contractVOS.add(contractVO);
  398. }
  399. return contractVOS;
  400. }
  401. }