Authored by wujiexiang

根据skup_type统计

... ... @@ -12,7 +12,7 @@ public class SellerOrderStatsConfig {
//排除的uid
private String excludeUid;
//属性
private String orderAttribute;
private String skupType;
//统计单位
private String statsUnit;
//统计周期
... ...
... ... @@ -5,14 +5,14 @@
<id column="id" property="id" jdbcType="BIGINT" />
<result column="stats_code" property="statsCode" jdbcType="VARCHAR" />
<result column="exclude_uid" property="excludeUid" jdbcType="VARCHAR" />
<result column="order_attribute" property="orderAttribute" jdbcType="VARCHAR" />
<result column="skup_type" property="skupType" jdbcType="VARCHAR" />
<result column="stats_unit" property="statsUnit" jdbcType="VARCHAR" />
<result column="stats_period" property="statsPeriod" jdbcType="INTEGER" />
<result column="stats_processor" property="statsProcessor" jdbcType="VARCHAR" />
<result column="action_param" property="actionParam" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, stats_code, exclude_uid,order_attribute, stats_unit, stats_period, stats_processor, action_param
id, stats_code, exclude_uid, skup_type, stats_unit, stats_period, stats_processor, action_param
</sql>
<select id="selectEnabledStatsConfig" resultMap="BaseResultMap" >
... ...
... ... @@ -4,7 +4,7 @@ import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.yoho.core.cache.LocalCache;
import com.yoho.core.cache.LocalCacheCallback;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.dal.order.SellerOrderStatsConfigMapper;
import com.yohoufo.dal.order.model.SellerOrderStatsConfig;
import com.yohoufo.order.service.stats.StatsUnit;
... ... @@ -57,7 +57,7 @@ public class SellerOrderStatsConfigCacheService {
SellerOrderStatsConfiguration configuration = SellerOrderStatsConfiguration.builder()
.statsCode(config.getStatsCode())
.excludeUids(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getExcludeUid()).stream().map(uid -> Integer.parseInt(uid.trim())).collect(Collectors.toList()))
.orderAttributes(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getOrderAttribute()).stream().map(code -> OrderAttributes.getOrderAttributes(Integer.parseInt(code.trim()))).collect(Collectors.toList()))
.skupTypes(Splitter.on(FIELD_SPLIT_TOKEN).omitEmptyStrings().splitToList(config.getSkupType()).stream().map(code -> SkupType.getSkupType(Integer.parseInt(code.trim()))).collect(Collectors.toList()))
.statsUnit(StatsUnit.find(config.getStatsUnit()))
.statsPeriod(config.getStatsPeriod())
.statsProcessorName(config.getStatsProcessor())
... ... @@ -76,11 +76,11 @@ public class SellerOrderStatsConfigCacheService {
});
}
public Optional<SellerOrderStatsConfiguration> findBy(OrderAttributes orderAttributes) {
public Optional<SellerOrderStatsConfiguration> findBy(SkupType skupType) {
List<SellerOrderStatsConfiguration> configurations = (List) localCache.get(SELLER_ORDER_STATS_CONFIG_KEY);
if (CollectionUtils.isEmpty(configurations)) {
return Optional.ofNullable(null);
}
return configurations.stream().filter(config -> config.getOrderAttributes().contains(orderAttributes)).findFirst();
return configurations.stream().filter(config -> config.getSkupTypes().contains(skupType)).findFirst();
}
}
... ...
... ... @@ -3,11 +3,15 @@ package com.yohoufo.order.service.listener.processor;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.core.rabbitmq.YhProducer;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.constants.ActivityTypeEnum;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.bo.ActivityBo;
... ... @@ -31,6 +35,9 @@ import java.util.Objects;
* Created by jiexiang.wu on 2019/5/24.
* 买家订单状态发生变化后,可以异步处理的业务逻辑,如
* 1.砍价订单需要通知活动模块
* 2.通知yohobuy 首单首购
* 3.通知resource清空新客缓存
* 4.鉴定通过、瑕疵接受 卖家订单统计
* 等等
*/
@Component
... ... @@ -39,6 +46,12 @@ public class BuyerOrderChangeBusinessPostProcessor {
final private Logger logger = LoggerUtils.getBuyerOrderLogger();
@Autowired
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
@Autowired
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
private BuyerOrderMetaMapperSupport buyerOrderMetaMapperSupport;
@Autowired
... ... @@ -277,11 +290,16 @@ public class BuyerOrderChangeBusinessPostProcessor {
}
private void doProcess(BuyerOrder buyerOrder) {
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrder.getOrderCode());
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(buyerOrderGoods.getSkup());
SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder()
.buyerUid(buyerOrder.getUid())
.buyerOrderCode(buyerOrder.getOrderCode())
.sellerUid(buyerOrder.getSellerUid())
.orderAttribute(OrderAttributes.getOrderAttributes(buyerOrder.getAttributes()))
.skupType(SkupType.getSkupType(sellerOrderGoods.getAttributes()))
.build();
SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry);
... ...
... ... @@ -4,8 +4,8 @@ import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.SellerBo;
import com.yohobuy.ufo.model.order.bo.SellerLevelFuncBo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp;
import com.yohoufo.common.cache.CacheKeyEnum;
... ... @@ -217,7 +217,7 @@ public class SellerService {
*/
private SellerPlatformServiceFee getCurrentTimeSellerPlatformServiceFee(int uid) {
//当前的扣点服务
SellerOrderStatsEntry currentStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).orderAttribute(OrderAttributes.COMMON_IN_STOCK).time(DateUtil.getCurrentTimeSecond()).build();
SellerOrderStatsEntry currentStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(SkupType.IN_STOCK).time(DateUtil.getCurrentTimeSecond()).build();
SellerOrderStatsConfiguration currentStatsConfig = statsConfigurationManager.getStatsConfig(currentStatsEntry);
return (SellerPlatformServiceFee)statsConfigurationManager.getStatsProcessor(currentStatsConfig.getStatsProcessorName()).apply(currentStatsEntry, currentStatsConfig);
}
... ... @@ -230,7 +230,7 @@ public class SellerService {
*/
private SellerPlatformServiceFee getNextPeriodSellerPlatformServiceFee(int uid) {
//下个周期
SellerOrderStatsEntry nextStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).orderAttribute(OrderAttributes.COMMON_IN_STOCK).build();
SellerOrderStatsEntry nextStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(SkupType.IN_STOCK).build();
SellerOrderStatsConfiguration nextStatsConfig = statsConfigurationManager.getStatsConfig(nextStatsEntry);
Pair<Integer, Integer> nextValidityTimeTuple = nextStatsConfig.getStatsUnit().nextPeriodTimeTuple(nextStatsConfig.getStatsPeriod(), nextStatsConfig.getStatsPeriod());
//设置查询时间为下个周期的开始时间
... ...
package com.yohoufo.order.service.stats.impl;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.service.stats.StatsConfiguration;
import com.yohoufo.order.service.stats.StatsUnit;
import lombok.*;
... ... @@ -24,7 +24,7 @@ public class SellerOrderStatsConfiguration implements StatsConfiguration {
//排除的uid
private List<Integer> excludeUids;
//属性
private List<OrderAttributes> orderAttributes;
private List<SkupType> skupTypes;
private StatsUnit statsUnit;
private int statsPeriod;
private String statsProcessorName;
... ...
... ... @@ -40,8 +40,8 @@ public class SellerOrderStatsConfigurationManager implements StatsConfigManager<
@Override
public SellerOrderStatsConfiguration getStatsConfig(SellerOrderStatsEntry statsEntry) {
Optional<SellerOrderStatsConfiguration> configurationOp = sellerOrderStatsConfigCacheService.findBy(statsEntry.getOrderAttribute());
if (!configurationOp.isPresent() || configurationOp.get().getExcludeUids().stream().anyMatch(uid -> uid == statsEntry.getSellerUid())) {
Optional<SellerOrderStatsConfiguration> configurationOp = sellerOrderStatsConfigCacheService.findBy(statsEntry.getSkupType());
if (!configurationOp.isPresent() || configurationOp.get().getExcludeUids().contains(statsEntry.getSellerUid())) {
// 没有找到配置项或卖家被排除
logger.info("stats config is null or seller is excluded for statsEntry:{}",statsEntry);
return SellerOrderStatsConfiguration.emptyConfiguration;
... ...
package com.yohoufo.order.service.stats.impl;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.service.stats.StatsEntry;
import lombok.*;
... ... @@ -17,7 +16,7 @@ public class SellerOrderStatsEntry implements StatsEntry {
private int sellerUid;
private int buyerUid;
private long buyerOrderCode;
private OrderAttributes orderAttribute;
private SkupType skupType;
//查询时间
private int time;
}
... ...
package com.yohoufo.order.service.support;
import com.yoho.core.common.utils.DateUtil;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohoufo.order.model.bo.SellerPlatformServiceFee;
import com.yohoufo.order.service.stats.StatsConfigManager;
import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration;
... ... @@ -28,13 +28,13 @@ public class SellerPlatformServiceFeeSupport {
* 获取平台技术服务费比例
*
* @param uid
* @param orderAttributes
* @param skupType
* @return 可能为null
*/
public BigDecimal getPlatformServiceFeeRate(int uid, OrderAttributes orderAttributes) {
logger.info("platformServiceFeeRate,uid {}, attribute:{}", uid, orderAttributes);
public BigDecimal getPlatformServiceFeeRate(int uid, SkupType skupType) {
logger.info("platformServiceFeeRate,uid {}, skupType:{}", uid, skupType);
SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).orderAttribute(orderAttributes).time(DateUtil.getCurrentTimeSecond()).build();
SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(skupType).time(DateUtil.getCurrentTimeSecond()).build();
SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry);
... ...