Authored by wujiexiang

Merge branch 'dev-seller-order-stat-6.9.9' into test6.9.9

... ... @@ -20,12 +20,6 @@ public class SellerOrderStatsConfig {
//统计处理器
private String statsProcessor;
//1 有效
private int statsEnabled;
//业务执行参数
private String actionParam;
//备注
private String remark;
}
... ...
... ... @@ -9,18 +9,16 @@
<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="stats_enabled" property="statsEnabled" jdbcType="INTEGER" />
<result column="action_param" property="actionParam" jdbcType="VARCHAR" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, stats_code, exclude_uid,order_attribute, stats_unit, stats_period, stats_processor, stats_enabled, action_param, remark
id, stats_code, exclude_uid,order_attribute, stats_unit, stats_period, stats_processor, action_param
</sql>
<select id="selectEnabledStatsConfig" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from seller_order_stats_config
where stats_enabled = 1
where stats_enabled = 'Y'
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -9,9 +9,9 @@ import com.yohoufo.dal.order.SellerOrderStatsConfigMapper;
import com.yohoufo.dal.order.model.SellerOrderStatsConfig;
import com.yohoufo.order.service.stats.StatsUnit;
import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -28,7 +28,10 @@ import java.util.stream.Collectors;
@Component
public class SellerOrderStatsConfigCacheService {
private static final Logger logger = LoggerFactory.getLogger(SellerOrderStatsConfigCacheService.class);
private static final Logger logger = LoggerUtils.getSellerOrderLogger();
//分隔字符
private static final String FIELD_SPLIT_TOKEN = ",";
//统计所有配置项
public final static String SELLER_ORDER_STATS_CONFIG_KEY = "SELLER_ORDER_STATS_CONFIG";
... ... @@ -53,8 +56,8 @@ public class SellerOrderStatsConfigCacheService {
configs.forEach(config -> {
SellerOrderStatsConfiguration configuration = SellerOrderStatsConfiguration.builder()
.statsCode(config.getStatsCode())
.excludeUids(Splitter.on(",").omitEmptyStrings().splitToList(config.getExcludeUid()).stream().map(uid -> Integer.parseInt(uid.trim())).collect(Collectors.toList()))
.orderAttributes(Splitter.on(",").omitEmptyStrings().splitToList(config.getOrderAttribute()).stream().map(code -> OrderAttributes.getOrderAttributes(Integer.parseInt(code.trim()))).collect(Collectors.toList()))
.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()))
.statsUnit(StatsUnit.find(config.getStatsUnit()))
.statsPeriod(config.getStatsPeriod())
.statsProcessorName(config.getStatsProcessor())
... ... @@ -63,7 +66,7 @@ public class SellerOrderStatsConfigCacheService {
configurations.add(configuration);
});
logger.info("key {}, old value is {}, new value is {}.", key, oldValue, configurations);
return configurations;
} catch (Exception ex) {
logger.warn("key {}, old value is {}, error message is {}.", key, oldValue, ex.getMessage());
... ...
... ... @@ -169,7 +169,7 @@ public class SellerService {
* @return
*/
public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) {
logger.info("platformServiceFee uid {}", uid);
logger.info("platformServiceFeeDetail uid {}", uid);
SellerPlatformServiceFee currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid);
SellerPlatformServiceFee nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid);
... ... @@ -188,6 +188,8 @@ public class SellerService {
List<PlatformServiceFeeDefinition.FeeRule> rules = new ArrayList<>(nextPeriodServiceFee.getDefinition().getRules());
//从小到大排序
rules.sort(Comparator.comparing(PlatformServiceFeeDefinition.FeeRule::getThreshold));
//构建返回结果中的扣点规则
List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> {
SellerPlatformServiceFeeResp.Node node = new SellerPlatformServiceFeeResp.Node();
node.setKey(rule.getThreshold());
... ... @@ -195,6 +197,7 @@ public class SellerService {
return node;
}).collect(Collectors.toList());
//最终返回结果
SellerPlatformServiceFeeResp resp = SellerPlatformServiceFeeResp.builder()
.currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate()))
.nodes(nodes)
... ... @@ -203,7 +206,7 @@ public class SellerService {
.nextRateRequiredIncOrderQuantity(Math.max(0, unsatisfiedFeeRule.getThreshold() - nextPeriodOrderQuantity))
.build();
logger.info("platformServiceFee uid {},resp {}", uid, resp);
logger.info("platformServiceFeeDetail uid {},resp {}", uid, resp);
return resp;
}
... ...