Authored by chenchao

add inbox 4 super seller wallet change compared with threshold

... ... @@ -16,6 +16,7 @@ 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.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerHelper;
... ... @@ -61,6 +62,9 @@ public class SellerEnterApplyService {
@Autowired
private ProductProxyService productProxyService;
@Autowired
private InBoxFacade inBoxFacade;
/**
* 申请成为超级卖家
* 对于未支付的某一种身份申请做订单号替换
... ... @@ -385,8 +389,10 @@ public class SellerEnterApplyService {
}
//身份等级配置
Map<EntrySellerType,EntryThreshold> estMap = metaConfigService.getEntryThreshold();
EntryThreshold set = estMap.get(currentEST);
//目标身份对应的等级
Integer level = SellerHelper.getType2Level(currentEST, estMap, left);
SellerLevelFuncBo bslfb = SellerHelper.getSellerLevelFunc(currentEST, set, left);
Integer level = bslfb.getLevel();
logger.info("in changeLevel4Super ready change StoredSeller level func, uid {} currentEnterType {} target Level {}",
uid, currentEnterType, level);
//超级卖家
... ... @@ -403,6 +409,8 @@ public class SellerEnterApplyService {
int result = 0;
if (levelNeedUpgrade && isValid) {
doUpgradeSuper(targetEST, currentLevel, level, uid);
SuperEnterStageLevel targetSESL = SuperEnterStageLevel.getSuperEnterStageLevel(level);
inBoxFacade.noticeSuperSellerDegrade(uid, targetSESL, bslfb.getWalletThreshold());
}
return result;
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yohoufo.order.service.proxy;
import com.alibaba.fastjson.JSON;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.inboxclient.model.InBoxResponse;
import com.yohoufo.inboxclient.model.InboxReqVO;
... ... @@ -14,6 +15,7 @@ import org.slf4j.helpers.MessageFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
... ... @@ -1108,6 +1110,51 @@ public class InBoxFacade {
}
}
public void noticeSuperSellerDegrade(Integer uid, SuperEnterStageLevel sesl, BigDecimal leftInWallet){
try {
executorService.execute(()->{
InboxBusinessTypeEnum smsIBT = null;
InboxBusinessTypeEnum inboxIBT = null;
switch (sesl){
case PARTITION:
inboxIBT = InboxBusinessTypeEnum.SUPER_SELLER_DEGRADE_PART_FUNC;
smsIBT = InboxBusinessTypeEnum.SMS_SUPER_SELLER_DEGRADE_PART_FUNC;
break;
case DISABLE:
inboxIBT = InboxBusinessTypeEnum.SUPER_SELLER_DEGRADE_ALL_FUNC;
smsIBT = InboxBusinessTypeEnum.SMS_SUPER_SELLER_DEGRADE_ALL_FUNC;
break;
}
if (smsIBT == null || inboxIBT == null ){
logger.warn("in noticeSuperSellerDegrade not match send condition, uid {}, SuperEnterStageLevel {},leftInWallet {}",
uid, sesl, leftInWallet);
return;
}
String params = buildParams(leftInWallet);
InboxReqVO req = buildInboxReqVO(uid, params, inboxIBT);
InBoxResponse resp = inBoxSDK.addInbox(req);
logger.info("record noticeSuperSellerDegrade to super seller inbox msg, uid {}, SuperEnterStageLevel {},leftInWallet {} resp {}",
uid, sesl, leftInWallet, resp);
//短信
String phone = userProxyService.getMobile(uid);
if (StringUtils.isBlank(phone)){
logger.warn("in noticeSuperSellerDegrade sms fail, uid {}, SuperEnterStageLevel {},leftInWallet {}",
uid, sesl, leftInWallet);
return;
}
List<String> mobileList = Arrays.asList(phone);
String content = getReplacedContent(smsIBT.getContent(), leftInWallet);
sendSmsService.smsSendByMobile(content,mobileList);
logger.info("record noticeSuperSellerDegrade inbox sms msg, uid {}, SuperEnterStageLevel {},leftInWallet {}",
uid, sesl, leftInWallet);
});
} catch (Exception e) {
logger.warn("InBoxFacade noticeSuperSellerDegrade error inbox msg, uid {}, SuperEnterStageLevel {},leftInWallet {}",
uid, sesl, leftInWallet, e);
}
}
public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) {
InboxReqVO req = new InboxReqVO();
req.setType(ibt.getType());
... ...
package com.yohoufo.order.utils;
import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo;
import com.yohobuy.ufo.model.order.common.CommonEnterStageLevel;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
... ... @@ -14,6 +15,38 @@ import java.util.Objects;
* Created by chao.chen on 2019/1/16.
*/
public class SellerHelper {
public static SellerLevelFuncBo getSellerLevelFunc(EntrySellerType est, EntryThreshold et, BigDecimal left){
Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL;
SellerLevelFuncBo slfb = new SellerLevelFuncBo();
BigDecimal theshold = null;
switch (est){
case COMMON:
theshold = et.getPrepaymentAmount();
if (theshold.compareTo(left) <= 0) {
level = CommonEnterStageLevel.ALL.getCode();
}
break;
case SUPER_ENTRY:
if (et.getPrepaymentAmount().compareTo(left) <= 0) {
theshold = et.getPrepaymentAmount();
level = SuperEnterStageLevel.FULL.getCode();
}else if (et.getGoodsOnOffShelveAmount().compareTo(left) <= 0){
theshold = et.getGoodsOnOffShelveAmount();
level = SuperEnterStageLevel.PARTITION.getCode();
}else if (et.getHiddenGoodsAmount().compareTo(left) <=0){
theshold = et.getHiddenGoodsAmount();
level = SuperEnterStageLevel.DISABLE.getCode();
}
break;
}
slfb.setLevel(level);
slfb.setWalletThreshold(theshold);
return slfb;
}
public static Integer getType2Level(EntrySellerType targetEst, Map<EntrySellerType,EntryThreshold> estMap,
BigDecimal left){
Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL;
... ...