|
|
@@ -1,12 +1,13 @@
|
|
|
package com.uas.platform.b2c.fa.payment.service.impl;
|
|
|
|
|
|
-import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
+import com.uas.platform.b2c.common.account.model.User;
|
|
|
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.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;
|
|
|
@@ -64,31 +65,27 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
public BankInfo save(BankInfo bankInfo, Integer type, FileUpload... fileItem) {
|
|
|
bankInfo.setOpraterUserType(type);
|
|
|
bankInfo.setCreateTime(new Date());
|
|
|
- if(type == Type.BUYER.value()) {
|
|
|
+ type = Type.SUP.value();
|
|
|
+ bankInfo.setStatus(Status.ALLOW.value());
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ if(user.getEnterprise() == null) {
|
|
|
if(bankInfo.getId() == null) {
|
|
|
- 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);
|
|
|
- if (bankInfo.getEnuu() == null) {
|
|
|
- bankInfo.setDissociative(Type.PERSONAL.value());
|
|
|
- } else {
|
|
|
- bankInfo.setDissociative(Type.ENTERPRISING.value());
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ list.add(Status.ALLOW.value());
|
|
|
+ int num = bankInfoDao.getCountByUseruuAndStatusAndDissociativeAndAccountType(user.getUserUU(), list, Type.PERSONAL.value(), bankInfo.getAccountType()) + 1;
|
|
|
+ bankInfo.setNum(num);
|
|
|
}
|
|
|
- bankInfo.setStatus(Status.ALLOW.value());
|
|
|
- }else if(type == Type.SUP.value()) {
|
|
|
- bankInfo.setEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ bankInfo.setUseruu(user.getUserUU());
|
|
|
+ bankInfo.setDissociative(Type.PERSONAL.value());
|
|
|
+ }else {
|
|
|
+ bankInfo.setEnuu(user.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.getCountByEnuuAndStatusAndDissociativeAndAccountType(user.getEnterprise().getUu(), statusList, Type.ENTERPRISING.value(), bankInfo.getAccountType());
|
|
|
bankInfo.setNum(count + 1);
|
|
|
}
|
|
|
+ }
|
|
|
+ if (AccountType.RECEIVE_TYPE.equals(bankInfo.getAccountType()) && (!sysConf.getEnUU().equals(bankInfo.getEnuu()))) {
|
|
|
bankInfo.setStatus(Status.SUBMITTED.value());
|
|
|
}
|
|
|
|
|
|
@@ -113,30 +110,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 操作人类型
|
|
|
@@ -145,13 +136,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
|
|
|
@@ -174,6 +166,8 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
final PageInfo pageInfo = new PageInfo(params);
|
|
|
pageInfo.filter("opraterUserType", operatorUserType);
|
|
|
pageInfo.filter("enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageInfo.filter("dissociative", Type.ENTERPRISING.value());
|
|
|
+ pageInfo.filter("accountType", AccountType.RECEIVE_TYPE);
|
|
|
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);
|
|
|
@@ -190,22 +184,27 @@ 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;
|
|
|
+ User user = SystemSession.getUser();
|
|
|
if(params.length == 0) {
|
|
|
- enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
|
|
|
+ enuu = user.getEnterprise() != null ? user.getEnterprise().getUu() : null;
|
|
|
}else {
|
|
|
enuu = params[0];
|
|
|
}
|
|
|
- if(operatorUserType == Type.BUYER.value()) {
|
|
|
- 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(user.getEnterprise() == null && enuu == null) {
|
|
|
+ return bankInfoDao.findByUseruuAndAccountTypeAndDissociativeAndStatusOrderByNumAsc(user.getUserUU(), AccountType.RECEIVE_TYPE, Type.PERSONAL.value(), status);
|
|
|
+ } else {
|
|
|
+ return bankInfoDao.findByEnuuAndStatusAndAccountTypeAndDissociativeOrderByNumAsc(enuu, status, AccountType.RECEIVE_TYPE, Type.ENTERPRISING.value());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -214,28 +213,10 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
return bankInfoDao.findOne(id);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<BankInfo> findBankInfoByUseruu(Long useruu, Long enuu, Integer opraterUserType) {
|
|
|
- return bankInfoDao.findByUseruuAndEnuuAndOpraterUserTypeAndStatusOrderByNumAsc(useruu, enuu, opraterUserType, Status.ALLOW.value());
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public BankInfo update(BankInfo bankInfo) {
|
|
|
return bankInfoDao.save(bankInfo);
|
|
|
}
|
|
|
-
|
|
|
- @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());
|
|
|
- size = bankInfoDao.getMallCountByEnuuAndStatus(bankInfo.getEnuu(),Type.MALL.value(), Status.ALLOW.value());
|
|
|
- bankInfo.setNum(++size);
|
|
|
- bankInfo.setStatus(Status.ALLOW.value());
|
|
|
- return bankInfoDao.save(bankInfo);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public void save(List<BankInfo> list) {
|
|
|
@@ -247,18 +228,18 @@ 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);
|
|
|
- BankInfo firstItem = bankInfos.get(0);
|
|
|
- if (firstItem.getStatus() == Status.ALLOW.value()){
|
|
|
- firstItem.setStatus(Status.EXPIRED.value());
|
|
|
+ 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);
|
|
|
+ if (AccountType.RECEIVE_TYPE.equals(baInfo.getAccountType())) {
|
|
|
+ BankInfo firstItem = bankInfos.get(0);
|
|
|
+ if (firstItem.getStatus() == Status.ALLOW.value()){
|
|
|
+ firstItem.setStatus(Status.EXPIRED.value());
|
|
|
+ }
|
|
|
+ baInfo.setStatus(Status.ALLOW.value());
|
|
|
+ bankInfoDao.save(baInfo);
|
|
|
}
|
|
|
- baInfo.setStatus(Status.ALLOW.value());
|
|
|
- bankInfoDao.save(baInfo);
|
|
|
}
|
|
|
setDefaultAccountAssist(bankInfos, id);
|
|
|
}
|
|
|
@@ -278,22 +259,22 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
bankInfoDao.save(bankInfos);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 返回的账户信息
|
|
|
+ * 获取制定账户的类型
|
|
|
*
|
|
|
- * @param operatorUserType 要获取的买家、卖家、平台账户
|
|
|
- * @param params 传入的企业uu,可能为空
|
|
|
+ * @param uu
|
|
|
+ * @param dissociative
|
|
|
+ * @param accountType
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<BankInfo> getEnterpriseBankInfo(Integer operatorUserType, Long... params) {
|
|
|
- Long enuu = null;
|
|
|
- if(params.length == 0) {
|
|
|
- enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- }else {
|
|
|
- enuu = params[0];
|
|
|
+ public List<BankInfo> getEnterpriseBankInfo(Long uu, Integer dissociative, String accountType) {
|
|
|
+ if (dissociative == Type.ENTERPRISING.value()) {
|
|
|
+ return bankInfoDao.findByEnuuAndAccountTypeAndDissociativeOrderByNumAsc(uu, accountType, dissociative);
|
|
|
+ } else {
|
|
|
+ return bankInfoDao.findByUseruuAndAccountTypeAndDissociativeOrderByNumAsc(uu, accountType, dissociative);
|
|
|
}
|
|
|
- return bankInfoDao.findByEnuuAndOpraterUserTypeOrderByNumAsc(enuu, operatorUserType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -350,21 +331,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());
|
|
|
- }
|
|
|
+ bankInfo.setStatus(Status.ALLOW.value());
|
|
|
+ bankInfo = bankInfoDao.save(bankInfo);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
@@ -382,22 +363,33 @@ public class BankInfoServiceImpl implements BankInfoService {
|
|
|
if (type != Type.MALL.value() && type != Type.BUYER.value() && type != Type.SUP.value()){
|
|
|
return new ResultMap(CodeType.ERROR_STATE, "类型不存在,确认要查找账户的类型");
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(number)){
|
|
|
+ if (StringUtils.isEmpty(number)) {
|
|
|
return new ResultMap(CodeType.NO_INFO, "银行账号丢失或为空,请确认银行账号");
|
|
|
}
|
|
|
Integer count = null;
|
|
|
- if (type == Type.BUYER.value()){
|
|
|
- Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
- if (enterprise != null){
|
|
|
- count = bankInfoDao.getBuyerCountByNumberAndEnuu(SystemSession.getUser().getUserUU(), enterprise.getUu(),
|
|
|
- Type.BUYER.value(), Status.ALLOW.value(), number);
|
|
|
- }else {
|
|
|
- count = bankInfoDao.getBuyerCountByNumberAndDissociative(SystemSession.getUser().getUserUU(), Type.PERSONAL.value(),
|
|
|
- Type.BUYER.value(), Status.ALLOW.value(), number);
|
|
|
- }
|
|
|
+ User user = SystemSession.getUser();
|
|
|
+ if (user.getEnterprise() != null) {
|
|
|
+ count = bankInfoDao.getSupCountByNumberAndDissociative(user.getEnterprise().getUu(), Type.ENTERPRISING.value(), Status.ALLOW.value(), number);
|
|
|
}else {
|
|
|
- count = bankInfoDao.getEnterpriseCountByNumberAndEnuu(SystemSession.getUser().getEnterprise().getUu(), type, statusList, number);
|
|
|
+ count = bankInfoDao.getBuyerCountByNumberAndDissociative(user.getUserUU(), Type.PERSONAL.value(), Status.ALLOW.value(), number);
|
|
|
}
|
|
|
return ResultMap.success(count);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取
|
|
|
+ *
|
|
|
+ * @param useruu
|
|
|
+ * @param enuu
|
|
|
+ * @param status
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BankInfo> getDefaultBankInfoByuuAndStatusAndAccountType(Long useruu, Long enuu, Integer status, String accountType) {
|
|
|
+ if (enuu == null) {
|
|
|
+ return bankInfoDao.findByUseruuAndAccountTypeAndDissociativeAndStatusOrderByNumAsc(useruu, accountType, Type.PERSONAL.value(), status);
|
|
|
+ } else {
|
|
|
+ return bankInfoDao.findByEnuuAndStatusAndAccountTypeAndDissociativeOrderByNumAsc(enuu, status, accountType, Type.ENTERPRISING.value());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|