add inbox 4 super seller wallet change compared with threshold
Showing
3 changed files
with
89 additions
and
1 deletions
@@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.SellerEnterApply; | @@ -16,6 +16,7 @@ import com.yohoufo.dal.order.model.SellerEnterApply; | ||
16 | import com.yohoufo.dal.order.model.StoredSeller; | 16 | import com.yohoufo.dal.order.model.StoredSeller; |
17 | import com.yohoufo.order.constants.SellerConfig; | 17 | import com.yohoufo.order.constants.SellerConfig; |
18 | import com.yohoufo.order.service.IStoredSellerService; | 18 | import com.yohoufo.order.service.IStoredSellerService; |
19 | +import com.yohoufo.order.service.proxy.InBoxFacade; | ||
19 | import com.yohoufo.order.service.proxy.ProductProxyService; | 20 | import com.yohoufo.order.service.proxy.ProductProxyService; |
20 | import com.yohoufo.order.utils.LoggerUtils; | 21 | import com.yohoufo.order.utils.LoggerUtils; |
21 | import com.yohoufo.order.utils.SellerHelper; | 22 | import com.yohoufo.order.utils.SellerHelper; |
@@ -61,6 +62,9 @@ public class SellerEnterApplyService { | @@ -61,6 +62,9 @@ public class SellerEnterApplyService { | ||
61 | @Autowired | 62 | @Autowired |
62 | private ProductProxyService productProxyService; | 63 | private ProductProxyService productProxyService; |
63 | 64 | ||
65 | + @Autowired | ||
66 | + private InBoxFacade inBoxFacade; | ||
67 | + | ||
64 | /** | 68 | /** |
65 | * 申请成为超级卖家 | 69 | * 申请成为超级卖家 |
66 | * 对于未支付的某一种身份申请做订单号替换 | 70 | * 对于未支付的某一种身份申请做订单号替换 |
@@ -385,8 +389,10 @@ public class SellerEnterApplyService { | @@ -385,8 +389,10 @@ public class SellerEnterApplyService { | ||
385 | } | 389 | } |
386 | //身份等级配置 | 390 | //身份等级配置 |
387 | Map<EntrySellerType,EntryThreshold> estMap = metaConfigService.getEntryThreshold(); | 391 | Map<EntrySellerType,EntryThreshold> estMap = metaConfigService.getEntryThreshold(); |
392 | + EntryThreshold set = estMap.get(currentEST); | ||
388 | //目标身份对应的等级 | 393 | //目标身份对应的等级 |
389 | - Integer level = SellerHelper.getType2Level(currentEST, estMap, left); | 394 | + SellerLevelFuncBo bslfb = SellerHelper.getSellerLevelFunc(currentEST, set, left); |
395 | + Integer level = bslfb.getLevel(); | ||
390 | logger.info("in changeLevel4Super ready change StoredSeller level func, uid {} currentEnterType {} target Level {}", | 396 | logger.info("in changeLevel4Super ready change StoredSeller level func, uid {} currentEnterType {} target Level {}", |
391 | uid, currentEnterType, level); | 397 | uid, currentEnterType, level); |
392 | //超级卖家 | 398 | //超级卖家 |
@@ -403,6 +409,8 @@ public class SellerEnterApplyService { | @@ -403,6 +409,8 @@ public class SellerEnterApplyService { | ||
403 | int result = 0; | 409 | int result = 0; |
404 | if (levelNeedUpgrade && isValid) { | 410 | if (levelNeedUpgrade && isValid) { |
405 | doUpgradeSuper(targetEST, currentLevel, level, uid); | 411 | doUpgradeSuper(targetEST, currentLevel, level, uid); |
412 | + SuperEnterStageLevel targetSESL = SuperEnterStageLevel.getSuperEnterStageLevel(level); | ||
413 | + inBoxFacade.noticeSuperSellerDegrade(uid, targetSESL, bslfb.getWalletThreshold()); | ||
406 | } | 414 | } |
407 | return result; | 415 | return result; |
408 | } | 416 | } |
@@ -2,6 +2,7 @@ package com.yohoufo.order.service.proxy; | @@ -2,6 +2,7 @@ package com.yohoufo.order.service.proxy; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum; | 4 | import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum; |
5 | +import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; | ||
5 | import com.yohoufo.dal.order.model.SellerOrderGoods; | 6 | import com.yohoufo.dal.order.model.SellerOrderGoods; |
6 | import com.yohoufo.inboxclient.model.InBoxResponse; | 7 | import com.yohoufo.inboxclient.model.InBoxResponse; |
7 | import com.yohoufo.inboxclient.model.InboxReqVO; | 8 | import com.yohoufo.inboxclient.model.InboxReqVO; |
@@ -14,6 +15,7 @@ import org.slf4j.helpers.MessageFormatter; | @@ -14,6 +15,7 @@ import org.slf4j.helpers.MessageFormatter; | ||
14 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
15 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
16 | 17 | ||
18 | +import java.math.BigDecimal; | ||
17 | import java.util.Arrays; | 19 | import java.util.Arrays; |
18 | import java.util.List; | 20 | import java.util.List; |
19 | import java.util.concurrent.ArrayBlockingQueue; | 21 | import java.util.concurrent.ArrayBlockingQueue; |
@@ -1108,6 +1110,51 @@ public class InBoxFacade { | @@ -1108,6 +1110,51 @@ public class InBoxFacade { | ||
1108 | } | 1110 | } |
1109 | } | 1111 | } |
1110 | 1112 | ||
1113 | + public void noticeSuperSellerDegrade(Integer uid, SuperEnterStageLevel sesl, BigDecimal leftInWallet){ | ||
1114 | + try { | ||
1115 | + executorService.execute(()->{ | ||
1116 | + InboxBusinessTypeEnum smsIBT = null; | ||
1117 | + InboxBusinessTypeEnum inboxIBT = null; | ||
1118 | + switch (sesl){ | ||
1119 | + case PARTITION: | ||
1120 | + inboxIBT = InboxBusinessTypeEnum.SUPER_SELLER_DEGRADE_PART_FUNC; | ||
1121 | + smsIBT = InboxBusinessTypeEnum.SMS_SUPER_SELLER_DEGRADE_PART_FUNC; | ||
1122 | + break; | ||
1123 | + case DISABLE: | ||
1124 | + inboxIBT = InboxBusinessTypeEnum.SUPER_SELLER_DEGRADE_ALL_FUNC; | ||
1125 | + smsIBT = InboxBusinessTypeEnum.SMS_SUPER_SELLER_DEGRADE_ALL_FUNC; | ||
1126 | + break; | ||
1127 | + } | ||
1128 | + if (smsIBT == null || inboxIBT == null ){ | ||
1129 | + logger.warn("in noticeSuperSellerDegrade not match send condition, uid {}, SuperEnterStageLevel {},leftInWallet {}", | ||
1130 | + uid, sesl, leftInWallet); | ||
1131 | + return; | ||
1132 | + } | ||
1133 | + String params = buildParams(leftInWallet); | ||
1134 | + InboxReqVO req = buildInboxReqVO(uid, params, inboxIBT); | ||
1135 | + | ||
1136 | + InBoxResponse resp = inBoxSDK.addInbox(req); | ||
1137 | + logger.info("record noticeSuperSellerDegrade to super seller inbox msg, uid {}, SuperEnterStageLevel {},leftInWallet {} resp {}", | ||
1138 | + uid, sesl, leftInWallet, resp); | ||
1139 | + //短信 | ||
1140 | + String phone = userProxyService.getMobile(uid); | ||
1141 | + if (StringUtils.isBlank(phone)){ | ||
1142 | + logger.warn("in noticeSuperSellerDegrade sms fail, uid {}, SuperEnterStageLevel {},leftInWallet {}", | ||
1143 | + uid, sesl, leftInWallet); | ||
1144 | + return; | ||
1145 | + } | ||
1146 | + List<String> mobileList = Arrays.asList(phone); | ||
1147 | + String content = getReplacedContent(smsIBT.getContent(), leftInWallet); | ||
1148 | + sendSmsService.smsSendByMobile(content,mobileList); | ||
1149 | + logger.info("record noticeSuperSellerDegrade inbox sms msg, uid {}, SuperEnterStageLevel {},leftInWallet {}", | ||
1150 | + uid, sesl, leftInWallet); | ||
1151 | + }); | ||
1152 | + } catch (Exception e) { | ||
1153 | + logger.warn("InBoxFacade noticeSuperSellerDegrade error inbox msg, uid {}, SuperEnterStageLevel {},leftInWallet {}", | ||
1154 | + uid, sesl, leftInWallet, e); | ||
1155 | + } | ||
1156 | + } | ||
1157 | + | ||
1111 | public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) { | 1158 | public InboxReqVO buildInboxReqVO(int uid, String params, InboxBusinessTypeEnum ibt) { |
1112 | InboxReqVO req = new InboxReqVO(); | 1159 | InboxReqVO req = new InboxReqVO(); |
1113 | req.setType(ibt.getType()); | 1160 | req.setType(ibt.getType()); |
1 | package com.yohoufo.order.utils; | 1 | package com.yohoufo.order.utils; |
2 | 2 | ||
3 | +import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo; | ||
3 | import com.yohobuy.ufo.model.order.common.CommonEnterStageLevel; | 4 | import com.yohobuy.ufo.model.order.common.CommonEnterStageLevel; |
4 | import com.yohobuy.ufo.model.order.common.EntrySellerType; | 5 | import com.yohobuy.ufo.model.order.common.EntrySellerType; |
5 | import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; | 6 | import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; |
@@ -14,6 +15,38 @@ import java.util.Objects; | @@ -14,6 +15,38 @@ import java.util.Objects; | ||
14 | * Created by chao.chen on 2019/1/16. | 15 | * Created by chao.chen on 2019/1/16. |
15 | */ | 16 | */ |
16 | public class SellerHelper { | 17 | public class SellerHelper { |
18 | + | ||
19 | + public static SellerLevelFuncBo getSellerLevelFunc(EntrySellerType est, EntryThreshold et, BigDecimal left){ | ||
20 | + Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL; | ||
21 | + SellerLevelFuncBo slfb = new SellerLevelFuncBo(); | ||
22 | + BigDecimal theshold = null; | ||
23 | + switch (est){ | ||
24 | + case COMMON: | ||
25 | + theshold = et.getPrepaymentAmount(); | ||
26 | + if (theshold.compareTo(left) <= 0) { | ||
27 | + level = CommonEnterStageLevel.ALL.getCode(); | ||
28 | + | ||
29 | + } | ||
30 | + break; | ||
31 | + case SUPER_ENTRY: | ||
32 | + | ||
33 | + if (et.getPrepaymentAmount().compareTo(left) <= 0) { | ||
34 | + theshold = et.getPrepaymentAmount(); | ||
35 | + level = SuperEnterStageLevel.FULL.getCode(); | ||
36 | + }else if (et.getGoodsOnOffShelveAmount().compareTo(left) <= 0){ | ||
37 | + theshold = et.getGoodsOnOffShelveAmount(); | ||
38 | + level = SuperEnterStageLevel.PARTITION.getCode(); | ||
39 | + }else if (et.getHiddenGoodsAmount().compareTo(left) <=0){ | ||
40 | + theshold = et.getHiddenGoodsAmount(); | ||
41 | + level = SuperEnterStageLevel.DISABLE.getCode(); | ||
42 | + } | ||
43 | + break; | ||
44 | + } | ||
45 | + slfb.setLevel(level); | ||
46 | + slfb.setWalletThreshold(theshold); | ||
47 | + return slfb; | ||
48 | + } | ||
49 | + | ||
17 | public static Integer getType2Level(EntrySellerType targetEst, Map<EntrySellerType,EntryThreshold> estMap, | 50 | public static Integer getType2Level(EntrySellerType targetEst, Map<EntrySellerType,EntryThreshold> estMap, |
18 | BigDecimal left){ | 51 | BigDecimal left){ |
19 | Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL; | 52 | Integer level = SellerConfig.ENTER_TYPE_DEFAULT_LEVEL; |
-
Please register or login to post a comment