Showing
9 changed files
with
41 additions
and
24 deletions
@@ -12,7 +12,7 @@ public class SellerOrderStatsConfig { | @@ -12,7 +12,7 @@ public class SellerOrderStatsConfig { | ||
12 | //排除的uid | 12 | //排除的uid |
13 | private String excludeUid; | 13 | private String excludeUid; |
14 | //属性 | 14 | //属性 |
15 | - private String orderAttribute; | 15 | + private String skupType; |
16 | //统计单位 | 16 | //统计单位 |
17 | private String statsUnit; | 17 | private String statsUnit; |
18 | //统计周期 | 18 | //统计周期 |
@@ -5,14 +5,14 @@ | @@ -5,14 +5,14 @@ | ||
5 | <id column="id" property="id" jdbcType="BIGINT" /> | 5 | <id column="id" property="id" jdbcType="BIGINT" /> |
6 | <result column="stats_code" property="statsCode" jdbcType="VARCHAR" /> | 6 | <result column="stats_code" property="statsCode" jdbcType="VARCHAR" /> |
7 | <result column="exclude_uid" property="excludeUid" jdbcType="VARCHAR" /> | 7 | <result column="exclude_uid" property="excludeUid" jdbcType="VARCHAR" /> |
8 | - <result column="order_attribute" property="orderAttribute" jdbcType="VARCHAR" /> | 8 | + <result column="skup_type" property="skupType" jdbcType="VARCHAR" /> |
9 | <result column="stats_unit" property="statsUnit" jdbcType="VARCHAR" /> | 9 | <result column="stats_unit" property="statsUnit" jdbcType="VARCHAR" /> |
10 | <result column="stats_period" property="statsPeriod" jdbcType="INTEGER" /> | 10 | <result column="stats_period" property="statsPeriod" jdbcType="INTEGER" /> |
11 | <result column="stats_processor" property="statsProcessor" jdbcType="VARCHAR" /> | 11 | <result column="stats_processor" property="statsProcessor" jdbcType="VARCHAR" /> |
12 | <result column="action_param" property="actionParam" jdbcType="VARCHAR" /> | 12 | <result column="action_param" property="actionParam" jdbcType="VARCHAR" /> |
13 | </resultMap> | 13 | </resultMap> |
14 | <sql id="Base_Column_List" > | 14 | <sql id="Base_Column_List" > |
15 | - id, stats_code, exclude_uid,order_attribute, stats_unit, stats_period, stats_processor, action_param | 15 | + id, stats_code, exclude_uid, skup_type, stats_unit, stats_period, stats_processor, action_param |
16 | </sql> | 16 | </sql> |
17 | 17 | ||
18 | <select id="selectEnabledStatsConfig" resultMap="BaseResultMap" > | 18 | <select id="selectEnabledStatsConfig" resultMap="BaseResultMap" > |
@@ -4,7 +4,7 @@ import com.google.common.base.Splitter; | @@ -4,7 +4,7 @@ import com.google.common.base.Splitter; | ||
4 | import com.google.common.collect.Lists; | 4 | import com.google.common.collect.Lists; |
5 | import com.yoho.core.cache.LocalCache; | 5 | import com.yoho.core.cache.LocalCache; |
6 | import com.yoho.core.cache.LocalCacheCallback; | 6 | import com.yoho.core.cache.LocalCacheCallback; |
7 | -import com.yohobuy.ufo.model.order.common.OrderAttributes; | 7 | +import com.yohobuy.ufo.model.order.constants.SkupType; |
8 | import com.yohoufo.dal.order.SellerOrderStatsConfigMapper; | 8 | import com.yohoufo.dal.order.SellerOrderStatsConfigMapper; |
9 | import com.yohoufo.dal.order.model.SellerOrderStatsConfig; | 9 | import com.yohoufo.dal.order.model.SellerOrderStatsConfig; |
10 | import com.yohoufo.order.service.stats.StatsUnit; | 10 | import com.yohoufo.order.service.stats.StatsUnit; |
@@ -57,7 +57,7 @@ public class SellerOrderStatsConfigCacheService { | @@ -57,7 +57,7 @@ public class SellerOrderStatsConfigCacheService { | ||
57 | SellerOrderStatsConfiguration configuration = SellerOrderStatsConfiguration.builder() | 57 | SellerOrderStatsConfiguration configuration = SellerOrderStatsConfiguration.builder() |
58 | .statsCode(config.getStatsCode()) | 58 | .statsCode(config.getStatsCode()) |
59 | .excludeUids(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getExcludeUid()).stream().map(uid -> Integer.parseInt(uid.trim())).collect(Collectors.toList())) | 59 | .excludeUids(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getExcludeUid()).stream().map(uid -> Integer.parseInt(uid.trim())).collect(Collectors.toList())) |
60 | - .orderAttributes(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getOrderAttribute()).stream().map(code -> OrderAttributes.getOrderAttributes(Integer.parseInt(code.trim()))).collect(Collectors.toList())) | 60 | + .skupTypes(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getSkupType()).stream().map(code -> SkupType.getSkupType(Integer.parseInt(code.trim()))).collect(Collectors.toList())) |
61 | .statsUnit(StatsUnit.find(config.getStatsUnit())) | 61 | .statsUnit(StatsUnit.find(config.getStatsUnit())) |
62 | .statsPeriod(config.getStatsPeriod()) | 62 | .statsPeriod(config.getStatsPeriod()) |
63 | .statsProcessorName(config.getStatsProcessor()) | 63 | .statsProcessorName(config.getStatsProcessor()) |
@@ -76,11 +76,11 @@ public class SellerOrderStatsConfigCacheService { | @@ -76,11 +76,11 @@ public class SellerOrderStatsConfigCacheService { | ||
76 | }); | 76 | }); |
77 | } | 77 | } |
78 | 78 | ||
79 | - public Optional<SellerOrderStatsConfiguration> findBy(OrderAttributes orderAttributes) { | 79 | + public Optional<SellerOrderStatsConfiguration> findBy(SkupType skupType) { |
80 | List<SellerOrderStatsConfiguration> configurations = (List) localCache.get(SELLER_ORDER_STATS_CONFIG_KEY); | 80 | List<SellerOrderStatsConfiguration> configurations = (List) localCache.get(SELLER_ORDER_STATS_CONFIG_KEY); |
81 | if (CollectionUtils.isEmpty(configurations)) { | 81 | if (CollectionUtils.isEmpty(configurations)) { |
82 | return Optional.ofNullable(null); | 82 | return Optional.ofNullable(null); |
83 | } | 83 | } |
84 | - return configurations.stream().filter(config -> config.getOrderAttributes().contains(orderAttributes)).findFirst(); | 84 | + return configurations.stream().filter(config -> config.getSkupTypes().contains(skupType)).findFirst(); |
85 | } | 85 | } |
86 | } | 86 | } |
@@ -3,11 +3,15 @@ package com.yohoufo.order.service.listener.processor; | @@ -3,11 +3,15 @@ package com.yohoufo.order.service.listener.processor; | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.google.common.collect.Lists; | 4 | import com.google.common.collect.Lists; |
5 | import com.yoho.core.rabbitmq.YhProducer; | 5 | import com.yoho.core.rabbitmq.YhProducer; |
6 | -import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
7 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 6 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
7 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
8 | import com.yohoufo.common.alarm.EventBusPublisher; | 8 | import com.yohoufo.common.alarm.EventBusPublisher; |
9 | import com.yohoufo.common.alarm.SmsAlarmEvent; | 9 | import com.yohoufo.common.alarm.SmsAlarmEvent; |
10 | +import com.yohoufo.dal.order.BuyerOrderGoodsMapper; | ||
11 | +import com.yohoufo.dal.order.SellerOrderGoodsMapper; | ||
10 | import com.yohoufo.dal.order.model.BuyerOrder; | 12 | import com.yohoufo.dal.order.model.BuyerOrder; |
13 | +import com.yohoufo.dal.order.model.BuyerOrderGoods; | ||
14 | +import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
11 | import com.yohoufo.order.constants.ActivityTypeEnum; | 15 | import com.yohoufo.order.constants.ActivityTypeEnum; |
12 | import com.yohoufo.order.constants.MetaKey; | 16 | import com.yohoufo.order.constants.MetaKey; |
13 | import com.yohoufo.order.model.bo.ActivityBo; | 17 | import com.yohoufo.order.model.bo.ActivityBo; |
@@ -31,6 +35,9 @@ import java.util.Objects; | @@ -31,6 +35,9 @@ import java.util.Objects; | ||
31 | * Created by jiexiang.wu on 2019/5/24. | 35 | * Created by jiexiang.wu on 2019/5/24. |
32 | * 买家订单状态发生变化后,可以异步处理的业务逻辑,如 | 36 | * 买家订单状态发生变化后,可以异步处理的业务逻辑,如 |
33 | * 1.砍价订单需要通知活动模块 | 37 | * 1.砍价订单需要通知活动模块 |
38 | + * 2.通知yohobuy 首单首购 | ||
39 | + * 3.通知resource清空新客缓存 | ||
40 | + * 4.鉴定通过、瑕疵接受 卖家订单统计 | ||
34 | * 等等 | 41 | * 等等 |
35 | */ | 42 | */ |
36 | @Component | 43 | @Component |
@@ -39,6 +46,12 @@ public class BuyerOrderChangeBusinessPostProcessor { | @@ -39,6 +46,12 @@ public class BuyerOrderChangeBusinessPostProcessor { | ||
39 | final private Logger logger = LoggerUtils.getBuyerOrderLogger(); | 46 | final private Logger logger = LoggerUtils.getBuyerOrderLogger(); |
40 | 47 | ||
41 | @Autowired | 48 | @Autowired |
49 | + private BuyerOrderGoodsMapper buyerOrderGoodsMapper; | ||
50 | + | ||
51 | + @Autowired | ||
52 | + private SellerOrderGoodsMapper sellerOrderGoodsMapper; | ||
53 | + | ||
54 | + @Autowired | ||
42 | private BuyerOrderMetaMapperSupport buyerOrderMetaMapperSupport; | 55 | private BuyerOrderMetaMapperSupport buyerOrderMetaMapperSupport; |
43 | 56 | ||
44 | @Autowired | 57 | @Autowired |
@@ -277,11 +290,16 @@ public class BuyerOrderChangeBusinessPostProcessor { | @@ -277,11 +290,16 @@ public class BuyerOrderChangeBusinessPostProcessor { | ||
277 | } | 290 | } |
278 | 291 | ||
279 | private void doProcess(BuyerOrder buyerOrder) { | 292 | private void doProcess(BuyerOrder buyerOrder) { |
293 | + | ||
294 | + BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrder.getOrderCode()); | ||
295 | + | ||
296 | + SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(buyerOrderGoods.getSkup()); | ||
297 | + | ||
280 | SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder() | 298 | SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder() |
281 | .buyerUid(buyerOrder.getUid()) | 299 | .buyerUid(buyerOrder.getUid()) |
282 | .buyerOrderCode(buyerOrder.getOrderCode()) | 300 | .buyerOrderCode(buyerOrder.getOrderCode()) |
283 | .sellerUid(buyerOrder.getSellerUid()) | 301 | .sellerUid(buyerOrder.getSellerUid()) |
284 | - .orderAttribute(OrderAttributes.getOrderAttributes(buyerOrder.getAttributes())) | 302 | + .skupType(SkupType.getSkupType(sellerOrderGoods.getAttributes())) |
285 | .build(); | 303 | .build(); |
286 | 304 | ||
287 | SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry); | 305 | SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry); |
@@ -4,8 +4,8 @@ import com.google.common.collect.Lists; | @@ -4,8 +4,8 @@ import com.google.common.collect.Lists; | ||
4 | import com.yohobuy.ufo.model.order.bo.SellerBo; | 4 | import com.yohobuy.ufo.model.order.bo.SellerBo; |
5 | import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo; | 5 | import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo; |
6 | import com.yohobuy.ufo.model.order.common.EntrySellerType; | 6 | import com.yohobuy.ufo.model.order.common.EntrySellerType; |
7 | -import com.yohobuy.ufo.model.order.common.OrderAttributes; | ||
8 | import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; | 7 | import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; |
8 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
9 | import com.yohobuy.ufo.model.order.resp.EntryThreshold; | 9 | import com.yohobuy.ufo.model.order.resp.EntryThreshold; |
10 | import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp; | 10 | import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp; |
11 | import com.yohoufo.common.cache.CacheKeyEnum; | 11 | import com.yohoufo.common.cache.CacheKeyEnum; |
@@ -217,7 +217,7 @@ public class SellerService { | @@ -217,7 +217,7 @@ public class SellerService { | ||
217 | */ | 217 | */ |
218 | private SellerPlatformServiceFee getCurrentTimeSellerPlatformServiceFee(int uid) { | 218 | private SellerPlatformServiceFee getCurrentTimeSellerPlatformServiceFee(int uid) { |
219 | //当前的扣点服务 | 219 | //当前的扣点服务 |
220 | - SellerOrderStatsEntry currentStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).orderAttribute(OrderAttributes.COMMON_IN_STOCK).time(DateUtil.getCurrentTimeSecond()).build(); | 220 | + SellerOrderStatsEntry currentStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(SkupType.IN_STOCK).time(DateUtil.getCurrentTimeSecond()).build(); |
221 | SellerOrderStatsConfiguration currentStatsConfig = statsConfigurationManager.getStatsConfig(currentStatsEntry); | 221 | SellerOrderStatsConfiguration currentStatsConfig = statsConfigurationManager.getStatsConfig(currentStatsEntry); |
222 | return (SellerPlatformServiceFee)statsConfigurationManager.getStatsProcessor(currentStatsConfig.getStatsProcessorName()).apply(currentStatsEntry, currentStatsConfig); | 222 | return (SellerPlatformServiceFee)statsConfigurationManager.getStatsProcessor(currentStatsConfig.getStatsProcessorName()).apply(currentStatsEntry, currentStatsConfig); |
223 | } | 223 | } |
@@ -230,7 +230,7 @@ public class SellerService { | @@ -230,7 +230,7 @@ public class SellerService { | ||
230 | */ | 230 | */ |
231 | private SellerPlatformServiceFee getNextPeriodSellerPlatformServiceFee(int uid) { | 231 | private SellerPlatformServiceFee getNextPeriodSellerPlatformServiceFee(int uid) { |
232 | //下个周期 | 232 | //下个周期 |
233 | - SellerOrderStatsEntry nextStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).orderAttribute(OrderAttributes.COMMON_IN_STOCK).build(); | 233 | + SellerOrderStatsEntry nextStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(SkupType.IN_STOCK).build(); |
234 | SellerOrderStatsConfiguration nextStatsConfig = statsConfigurationManager.getStatsConfig(nextStatsEntry); | 234 | SellerOrderStatsConfiguration nextStatsConfig = statsConfigurationManager.getStatsConfig(nextStatsEntry); |
235 | Pair<Integer, Integer> nextValidityTimeTuple = nextStatsConfig.getStatsUnit().nextPeriodTimeTuple(nextStatsConfig.getStatsPeriod(), nextStatsConfig.getStatsPeriod()); | 235 | Pair<Integer, Integer> nextValidityTimeTuple = nextStatsConfig.getStatsUnit().nextPeriodTimeTuple(nextStatsConfig.getStatsPeriod(), nextStatsConfig.getStatsPeriod()); |
236 | //设置查询时间为下个周期的开始时间 | 236 | //设置查询时间为下个周期的开始时间 |
1 | package com.yohoufo.order.service.stats.impl; | 1 | package com.yohoufo.order.service.stats.impl; |
2 | 2 | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | -import com.yohobuy.ufo.model.order.common.OrderAttributes; | 4 | +import com.yohobuy.ufo.model.order.constants.SkupType; |
5 | import com.yohoufo.order.service.stats.StatsConfiguration; | 5 | import com.yohoufo.order.service.stats.StatsConfiguration; |
6 | import com.yohoufo.order.service.stats.StatsUnit; | 6 | import com.yohoufo.order.service.stats.StatsUnit; |
7 | import lombok.*; | 7 | import lombok.*; |
@@ -24,7 +24,7 @@ public class SellerOrderStatsConfiguration implements StatsConfiguration { | @@ -24,7 +24,7 @@ public class SellerOrderStatsConfiguration implements StatsConfiguration { | ||
24 | //排除的uid | 24 | //排除的uid |
25 | private List<Integer> excludeUids; | 25 | private List<Integer> excludeUids; |
26 | //属性 | 26 | //属性 |
27 | - private List<OrderAttributes> orderAttributes; | 27 | + private List<SkupType> skupTypes; |
28 | private StatsUnit statsUnit; | 28 | private StatsUnit statsUnit; |
29 | private int statsPeriod; | 29 | private int statsPeriod; |
30 | private String statsProcessorName; | 30 | private String statsProcessorName; |
@@ -40,8 +40,8 @@ public class SellerOrderStatsConfigurationManager implements StatsConfigManager< | @@ -40,8 +40,8 @@ public class SellerOrderStatsConfigurationManager implements StatsConfigManager< | ||
40 | 40 | ||
41 | @Override | 41 | @Override |
42 | public SellerOrderStatsConfiguration getStatsConfig(SellerOrderStatsEntry statsEntry) { | 42 | public SellerOrderStatsConfiguration getStatsConfig(SellerOrderStatsEntry statsEntry) { |
43 | - Optional<SellerOrderStatsConfiguration> configurationOp = sellerOrderStatsConfigCacheService.findBy(statsEntry.getOrderAttribute()); | ||
44 | - if (!configurationOp.isPresent() || configurationOp.get().getExcludeUids().stream().anyMatch(uid -> uid == statsEntry.getSellerUid())) { | 43 | + Optional<SellerOrderStatsConfiguration> configurationOp = sellerOrderStatsConfigCacheService.findBy(statsEntry.getSkupType()); |
44 | + if (!configurationOp.isPresent() || configurationOp.get().getExcludeUids().contains(statsEntry.getSellerUid())) { | ||
45 | // 没有找到配置项或卖家被排除 | 45 | // 没有找到配置项或卖家被排除 |
46 | logger.info("stats config is null or seller is excluded for statsEntry:{}",statsEntry); | 46 | logger.info("stats config is null or seller is excluded for statsEntry:{}",statsEntry); |
47 | return SellerOrderStatsConfiguration.emptyConfiguration; | 47 | return SellerOrderStatsConfiguration.emptyConfiguration; |
1 | package com.yohoufo.order.service.stats.impl; | 1 | package com.yohoufo.order.service.stats.impl; |
2 | 2 | ||
3 | - | ||
4 | -import com.yohobuy.ufo.model.order.common.OrderAttributes; | 3 | +import com.yohobuy.ufo.model.order.constants.SkupType; |
5 | import com.yohoufo.order.service.stats.StatsEntry; | 4 | import com.yohoufo.order.service.stats.StatsEntry; |
6 | import lombok.*; | 5 | import lombok.*; |
7 | 6 | ||
@@ -17,7 +16,7 @@ public class SellerOrderStatsEntry implements StatsEntry { | @@ -17,7 +16,7 @@ public class SellerOrderStatsEntry implements StatsEntry { | ||
17 | private int sellerUid; | 16 | private int sellerUid; |
18 | private int buyerUid; | 17 | private int buyerUid; |
19 | private long buyerOrderCode; | 18 | private long buyerOrderCode; |
20 | - private OrderAttributes orderAttribute; | 19 | + private SkupType skupType; |
21 | //查询时间 | 20 | //查询时间 |
22 | private int time; | 21 | private int time; |
23 | } | 22 | } |
1 | package com.yohoufo.order.service.support; | 1 | package com.yohoufo.order.service.support; |
2 | 2 | ||
3 | import com.yoho.core.common.utils.DateUtil; | 3 | import com.yoho.core.common.utils.DateUtil; |
4 | -import com.yohobuy.ufo.model.order.common.OrderAttributes; | 4 | +import com.yohobuy.ufo.model.order.constants.SkupType; |
5 | import com.yohoufo.order.model.bo.SellerPlatformServiceFee; | 5 | import com.yohoufo.order.model.bo.SellerPlatformServiceFee; |
6 | import com.yohoufo.order.service.stats.StatsConfigManager; | 6 | import com.yohoufo.order.service.stats.StatsConfigManager; |
7 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; | 7 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; |
@@ -28,13 +28,13 @@ public class SellerPlatformServiceFeeSupport { | @@ -28,13 +28,13 @@ public class SellerPlatformServiceFeeSupport { | ||
28 | * 获取平台技术服务费比例 | 28 | * 获取平台技术服务费比例 |
29 | * | 29 | * |
30 | * @param uid | 30 | * @param uid |
31 | - * @param orderAttributes | 31 | + * @param skupType |
32 | * @return 可能为null | 32 | * @return 可能为null |
33 | */ | 33 | */ |
34 | - public BigDecimal getPlatformServiceFeeRate(int uid, OrderAttributes orderAttributes) { | ||
35 | - logger.info("platformServiceFeeRate,uid {}, attribute:{}", uid, orderAttributes); | 34 | + public BigDecimal getPlatformServiceFeeRate(int uid, SkupType skupType) { |
35 | + logger.info("platformServiceFeeRate,uid {}, skupType:{}", uid, skupType); | ||
36 | 36 | ||
37 | - SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).orderAttribute(orderAttributes).time(DateUtil.getCurrentTimeSecond()).build(); | 37 | + SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(skupType).time(DateUtil.getCurrentTimeSecond()).build(); |
38 | 38 | ||
39 | SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry); | 39 | SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry); |
40 | 40 |
-
Please register or login to post a comment