Authored by chenchao

add product proxy hidden or cancel hidden

... ... @@ -12,7 +12,7 @@
<result column="status" jdbcType="SMALLINT" property="status" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, pre_enter_type, enter_type, create_time, update_time, status
id, uid, order_code, pre_enter_type, enter_type, create_time, update_time, `status`
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
... ...
... ... @@ -10,10 +10,12 @@ 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.StoredSellerMapper;
import com.yohoufo.dal.order.model.SellerEnterApply;
import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.order.constants.SellerConfig;
import com.yohoufo.order.service.IStoredSellerService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
... ... @@ -45,6 +47,9 @@ public class SellerEnterApplyService {
@Autowired
private SellerFuncService sellerFuncService;
@Autowired
private StoredSellerMapper storedSellerMapper;
/**
* 申请成为超级卖家
* 对于未支付的某一种身份申请做订单号替换
... ... @@ -61,7 +66,7 @@ public class SellerEnterApplyService {
logger.warn("in applySuperEntry uid {} orderCode {} targetEST is null", uid, orderCode);
throw new UfoServiceException(400, "EntrySellerType is null");
}
SellerService.SellerWrapper sellerWrapper = new SellerService().new SellerWrapper(uid).buildBase();
SellerService.SellerWrapper sellerWrapper = new SellerService().new SellerWrapper(uid).storedSellerDataSource(storedSellerMapper::selectByUid).buildBase();
SellerBo sellerBo = sellerWrapper.build();
EntrySellerType currentEST = sellerBo.getEntrySellerType();
... ... @@ -174,7 +179,8 @@ public class SellerEnterApplyService {
logger.warn("in upgradeLevel one orderCode mapped multiple apply,uid {} orderCode {}", uid, orderCode);
}
//卖家包装类
SellerService.SellerWrapper sellerWrapper = new SellerService().new SellerWrapper(uid).buildBase();
SellerService.SellerWrapper sellerWrapper = new SellerService().new SellerWrapper(uid)
.storedSellerDataSource(storedSellerMapper::selectByUid).buildBase();
upgradeLevel(sellerWrapper, orderCode, left, seaList);
}
... ... @@ -248,6 +254,27 @@ public class SellerEnterApplyService {
if (!noStoredSeller && isMatchedET && levelNeedUpgrade) {
SellerLevelFuncBo slfb = sellerFuncService.getSellerLevelFunc(targetEst.getCode(), level);
storedSellerService.updateEnterSeller(uid, targetEst, slfb);
processWithLevel(currentLevel, level, uid);
}
}
}
@Autowired
private ProductProxyService productProxyService;
public void processWithLevel(Integer currentLevel, Integer targetLevel, Integer uid){
logger.info("processWithLevel currentLevel {} targetLevel {} uid {}",currentLevel, targetLevel, uid);
if (SellerConfig.ENTER_TYPE_DEFAULT_LEVEL == currentLevel){
if(targetLevel == SuperEnterStageLevel.FULL.getCode()
||targetLevel == SuperEnterStageLevel.PARTITION.getCode()){
productProxyService.cancelHiddenGoods(uid);
}
}
if (SellerConfig.ENTER_TYPE_DEFAULT_LEVEL == targetLevel) {
if (currentLevel == SuperEnterStageLevel.FULL.getCode()
|| currentLevel == SuperEnterStageLevel.PARTITION.getCode()) {
productProxyService.hiddenGoods(uid);
}
}
}
... ...
... ... @@ -33,6 +33,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
... ... @@ -142,12 +144,19 @@ public class SellerService {
StoredSeller storedSeller;
@Getter
Integer uid;
Function<Integer,StoredSeller> storedSellerFunc;
SellerBo sellerBo = new SellerBo();
SellerWrapper(int uid){
this.uid = uid;
this.sellerBo.setUid(uid);
}
SellerWrapper storedSellerDataSource(Function<Integer,StoredSeller> storedSellerFunc){
this.storedSellerFunc = storedSellerFunc;
return this;
}
SellerWrapper buildBase(){
logger.info("buildBase uid {}", uid);
... ... @@ -158,7 +167,7 @@ public class SellerService {
EntrySellerType est = null;
//case 1 : not entry
this.storedSeller = storedSellerMapper.selectByUid(uid);
this.storedSeller = storedSellerFunc.apply(uid);//storedSellerMapper.selectByUid(uid);
if (Objects.isNull(storedSeller)){
est = EntrySellerType.NOT_ENTRY;
logger.info("buildBase storedSeller is null uid {} entryType {}",
... ... @@ -227,7 +236,7 @@ public class SellerService {
*/
public EntrySellerType getEntrySellerType(int uid){
logger.info("getEntrySellerType uid {}", uid);
SellerBo sellerBo = new SellerWrapper(uid).buildBase().build();
SellerBo sellerBo = new SellerWrapper(uid).storedSellerDataSource(storedSellerMapper::selectByUid).buildBase().build();
EntrySellerType est = sellerBo.getEntrySellerType();
logger.info("getEntrySellerType uid {} EntrySellerType {}", uid, est);
return est;
... ... @@ -263,7 +272,7 @@ public class SellerService {
public Boolean applySuperEnter(Integer uid){
SellerService.SellerWrapper sellerWrapper = new SellerService()
.new SellerWrapper(uid).buildBase();
.new SellerWrapper(uid).storedSellerDataSource(storedSellerMapper::selectByUid).buildBase();
SellerBo sellerBo = sellerWrapper.build();
EntrySellerType currentEST = sellerBo.getEntrySellerType();
EntrySellerType targetEST = EntrySellerType.SUPER_ENTRY;
... ...
... ... @@ -22,8 +22,6 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Service
... ...
... ... @@ -321,5 +321,31 @@ public class ProductProxyService {
return (null == resp || null == resp.getData())? false : (boolean)resp.getData();
}
private final static String hideSellerAllSkup = "ufo.product.hideSellerAllSkup",
showSellerAllSkup = "ufo.product.showSellerAllSkup";
public boolean hiddenGoods(Integer uid){
logger.info("begin in {} uid {}", hideSellerAllSkup, uid);
ApiResponse resp = null;
try {
resp = ufoServiceCaller.call(hideSellerAllSkup, uid);
} catch (Exception e) {
logger.warn("in {} call fail uid {}", hideSellerAllSkup, uid, e);
}
logger.info("finish {} -> uid {}", hideSellerAllSkup, uid);
return (null == resp || null == resp.getData())? false : (boolean)resp.getData();
}
public boolean cancelHiddenGoods(Integer uid){
logger.info("begin in {} uid {}", showSellerAllSkup, uid);
ApiResponse resp = null;
try {
resp = ufoServiceCaller.call(showSellerAllSkup, uid);
}catch (Exception ex){
logger.warn("in {} call fail uid {}", showSellerAllSkup, uid, ex);
}
logger.info("finish {} -> uid {}", showSellerAllSkup, uid);
return (null == resp || null == resp.getData())? false : (boolean)resp.getData();
}
}
... ...