|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.yohobuy.ufo.model.enums.StoredSellerStatusEnum;
|
|
|
import com.yohobuy.ufo.model.order.bo.SellerBo;
|
|
|
import com.yohobuy.ufo.model.order.common.EntrySellerType;
|
|
|
import com.yohobuy.ufo.model.order.common.SellerEnterApplyStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
|
|
|
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.SellerEnterApplyMapper;
|
|
|
import com.yohoufo.dal.order.SellerLevelFuncMapper;
|
|
|
import com.yohoufo.dal.order.StoredSellerMapper;
|
|
|
import com.yohoufo.dal.order.SuperEntrySellerMapper;
|
|
|
import com.yohoufo.dal.order.model.SellerEnterApply;
|
|
|
import com.yohoufo.dal.order.model.SellerLevelFunc;
|
|
|
import com.yohoufo.dal.order.model.StoredSeller;
|
|
|
import com.yohoufo.dal.order.model.SuperEntrySeller;
|
|
|
import com.yohoufo.order.common.SurperEntrySellerStatus;
|
...
|
...
|
@@ -14,6 +22,7 @@ import com.yohoufo.order.service.MerchantOrderPaymentService; |
|
|
import com.yohoufo.order.service.cache.StoredSellerCacheService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import com.yohoufo.user.cache.CacheKeyEnum;
|
|
|
import lombok.Getter;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -35,7 +44,7 @@ import java.util.stream.Collectors; |
|
|
@Service
|
|
|
public class SellerService {
|
|
|
|
|
|
private final Logger logger = LoggerUtils.getSellerOrderLogger();
|
|
|
private static final Logger logger = LoggerUtils.getSellerOrderLogger();
|
|
|
|
|
|
@Autowired
|
|
|
private StoredSellerCacheService storedSellerCacheService;
|
...
|
...
|
@@ -51,6 +60,11 @@ public class SellerService { |
|
|
|
|
|
@Autowired
|
|
|
private MerchantOrderPaymentService merchantOrderPaymentService;
|
|
|
|
|
|
@Autowired
|
|
|
private SellerLevelFuncMapper sellerLevelFuncMapper;
|
|
|
|
|
|
|
|
|
/**更低出价提醒
|
|
|
* 1)当有新卖家出价成功或调价成功时,给所有正在出售该sku(尺码)的其他卖家推送一条消息(push+消息盒子)
|
|
|
*2)同一卖家的同一SKU 1小时内仅推送一条提醒(最先推送的那条)
|
...
|
...
|
@@ -115,6 +129,87 @@ public class SellerService { |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
public class SellerWrapper{
|
|
|
@Getter
|
|
|
StoredSeller storedSeller;
|
|
|
Integer uid;
|
|
|
SellerBo sellerBo = new SellerBo();
|
|
|
|
|
|
SellerWrapper(int uid){
|
|
|
this.uid = uid;
|
|
|
this.sellerBo.setUid(uid);
|
|
|
}
|
|
|
|
|
|
SellerWrapper buildBase(){
|
|
|
logger.info("buildBase uid {}", uid);
|
|
|
if (uid <= 0){
|
|
|
logger.warn("buildBase illegal uid {}", uid);
|
|
|
throw new UfoServiceException(401, "uid is not legal");
|
|
|
}
|
|
|
|
|
|
EntrySellerType est = null;
|
|
|
//case 1 : not entry
|
|
|
this.storedSeller = storedSellerMapper.selectByUid(uid);
|
|
|
if (Objects.isNull(storedSeller)){
|
|
|
est = EntrySellerType.NOT_ENTRY;
|
|
|
logger.info("buildBase storedSeller is null uid {} entryType {}",
|
|
|
uid, est);
|
|
|
}else {
|
|
|
//case 2:exit entry
|
|
|
Integer validStatus = storedSeller.getValidStatus();
|
|
|
Integer entryType = storedSeller.getEntryType();
|
|
|
logger.info("buildBase uid {} validStatus {} entryType {}",
|
|
|
uid, validStatus, entryType);
|
|
|
if (Objects.equals(StoredSellerStatusEnum.quit.getId(), validStatus)) {
|
|
|
est = EntrySellerType.NOT_ENTRY;
|
|
|
} else if (isSpecialSuper(uid)) {
|
|
|
//case 3:valid ok and in white list
|
|
|
est = EntrySellerType.SPECIAL_SUPER;
|
|
|
} else if (Objects.equals(StoredSellerStatusEnum.entered.getId(), validStatus)) {
|
|
|
//case 4: left common or super
|
|
|
est = EntrySellerType.getEntrySellerType(entryType);
|
|
|
}
|
|
|
Integer funcId;
|
|
|
if (Objects.nonNull(funcId = storedSeller.getLevelFuncId())){
|
|
|
sellerBo.setLevelFuncId(funcId);
|
|
|
}
|
|
|
}
|
|
|
logger.info("buildBase uid {} EntrySellerType {}", uid, est);
|
|
|
|
|
|
if (Objects.nonNull(est)) {
|
|
|
sellerBo.setEntrySellerType(est);
|
|
|
sellerBo.setEntryTypeCode(est.getCode());
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
SellerWrapper buildSuperEnterStageLevel(){
|
|
|
EntrySellerType entrySellerType = sellerBo.getEntrySellerType();
|
|
|
|
|
|
if (Objects.nonNull(entrySellerType)){
|
|
|
//
|
|
|
Integer entryType = sellerBo.getEntryTypeCode();
|
|
|
if(Objects.equals(entryType, EntrySellerType.SUPER_ENTRY.getCode())){
|
|
|
Integer levelFuncId = sellerBo.getLevelFuncId();
|
|
|
if(Objects.nonNull(levelFuncId)){
|
|
|
SellerLevelFunc slf = sellerLevelFuncMapper.selectByPrimaryKey(levelFuncId);
|
|
|
logger.info("buildSuperEnterStageLevel SellerLevelFunc uid {} levelFuncId {} SellerLevelFunc {}",
|
|
|
uid, levelFuncId, slf);
|
|
|
Integer level = slf.getLevel();
|
|
|
SuperEnterStageLevel sesl = SuperEnterStageLevel.getSuperEnterStageLevel(level);
|
|
|
sellerBo.setSuperEnterStageLevel(sesl);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
SellerBo build(){
|
|
|
return sellerBo;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取入驻商家类型
|
...
|
...
|
@@ -123,46 +218,13 @@ public class SellerService { |
|
|
*/
|
|
|
public EntrySellerType getEntrySellerType(int uid){
|
|
|
logger.info("getEntrySellerType uid {}", uid);
|
|
|
if (uid<=0){
|
|
|
logger.warn("getEntrySellerType illegal uid {}", uid);
|
|
|
throw new UfoServiceException(401, "uid is not legal");
|
|
|
}
|
|
|
EntrySellerType est = null;
|
|
|
//case 1 : not entry
|
|
|
StoredSeller storedSeller = storedSellerMapper.selectByUid(uid);
|
|
|
if (Objects.isNull(storedSeller)){
|
|
|
est = EntrySellerType.NOT_ENTRY;
|
|
|
logger.info("getEntrySellerType storedSeller is null uid {} entryType {}",
|
|
|
uid, est);
|
|
|
return est;
|
|
|
}
|
|
|
//case 2:exit entry
|
|
|
Integer validStatus = storedSeller.getValidStatus();
|
|
|
Integer entryType = storedSeller.getEntryType();
|
|
|
logger.info("getEntrySellerType uid {} validStatus {} entryType {}",
|
|
|
uid, validStatus, entryType);
|
|
|
if (Objects.equals(StoredSellerStatusEnum.quit.getId(), validStatus)){
|
|
|
est = EntrySellerType.NOT_ENTRY;
|
|
|
}else if(isSpecialSuper(uid)){
|
|
|
//case 3:valid ok and in white list
|
|
|
est = EntrySellerType.SPECIAL_SUPER;
|
|
|
}else if (Objects.equals(StoredSellerStatusEnum.entered.getId(), validStatus)){
|
|
|
//case 4: left common or super
|
|
|
est = EntrySellerType.getEntrySellerType(entryType);
|
|
|
}
|
|
|
SellerBo sellerBo = new SellerWrapper(uid).buildBase().build();
|
|
|
EntrySellerType est = sellerBo.getEntrySellerType();
|
|
|
logger.info("getEntrySellerType uid {} EntrySellerType {}", uid, est);
|
|
|
return est;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 申请成为超级卖家
|
|
|
* 对于未支付的某一种身份申请做订单号替换
|
|
|
* @param uid
|
|
|
* @param orderCode
|
|
|
*/
|
|
|
public void applySuperEntry(Integer uid, Long orderCode, EntrySellerType targetEST){
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 支付成功后回调
|
...
|
...
|
@@ -183,22 +245,11 @@ public class SellerService { |
|
|
|
|
|
}
|
|
|
|
|
|
public Map<EntrySellerType,EntryThreshold> getEntryThreshold(){
|
|
|
Map<EntrySellerType,EntryThreshold> map = new HashMap<>(2);
|
|
|
|
|
|
EntryThreshold commonET = new EntryThreshold();
|
|
|
commonET.setEntrySellerType(EntrySellerType.COMMON);
|
|
|
commonET.setPrepaymentAmount(new BigDecimal(999));
|
|
|
map.put(commonET.getEntrySellerType(), commonET);
|
|
|
|
|
|
EntryThreshold superET = new EntryThreshold();
|
|
|
superET.setEntrySellerType(EntrySellerType.SUPER_ENTRY);
|
|
|
superET.setPrepaymentAmount(new BigDecimal(5000));
|
|
|
superET.setGoodsOnOffShelveAmount(new BigDecimal(3000));
|
|
|
superET.setHiddenGoodsAmount(new BigDecimal(1000));
|
|
|
map.put(superET.getEntrySellerType(), superET);
|
|
|
@Autowired
|
|
|
private MetaConfigService metaConfigService;
|
|
|
|
|
|
return map;
|
|
|
public Map<EntrySellerType,EntryThreshold> getEntryThreshold(){
|
|
|
return metaConfigService.getEntryThreshold();
|
|
|
}
|
|
|
|
|
|
public Boolean applySuperEnter(Integer uid){
|
...
|
...
|
|