|
|
@@ -3,19 +3,19 @@ package com.uas.platform.b2c.fa.payment.service.impl;
|
|
|
import com.uas.platform.b2c.common.base.model.FileUpload;
|
|
|
import com.uas.platform.b2c.common.base.service.FileService;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
+import com.uas.platform.b2c.core.constant.Status;
|
|
|
+import com.uas.platform.b2c.core.constant.Type;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.fa.payment.dao.BankInfoDao;
|
|
|
import com.uas.platform.b2c.fa.payment.model.BankInfo;
|
|
|
import com.uas.platform.b2c.fa.payment.service.BankInfoService;
|
|
|
import com.uas.platform.b2c.trade.support.CodeType;
|
|
|
import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
-import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
-import com.uas.platform.core.model.Status;
|
|
|
-import com.uas.platform.core.model.Type;
|
|
|
import com.uas.platform.core.persistence.criteria.CriterionExpression;
|
|
|
import com.uas.platform.core.persistence.criteria.LogicalExpression;
|
|
|
+import com.uas.platform.core.persistence.criteria.PredicateUtils;
|
|
|
import com.uas.platform.core.persistence.criteria.SimpleExpression;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -29,6 +29,8 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -48,27 +50,28 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
@Autowired
|
|
|
SysConf sysConf;
|
|
|
|
|
|
+ private final static List<Integer> statusList = Arrays.asList(Status.SUBMITTED.value(), Status.NOTALLOW.value(), Status.ALLOW.value(), Status.EXPIRED.value());
|
|
|
+
|
|
|
/**
|
|
|
- * 保存账户的信息
|
|
|
+ * 已修改,保存账户的信息
|
|
|
* @param bankInfo 需要保存的信息
|
|
|
- * @param personal 是否是个人,还是企业
|
|
|
* @param type [buyer, mall, sup]
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public BankInfo save(BankInfo bankInfo, boolean personal, Integer type, FileUpload... fileItem) {
|
|
|
+ public BankInfo save(BankInfo bankInfo, Integer type, FileUpload... fileItem) {
|
|
|
bankInfo.setOpraterUserType(type);
|
|
|
bankInfo.setCreateTime(new Date());
|
|
|
if(type == Type.BUYER.value()) {
|
|
|
- if (personal) {
|
|
|
- bankInfo.setType((short)1);
|
|
|
- } else {
|
|
|
- bankInfo.setType((short)2);
|
|
|
- }
|
|
|
if(bankInfo.getId() == null) {
|
|
|
- bankInfo.setNum(SystemSession.getUser().getEnterprise() != null ?
|
|
|
- bankInfoDao.getKindCountByUseruuAndStatus(SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu(), bankInfo.getType(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1 : bankInfoDao.getKindCountByUseruuAndStatusAndDissociative(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), bankInfo.getType(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1);
|
|
|
+ if (SystemSession.getUser().getEnterprise() != null){
|
|
|
+ int num = bankInfoDao.getCountByUseruuAndStatus(SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1;
|
|
|
+ bankInfo.setNum(num);
|
|
|
+ }else {
|
|
|
+ int num = bankInfoDao.getCountByUseruuAndStatusAndDissociative(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1;
|
|
|
+ bankInfo.setNum(num);
|
|
|
+ }
|
|
|
}
|
|
|
bankInfo.setUseruu(SystemSession.getUser().getUserUU());
|
|
|
bankInfo.setEnuu(SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null);
|
|
|
@@ -80,14 +83,10 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
bankInfo.setStatus(Status.ALLOW.value());
|
|
|
}else if(type == Type.SUP.value()) {
|
|
|
bankInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- bankInfo.setType((short)2);
|
|
|
+ bankInfo.setDissociative(Type.ENTERPRISING.value());
|
|
|
if(bankInfo.getId() == null) {
|
|
|
- int count = bankInfoDao.getKindCountByEnuuAndStatus(SystemSession.getUser().getEnterprise().getUu(), bankInfo.getType(), bankInfo.getOpraterUserType(), Status.ALLOW.value());
|
|
|
- if(count > 0) {
|
|
|
- throw new IllegalOperatorException("供应商企业账户只能保存一条,请删除之后重新操作");
|
|
|
- }
|
|
|
- int num = bankInfoDao.getKindCountByEnuuAndStatus(SystemSession.getUser().getEnterprise().getUu(), bankInfo.getType(), bankInfo.getOpraterUserType(), Status.SUBMITTED.value());
|
|
|
- bankInfo.setNum(num + 1);
|
|
|
+ int count = bankInfoDao.getCountByEnuuAndStatus(SystemSession.getUser().getEnterprise().getUu(), bankInfo.getOpraterUserType(), statusList);
|
|
|
+ bankInfo.setNum(count + 1);
|
|
|
}
|
|
|
bankInfo.setStatus(Status.SUBMITTED.value());
|
|
|
}
|
|
|
@@ -100,6 +99,10 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
return bankInfoDao.save(bankInfo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 已修改,删除账户信息,取出对应账户信息排序
|
|
|
+ * @param id the id
|
|
|
+ */
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void delete(Long id) {
|
|
|
@@ -109,15 +112,20 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
baInfo.setStatus(Status.DELETED.value());
|
|
|
bankInfoDao.save(baInfo);
|
|
|
int i = 1;
|
|
|
- if (baInfo.getType() == 2) {
|
|
|
- List<BankInfo> list = bankInfoDao.findByEnuuAndTypeAndStatusAndOpraterUserTypeOrderByNumAsc(baInfo.getEnuu(), (short)2, Status.ALLOW.value(), baInfo.getOpraterUserType());
|
|
|
+ if (baInfo.getOpraterUserType() == Type.BUYER.value()){
|
|
|
+ List<BankInfo> list = new ArrayList<>();
|
|
|
+ if (baInfo.getEnuu() != null){
|
|
|
+ list = bankInfoDao.findByUseruuAndEnuuAndOpraterUserTypeAndStatusOrderByNumAsc(baInfo.getUseruu(), baInfo.getEnuu(), baInfo.getOpraterUserType(), Status.ALLOW.value());
|
|
|
+ }else {
|
|
|
+ list = bankInfoDao.findByUseruuAndDissociativeAndOpraterUserTypeAndStatusOrderByNumAsc(baInfo.getUseruu(), Type.PERSONAL.value(), baInfo.getOpraterUserType(), Status.ALLOW.value());
|
|
|
+ }
|
|
|
for (BankInfo bankInfo : list) {
|
|
|
bankInfo.setNum(i);
|
|
|
i++;
|
|
|
}
|
|
|
bankInfoDao.save(list);
|
|
|
- } else {
|
|
|
- List<BankInfo> list = bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(baInfo.getUseruu(), baInfo.getEnuu(), (short)1, baInfo.getOpraterUserType(), Status.ALLOW.value());
|
|
|
+ } else if (baInfo.getOpraterUserType() == Type.SUP.value()){
|
|
|
+ List<BankInfo> list = bankInfoDao.findSupBankList(baInfo.getEnuu(), baInfo.getOpraterUserType(), statusList);
|
|
|
for (BankInfo bankInfo : list) {
|
|
|
bankInfo.setNum(i);
|
|
|
i++;
|
|
|
@@ -127,34 +135,78 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 已修改,分页获取买家账户信息
|
|
|
+ * @param params
|
|
|
+ * @param operatorUserType 操作人类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<BankInfo> getPersonBankInfo(Integer operatorUserType) {
|
|
|
- if (SystemSession.getUser().getEnterprise() != null) {
|
|
|
- return bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu(), (short)1, operatorUserType, Status.ALLOW.value());
|
|
|
- } else {
|
|
|
- return bankInfoDao.findByUseruuAndDissociativeAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), (short)1, operatorUserType, Status.ALLOW.value());
|
|
|
+ public Page<BankInfo> getPersonBankInfo(PageParams params, Integer operatorUserType) {
|
|
|
+ final PageInfo pageInfo = new PageInfo(params);
|
|
|
+ pageInfo.filter("opraterUserType", operatorUserType);
|
|
|
+ pageInfo.filter("useruu", SystemSession.getUser().getUserUU());
|
|
|
+ if (SystemSession.getUser().getEnterprise() != null){
|
|
|
+ pageInfo.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ }else {
|
|
|
+ pageInfo.filter("dissociative", Type.PERSONAL.value());
|
|
|
}
|
|
|
-
|
|
|
+ pageInfo.filter("status", Status.ALLOW.value());
|
|
|
+ return bankInfoDao.findAll(new Specification<BankInfo>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<BankInfo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ query.where(pageInfo.getPredicates(root, query, cb));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 已修改,分页获取卖家账户信息
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @param operatorUserType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public List<BankInfo> getEnterpriseBankInfoContainsStatus(Integer operatorUserType, Integer status, Long... params) {
|
|
|
- Long enuu = null;
|
|
|
- if(params.length == 0) {
|
|
|
- enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
|
|
|
- }else {
|
|
|
- enuu = params[0];
|
|
|
- }
|
|
|
- if(operatorUserType == Type.BUYER.value()) {
|
|
|
- if (enuu != null) {
|
|
|
- return bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), enuu, (short)2, operatorUserType, status);
|
|
|
- } else {
|
|
|
- return bankInfoDao.findByUseruuAndDissociativeAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), (short)2, operatorUserType, status);
|
|
|
+ public Page<BankInfo> getSupBankInfo(PageParams params, Integer operatorUserType) {
|
|
|
+ final PageInfo pageInfo = new PageInfo(params);
|
|
|
+ pageInfo.filter("opraterUserType", operatorUserType);
|
|
|
+ pageInfo.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SimpleExpression expression1 = new SimpleExpression("status", Status.SUBMITTED.value(), CriterionExpression.Operator.EQ);
|
|
|
+ SimpleExpression expression2 = new SimpleExpression("status", Status.NOTALLOW.value(), CriterionExpression.Operator.EQ);
|
|
|
+ SimpleExpression expression3 = new SimpleExpression("status", Status.ALLOW.value(), CriterionExpression.Operator.EQ);
|
|
|
+ SimpleExpression expression4 = new SimpleExpression("status", Status.EXPIRED.value(), CriterionExpression.Operator.EQ);
|
|
|
+ SimpleExpression[] expressions = new SimpleExpression[]{expression1, expression2, expression3, expression4};
|
|
|
+ pageInfo.expression(PredicateUtils.or(expressions));
|
|
|
+
|
|
|
+ return bankInfoDao.findAll(new Specification<BankInfo>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<BankInfo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ query.where(pageInfo.getPredicates(root, query, cb));
|
|
|
+ return null;
|
|
|
}
|
|
|
- }else {
|
|
|
- return bankInfoDao.findByEnuuAndTypeAndStatusAndOpraterUserTypeOrderByNumAsc(enuu, (short)2, status, operatorUserType);
|
|
|
- }
|
|
|
+ }, pageInfo);
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<BankInfo> getEnterpriseBankInfoContainsStatus(Integer operatorUserType, Integer status, Long... params) {
|
|
|
+// Long enuu = null;
|
|
|
+// if(params.length == 0) {
|
|
|
+// enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
|
|
|
+// }else {
|
|
|
+// enuu = params[0];
|
|
|
+// }
|
|
|
+// if(operatorUserType == Type.BUYER.value()) {
|
|
|
+// if (enuu != null) {
|
|
|
+// return bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), enuu, (short)2, operatorUserType, status);
|
|
|
+// } else {
|
|
|
+// return bankInfoDao.findByUseruuAndDissociativeAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), (short)2, operatorUserType, status);
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// return bankInfoDao.findByEnuuAndTypeAndStatusAndOpraterUserTypeOrderByNumAsc(enuu, (short)2, status, operatorUserType);
|
|
|
+// }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -164,7 +216,8 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
|
|
|
@Override
|
|
|
public List<BankInfo> findBankInfoByUseruu(Long useruu, Long enuu, Integer opraterUserType) {
|
|
|
- return bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(useruu, enuu, (short)1, opraterUserType, Status.ALLOW.value());
|
|
|
+// return bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(useruu, enuu, (short)1, opraterUserType, Status.ALLOW.value());
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -175,26 +228,27 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public BankInfo saveB2cAccount(BankInfo bankInfo, Integer operatorType, boolean isPersonal) {
|
|
|
- int size = 0;
|
|
|
- bankInfo.setOpraterUserType(Type.MALL.value());
|
|
|
- bankInfo.setEnuu(sysConf.getEnUU());
|
|
|
- bankInfo.setCreateTime(new Date());
|
|
|
- if(isPersonal) {
|
|
|
- bankInfo.setUseruu(sysConf.getAdminUU());
|
|
|
- bankInfo.setType((short)1);
|
|
|
- }else {
|
|
|
- bankInfo.setType((short)2);
|
|
|
- }
|
|
|
- if(bankInfo.getType() == 2) {
|
|
|
- size = bankInfoDao.getKindCountByEnuuAndStatus(bankInfo.getEnuu(), (short)2, Type.MALL.value(), Status.ALLOW.value());
|
|
|
- }else if(bankInfo.getType() == 1) {
|
|
|
- size = bankInfoDao.getKindCountByUseruuAndStatus(bankInfo.getUseruu(), bankInfo.getEnuu(), (short)1, Type.MALL.value(), Status.ALLOW.value());
|
|
|
- }else {
|
|
|
- new IllegalOperatorException("没有给账户设置对应的类型");
|
|
|
- }
|
|
|
- bankInfo.setNum(++size);
|
|
|
- bankInfo.setStatus(Status.ALLOW.value());
|
|
|
- return bankInfoDao.save(bankInfo);
|
|
|
+// int size = 0;
|
|
|
+// bankInfo.setOpraterUserType(Type.MALL.value());
|
|
|
+// bankInfo.setEnuu(sysConf.getEnUU());
|
|
|
+// bankInfo.setCreateTime(new Date());
|
|
|
+// if(isPersonal) {
|
|
|
+// bankInfo.setUseruu(sysConf.getAdminUU());
|
|
|
+// bankInfo.setType((short)1);
|
|
|
+// }else {
|
|
|
+// bankInfo.setType((short)2);
|
|
|
+// }
|
|
|
+// if(bankInfo.getType() == 2) {
|
|
|
+// size = bankInfoDao.getKindCountByEnuuAndStatus(bankInfo.getEnuu(), (short)2, Type.MALL.value(), Status.ALLOW.value());
|
|
|
+// }else if(bankInfo.getType() == 1) {
|
|
|
+// size = bankInfoDao.getKindCountByUseruuAndStatus(bankInfo.getUseruu(), bankInfo.getEnuu(), (short)1, Type.MALL.value(), Status.ALLOW.value());
|
|
|
+// }else {
|
|
|
+// new IllegalOperatorException("没有给账户设置对应的类型");
|
|
|
+// }
|
|
|
+// bankInfo.setNum(++size);
|
|
|
+// bankInfo.setStatus(Status.ALLOW.value());
|
|
|
+// return bankInfoDao.save(bankInfo);
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -205,22 +259,21 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void setDefaultAccount(Long id) {
|
|
|
- BankInfo account = bankInfoDao.findOne(id);
|
|
|
+ BankInfo baInfo = bankInfoDao.findOne(id);
|
|
|
List<BankInfo> bankInfos = null;
|
|
|
- if(account.getOpraterUserType() == Type.BUYER.value()) {
|
|
|
- bankInfos = bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(account.getUseruu(), account.getEnuu(), account.getType(), account.getOpraterUserType(), account.getStatus());
|
|
|
- }else if(account.getOpraterUserType() == Type.SUP.value()){
|
|
|
- bankInfos = bankInfoDao.findByEnuuAndTypeAndStatusAndOpraterUserTypeOrderByNumAsc(account.getEnuu(), account.getType(), account.getStatus(), account.getOpraterUserType());
|
|
|
- }else if(account.getOpraterUserType() == Type.MALL.value()) {
|
|
|
- if(account.getType() == 2) {
|
|
|
- bankInfos = bankInfoDao.findByEnuuAndTypeAndStatusAndOpraterUserTypeOrderByNumAsc(account.getEnuu(), account.getType(), account.getStatus(), account.getOpraterUserType());
|
|
|
- } else {
|
|
|
- if(account.getType() == 1) {
|
|
|
- bankInfos = bankInfoDao.findByUseruuAndEnuuAndTypeAndOpraterUserTypeAndStatusOrderByNumAsc(account.getUseruu(), account.getEnuu(), account.getType(), account.getOpraterUserType(),account.getStatus());
|
|
|
- }
|
|
|
+ if (baInfo.getOpraterUserType() == Type.BUYER.value()){
|
|
|
+ //只有买家账户才涉及到默认账户
|
|
|
+ bankInfos = bankInfoDao.findByUseruuAndEnuuAndOpraterUserTypeAndStatusOrderByNumAsc(baInfo.getUseruu(), baInfo.getEnuu(), baInfo.getOpraterUserType(), Status.ALLOW.value());
|
|
|
+ }else if (baInfo.getOpraterUserType() == Type.SUP.value()){
|
|
|
+ //卖家账户重新使用
|
|
|
+ bankInfos = bankInfoDao.findSupBankList(baInfo.getEnuu(), baInfo.getOpraterUserType(), statusList);
|
|
|
+ BankInfo firstItem = bankInfos.get(0);
|
|
|
+ if (firstItem.getStatus() == Status.ALLOW.value()){
|
|
|
+ firstItem.setStatus(Status.EXPIRED.value());
|
|
|
}
|
|
|
+ baInfo.setStatus(Status.ALLOW.value());
|
|
|
+ bankInfoDao.save(baInfo);
|
|
|
}
|
|
|
-
|
|
|
setDefaultAccountAssist(bankInfos, id);
|
|
|
}
|
|
|
|
|
|
@@ -254,7 +307,8 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
}else {
|
|
|
enuu = params[0];
|
|
|
}
|
|
|
- return bankInfoDao.findByEnuuAndTypeAndOpraterUserTypeOrderByNumAsc(enuu, (short)2, operatorUserType);
|
|
|
+// return bankInfoDao.findByEnuuAndTypeAndOpraterUserTypeOrderByNumAsc(enuu, (short)2, operatorUserType);
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -308,15 +362,22 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
return new ResultMap(CodeType.NOT_EXiST, "操作的实体不存在");
|
|
|
}
|
|
|
if(bankInfo.getStatus() != Status.SUBMITTED.value()) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT, "该账户信息不是已经交状态,不能审核");
|
|
|
+ return new ResultMap(CodeType.NOT_PERMIT, "该账户信息不是已提交状态,不能审核");
|
|
|
}
|
|
|
if(status == Status.ALLOW.value()) { //审核通过
|
|
|
- if(bankInfo.getOpraterUserType().intValue() == Type.SUP.value()) {
|
|
|
- int num = bankInfoDao.getKindCountByEnuuAndStatus(bankInfo.getEnuu(), bankInfo.getType(), Type.SUP.value(), Status.ALLOW.value());
|
|
|
- if(num > 0) {
|
|
|
- return new ResultMap(CodeType.NOT_PERMIT, "该公司的银行账户已经存在了,不能再增加了");
|
|
|
+ if(bankInfo.getOpraterUserType() == Type.SUP.value()) {
|
|
|
+ //获取已通过且为已使用状态的账户信息
|
|
|
+ List<BankInfo> infoList = bankInfoDao.findSupBankList(bankInfo.getEnuu(), bankInfo.getOpraterUserType(), statusList);
|
|
|
+ if (!CollectionUtils.isEmpty(infoList)){
|
|
|
+ BankInfo first = infoList.get(0); //获取第一个账户信息
|
|
|
+ if (first.getStatus() == Status.ALLOW.value()){
|
|
|
+ //已有使用中的账户
|
|
|
+ first.setStatus(Status.EXPIRED.value());
|
|
|
+ setDefaultAccountAssist(infoList, bankInfo.getId());
|
|
|
+ }else {
|
|
|
+ setDefaultAccountAssist(infoList, bankInfo.getId());
|
|
|
+ }
|
|
|
}
|
|
|
- bankInfo.setNum(1);
|
|
|
bankInfo.setStatus(Status.ALLOW.value());
|
|
|
bankInfo = bankInfoDao.save(bankInfo);
|
|
|
}
|