From b4c5e6ee6fdb9f77c036d5e13103baab3d0354c5 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Tue, 14 Jan 2025 17:57:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bank/service/PersonalBankCardService.java | 38 ++ .../impl/PersonalBankCardServiceImpl.java | 338 ++++++++++++++++++ 2 files changed, 376 insertions(+) create mode 100644 src/main/java/com/sztzjy/bank/service/PersonalBankCardService.java create mode 100644 src/main/java/com/sztzjy/bank/service/impl/PersonalBankCardServiceImpl.java diff --git a/src/main/java/com/sztzjy/bank/service/PersonalBankCardService.java b/src/main/java/com/sztzjy/bank/service/PersonalBankCardService.java new file mode 100644 index 0000000..f2eed97 --- /dev/null +++ b/src/main/java/com/sztzjy/bank/service/PersonalBankCardService.java @@ -0,0 +1,38 @@ +package com.sztzjy.bank.service; + +import com.sztzjy.bank.entity.BankCardInformation; +import com.sztzjy.bank.entity.CustomerInformation; +import com.sztzjy.bank.util.ResultDataEntity; +import com.sztzjy.bank.util.ResultEntity; + +import javax.validation.Valid; + +/** + * @author 17803 + * @date 2025-01-11 14:24 + */ +public interface PersonalBankCardService { + /** + * 提交/保存 + * @param customerInformation + * @return + */ + + ResultEntity submitByPersonBankCard(@Valid CustomerInformation customerInformation); + + /** + * 查询回显 + * @param userId + * @return + */ + + ResultDataEntity getBaseInfoByPersonBankCard(String userId,Integer number); + + /** + * 开设银行卡-提交/保存 + * @param bankCardInformation + * @return + */ + + ResultEntity submitByCreateCard(@Valid BankCardInformation bankCardInformation); +} diff --git a/src/main/java/com/sztzjy/bank/service/impl/PersonalBankCardServiceImpl.java b/src/main/java/com/sztzjy/bank/service/impl/PersonalBankCardServiceImpl.java new file mode 100644 index 0000000..f04f484 --- /dev/null +++ b/src/main/java/com/sztzjy/bank/service/impl/PersonalBankCardServiceImpl.java @@ -0,0 +1,338 @@ +package com.sztzjy.bank.service.impl; + +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSON; +import com.sztzjy.bank.entity.*; +import com.sztzjy.bank.entity.dto.BankCardInformationAnswerDTO; +import com.sztzjy.bank.entity.dto.CustomerInformationAnswerDTO; +import com.sztzjy.bank.mapper.BankCardInformationMapper; +import com.sztzjy.bank.mapper.CaseAnswerInfoMapper; +import com.sztzjy.bank.mapper.CaseInfoMapper; +import com.sztzjy.bank.mapper.CustomerInformationMapper; +import com.sztzjy.bank.service.PersonalBankCardService; +import com.sztzjy.bank.util.RedisUtil; +import com.sztzjy.bank.util.ResultDataEntity; +import com.sztzjy.bank.util.ResultEntity; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Date; +import java.util.List; + +/** + * @author 17803 + * @date 2025-01-11 14:24 + */ +@Service +public class PersonalBankCardServiceImpl implements PersonalBankCardService { + + @Autowired + private CustomerInformationMapper customerInformationMapper; + + @Autowired + private BankCardInformationMapper bankCardInformationMapper; + + @Autowired + RedisUtil redisUtil; + + @Autowired + private CaseInfoMapper caseInfoMapper; + + @Autowired + private CaseAnswerInfoMapper caseAnswerInfoMapper; + + + + + //提交/保存 + @Override + public ResultEntity submitByPersonBankCard(CustomerInformation customerInformation) { + + //判断是报错还是提交 + CustomerInformationExample example = new CustomerInformationExample(); + example.createCriteria().andUserIdEqualTo(customerInformation.getUserId()).andNumberEqualTo(customerInformation.getNumber()); + List informationList = customerInformationMapper.selectByExample(example); + + if (CollectionUtils.isEmpty(informationList)) { + //首次提交 + customerInformation.setId(IdUtil.simpleUUID()); + + if (customerInformation.getSubState()==1) + { + customerInformation = submitByPersonBankCardCaculate(customerInformation); + customerInformation.setHandlingAgency("0000100"); + customerInformation.setSerialNumber("0000000150101"); + customerInformation.setHandlingTeller("000000015"); + } + //数据保存 + customerInformationMapper.insertSelective(customerInformation); + + return new ResultEntity<>(HttpStatus.OK); + + }else { + CustomerInformation information = informationList.get(0); + + //校验时候已经提交 + if (information.getSubState()==1) + { + return new ResultEntity<>(HttpStatus.OK,"提交成功",2); + } + + if (customerInformation.getSubState()==1) + { + customerInformation = submitByPersonBankCardCaculate(customerInformation); + customerInformation.setHandlingAgency("0000100"); + customerInformation.setSerialNumber("0000000150101"); + customerInformation.setHandlingTeller("000000015"); + } + + + String id = information.getId(); + + BeanUtils.copyProperties(customerInformation, information); + //当值ID为空被覆盖 + information.setId(id); + customerInformationMapper.updateByPrimaryKeySelective(information); + + return new ResultEntity<>(HttpStatus.OK,"提交成功",1); + } + + } + + + private CustomerInformation submitByPersonBankCardCaculate(CustomerInformation customerInformation) { + + String answer = redisUtil.get("bank" + "-个人银行卡业务" + "-录入客户信息"); + if (answer == null) { + CaseInfoExample caseInfoExample = new CaseInfoExample(); + caseInfoExample.createCriteria().andLargeModuleEqualTo("个人银行卡业务").andModuleEqualTo("录入客户信息").andNumberEqualTo(customerInformation.getNumber()); + List caseInfoList = caseInfoMapper.selectByExampleWithBLOBs(caseInfoExample); + if (!CollectionUtils.isEmpty(caseInfoList)) { + CaseInfo caseInfo = caseInfoList.get(0); + CaseAnswerInfoExample caseAnswerInfoExample = new CaseAnswerInfoExample(); + caseAnswerInfoExample.createCriteria().andCaseIdEqualTo(caseInfo.getCaseId()); + List answerInfoList = caseAnswerInfoMapper.selectByExampleWithBLOBs(caseAnswerInfoExample); + if (!CollectionUtils.isEmpty(answerInfoList)) { + String info = answerInfoList.get(0).getAnswer(); + redisUtil.set("bank" + "-个人银行卡业务" + "-录入客户信息",info,3600); + } + } + } + + // 解析 JSON 字符串 + CustomerInformationAnswerDTO answerDTO = JSON.parseObject(answer, CustomerInformationAnswerDTO.class); + + int errorNumber = 0; + //中文名称 + if (!answerDTO.getChName().equals(customerInformation.getChName())) { + errorNumber++; + } + //性别 + if (answerDTO.getSex()!=customerInformation.getSex()) { + errorNumber++; + } + //民群 + if (!answerDTO.getNationality().equals(customerInformation.getNationality())) { + errorNumber++; + } + + //证件类型 + if (!answerDTO.getIdType().equals(customerInformation.getIdType())) { + errorNumber++; + } + + //证件号码 + if (!answerDTO.getIdNumber().equals(customerInformation.getIdNumber())) { + errorNumber++; + } + + //期限类型 + if (!answerDTO.getDeadlineType().equals(customerInformation.getDeadlineType())) { + errorNumber++; + } + + //出生日期 + if (answerDTO.getBirthday().compareTo(customerInformation.getBirthday()) != 0) { + errorNumber++; + } + + + //发证机关 + if (!answerDTO.getLicenceIssuAuth().equals(customerInformation.getLicenceIssuAuth())) { + errorNumber++; + } + + //有效开始日期 + if (answerDTO.getEffectiveStartDate().compareTo(answerDTO.getEffectiveStartDate()) != 0) { + errorNumber++; + } + + //有效终止日期 + if (answerDTO.getEffectiveEndDate().compareTo(answerDTO.getEffectiveEndDate()) != 0) { + errorNumber++; + } + + //户籍地址 + if (!answerDTO.getAddress().equals(customerInformation.getAddress())) { + errorNumber++; + } + + //通讯地址 + if (!answerDTO.getMailAddress().equals(customerInformation.getMailAddress())) { + errorNumber++; + } + //联系电话 + if (!answerDTO.getTel().equals(customerInformation.getTel())) { + errorNumber++; + } + + //错误次数 + customerInformation.setErrorNumber(errorNumber); + + return customerInformation; + + } + + //查询回显 + @Override + public ResultDataEntity getBaseInfoByPersonBankCard(String userId,Integer number) { + CustomerInformationExample example = new CustomerInformationExample(); + example.createCriteria().andUserIdEqualTo(userId).andNumberEqualTo(number); + List informationList = customerInformationMapper.selectByExample(example); + + if (CollectionUtils.isEmpty(informationList)) { + return new ResultDataEntity<>(HttpStatus.OK); + }else { + return new ResultDataEntity<>(HttpStatus.OK,"查询成功",informationList.get(0)); + } + } + + /* + * 开设银行卡-提交/保存 + * @param null + * @return + */ + + @Override + public ResultEntity submitByCreateCard(BankCardInformation bankCardInformation) { + + BankCardInformationExample example = new BankCardInformationExample(); + example.createCriteria().andUserIdEqualTo(bankCardInformation.getUserId()); + List bankCardInformationList = bankCardInformationMapper.selectByExample(example); + if (CollectionUtils.isEmpty(bankCardInformationList)) { + //首次提交 + bankCardInformation.setId(IdUtil.simpleUUID()); + if (bankCardInformation.getSubState()==1) + { + bankCardInformation = submitByCreateCardCaculate(bankCardInformation); + } + + bankCardInformationMapper.insertSelective(bankCardInformation); + return new ResultEntity<>(HttpStatus.OK,"提交成功"); + }else { + BankCardInformation bankCardInfo = bankCardInformationList.get(0); + + //校验时候已经提交 + if (bankCardInfo.getSubState()==1) + { + return new ResultEntity<>(HttpStatus.OK,"提交成功",2); + } + + if (bankCardInformation.getSubState()==1) + { + bankCardInformation = submitByCreateCardCaculate(bankCardInformation); + } + + + String id = bankCardInfo.getId(); + + BeanUtils.copyProperties(bankCardInformation, bankCardInfo); + //当值ID为空被覆盖 + bankCardInfo.setId(id); + bankCardInformationMapper.updateByPrimaryKeySelective(bankCardInfo); + + return new ResultEntity<>(HttpStatus.OK,"提交成功",1); + + } + + + } + //开设银行卡-提交计算 + private BankCardInformation submitByCreateCardCaculate(BankCardInformation bankCardInformation){ + + String answer = redisUtil.get("bank" + "-个人银行卡业务" + "-开设银行卡"); + if (answer == null) { + CaseInfoExample caseInfoExample = new CaseInfoExample(); + caseInfoExample.createCriteria().andLargeModuleEqualTo("个人银行卡业务").andModuleEqualTo("开设银行卡").andNumberEqualTo(bankCardInformation.getNumber()); + List caseInfoList = caseInfoMapper.selectByExampleWithBLOBs(caseInfoExample); + if (!CollectionUtils.isEmpty(caseInfoList)) { + CaseInfo caseInfo = caseInfoList.get(0); + CaseAnswerInfoExample caseAnswerInfoExample = new CaseAnswerInfoExample(); + caseAnswerInfoExample.createCriteria().andCaseIdEqualTo(caseInfo.getCaseId()); + List answerInfoList = caseAnswerInfoMapper.selectByExampleWithBLOBs(caseAnswerInfoExample); + if (!CollectionUtils.isEmpty(answerInfoList)) { + String info = answerInfoList.get(0).getAnswer(); + redisUtil.set("bank" + "-个人银行卡业务" + "-开设银行卡",info,3600); + } + } + } + + // 解析 JSON 字符串 + BankCardInformationAnswerDTO answerDTO = JSON.parseObject(answer, BankCardInformationAnswerDTO.class); + + if (bankCardInformation.getErrorNumber()==null) + { + bankCardInformation.setErrorNumber(0); + } + + int errorNumber = bankCardInformation.getErrorNumber(); + //币种 + if (!answerDTO.getCurrency().equals(bankCardInformation.getCurrency())) { + errorNumber++; + } + + //钞汇标志 + if (!answerDTO.getCurrencyExchangeSymbol().equals(bankCardInformation.getCurrencyExchangeSymbol())) { + errorNumber++; + } + + //分级类型 + if (!answerDTO.getClassifyType().equals(bankCardInformation.getClassifyType())) { + errorNumber++; + } + + //账户性质 + if (!answerDTO.getNatureAccount().equals(bankCardInformation.getNatureAccount())) { + errorNumber++; + } + + //凭证类型 + if (!answerDTO.getVoucherType().equals(bankCardInformation.getVoucherType())) { + errorNumber++; + } + + //支取密码 + if (!answerDTO.getWithdrawalPwd().equals(bankCardInformation.getWithdrawalPwd())) { + errorNumber++; + } + + //确认密码 + if (!answerDTO.getConfirmPassword().equals(bankCardInformation.getConfirmPassword())) { + errorNumber++; + } + + //错误次数 + bankCardInformation.setErrorNumber(errorNumber); + + return bankCardInformation; + + + } + + + + +}