Merge branch 'dev-seller-order-stat-6.9.9' into test6.9.9
Showing
4 changed files
with
15 additions
and
17 deletions
@@ -20,12 +20,6 @@ public class SellerOrderStatsConfig { | @@ -20,12 +20,6 @@ public class SellerOrderStatsConfig { | ||
20 | //统计处理器 | 20 | //统计处理器 |
21 | private String statsProcessor; | 21 | private String statsProcessor; |
22 | 22 | ||
23 | - //1 有效 | ||
24 | - private int statsEnabled; | ||
25 | - | ||
26 | //业务执行参数 | 23 | //业务执行参数 |
27 | private String actionParam; | 24 | private String actionParam; |
28 | - | ||
29 | - //备注 | ||
30 | - private String remark; | ||
31 | } | 25 | } |
@@ -9,18 +9,16 @@ | @@ -9,18 +9,16 @@ | ||
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="stats_enabled" property="statsEnabled" jdbcType="INTEGER" /> | ||
13 | <result column="action_param" property="actionParam" jdbcType="VARCHAR" /> | 12 | <result column="action_param" property="actionParam" jdbcType="VARCHAR" /> |
14 | - <result column="remark" property="remark" jdbcType="VARCHAR" /> | ||
15 | </resultMap> | 13 | </resultMap> |
16 | <sql id="Base_Column_List" > | 14 | <sql id="Base_Column_List" > |
17 | - id, stats_code, exclude_uid,order_attribute, stats_unit, stats_period, stats_processor, stats_enabled, action_param, remark | 15 | + id, stats_code, exclude_uid,order_attribute, stats_unit, stats_period, stats_processor, action_param |
18 | </sql> | 16 | </sql> |
19 | 17 | ||
20 | <select id="selectEnabledStatsConfig" resultMap="BaseResultMap" > | 18 | <select id="selectEnabledStatsConfig" resultMap="BaseResultMap" > |
21 | select | 19 | select |
22 | <include refid="Base_Column_List" /> | 20 | <include refid="Base_Column_List" /> |
23 | from seller_order_stats_config | 21 | from seller_order_stats_config |
24 | - where stats_enabled = 1 | 22 | + where stats_enabled = 'Y' |
25 | </select> | 23 | </select> |
26 | </mapper> | 24 | </mapper> |
@@ -9,9 +9,9 @@ import com.yohoufo.dal.order.SellerOrderStatsConfigMapper; | @@ -9,9 +9,9 @@ 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; |
11 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; | 11 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; |
12 | +import com.yohoufo.order.utils.LoggerUtils; | ||
12 | import org.apache.commons.collections.CollectionUtils; | 13 | import org.apache.commons.collections.CollectionUtils; |
13 | import org.slf4j.Logger; | 14 | import org.slf4j.Logger; |
14 | -import org.slf4j.LoggerFactory; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
16 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
17 | 17 | ||
@@ -28,7 +28,10 @@ import java.util.stream.Collectors; | @@ -28,7 +28,10 @@ import java.util.stream.Collectors; | ||
28 | @Component | 28 | @Component |
29 | public class SellerOrderStatsConfigCacheService { | 29 | public class SellerOrderStatsConfigCacheService { |
30 | 30 | ||
31 | - private static final Logger logger = LoggerFactory.getLogger(SellerOrderStatsConfigCacheService.class); | 31 | + private static final Logger logger = LoggerUtils.getSellerOrderLogger(); |
32 | + | ||
33 | + //分隔字符 | ||
34 | + private static final String FIELD_SPLIT_TOKEN = ","; | ||
32 | 35 | ||
33 | //统计所有配置项 | 36 | //统计所有配置项 |
34 | public final static String SELLER_ORDER_STATS_CONFIG_KEY = "SELLER_ORDER_STATS_CONFIG"; | 37 | public final static String SELLER_ORDER_STATS_CONFIG_KEY = "SELLER_ORDER_STATS_CONFIG"; |
@@ -53,8 +56,8 @@ public class SellerOrderStatsConfigCacheService { | @@ -53,8 +56,8 @@ public class SellerOrderStatsConfigCacheService { | ||
53 | configs.forEach(config -> { | 56 | configs.forEach(config -> { |
54 | SellerOrderStatsConfiguration configuration = SellerOrderStatsConfiguration.builder() | 57 | SellerOrderStatsConfiguration configuration = SellerOrderStatsConfiguration.builder() |
55 | .statsCode(config.getStatsCode()) | 58 | .statsCode(config.getStatsCode()) |
56 | - .excludeUids(Splitter.on(",").omitEmptyStrings().splitToList(config.getExcludeUid()).stream().map(uid -> Integer.parseInt(uid.trim())).collect(Collectors.toList())) | ||
57 | - .orderAttributes(Splitter.on(",").omitEmptyStrings().splitToList(config.getOrderAttribute()).stream().map(code -> OrderAttributes.getOrderAttributes(Integer.parseInt(code.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())) | ||
58 | .statsUnit(StatsUnit.find(config.getStatsUnit())) | 61 | .statsUnit(StatsUnit.find(config.getStatsUnit())) |
59 | .statsPeriod(config.getStatsPeriod()) | 62 | .statsPeriod(config.getStatsPeriod()) |
60 | .statsProcessorName(config.getStatsProcessor()) | 63 | .statsProcessorName(config.getStatsProcessor()) |
@@ -63,7 +66,7 @@ public class SellerOrderStatsConfigCacheService { | @@ -63,7 +66,7 @@ public class SellerOrderStatsConfigCacheService { | ||
63 | 66 | ||
64 | configurations.add(configuration); | 67 | configurations.add(configuration); |
65 | }); | 68 | }); |
66 | - | 69 | + logger.info("key {}, old value is {}, new value is {}.", key, oldValue, configurations); |
67 | return configurations; | 70 | return configurations; |
68 | } catch (Exception ex) { | 71 | } catch (Exception ex) { |
69 | logger.warn("key {}, old value is {}, error message is {}.", key, oldValue, ex.getMessage()); | 72 | logger.warn("key {}, old value is {}, error message is {}.", key, oldValue, ex.getMessage()); |
@@ -169,7 +169,7 @@ public class SellerService { | @@ -169,7 +169,7 @@ public class SellerService { | ||
169 | * @return | 169 | * @return |
170 | */ | 170 | */ |
171 | public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) { | 171 | public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) { |
172 | - logger.info("platformServiceFee uid {}", uid); | 172 | + logger.info("platformServiceFeeDetail uid {}", uid); |
173 | SellerPlatformServiceFee currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid); | 173 | SellerPlatformServiceFee currentServiceFee = getCurrentTimeSellerPlatformServiceFee(uid); |
174 | 174 | ||
175 | SellerPlatformServiceFee nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid); | 175 | SellerPlatformServiceFee nextPeriodServiceFee = getNextPeriodSellerPlatformServiceFee(uid); |
@@ -188,6 +188,8 @@ public class SellerService { | @@ -188,6 +188,8 @@ public class SellerService { | ||
188 | List<PlatformServiceFeeDefinition.FeeRule> rules = new ArrayList<>(nextPeriodServiceFee.getDefinition().getRules()); | 188 | List<PlatformServiceFeeDefinition.FeeRule> rules = new ArrayList<>(nextPeriodServiceFee.getDefinition().getRules()); |
189 | //从小到大排序 | 189 | //从小到大排序 |
190 | rules.sort(Comparator.comparing(PlatformServiceFeeDefinition.FeeRule::getThreshold)); | 190 | rules.sort(Comparator.comparing(PlatformServiceFeeDefinition.FeeRule::getThreshold)); |
191 | + | ||
192 | + //构建返回结果中的扣点规则 | ||
191 | List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> { | 193 | List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> { |
192 | SellerPlatformServiceFeeResp.Node node = new SellerPlatformServiceFeeResp.Node(); | 194 | SellerPlatformServiceFeeResp.Node node = new SellerPlatformServiceFeeResp.Node(); |
193 | node.setKey(rule.getThreshold()); | 195 | node.setKey(rule.getThreshold()); |
@@ -195,6 +197,7 @@ public class SellerService { | @@ -195,6 +197,7 @@ public class SellerService { | ||
195 | return node; | 197 | return node; |
196 | }).collect(Collectors.toList()); | 198 | }).collect(Collectors.toList()); |
197 | 199 | ||
200 | + //最终返回结果 | ||
198 | SellerPlatformServiceFeeResp resp = SellerPlatformServiceFeeResp.builder() | 201 | SellerPlatformServiceFeeResp resp = SellerPlatformServiceFeeResp.builder() |
199 | .currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate())) | 202 | .currentRate(MathUtils.convert2Percent(currentServiceFee.getFeeRate())) |
200 | .nodes(nodes) | 203 | .nodes(nodes) |
@@ -203,7 +206,7 @@ public class SellerService { | @@ -203,7 +206,7 @@ public class SellerService { | ||
203 | .nextRateRequiredIncOrderQuantity(Math.max(0, unsatisfiedFeeRule.getThreshold() - nextPeriodOrderQuantity)) | 206 | .nextRateRequiredIncOrderQuantity(Math.max(0, unsatisfiedFeeRule.getThreshold() - nextPeriodOrderQuantity)) |
204 | .build(); | 207 | .build(); |
205 | 208 | ||
206 | - logger.info("platformServiceFee uid {},resp {}", uid, resp); | 209 | + logger.info("platformServiceFeeDetail uid {},resp {}", uid, resp); |
207 | return resp; | 210 | return resp; |
208 | } | 211 | } |
209 | 212 |
-
Please register or login to post a comment