Merge branch 'test6.9.10' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.10
Showing
9 changed files
with
109 additions
and
98 deletions
@@ -156,6 +156,6 @@ | @@ -156,6 +156,6 @@ | ||
156 | select | 156 | select |
157 | <include refid="Base_Column_List" /> | 157 | <include refid="Base_Column_List" /> |
158 | from appraise_order_storage | 158 | from appraise_order_storage |
159 | - where order_code = #{orderCode,jdbcType=BIGINT} | 159 | + where order_code = #{orderCode,jdbcType=BIGINT} ORDER BY id desc limit 1 |
160 | </select> | 160 | </select> |
161 | </mapper> | 161 | </mapper> |
@@ -233,7 +233,7 @@ public class DepositController { | @@ -233,7 +233,7 @@ public class DepositController { | ||
233 | /** | 233 | /** |
234 | * 不可重复调用,新增记录不好防并发 | 234 | * 不可重复调用,新增记录不好防并发 |
235 | * | 235 | * |
236 | - * http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/?debug=XYZ&method=ufo.deposit.insertFakeDeposit&uid=500031826&skup=2&appraiseOrderCode=9776718192640&parentAppraiseOrderCode=123 | 236 | + * http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/?debug=XYZ&method=ufo.deposit.insertFakeDeposit&uid=500031826&appraiseOrderCode=9989014675295&parentAppraiseOrderCode=123 |
237 | * | 237 | * |
238 | * 新增一条现货寄存的虚拟库存 | 238 | * 新增一条现货寄存的虚拟库存 |
239 | * @param uid | 239 | * @param uid |
1 | package com.yohoufo.order.controller; | 1 | package com.yohoufo.order.controller; |
2 | 2 | ||
3 | -import com.google.common.base.Splitter; | ||
4 | import com.yohobuy.ufo.model.order.common.EntrySellerType; | 3 | import com.yohobuy.ufo.model.order.common.EntrySellerType; |
5 | import com.yohobuy.ufo.model.order.resp.EntryThreshold; | 4 | import com.yohobuy.ufo.model.order.resp.EntryThreshold; |
6 | import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp; | 5 | import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp; |
7 | import com.yohobuy.ufo.model.order.resp.SellerResp; | 6 | import com.yohobuy.ufo.model.order.resp.SellerResp; |
8 | import com.yohoufo.common.ApiResponse; | 7 | import com.yohoufo.common.ApiResponse; |
9 | -import com.yohoufo.common.annotation.IgnoreSession; | ||
10 | -import com.yohoufo.common.annotation.IgnoreSignature; | ||
11 | import com.yohoufo.common.exception.GatewayException; | 8 | import com.yohoufo.common.exception.GatewayException; |
12 | import com.yohoufo.common.exception.UfoServiceException; | 9 | import com.yohoufo.common.exception.UfoServiceException; |
13 | import com.yohoufo.order.service.IStoredSellerDepositService; | 10 | import com.yohoufo.order.service.IStoredSellerDepositService; |
@@ -180,19 +177,4 @@ public class SellerController { | @@ -180,19 +177,4 @@ public class SellerController { | ||
180 | SellerPlatformServiceFeeResp resp = sellerService.platformServiceFeeDetail(uid); | 177 | SellerPlatformServiceFeeResp resp = sellerService.platformServiceFeeDetail(uid); |
181 | return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("ok").build(); | 178 | return new ApiResponse.ApiResponseBuilder().code(200).data(resp).message("ok").build(); |
182 | } | 179 | } |
183 | - | ||
184 | - /** | ||
185 | - * 统计表没有入驻类型,手动补充 | ||
186 | - * | ||
187 | - * @param sellerUids 多个用,分隔 | ||
188 | - * @return | ||
189 | - */ | ||
190 | - @RequestMapping(params = "method=ufo.seller.orderQuantityStats.updateEnterType") | ||
191 | - @IgnoreSession | ||
192 | - @IgnoreSignature | ||
193 | - @ResponseBody | ||
194 | - public ApiResponse updateEnterTypeForOrderQuantityStats(@RequestParam("sellerUids") String sellerUids) { | ||
195 | - sellerService.updateEnterTypeForOrderQuantityStats(Splitter.on(",").omitEmptyStrings().splitToList(sellerUids)); | ||
196 | - return new ApiResponse.ApiResponseBuilder().code(200).data(null).message("ok").build(); | ||
197 | - } | ||
198 | } | 180 | } |
@@ -264,10 +264,7 @@ public class DepositOrderService { | @@ -264,10 +264,7 @@ public class DepositOrderService { | ||
264 | * @return | 264 | * @return |
265 | */ | 265 | */ |
266 | private DepositOrderComputeResp.PriceInfo getOrderFeeInfo(String depositCode, int uid, int depositId, Integer outType, Long orderCode) { | 266 | private DepositOrderComputeResp.PriceInfo getOrderFeeInfo(String depositCode, int uid, int depositId, Integer outType, Long orderCode) { |
267 | - DepositOrderComputeResp.PriceInfo priceInfo = DepositOrderComputeResp.PriceInfo.builder().build(); | ||
268 | - | ||
269 | - | ||
270 | - if (DepositOutTypeEnum.OUTTYPE_EXPIRED.equals(outType)) { // 现货寄存未入库的部分 | 267 | + if (DepositOutTypeEnum.OUTTYPE_EXPIRED.getCode().equals(outType)) { // 现货寄存未入库的部分 |
271 | 268 | ||
272 | AppraiseOrder appraiseOrder = depositHelpService.queryAppraiseOrderInfo(orderCode); | 269 | AppraiseOrder appraiseOrder = depositHelpService.queryAppraiseOrderInfo(orderCode); |
273 | 270 |
@@ -158,7 +158,7 @@ public class DepositHelpService { | @@ -158,7 +158,7 @@ public class DepositHelpService { | ||
158 | return Maps.newHashMap(); | 158 | return Maps.newHashMap(); |
159 | } | 159 | } |
160 | 160 | ||
161 | - // http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/?debug=XYZ&method=ufo.product.list.data&productIdList=10001272 | 161 | + // http://java-yohoufo-fore.test3.ingress.dev.yohocorp.com/ufo-gateway/?debug=XYZ&method=ufo.product.storageList.data&storageIdList=10090886 |
162 | List<StorageDataResp> storageRespList = (List<StorageDataResp>)ufoServiceCaller.call("ufo.product.storageList.data", List.class, storageList); | 162 | List<StorageDataResp> storageRespList = (List<StorageDataResp>)ufoServiceCaller.call("ufo.product.storageList.data", List.class, storageList); |
163 | Map<Integer, SellerOrderGoods> result = new HashMap<>(); | 163 | Map<Integer, SellerOrderGoods> result = new HashMap<>(); |
164 | 164 | ||
@@ -167,7 +167,7 @@ public class DepositHelpService { | @@ -167,7 +167,7 @@ public class DepositHelpService { | ||
167 | bo.setProductName(item.getProductName()); | 167 | bo.setProductName(item.getProductName()); |
168 | bo.setColorName(item.getColorName()); | 168 | bo.setColorName(item.getColorName()); |
169 | bo.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU=")); | 169 | bo.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU=")); |
170 | - bo.setSizeName(null == item.getSize() ? "-" : bo.getSizeName()); | 170 | + bo.setSizeName(null == item.getSize() ? "-" : item.getSize().getSizeName()); |
171 | 171 | ||
172 | result.put(item.getStorageId(), bo); | 172 | result.put(item.getStorageId(), bo); |
173 | } | 173 | } |
@@ -8,26 +8,18 @@ import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; | @@ -8,26 +8,18 @@ import com.yohobuy.ufo.model.order.common.SuperEnterStageLevel; | ||
8 | import com.yohobuy.ufo.model.order.constants.SkupType; | 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.alarm.EventBusPublisher; | ||
12 | import com.yohoufo.common.cache.CacheKeyEnum; | 11 | import com.yohoufo.common.cache.CacheKeyEnum; |
13 | -import com.yohoufo.common.utils.DateUtil; | ||
14 | import com.yohoufo.dal.order.SellerEnterApplyMapper; | 12 | import com.yohoufo.dal.order.SellerEnterApplyMapper; |
15 | import com.yohoufo.dal.order.StoredSellerMapper; | 13 | import com.yohoufo.dal.order.StoredSellerMapper; |
16 | import com.yohoufo.dal.order.SuperEntrySellerMapper; | 14 | import com.yohoufo.dal.order.SuperEntrySellerMapper; |
17 | -import com.yohoufo.dal.order.model.SellerOrderStatsResult; | ||
18 | import com.yohoufo.dal.order.model.SuperEntrySeller; | 15 | import com.yohoufo.dal.order.model.SuperEntrySeller; |
19 | -import com.yohoufo.order.common.EnterQuitEnum; | ||
20 | import com.yohoufo.order.common.SuperEntrySellerStatus; | 16 | import com.yohoufo.order.common.SuperEntrySellerStatus; |
21 | -import com.yohoufo.order.event.SellerEnterTypeChangeEvent; | ||
22 | import com.yohoufo.order.model.bo.PlatformServiceFeeDefinition; | 17 | import com.yohoufo.order.model.bo.PlatformServiceFeeDefinition; |
23 | import com.yohoufo.order.model.bo.SellerPlatformServiceFee; | 18 | import com.yohoufo.order.model.bo.SellerPlatformServiceFee; |
24 | import com.yohoufo.order.service.IStoredSellerService; | 19 | import com.yohoufo.order.service.IStoredSellerService; |
25 | import com.yohoufo.order.service.MerchantOrderPaymentService; | 20 | import com.yohoufo.order.service.MerchantOrderPaymentService; |
26 | import com.yohoufo.order.service.cache.StoredSellerCacheService; | 21 | import com.yohoufo.order.service.cache.StoredSellerCacheService; |
27 | import com.yohoufo.order.service.impl.MetaConfigService; | 22 | import com.yohoufo.order.service.impl.MetaConfigService; |
28 | -import com.yohoufo.order.service.stats.StatsConfigManager; | ||
29 | -import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; | ||
30 | -import com.yohoufo.order.service.stats.impl.SellerOrderStatsEntry; | ||
31 | import com.yohoufo.order.service.support.SellerPlatformServiceFeeSupport; | 23 | import com.yohoufo.order.service.support.SellerPlatformServiceFeeSupport; |
32 | import com.yohoufo.order.utils.LoggerUtils; | 24 | import com.yohoufo.order.utils.LoggerUtils; |
33 | import com.yohoufo.order.utils.MathUtils; | 25 | import com.yohoufo.order.utils.MathUtils; |
@@ -77,9 +69,6 @@ public class SellerService { | @@ -77,9 +69,6 @@ public class SellerService { | ||
77 | private SellerEnterApplyMapper sellerEnterApplyMapper; | 69 | private SellerEnterApplyMapper sellerEnterApplyMapper; |
78 | 70 | ||
79 | @Autowired | 71 | @Autowired |
80 | - private StatsConfigManager<SellerOrderStatsEntry, SellerOrderStatsConfiguration> statsConfigurationManager; | ||
81 | - | ||
82 | - @Autowired | ||
83 | private SellerPlatformServiceFeeSupport sellerPlatformServiceFeeSupport; | 72 | private SellerPlatformServiceFeeSupport sellerPlatformServiceFeeSupport; |
84 | 73 | ||
85 | 74 | ||
@@ -178,8 +167,8 @@ public class SellerService { | @@ -178,8 +167,8 @@ public class SellerService { | ||
178 | public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) { | 167 | public SellerPlatformServiceFeeResp platformServiceFeeDetail(int uid) { |
179 | logger.info("platformServiceFeeDetail uid {}", uid); | 168 | logger.info("platformServiceFeeDetail uid {}", uid); |
180 | SellerPlatformServiceFee currentServiceFee, nextPeriodServiceFee; | 169 | SellerPlatformServiceFee currentServiceFee, nextPeriodServiceFee; |
181 | - if (!(currentServiceFee = currentPeriodSellerPlatformServiceFee(uid)).isRuleConfigured() | ||
182 | - || !(nextPeriodServiceFee = nextPeriodSellerPlatformServiceFee(uid)).isRuleConfigured()) { | 170 | + if (!(currentServiceFee = sellerPlatformServiceFeeSupport.currentPeriod(uid, SkupType.IN_STOCK)).isRuleConfigured() |
171 | + || !(nextPeriodServiceFee = sellerPlatformServiceFeeSupport.nextPeriod(uid, SkupType.IN_STOCK)).isRuleConfigured()) { | ||
183 | logger.info("platformServiceFee rule is not configured,uid {}", uid); | 172 | logger.info("platformServiceFee rule is not configured,uid {}", uid); |
184 | return SellerPlatformServiceFeeResp.builder() | 173 | return SellerPlatformServiceFeeResp.builder() |
185 | .nodes(Lists.newArrayList()) | 174 | .nodes(Lists.newArrayList()) |
@@ -190,9 +179,13 @@ public class SellerService { | @@ -190,9 +179,13 @@ public class SellerService { | ||
190 | //未到达的规则 | 179 | //未到达的规则 |
191 | PlatformServiceFeeDefinition.FeeRule unsatisfiedFeeRule = nextPeriodServiceFee.getDefinition().getUnsatisfiedFeeRule(nextPeriodOrderQuantity); | 180 | PlatformServiceFeeDefinition.FeeRule unsatisfiedFeeRule = nextPeriodServiceFee.getDefinition().getUnsatisfiedFeeRule(nextPeriodOrderQuantity); |
192 | //扣点比例 | 181 | //扣点比例 |
193 | - List<PlatformServiceFeeDefinition.FeeRule> rules = new ArrayList<>(nextPeriodServiceFee.getDefinition().getRules()); | ||
194 | - //从小到大排序 | ||
195 | - rules.sort(Comparator.comparing(PlatformServiceFeeDefinition.FeeRule::getThreshold)); | 182 | + List<PlatformServiceFeeDefinition.FeeRule> rules = new ArrayList() { |
183 | + { | ||
184 | + addAll(nextPeriodServiceFee.getDefinition().getRules()); | ||
185 | + // //从小到大排序 | ||
186 | + sort(Comparator.comparing(PlatformServiceFeeDefinition.FeeRule::getThreshold)); | ||
187 | + } | ||
188 | + }; | ||
196 | 189 | ||
197 | //构建返回结果中的扣点规则 | 190 | //构建返回结果中的扣点规则 |
198 | List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> { | 191 | List<SellerPlatformServiceFeeResp.Node> nodes = rules.stream().map(rule -> { |
@@ -216,37 +209,6 @@ public class SellerService { | @@ -216,37 +209,6 @@ public class SellerService { | ||
216 | } | 209 | } |
217 | 210 | ||
218 | /** | 211 | /** |
219 | - * 当前 | ||
220 | - * @param uid | ||
221 | - * @return | ||
222 | - */ | ||
223 | - private SellerPlatformServiceFee currentPeriodSellerPlatformServiceFee(int uid) { | ||
224 | - //当前的扣点服务 | ||
225 | - SellerOrderStatsEntry currentStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(SkupType.IN_STOCK).time(DateUtil.getCurrentTimeSecond()).build(); | ||
226 | - SellerOrderStatsConfiguration currentStatsConfig = statsConfigurationManager.getStatsConfig(currentStatsEntry); | ||
227 | - SellerOrderStatsResult statsResult = (SellerOrderStatsResult)statsConfigurationManager.getStatsProcessor(currentStatsConfig.getStatsProcessorName()).getResult(currentStatsEntry, currentStatsConfig); | ||
228 | - return sellerPlatformServiceFeeSupport.buildSellerPlatformServiceFee(statsResult); | ||
229 | - } | ||
230 | - | ||
231 | - /** | ||
232 | - * 下个周期的 | ||
233 | - * | ||
234 | - * @param uid | ||
235 | - * @return | ||
236 | - */ | ||
237 | - private SellerPlatformServiceFee nextPeriodSellerPlatformServiceFee(int uid) { | ||
238 | - //下个周期 | ||
239 | - SellerOrderStatsEntry nextStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(SkupType.IN_STOCK).build(); | ||
240 | - SellerOrderStatsConfiguration nextStatsConfig = statsConfigurationManager.getStatsConfig(nextStatsEntry); | ||
241 | - //设置查询时间为下个周期的开始时间 | ||
242 | - nextStatsEntry.setTime(nextStatsConfig.getStatsUnit().nextPeriodTimeTuple(nextStatsConfig.getStatsPeriod(), nextStatsConfig.getStatsPeriod()).getKey()); | ||
243 | - SellerOrderStatsResult statsResult = (SellerOrderStatsResult) statsConfigurationManager.getStatsProcessor(nextStatsConfig.getStatsProcessorName()).getResult(nextStatsEntry, nextStatsConfig); | ||
244 | - return sellerPlatformServiceFeeSupport.buildSellerPlatformServiceFee(statsResult); | ||
245 | - } | ||
246 | - | ||
247 | - | ||
248 | - | ||
249 | - /** | ||
250 | * 获取入驻商家类型 | 212 | * 获取入驻商家类型 |
251 | * @param uid | 213 | * @param uid |
252 | * @return | 214 | * @return |
@@ -392,10 +354,4 @@ public class SellerService { | @@ -392,10 +354,4 @@ public class SellerService { | ||
392 | .attachWallet(merchantOrderPaymentService::getWalletLeftAmount); | 354 | .attachWallet(merchantOrderPaymentService::getWalletLeftAmount); |
393 | return sellerWrapper; | 355 | return sellerWrapper; |
394 | } | 356 | } |
395 | - | ||
396 | - public void updateEnterTypeForOrderQuantityStats(List<String> uids) { | ||
397 | - uids.forEach(uid -> { | ||
398 | - EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(Integer.parseInt(uid)).eventType(EnterQuitEnum.ENTER).build()); | ||
399 | - }); | ||
400 | - } | ||
401 | } | 357 | } |
@@ -60,7 +60,7 @@ public class SellerOrderQuantityStatsProcessor implements StatsProcessor<SellerO | @@ -60,7 +60,7 @@ public class SellerOrderQuantityStatsProcessor implements StatsProcessor<SellerO | ||
60 | public SellerOrderStatsResult getResult(SellerOrderStatsEntry entry, SellerOrderStatsConfiguration configuration) { | 60 | public SellerOrderStatsResult getResult(SellerOrderStatsEntry entry, SellerOrderStatsConfiguration configuration) { |
61 | logger.info("[{}] sellerOrderQuantityStatsProcessor getResult by entry:{}", entry.getSellerUid(), entry); | 61 | logger.info("[{}] sellerOrderQuantityStatsProcessor getResult by entry:{}", entry.getSellerUid(), entry); |
62 | SellerOrderStatsResult result = sellerOrderStatsResultMapper.selectStatsResult(entry.getSellerUid(), configuration.getStatsCode(), entry.getTime()); | 62 | SellerOrderStatsResult result = sellerOrderStatsResultMapper.selectStatsResult(entry.getSellerUid(), configuration.getStatsCode(), entry.getTime()); |
63 | - logger.info("[{}] seller order stats result:{}", entry.getSellerUid(), result); | 63 | + logger.info("[{}] sellerOrderQuantityStatsProcessor result:{}", entry.getSellerUid(), result); |
64 | return result; | 64 | return result; |
65 | } | 65 | } |
66 | } | 66 | } |
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.EntrySellerType; | ||
4 | import com.yohobuy.ufo.model.order.constants.SkupType; | 5 | import com.yohobuy.ufo.model.order.constants.SkupType; |
5 | import com.yohoufo.dal.order.model.SellerOrderStatsResult; | 6 | import com.yohoufo.dal.order.model.SellerOrderStatsResult; |
6 | import com.yohoufo.order.model.bo.PlatformServiceFeeDefinition; | 7 | import com.yohoufo.order.model.bo.PlatformServiceFeeDefinition; |
7 | import com.yohoufo.order.model.bo.SellerPlatformServiceFee; | 8 | import com.yohoufo.order.model.bo.SellerPlatformServiceFee; |
8 | import com.yohoufo.order.model.bo.SellerServiceFeeRuleDefinition; | 9 | import com.yohoufo.order.model.bo.SellerServiceFeeRuleDefinition; |
9 | import com.yohoufo.order.service.cache.SellerServiceFeeRuleCacheService; | 10 | import com.yohoufo.order.service.cache.SellerServiceFeeRuleCacheService; |
11 | +import com.yohoufo.order.service.seller.setting.SellerService; | ||
10 | import com.yohoufo.order.service.stats.StatsConfigManager; | 12 | import com.yohoufo.order.service.stats.StatsConfigManager; |
11 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; | 13 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration; |
12 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsEntry; | 14 | import com.yohoufo.order.service.stats.impl.SellerOrderStatsEntry; |
@@ -17,9 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -17,9 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
17 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
18 | 20 | ||
19 | import java.math.BigDecimal; | 21 | import java.math.BigDecimal; |
20 | -import java.util.List; | ||
21 | -import java.util.Objects; | ||
22 | -import java.util.Optional; | 22 | +import java.util.*; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Created by jiexiang.wu on 2019/7/23. | 25 | * Created by jiexiang.wu on 2019/7/23. |
@@ -35,6 +35,47 @@ public class SellerPlatformServiceFeeSupport { | @@ -35,6 +35,47 @@ public class SellerPlatformServiceFeeSupport { | ||
35 | @Autowired | 35 | @Autowired |
36 | private SellerServiceFeeRuleCacheService sellerServiceFeeRuleCacheService; | 36 | private SellerServiceFeeRuleCacheService sellerServiceFeeRuleCacheService; |
37 | 37 | ||
38 | + @Autowired | ||
39 | + private SellerService sellerService; | ||
40 | + | ||
41 | + /** | ||
42 | + * 当前周期 | ||
43 | + * | ||
44 | + * @param uid | ||
45 | + * @return | ||
46 | + */ | ||
47 | + public SellerPlatformServiceFee currentPeriod(int uid, SkupType skupType) { | ||
48 | + //当前的扣点服务 | ||
49 | + SellerOrderStatsEntry currentStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(skupType).time(com.yohoufo.common.utils.DateUtil.getCurrentTimeSecond()).build(); | ||
50 | + SellerOrderStatsConfiguration currentStatsConfig = statsConfigurationManager.getStatsConfig(currentStatsEntry); | ||
51 | + SellerOrderStatsResult statsResult = (SellerOrderStatsResult) statsConfigurationManager.getStatsProcessor(currentStatsConfig.getStatsProcessorName()).getResult(currentStatsEntry, currentStatsConfig); | ||
52 | + if (Objects.isNull(statsResult)) { | ||
53 | + statsResult = createEmptyStatsResult(uid); | ||
54 | + } | ||
55 | + return this.buildSellerPlatformServiceFee(uid, statsResult); | ||
56 | + } | ||
57 | + | ||
58 | + | ||
59 | + /** | ||
60 | + * 下个周期的 | ||
61 | + * | ||
62 | + * @param uid | ||
63 | + * @return | ||
64 | + */ | ||
65 | + public SellerPlatformServiceFee nextPeriod(int uid, SkupType skupType) { | ||
66 | + //下个周期 | ||
67 | + SellerOrderStatsEntry nextStatsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(skupType).build(); | ||
68 | + SellerOrderStatsConfiguration nextStatsConfig = statsConfigurationManager.getStatsConfig(nextStatsEntry); | ||
69 | + //设置查询时间为下个周期的开始时间 | ||
70 | + nextStatsEntry.setTime(nextStatsConfig.getStatsUnit().nextPeriodTimeTuple(nextStatsConfig.getStatsPeriod(), nextStatsConfig.getStatsPeriod()).getKey()); | ||
71 | + SellerOrderStatsResult statsResult = (SellerOrderStatsResult) statsConfigurationManager.getStatsProcessor(nextStatsConfig.getStatsProcessorName()).getResult(nextStatsEntry, nextStatsConfig); | ||
72 | + if (Objects.isNull(statsResult)) { | ||
73 | + statsResult = createEmptyStatsResult(uid); | ||
74 | + } | ||
75 | + return this.buildSellerPlatformServiceFee(uid, statsResult); | ||
76 | + } | ||
77 | + | ||
78 | + | ||
38 | /** | 79 | /** |
39 | * 获取平台技术服务费比例 | 80 | * 获取平台技术服务费比例 |
40 | * | 81 | * |
@@ -45,13 +86,8 @@ public class SellerPlatformServiceFeeSupport { | @@ -45,13 +86,8 @@ public class SellerPlatformServiceFeeSupport { | ||
45 | public BigDecimal getPlatformServiceFeeRate(int uid, SkupType skupType) { | 86 | public BigDecimal getPlatformServiceFeeRate(int uid, SkupType skupType) { |
46 | logger.info("[{}] in platformServiceFeeRate,skupType:{}", uid, skupType); | 87 | logger.info("[{}] in platformServiceFeeRate,skupType:{}", uid, skupType); |
47 | 88 | ||
48 | - //1.获取卖家统计结果 | ||
49 | - SellerOrderStatsEntry statsEntry = SellerOrderStatsEntry.builder().sellerUid(uid).skupType(skupType).time(DateUtil.getCurrentTimeSecond()).build(); | ||
50 | - SellerOrderStatsConfiguration statsConfig = statsConfigurationManager.getStatsConfig(statsEntry); | ||
51 | - SellerOrderStatsResult statsResult = (SellerOrderStatsResult) statsConfigurationManager.getStatsProcessor(statsConfig.getStatsProcessorName()).getResult(statsEntry, statsConfig); | ||
52 | - | ||
53 | - //2.通过统计结果获取费用定义 | ||
54 | - SellerPlatformServiceFee sellerPlatformServiceFee = buildSellerPlatformServiceFee(statsResult); | 89 | + //查询当前周期的费用 |
90 | + SellerPlatformServiceFee sellerPlatformServiceFee = currentPeriod(uid, skupType); | ||
55 | 91 | ||
56 | //3.最终的费用 | 92 | //3.最终的费用 |
57 | BigDecimal feeRate = sellerPlatformServiceFee.getFeeRate(); | 93 | BigDecimal feeRate = sellerPlatformServiceFee.getFeeRate(); |
@@ -60,12 +96,36 @@ public class SellerPlatformServiceFeeSupport { | @@ -60,12 +96,36 @@ public class SellerPlatformServiceFeeSupport { | ||
60 | return feeRate; | 96 | return feeRate; |
61 | } | 97 | } |
62 | 98 | ||
63 | - public SellerPlatformServiceFee buildSellerPlatformServiceFee(SellerOrderStatsResult statsResult) { | 99 | + private SellerPlatformServiceFee buildSellerPlatformServiceFee(int uid, SellerOrderStatsResult statsResult) { |
100 | + | ||
101 | + replaceEnterTypeIfNeed(statsResult); | ||
102 | + | ||
64 | //通过统计结果获取费用定义 | 103 | //通过统计结果获取费用定义 |
65 | PlatformServiceFeeDefinition platformServiceFeeDefinition = fetchPlatformServiceFeeDefinitionByStatsResult(statsResult); | 104 | PlatformServiceFeeDefinition platformServiceFeeDefinition = fetchPlatformServiceFeeDefinitionByStatsResult(statsResult); |
66 | 105 | ||
67 | - return new SellerPlatformServiceFee(statsResult == null ? 0 : statsResult.getQuantity(), | ||
68 | - platformServiceFeeDefinition == null ? PlatformServiceFeeDefinition.EMPTY_DEFINITION : platformServiceFeeDefinition); | 106 | + return new SellerPlatformServiceFee(statsResult.getQuantity(), platformServiceFeeDefinition); |
107 | + } | ||
108 | + | ||
109 | + private SellerOrderStatsResult createEmptyStatsResult(int uid) { | ||
110 | + SellerOrderStatsResult statsResult = new SellerOrderStatsResult(); | ||
111 | + statsResult.setUid(uid); | ||
112 | + statsResult.setQuantity(0); | ||
113 | + statsResult.setEnterType(-1); | ||
114 | + return statsResult; | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * enterType < 0,使用用户当前的入驻类型 | ||
119 | + * | ||
120 | + * @param statsResult | ||
121 | + */ | ||
122 | + private void replaceEnterTypeIfNeed(SellerOrderStatsResult statsResult) { | ||
123 | + if (statsResult.getEnterType() < 0) { | ||
124 | + logger.info("[{}] use current enterType to replace for orderStatsResult", statsResult.getUid()); | ||
125 | + //查询用户当前入驻类型 | ||
126 | + EntrySellerType entrySellerType = sellerService.getEntrySellerType(statsResult.getUid()); | ||
127 | + statsResult.setEnterType(entrySellerType.getCode()); | ||
128 | + } | ||
69 | } | 129 | } |
70 | 130 | ||
71 | /** | 131 | /** |
@@ -75,9 +135,6 @@ public class SellerPlatformServiceFeeSupport { | @@ -75,9 +135,6 @@ public class SellerPlatformServiceFeeSupport { | ||
75 | * @return | 135 | * @return |
76 | */ | 136 | */ |
77 | private PlatformServiceFeeDefinition fetchPlatformServiceFeeDefinitionByStatsResult(SellerOrderStatsResult sellerOrderStatsResult) { | 137 | private PlatformServiceFeeDefinition fetchPlatformServiceFeeDefinitionByStatsResult(SellerOrderStatsResult sellerOrderStatsResult) { |
78 | - if (Objects.isNull(sellerOrderStatsResult)) { | ||
79 | - return null; | ||
80 | - } | ||
81 | //平台服务费的规则定义 | 138 | //平台服务费的规则定义 |
82 | List<SellerServiceFeeRuleDefinition> ruleDefinitions = sellerServiceFeeRuleCacheService.getRuleDefinitions(); | 139 | List<SellerServiceFeeRuleDefinition> ruleDefinitions = sellerServiceFeeRuleCacheService.getRuleDefinitions(); |
83 | //按统计码、入驻类型获取特定的规则 | 140 | //按统计码、入驻类型获取特定的规则 |
@@ -85,6 +142,6 @@ public class SellerPlatformServiceFeeSupport { | @@ -85,6 +142,6 @@ public class SellerPlatformServiceFeeSupport { | ||
85 | .filter(ruleDefinition -> StringUtils.equals(ruleDefinition.getStatsCode(), sellerOrderStatsResult.getStatsCode())) | 142 | .filter(ruleDefinition -> StringUtils.equals(ruleDefinition.getStatsCode(), sellerOrderStatsResult.getStatsCode())) |
86 | .filter(ruleDefinition -> ruleDefinition.getEnterType() == sellerOrderStatsResult.getEnterType()) | 143 | .filter(ruleDefinition -> ruleDefinition.getEnterType() == sellerOrderStatsResult.getEnterType()) |
87 | .map(ruleDefinition -> ruleDefinition.getServiceFeeDefinition()).findFirst(); | 144 | .map(ruleDefinition -> ruleDefinition.getServiceFeeDefinition()).findFirst(); |
88 | - return psfdOp.isPresent() ? psfdOp.get() : null; | 145 | + return psfdOp.isPresent() ? psfdOp.get() : PlatformServiceFeeDefinition.EMPTY_DEFINITION; |
89 | } | 146 | } |
90 | } | 147 | } |
1 | package com.yohoufo.order.service.seller; | 1 | package com.yohoufo.order.service.seller; |
2 | 2 | ||
3 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 3 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
4 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
4 | import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp; | 5 | import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp; |
5 | import com.yohoufo.common.alarm.EventBusPublisher; | 6 | import com.yohoufo.common.alarm.EventBusPublisher; |
6 | import com.yohoufo.dal.order.model.BuyerOrder; | 7 | import com.yohoufo.dal.order.model.BuyerOrder; |
@@ -10,10 +11,13 @@ import com.yohoufo.order.event.SellerEnterTypeChangeEvent; | @@ -10,10 +11,13 @@ import com.yohoufo.order.event.SellerEnterTypeChangeEvent; | ||
10 | import com.yohoufo.order.service.listener.BuyerOrderChangeEvent; | 11 | import com.yohoufo.order.service.listener.BuyerOrderChangeEvent; |
11 | import com.yohoufo.order.service.listener.OrderChangeListenerContainer; | 12 | import com.yohoufo.order.service.listener.OrderChangeListenerContainer; |
12 | import com.yohoufo.order.service.seller.setting.SellerService; | 13 | import com.yohoufo.order.service.seller.setting.SellerService; |
14 | +import com.yohoufo.order.service.support.SellerPlatformServiceFeeSupport; | ||
13 | import org.junit.Assert; | 15 | import org.junit.Assert; |
14 | import org.junit.Test; | 16 | import org.junit.Test; |
15 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
16 | 18 | ||
19 | +import java.math.BigDecimal; | ||
20 | + | ||
17 | public class SellerEnterTypeChangeEventTest extends BaseWebTest { | 21 | public class SellerEnterTypeChangeEventTest extends BaseWebTest { |
18 | 22 | ||
19 | @Autowired | 23 | @Autowired |
@@ -22,6 +26,9 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest { | @@ -22,6 +26,9 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest { | ||
22 | @Autowired | 26 | @Autowired |
23 | private SellerService sellerService; | 27 | private SellerService sellerService; |
24 | 28 | ||
29 | + @Autowired | ||
30 | + private SellerPlatformServiceFeeSupport sellerPlatformServiceFeeSupport; | ||
31 | + | ||
25 | @Test | 32 | @Test |
26 | public void test_stats_event() { | 33 | public void test_stats_event() { |
27 | BuyerOrder buyerOrder = new BuyerOrder(); | 34 | BuyerOrder buyerOrder = new BuyerOrder(); |
@@ -47,6 +54,18 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest { | @@ -47,6 +54,18 @@ public class SellerEnterTypeChangeEventTest extends BaseWebTest { | ||
47 | SellerPlatformServiceFeeResp sellerPlatformServiceFeeResp = sellerService.platformServiceFeeDetail(500031424); | 54 | SellerPlatformServiceFeeResp sellerPlatformServiceFeeResp = sellerService.platformServiceFeeDetail(500031424); |
48 | System.out.println(sellerPlatformServiceFeeResp); | 55 | System.out.println(sellerPlatformServiceFeeResp); |
49 | Assert.assertNotNull(sellerPlatformServiceFeeResp); | 56 | Assert.assertNotNull(sellerPlatformServiceFeeResp); |
50 | - Assert.assertEquals(sellerPlatformServiceFeeResp.getCurrentRate(),"5.0%"); | 57 | + Assert.assertEquals(sellerPlatformServiceFeeResp.getCurrentRate(), "5.0%"); |
58 | + } | ||
59 | + | ||
60 | + @Test | ||
61 | + public void getPlatformServiceFeeRate() { | ||
62 | + BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK); | ||
63 | + Assert.assertEquals(feeRate.toPlainString(),"0.049"); | ||
64 | + } | ||
65 | + | ||
66 | + @Test | ||
67 | + public void getPlatformServiceFeeRate_withoutRules() { | ||
68 | + BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK); | ||
69 | + Assert.assertEquals(feeRate,null); | ||
51 | } | 70 | } |
52 | } | 71 | } |
-
Please register or login to post a comment