...
|
...
|
@@ -75,10 +75,11 @@ public class SellerEnterApplyService { |
|
|
* @param uid
|
|
|
* @param orderCode
|
|
|
*/
|
|
|
public void applySuperEntry(Integer uid, Long orderCode, EntrySellerType targetEST){
|
|
|
public SellerEnterApply applySuperEntry(Integer uid, Long orderCode, EntrySellerType targetEST){
|
|
|
logger.info("in applySuperEntry uid {} orderCode {} targetEST {}", uid, orderCode, targetEST);
|
|
|
|
|
|
if (Objects.isNull(orderCode)){
|
|
|
SellerEnterApply sea = null;
|
|
|
boolean orderCodeIsNull;
|
|
|
if (orderCodeIsNull = Objects.isNull(orderCode)){
|
|
|
logger.warn("in applySuperEntry uid {} orderCode is null targetEST {}", uid, targetEST);
|
|
|
//throw new UfoServiceException(400, "orderCode is null");
|
|
|
}
|
...
|
...
|
@@ -90,7 +91,7 @@ public class SellerEnterApplyService { |
|
|
||Objects.equals(targetEST, EntrySellerType.SPECIAL_SUPER)){
|
|
|
logger.warn("in applySuperEntry no need apply uid {} orderCode {} targetEST {}",
|
|
|
uid, orderCode, targetEST);
|
|
|
return;
|
|
|
return sea;
|
|
|
}
|
|
|
|
|
|
SellerWrapper sellerWrapper = new SellerWrapper(uid,logger)
|
...
|
...
|
@@ -105,7 +106,7 @@ public class SellerEnterApplyService { |
|
|
if(Objects.equals(estCode=currentEST.getCode(), targetEST.getCode())){
|
|
|
logger.info("applySuperEntry own same level uid {} orderCode {} current EST {} target EST {}",
|
|
|
uid, orderCode, currentEST, targetEST);
|
|
|
return;
|
|
|
return sea;
|
|
|
}
|
|
|
|
|
|
StoredSeller storedSeller = sellerWrapper.getStoredSeller();
|
...
|
...
|
@@ -128,22 +129,26 @@ public class SellerEnterApplyService { |
|
|
condition.setUid(uid);
|
|
|
condition.setPreEnterType(estCode);
|
|
|
condition.setEnterType(targetEST.getCode());
|
|
|
//查询 当前身份和目标身份一致的申请
|
|
|
List<SellerEnterApply> seaList = sellerEnterApplyMapper.selectByUOCET(condition);
|
|
|
//是否已经申请
|
|
|
if (CollectionUtils.isNotEmpty(seaList)){
|
|
|
//有记录
|
|
|
SellerEnterApply msea = findSellerEnterApply(uid, orderCode, targetEST, seaList);
|
|
|
addOrUpdate(msea, uid, orderCode, currentEST, targetEST);
|
|
|
sea = addOrUpdate(msea, uid, orderCode, currentEST, targetEST);
|
|
|
}else{
|
|
|
//没有申请过 => 第一次申请
|
|
|
logger.info("applySuperEntry no one apply of waiting audit then add new, uid {} orderCode {} targetEST {} ",
|
|
|
uid, orderCode, targetEST);
|
|
|
//create new apply
|
|
|
add(uid, orderCode, currentEST, targetEST);
|
|
|
sea = add(uid, orderCode, currentEST, targetEST);
|
|
|
}
|
|
|
return sea;
|
|
|
}
|
|
|
|
|
|
private int addOrUpdate(SellerEnterApply msea,Integer uid, Long orderCode,
|
|
|
private SellerEnterApply addOrUpdate(SellerEnterApply msea,
|
|
|
Integer uid,
|
|
|
Long orderCode,
|
|
|
EntrySellerType currentEST, EntrySellerType targetEST){
|
|
|
if (Objects.isNull(msea)){
|
|
|
logger.info("addOrUpdate no one apply of waiting audit then add new, uid {} orderCode {} targetEST {} ",
|
...
|
...
|
@@ -154,7 +159,7 @@ public class SellerEnterApplyService { |
|
|
//update matched one
|
|
|
logger.info("addOrUpdate one apply waiting audit then update uid {} orderCode {} targetEST {} matched SellerEnterApply {}",
|
|
|
uid, orderCode, targetEST, msea);
|
|
|
return update(msea.getId(),orderCode, currentEST, targetEST);
|
|
|
return update(msea);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -173,22 +178,27 @@ public class SellerEnterApplyService { |
|
|
seac.setUid(uid);
|
|
|
seac.setOrderCode(orderCode);
|
|
|
List<SellerEnterApply> seaList = sellerEnterApplyMapper.selectByUOCET(seac);
|
|
|
doAudit(uid, orderCode, left, seaList);
|
|
|
if (seaList.size() > 1) {
|
|
|
logger.warn("in audit one orderCode mapped multiple apply,uid {} orderCode {}", uid, orderCode);
|
|
|
}
|
|
|
SellerEnterApply msea = seaList.get(0);
|
|
|
doAudit(uid, orderCode, left, msea);
|
|
|
}
|
|
|
|
|
|
|
|
|
public void doAudit(int uid, Long orderCode, BigDecimal left, List<SellerEnterApply> seaList){
|
|
|
private void doAudit(int uid, Long orderCode, BigDecimal left, SellerEnterApply msea){
|
|
|
|
|
|
//卖家包装类
|
|
|
SellerWrapper sellerWrapper = new SellerWrapper(uid,logger)
|
|
|
.storedSellerDataSource(storedSellerMapper::selectByUid)
|
|
|
.addSpecialSuperFunc(sellerService::isSpecialSuper)
|
|
|
.buildBase();
|
|
|
upgradeLevel(sellerWrapper, orderCode, left, seaList);
|
|
|
upgradeLevel(sellerWrapper, orderCode, left, msea);
|
|
|
}
|
|
|
|
|
|
public void upgradeLevel(SellerWrapper sellerWrapper,
|
|
|
Long orderCode, BigDecimal left, List<SellerEnterApply> seaList){
|
|
|
Long orderCode, BigDecimal left,
|
|
|
SellerEnterApply msea){
|
|
|
int uid = sellerWrapper.getUid();
|
|
|
//是否有申请记录
|
|
|
//有两种:
|
...
|
...
|
@@ -197,29 +207,41 @@ public class SellerEnterApplyService { |
|
|
// 1.2 普通充值没有申请记录
|
|
|
// 2. client 直接升级,根据请求的目标身份
|
|
|
//existApply 为false 只会是普通充值订单
|
|
|
boolean existApply = CollectionUtils.isNotEmpty(seaList);
|
|
|
boolean existApply = Objects.nonNull(msea);
|
|
|
logger.info("in upgradeLevel uid {} orderCode {} left wallet {} existApply {}",
|
|
|
uid, orderCode, left, existApply );
|
|
|
if (existApply){
|
|
|
processApplyOrder(sellerWrapper, left, orderCode, seaList);
|
|
|
processApplyOrder(sellerWrapper, left, orderCode, msea);
|
|
|
}else {
|
|
|
processCommonChargeOrder(sellerWrapper, orderCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 当卖家钱包余额充足时,直接升级
|
|
|
* @param sellerWrapper
|
|
|
* @param orderCode
|
|
|
* @param targetEST
|
|
|
*/
|
|
|
public void upgradeLevelIfFatWallet(SellerWrapper sellerWrapper, Long orderCode,
|
|
|
EntrySellerType targetEST){
|
|
|
Integer uid = sellerWrapper.getUid();
|
|
|
BigDecimal leftInWallet = sellerWrapper.getLeftInWallet();
|
|
|
SellerEnterApply sea = this.applySuperEntry(uid, orderCode, targetEST);
|
|
|
this.upgradeLevel(sellerWrapper, orderCode, leftInWallet, sea);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 充值订单处理
|
|
|
* @param sellerWrapper
|
|
|
* @param left
|
|
|
* @param orderCode
|
|
|
* @param seaList
|
|
|
* @param msea
|
|
|
*/
|
|
|
private void processApplyOrder(SellerWrapper sellerWrapper,BigDecimal left,
|
|
|
Long orderCode, List<SellerEnterApply> seaList){
|
|
|
Long orderCode, SellerEnterApply msea){
|
|
|
int uid = sellerWrapper.getUid();
|
|
|
if (seaList.size() > 1) {
|
|
|
logger.warn("in upgradeLevel one orderCode mapped multiple apply,uid {} orderCode {}", uid, orderCode);
|
|
|
}
|
|
|
|
|
|
//持久化的入驻信息
|
|
|
StoredSeller pss = sellerWrapper.getStoredSeller();
|
|
|
boolean noStoredSeller = Objects.isNull(pss);
|
...
|
...
|
@@ -230,7 +252,6 @@ public class SellerEnterApplyService { |
|
|
//身份等级配置
|
|
|
Map<EntrySellerType,EntryThreshold> estMap = metaConfigService.getEntryThreshold();
|
|
|
|
|
|
SellerEnterApply msea = seaList.get(0);
|
|
|
//目标身份
|
|
|
EntrySellerType targetEst = EntrySellerType.getEntrySellerType(msea.getEnterType());
|
|
|
//申请是否已经通过
|
...
|
...
|
@@ -366,7 +387,7 @@ public class SellerEnterApplyService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public int doUpgradeSuper(EntrySellerType targetEst,Integer currentLevel, Integer level, Integer uid){
|
|
|
private int doUpgradeSuper(EntrySellerType targetEst,Integer currentLevel, Integer level, Integer uid){
|
|
|
logger.info("doUpgradeSuper uid {} targetEst {} currentLevel {} target level {}",
|
|
|
uid, targetEst, currentLevel, level);
|
|
|
SellerLevelFuncBo slfb = sellerFuncService.getSellerLevelFunc(targetEst.getCode(), level);
|
...
|
...
|
@@ -376,7 +397,7 @@ public class SellerEnterApplyService { |
|
|
}
|
|
|
|
|
|
|
|
|
public void processWithLevel(Integer currentLevel, Integer targetLevel, Integer uid){
|
|
|
private void processWithLevel(Integer currentLevel, Integer targetLevel, Integer uid){
|
|
|
logger.info("processWithLevel currentLevel {} targetLevel {} uid {}",currentLevel, targetLevel, uid);
|
|
|
if (SellerConfig.ENTER_TYPE_DEFAULT_LEVEL == currentLevel ||
|
|
|
currentLevel== SuperEnterStageLevel.DISABLE.getCode()){
|
...
|
...
|
@@ -444,18 +465,30 @@ public class SellerEnterApplyService { |
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SellerEnterApply findSellerEnterApply(Integer uid, Long orderCode, EntrySellerType targetEST,List<SellerEnterApply> seaList){
|
|
|
/**
|
|
|
* 需要排除已经通过申请,和订单号不匹配
|
|
|
* @param uid
|
|
|
* @param orderCode
|
|
|
* @param targetEST
|
|
|
* @param seaList 只是当前和目标身份匹配出来的申请集合
|
|
|
* @return
|
|
|
*/
|
|
|
private SellerEnterApply findSellerEnterApply(Integer uid,
|
|
|
Long orderCode,
|
|
|
EntrySellerType targetEST,
|
|
|
List<SellerEnterApply> seaList){
|
|
|
SellerEnterApply msea = null;
|
|
|
for(SellerEnterApply sea : seaList){
|
|
|
// 异常情况:已经通过
|
|
|
if (Objects.equals(sea.getStatus(), SellerEnterApplyStatus.PASS.getCode())){
|
|
|
logger.warn("findSellerEnterApply pass one apply, uid {} orderCode {} targetEST {} SellerEnterApply {}",
|
|
|
uid, orderCode, targetEST, sea);
|
|
|
continue;
|
|
|
}
|
|
|
// 没有通过
|
|
|
if (Objects.equals(sea.getStatus(),SellerEnterApplyStatus.WAITING_AUDIT.getCode())){
|
|
|
// 没有通过 + 充值订单号已申请
|
|
|
boolean waitingAudit = Objects.equals(sea.getStatus(),SellerEnterApplyStatus.WAITING_AUDIT.getCode());
|
|
|
boolean matchOrderCode = Objects.nonNull(orderCode) && orderCode.equals(sea.getOrderCode());
|
|
|
if (waitingAudit && matchOrderCode){
|
|
|
msea = sea;
|
|
|
logger.info("findSellerEnterApply one apply waiting audit, uid {} orderCode {} targetEST {} matched SellerEnterApply {}",
|
|
|
uid, orderCode, targetEST, msea);
|
...
|
...
|
@@ -465,6 +498,11 @@ public class SellerEnterApplyService { |
|
|
return msea;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int passApply(SellerEnterApply sea){
|
|
|
if (Objects.equals(SellerEnterApplyStatus.PASS.getCode(), sea.getStatus())){
|
|
|
logger.info("passApply apply was passed, sea {}", sea);
|
...
|
...
|
@@ -478,19 +516,20 @@ public class SellerEnterApplyService { |
|
|
return sellerEnterApplyMapper.updateByPrimaryKeySelective(wpOfSea);
|
|
|
}
|
|
|
|
|
|
public int update(Integer id,Long orderCode, EntrySellerType currentEST, EntrySellerType targetEST){
|
|
|
private SellerEnterApply update(SellerEnterApply msea){
|
|
|
Integer id = msea.getId();
|
|
|
SellerEnterApply wpOfSea = new SellerEnterApply();
|
|
|
wpOfSea.setId(id);
|
|
|
Integer cdt = DateUtil.getCurrentTimeSecond();
|
|
|
wpOfSea.setUpdateTime(cdt);
|
|
|
wpOfSea.setOrderCode(orderCode);
|
|
|
wpOfSea.setPreEnterType(currentEST.getCode());
|
|
|
wpOfSea.setEnterType(targetEST.getCode());
|
|
|
return sellerEnterApplyMapper.updateByPrimaryKeySelective(wpOfSea);
|
|
|
if(sellerEnterApplyMapper.updateByPrimaryKeySelective(wpOfSea) > 0){
|
|
|
msea.setUpdateTime(cdt);
|
|
|
}
|
|
|
return msea;
|
|
|
}
|
|
|
|
|
|
|
|
|
public int add(int uid, Long orderCode, EntrySellerType currentEST, EntrySellerType targetEST){
|
|
|
private SellerEnterApply add(int uid, Long orderCode, EntrySellerType currentEST, EntrySellerType targetEST){
|
|
|
SellerEnterApply wpOfSea = new SellerEnterApply();
|
|
|
wpOfSea.setUid(uid);
|
|
|
wpOfSea.setOrderCode(orderCode);
|
...
|
...
|
@@ -500,6 +539,7 @@ public class SellerEnterApplyService { |
|
|
wpOfSea.setCreateTime(cdt);
|
|
|
wpOfSea.setUpdateTime(cdt);
|
|
|
wpOfSea.setStatus(SellerEnterApplyStatus.WAITING_AUDIT.getCode());
|
|
|
return sellerEnterApplyMapper.insertSelective(wpOfSea);
|
|
|
sellerEnterApplyMapper.insertSelective(wpOfSea);
|
|
|
return wpOfSea;
|
|
|
}
|
|
|
} |
...
|
...
|
|