Authored by wujiexiang

需求:卖家阶梯扣点

package com.yohoufo.order.service.stat;
/**
* Created by jiexiang.wu on 2019/7/19.
*/
public interface StatsConfigManager<T extends StatsEntry> {
StatsProcessorRegistry getRegistry();
/**
* 获取统计器
*
* @param statsEntry
* @return
*/
StatsProcessor getStatsProcessor(T statsEntry);
}
... ...
package com.yohoufo.order.service.stat;
/**
* Created by jiexiang.wu on 2019/7/19.
* 统计基础类 标识
*/
public interface StatsEntry {
}
... ...
package com.yohoufo.order.service.stat;
import java.util.function.Consumer;
/**
* Created by jiexiang.wu on 2019/7/19.
* 统计处理器
*/
public interface StatsProcessor<T extends StatsEntry> extends Consumer<T> {
/**
* 名称
* 必须保证唯一,建议使用类名
*
* @return
*/
String getName();
@Override
void accept(T entry);
}
... ...
package com.yohoufo.order.service.stat;
import java.util.HashMap;
import java.util.Map;
/**
* Created by jiexiang.wu on 2019/7/19.
* 统计器注册容器
*/
public class StatsProcessorRegistry {
private final Map<String, StatsProcessor> statisticsMap = new HashMap<String, StatsProcessor>();
public StatsProcessor getStatsProcessor(String name) {
return statisticsMap.get(name);
}
}
... ...
package com.yohoufo.order.service.stat.impl;
import com.yohoufo.order.service.stat.StatsProcessor;
/**
* Created by jiexiang.wu on 2019/7/19.
* 卖家订单数量汇总统计
*/
public class SellerOrderQuantitySummaryStatsProcessor implements StatsProcessor<SellerOrderStatsEntry> {
@Override
public String getName() {
return "sellerOrderQuantitySummaryStatsProcessor";
}
@Override
public void accept(SellerOrderStatsEntry entry) {
}
}
... ...
package com.yohoufo.order.service.stat.impl;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import lombok.*;
import java.util.List;
/**
* Created by jiexiang.wu on 2019/7/19.
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class SellerOrderStatConfig {
private String statsCode;
//排除的uid
private List<Integer> excludeUids;
//属性
private List<OrderAttributes> orderAttributes;
private String statsUnit;
private int statsPeriod;
private String statsProcessor;
}
... ...
package com.yohoufo.order.service.stat.impl;
import com.yohoufo.order.service.stat.StatsConfigManager;
import com.yohoufo.order.service.stat.StatsProcessor;
import com.yohoufo.order.service.stat.StatsProcessorRegistry;
/**
* Created by jiexiang.wu on 2019/7/19.
* 卖家订单统计配置管理
*/
public class SellerOrderStatConfigurationManager implements StatsConfigManager<SellerOrderStatsEntry> {
private StatsProcessorRegistry registry = new StatsProcessorRegistry();
@Override
public StatsProcessor getStatsProcessor(SellerOrderStatsEntry statsEntry) {
return null;
}
@Override
public StatsProcessorRegistry getRegistry() {
return registry;
}
}
... ...
package com.yohoufo.order.service.stat.impl;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohoufo.order.service.stat.StatsEntry;
import lombok.*;
/**
* Created by jiexiang.wu on 2019/7/19.
*/
@Data
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class SellerOrderStatsEntry implements StatsEntry {
private int sellerUid;
private int buyerUid;
private long buyerOrderCode;
private OrderAttributes orderAttribute;
}
... ...