|
|
@@ -7,6 +7,7 @@ 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.constant.AccountType;
|
|
|
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;
|
|
|
@@ -30,7 +31,6 @@ 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;
|
|
|
@@ -65,21 +65,23 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
bankInfo.setOpraterUserType(type);
|
|
|
bankInfo.setCreateTime(new Date());
|
|
|
type = Type.SUP.value();
|
|
|
+ bankInfo.setStatus(Status.ALLOW.value());
|
|
|
if(SystemSession.getUser().getEnterprise() == null) {
|
|
|
if(bankInfo.getId() == null) {
|
|
|
- int num = bankInfoDao.getCountByUseruuAndStatusAndDissociative(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), bankInfo.getOpraterUserType(), Status.ALLOW.value()) + 1;
|
|
|
+ int num = bankInfoDao.getCountByUseruuAndStatusAndDissociativeAndAccountType(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), bankInfo.getOpraterUserType(), Status.ALLOW.value(), bankInfo.getAccountType()) + 1;
|
|
|
bankInfo.setNum(num);
|
|
|
}
|
|
|
bankInfo.setUseruu(SystemSession.getUser().getUserUU());
|
|
|
bankInfo.setDissociative(Type.PERSONAL.value());
|
|
|
- bankInfo.setStatus(Status.ALLOW.value());
|
|
|
}else {
|
|
|
bankInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
bankInfo.setDissociative(Type.ENTERPRISING.value());
|
|
|
if(bankInfo.getId() == null) {
|
|
|
- int count = bankInfoDao.getCountByEnuuAndStatus(SystemSession.getUser().getEnterprise().getUu(), bankInfo.getOpraterUserType(), statusList);
|
|
|
+ int count = bankInfoDao.getCountByEnuuAndStatusAndAccountType(SystemSession.getUser().getEnterprise().getUu(), bankInfo.getOpraterUserType(), statusList, bankInfo.getAccountType());
|
|
|
bankInfo.setNum(count + 1);
|
|
|
}
|
|
|
+ }
|
|
|
+ if (AccountType.RECEIVE_TYPE.equals(bankInfo.getAccountType())) {
|
|
|
bankInfo.setStatus(Status.SUBMITTED.value());
|
|
|
}
|
|
|
|
|
|
@@ -104,30 +106,24 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
baInfo.setStatus(Status.DELETED.value());
|
|
|
bankInfoDao.save(baInfo);
|
|
|
int i = 1;
|
|
|
- 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 if (baInfo.getOpraterUserType() == Type.SUP.value()){
|
|
|
- List<BankInfo> list = bankInfoDao.findSupBankList(baInfo.getEnuu(), baInfo.getOpraterUserType(), statusList);
|
|
|
- for (BankInfo bankInfo : list) {
|
|
|
- bankInfo.setNum(i);
|
|
|
- i++;
|
|
|
- }
|
|
|
+ List<BankInfo> list = null;
|
|
|
+ if (baInfo.getDissociative() == Type.PERSONAL.value()){
|
|
|
+ list = bankInfoDao.findByUseruuAndAccountTypeAndDissociativeAndStatusOrderByNumAsc(baInfo.getUseruu(), baInfo.getAccountType(), baInfo.getDissociative(), Status.ALLOW.value());
|
|
|
+ } else {
|
|
|
+ list = bankInfoDao.findSupBankList(baInfo.getEnuu(), baInfo.getDissociative(), baInfo.getAccountType(), statusList);
|
|
|
+ }
|
|
|
+ for (BankInfo bankInfo : list) {
|
|
|
+ bankInfo.setNum(i);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
bankInfoDao.save(list);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 默认获取付款账户
|
|
|
* 已修改,分页获取买家账户信息
|
|
|
* @param params
|
|
|
* @param operatorUserType 操作人类型
|
|
|
@@ -136,13 +132,14 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
@Override
|
|
|
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 {
|
|
|
+ if (SystemSession.getUser().getEnterprise() == null) {
|
|
|
pageInfo.filter("dissociative", Type.PERSONAL.value());
|
|
|
+ pageInfo.filter("useruu", SystemSession.getUser().getUserUU());
|
|
|
+ } else {
|
|
|
+ pageInfo.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageInfo.filter("dissociative", Type.ENTERPRISING.value());
|
|
|
}
|
|
|
+ pageInfo.filter("accountType", AccountType.PAY_TYPE);
|
|
|
pageInfo.filter("status", Status.ALLOW.value());
|
|
|
return bankInfoDao.findAll(new Specification<BankInfo>() {
|
|
|
@Override
|
|
|
@@ -181,6 +178,13 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
}, pageInfo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 这个账户默认获取收款账户
|
|
|
+ * @param operatorUserType 操作人类型
|
|
|
+ * @param status 状态
|
|
|
+ * @param params 传入的企业uu,可能为空
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public List<BankInfo> getEnterpriseBankInfoContainsStatus(Integer operatorUserType, Integer status, Long... params) {
|
|
|
Long enuu = null;
|
|
|
@@ -190,14 +194,10 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
enuu = params[0];
|
|
|
}
|
|
|
//如果是个人用户登录
|
|
|
- if(SystemSession.getUser().getEnterprise() == null) {
|
|
|
- if (enuu != null) {
|
|
|
- return bankInfoDao.findByUseruuAndEnuuAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), enuu, operatorUserType, status);
|
|
|
- } else {
|
|
|
- return bankInfoDao.findByUseruuAndDissociativeAndOpraterUserTypeAndStatusOrderByNumAsc(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), operatorUserType, status);
|
|
|
- }
|
|
|
- }else {
|
|
|
- return bankInfoDao.findByEnuuAndStatusAndOpraterUserTypeOrderByNumAsc(enuu, status, operatorUserType);
|
|
|
+ if(SystemSession.getUser().getEnterprise() == null && enuu == null) {
|
|
|
+ return bankInfoDao.findByUseruuAndDissociativeAndOpraterUserTypeAndStatusAndAccountTypeOrderByNumAsc(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(), operatorUserType, AccountType.RECEIVE_TYPE, status);
|
|
|
+ } else {
|
|
|
+ return bankInfoDao.findByEnuuAndStatusAndOpraterUserTypeAndAccountTypeOrderByNumAsc(enuu, status, operatorUserType, AccountType.RECEIVE_TYPE);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -239,12 +239,10 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
public void setDefaultAccount(Long id) {
|
|
|
BankInfo baInfo = bankInfoDao.findOne(id);
|
|
|
List<BankInfo> bankInfos = null;
|
|
|
- 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);
|
|
|
+ if (baInfo.getDissociative() == Type.PERSONAL.value()){
|
|
|
+ bankInfos = bankInfoDao.findByUseruuAndAccountTypeAndDissociativeAndStatusOrderByNumAsc(baInfo.getUseruu(), baInfo.getAccountType(), baInfo.getDissociative(), Status.ALLOW.value());
|
|
|
+ } else {
|
|
|
+ bankInfos = bankInfoDao.findSupBankList(baInfo.getEnuu(), baInfo.getDissociative(), baInfo.getAccountType(), statusList);
|
|
|
BankInfo firstItem = bankInfos.get(0);
|
|
|
if (firstItem.getStatus() == Status.ALLOW.value()){
|
|
|
firstItem.setStatus(Status.EXPIRED.value());
|
|
|
@@ -342,21 +340,21 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
return new ResultMap(CodeType.NOT_PERMIT, "该账户信息不是已提交状态,不能审核");
|
|
|
}
|
|
|
if(status == Status.ALLOW.value()) { //审核通过
|
|
|
- if(bankInfo.getOpraterUserType() == Type.SUP.value()) {
|
|
|
- bankInfo.setStatus(Status.ALLOW.value());
|
|
|
- bankInfo = bankInfoDao.save(bankInfo);
|
|
|
- //获取所有的账户信息
|
|
|
- List<BankInfo> infoList = bankInfoDao.findSupBankList(bankInfo.getEnuu(), bankInfo.getOpraterUserType(), statusList);
|
|
|
- if (!CollectionUtils.isEmpty(infoList) && infoList.size() > 1){
|
|
|
- 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());
|
|
|
- }
|
|
|
+ List<BankInfo> infoList = null;
|
|
|
+ if (bankInfo.getDissociative() == Type.PERSONAL.value()){
|
|
|
+ infoList = bankInfoDao.findByUseruuAndAccountTypeAndDissociativeAndStatusOrderByNumAsc(bankInfo.getUseruu(), bankInfo.getAccountType(), bankInfo.getDissociative(), Status.ALLOW.value());
|
|
|
+ } else {
|
|
|
+ infoList = bankInfoDao.findSupBankList(bankInfo.getEnuu(), bankInfo.getDissociative(), bankInfo.getAccountType(), statusList);
|
|
|
+ }
|
|
|
+ bankInfo.setStatus(Status.ALLOW.value());
|
|
|
+ bankInfo = bankInfoDao.save(bankInfo);
|
|
|
+ if (!CollectionUtils.isEmpty(infoList) && infoList.size() > 1){
|
|
|
+ BankInfo first = infoList.get(0); //获取第一个账户信息
|
|
|
+ if (first.getStatus() == Status.ALLOW.value()){
|
|
|
+ //已有使用中的账户
|
|
|
+ first.setStatus(Status.EXPIRED.value());
|
|
|
}
|
|
|
+ setDefaultAccountAssist(infoList, bankInfo.getId());
|
|
|
}
|
|
|
}else if(status == Status.NOTALLOW.value()){
|
|
|
if(str == null || str.length == 0) {
|