add bonded order trace info
Showing
10 changed files
with
363 additions
and
62 deletions
1 | +package com.yoho.core.rabbitmq.properties; | ||
2 | + | ||
3 | +import com.google.common.base.Splitter; | ||
4 | +import lombok.Getter; | ||
5 | +import org.apache.commons.configuration.Configuration; | ||
6 | +import org.apache.commons.configuration.ConfigurationException; | ||
7 | +import org.apache.commons.configuration.PropertiesConfiguration; | ||
8 | +import org.apache.commons.lang3.StringUtils; | ||
9 | +import org.slf4j.Logger; | ||
10 | +import org.slf4j.LoggerFactory; | ||
11 | +import org.springframework.beans.BeansException; | ||
12 | +import org.springframework.beans.factory.config.YamlMapFactoryBean; | ||
13 | +import org.springframework.core.io.ClassPathResource; | ||
14 | + | ||
15 | +import java.util.*; | ||
16 | +import java.util.stream.Collectors; | ||
17 | + | ||
18 | +/** | ||
19 | + * Created by jack on 2017/10/11. | ||
20 | + * <p> | ||
21 | + * for read rabbitmq.yml | ||
22 | + */ | ||
23 | +public class RabbitYmlFactory { | ||
24 | + private static final Logger logger = LoggerFactory.getLogger(RabbitYmlFactory.class); | ||
25 | + | ||
26 | + // consumer info list | ||
27 | + @Getter | ||
28 | + private static List<ConsumerInfo> consumerInfoList = new ArrayList<>(); | ||
29 | + | ||
30 | + //producer info list | ||
31 | + @Getter | ||
32 | + private static List<ProducerInfo> producerInfoList = new ArrayList<>(); | ||
33 | + | ||
34 | + //connection info list | ||
35 | + @Getter | ||
36 | + private static HashSet<ConnectionInfo> connectionInfoSet = new HashSet<>(); | ||
37 | + | ||
38 | + // web context | ||
39 | + private static String webContext; | ||
40 | + | ||
41 | + //class load read yaml | ||
42 | + static { | ||
43 | + readRabbitYml(); | ||
44 | + } | ||
45 | + | ||
46 | + | ||
47 | + public static void readRabbitYml() throws BeansException { | ||
48 | + YamlMapFactoryBean yaml = new YamlMapFactoryBean(); | ||
49 | + ClassPathResource oneResource = new ClassPathResource("rabbitmq.yml"); | ||
50 | + if (!oneResource.exists()) { | ||
51 | + logger.error("not found rabbitmq.yml in classpath..."); | ||
52 | + return; | ||
53 | + } | ||
54 | + yaml.setResources(oneResource); | ||
55 | + | ||
56 | + Map<String, Object> rabbitmqYml = yaml.getObject(); | ||
57 | + | ||
58 | + try { | ||
59 | + Configuration configuration = new PropertiesConfiguration(RabbitYmlFactory.class.getClassLoader().getResource("config.properties")); | ||
60 | + if (null != configuration) { | ||
61 | + webContext = Optional.ofNullable(configuration.getString("web.context")).orElse("default"); | ||
62 | + } | ||
63 | + | ||
64 | + } catch (ConfigurationException e) { | ||
65 | + logger.error("not found config.properties in classpath..."); | ||
66 | + webContext = "default"; | ||
67 | + } | ||
68 | + // read consumers | ||
69 | + readConsumers(rabbitmqYml); | ||
70 | + | ||
71 | + //read producers | ||
72 | + readProducers(rabbitmqYml); | ||
73 | + } | ||
74 | + | ||
75 | + private static final int DEFAULT_DELAY_INTERVAL = 10; | ||
76 | + private static final String SEPERATOR = ","; | ||
77 | + private static Set<Integer> buildDelayIntervalSet(Map<String, Object> consumerMap){ | ||
78 | + Set<Integer> delayIntervalSet = new HashSet<>(8); | ||
79 | + Map<String, Object> delay = (Map<String, Object>) consumerMap.get("delay"); | ||
80 | + if (Objects.isNull(delay)){ | ||
81 | + delayIntervalSet.add(DEFAULT_DELAY_INTERVAL); | ||
82 | + return delayIntervalSet; | ||
83 | + } | ||
84 | + //parse interval | ||
85 | + String intervalStr = String.valueOf(delay.get("interval")); | ||
86 | + if (StringUtils.isBlank(intervalStr)){ | ||
87 | + delayIntervalSet.add(DEFAULT_DELAY_INTERVAL); | ||
88 | + return delayIntervalSet; | ||
89 | + } | ||
90 | + | ||
91 | + if(intervalStr.contains(SEPERATOR)){ | ||
92 | + List<String> delayIntervalStrList = Splitter.on(SEPERATOR) | ||
93 | + .omitEmptyStrings().trimResults() | ||
94 | + .splitToList(intervalStr); | ||
95 | + //multiple | ||
96 | + delayIntervalSet = delayIntervalStrList | ||
97 | + .stream().map(Integer::valueOf) | ||
98 | + .collect(Collectors.toSet()); | ||
99 | + | ||
100 | + }else { | ||
101 | + //single | ||
102 | + Integer delayInterval = Optional.ofNullable(Integer.valueOf(intervalStr)).orElse(10); | ||
103 | + delayIntervalSet.add(delayInterval); | ||
104 | + } | ||
105 | + return delayIntervalSet; | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * read consumers defined in rabbitmq.yml | ||
110 | + * | ||
111 | + * @param rabbitmqYml | ||
112 | + * @throws Exception | ||
113 | + */ | ||
114 | + private static void readConsumers(Map<String, Object> rabbitmqYml) throws BeansException { | ||
115 | + logger.info("RabbitYmlFactory:read consumers"); | ||
116 | + List<Object> connections = (List<Object>) rabbitmqYml.get("consumer"); | ||
117 | + | ||
118 | + if (null == connections) return; | ||
119 | + for (Object oneConn : connections) { | ||
120 | + Map<String, Object> connMap = (Map<String, Object>) oneConn; | ||
121 | + | ||
122 | + List<Object> consumerList = (List<Object>) connMap.get("consumers"); | ||
123 | + //if no consumers are in this connection , continue | ||
124 | + if (null == consumerList) continue; | ||
125 | + | ||
126 | + // construct connection info | ||
127 | + String address = (String) connMap.get("address"); | ||
128 | + String user = Optional.ofNullable((String) connMap.get("username")).orElse("yoho"); | ||
129 | + String passwd = Optional.ofNullable((String) connMap.get("password")).orElse("yoho"); | ||
130 | + String vhost = Optional.ofNullable((String) connMap.get("vhost")).orElse("yoho"); | ||
131 | + Integer heartbeat = Optional.ofNullable((Integer) connMap.get("hearbeat")).orElse(5); | ||
132 | + | ||
133 | + ConnectionInfo consumerConn = new ConnectionInfo(address, user, passwd, vhost, heartbeat); | ||
134 | + String connectionBean = "rabbit-connection-" + consumerConn.hashCode(); | ||
135 | + consumerConn.setBeanId(connectionBean); | ||
136 | + | ||
137 | + connectionInfoSet.add(consumerConn); | ||
138 | + | ||
139 | + | ||
140 | + //construct consumer info | ||
141 | + for (Object oneConsumer : consumerList) { | ||
142 | + Map<String, Object> consumerMap = (Map<String, Object>) oneConsumer; | ||
143 | + boolean existDelayKey = consumerMap.containsKey("delay"); | ||
144 | + int sonNum = 1; | ||
145 | + Set<Integer> delayIntervalSet = null; | ||
146 | + if (existDelayKey){ | ||
147 | + delayIntervalSet = buildDelayIntervalSet(consumerMap); | ||
148 | + sonNum= delayIntervalSet.size(); | ||
149 | + } | ||
150 | + | ||
151 | + if (sonNum==1){ | ||
152 | + ConsumerInfo info = buildSingleConsumerInfo(consumerMap, consumerConn, existDelayKey, existDelayKey ? delayIntervalSet.iterator().next():null); | ||
153 | + consumerInfoList.add(info); | ||
154 | + }else{ | ||
155 | + delayIntervalSet.stream().forEach(delayInterval-> consumerInfoList.add(buildSingleConsumerInfo(consumerMap,consumerConn, existDelayKey, delayInterval))); | ||
156 | + } | ||
157 | + | ||
158 | + | ||
159 | + } | ||
160 | + } | ||
161 | + logger.info("RabbitYmlFactory: consumers info {}", consumerInfoList); | ||
162 | + } | ||
163 | + | ||
164 | + private static ConsumerInfo buildSingleConsumerInfo(Map<String, Object> consumerMap, | ||
165 | + ConnectionInfo consumerConn, | ||
166 | + boolean existDelayKey, | ||
167 | + Integer delayInterval){ | ||
168 | + ConsumerInfo info = new ConsumerInfo(); | ||
169 | + | ||
170 | + info.setConnection(consumerConn); | ||
171 | + info.setConsumeClass((String) consumerMap.get("class")); | ||
172 | + | ||
173 | + info.setTopic((String) consumerMap.get("topic")); | ||
174 | + //default yoho:webcontext:topic | ||
175 | + String queue = Optional.ofNullable((String) consumerMap.get("queue")).orElse(info.getTopic()); | ||
176 | + info.setQueue("yoho:" + webContext + ":" + queue); | ||
177 | + | ||
178 | + info.setConcurrent(Optional.ofNullable((Integer) consumerMap.get("concurrent")).orElse(1)); | ||
179 | + info.setPrefetch(Optional.ofNullable((Integer) consumerMap.get("prefetch")).orElse(10)); | ||
180 | + | ||
181 | + //set federation config | ||
182 | + if (consumerMap.containsKey("federation")) { | ||
183 | + info.setFederation(true); | ||
184 | + Map<String, Object> fed = (Map<String, Object>) consumerMap.get("federation"); | ||
185 | + if (null != fed) { | ||
186 | + info.setFedExchange(Optional.ofNullable((String) fed.get("exchange")).orElse("yoho.federation.topic")); | ||
187 | + } else { | ||
188 | + info.setFedExchange("yoho.federation.topic"); | ||
189 | + } | ||
190 | + } | ||
191 | + | ||
192 | + //if contains retry | ||
193 | + if (consumerMap.containsKey("retry")) { | ||
194 | + info.setRetry(true); | ||
195 | + //default yoho_retry:webcontext:topic | ||
196 | + info.setQueue("yoho_retry:" + webContext + ":" + queue); | ||
197 | + Map<String, Object> retry = (Map<String, Object>) consumerMap.get("retry"); | ||
198 | + if (retry != null) { | ||
199 | + info.setRetryInterval(Optional.of((Integer) retry.get("interval")).orElse(10)); | ||
200 | + //default queueName:retry:10m | ||
201 | + info.setRetryQueue(Optional.ofNullable((String) retry.get("queue")).orElse("retry:" + info.getRetryInterval() + "m" + ".queue")); | ||
202 | + } else { | ||
203 | + info.setRetryInterval(10); | ||
204 | + info.setRetryQueue("retry:" + info.getRetryInterval() + "m" + ".queue"); | ||
205 | + } | ||
206 | + } | ||
207 | + //if contains delay | ||
208 | + if (existDelayKey) { | ||
209 | + //set first,then get after | ||
210 | + info.setDelayInterval(delayInterval); | ||
211 | + info.setDelay(true); | ||
212 | + info.setQueue("yoho_delay:" + webContext + ":" + queue); | ||
213 | + Map<String, Object> delay = (Map<String, Object>) consumerMap.get("delay"); | ||
214 | + if (null != delay) { | ||
215 | + //default delay:10m.queue | ||
216 | + info.setDelayQueue(Optional.ofNullable((String) delay.get("queue")).orElse("delay:" + info.getDelayInterval() + "m" + ".queue")); | ||
217 | + } else { | ||
218 | + info.setDelayQueue("delay:" + info.getDelayInterval() + "m" + ".queue"); | ||
219 | + } | ||
220 | + | ||
221 | + } | ||
222 | + //if contains rateLimit | ||
223 | + Integer rate = Optional.ofNullable((Integer) consumerMap.get("ratelimit")).orElse(0); | ||
224 | + if (0 < rate) { | ||
225 | + info.setRateLimit(true); | ||
226 | + info.setRateLimiter(rate); | ||
227 | + } | ||
228 | + String beanId = "consumer-" + UUID.randomUUID().toString(); | ||
229 | + info.setBeanName(beanId); | ||
230 | + return info; | ||
231 | + } | ||
232 | + | ||
233 | + | ||
234 | + /** | ||
235 | + * read producers defined in rabbitmq.yml | ||
236 | + * | ||
237 | + * @param rabbitmqYml | ||
238 | + */ | ||
239 | + private static void readProducers(Map<String, Object> rabbitmqYml) { | ||
240 | + logger.info("RabbitYmlFactory:read producers"); | ||
241 | + List<Object> allProducers = (List<Object>) rabbitmqYml.get("producer"); | ||
242 | + if (null == allProducers) { | ||
243 | + logger.info("not found producers config in rabbitmq.yml"); | ||
244 | + return; | ||
245 | + } | ||
246 | + for (Object oneConn : allProducers) { | ||
247 | + Map<String, Object> connMap = (Map<String, Object>) oneConn; | ||
248 | + List<Object> producers = (List<Object>) connMap.get("producers"); | ||
249 | + if (null == producers) continue; | ||
250 | + | ||
251 | + // construct connection info | ||
252 | + String address = (String) connMap.get("address"); | ||
253 | + String user = Optional.ofNullable((String) connMap.get("username")).orElse("yoho"); | ||
254 | + String passwd = Optional.ofNullable((String) connMap.get("password")).orElse("yoho"); | ||
255 | + String vhost = Optional.ofNullable((String) connMap.get("vhost")).orElse("yoho"); | ||
256 | + Integer heartbeat = Optional.ofNullable((Integer) connMap.get("hearbeat")).orElse(5); | ||
257 | + ConnectionInfo producerConn = new ConnectionInfo(address, user, passwd, vhost, heartbeat); | ||
258 | + | ||
259 | + String connectionBean = "rabbit-connection-" + producerConn.hashCode(); | ||
260 | + producerConn.setBeanId(connectionBean); | ||
261 | + connectionInfoSet.add(producerConn); | ||
262 | + | ||
263 | + //construct producer info | ||
264 | + for (Object oneProducer : producers) { | ||
265 | + Map<String, Object> producerMap = (Map<String, Object>) oneProducer; | ||
266 | + ProducerInfo info = new ProducerInfo(); | ||
267 | + info.setConnection(producerConn); | ||
268 | + info.setAsync(Optional.ofNullable((Boolean) producerMap.get("async")).orElse(false)); | ||
269 | + info.setConfirm(Optional.ofNullable((Boolean) producerMap.get("confirm")).orElse(true)); | ||
270 | + info.setConfirmCallback(Optional.ofNullable((String)producerMap.get("confirmcallback")).orElse("")); | ||
271 | + info.setTrace(Optional.ofNullable((Boolean) producerMap.get("trace")).orElse(false)); | ||
272 | + info.setPersistent(Optional.ofNullable((Boolean) producerMap.get("persistent")).orElse(false)); | ||
273 | + String beanId = Optional.ofNullable((String) producerMap.get("bean")).orElse("producer-" + UUID.randomUUID().toString()); | ||
274 | + info.setBeanName(beanId); | ||
275 | + producerInfoList.add(info); | ||
276 | + } | ||
277 | + } | ||
278 | + | ||
279 | + logger.info("RabbitYmlFactory: producers info {}", producerInfoList); | ||
280 | + } | ||
281 | +} |
1 | +package com.yohoufo.order.model.dto; | ||
2 | + | ||
3 | +import lombok.AllArgsConstructor; | ||
4 | +import lombok.Builder; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.NoArgsConstructor; | ||
7 | + | ||
8 | +import java.util.concurrent.TimeUnit; | ||
9 | +@Data | ||
10 | +@Builder | ||
11 | +@NoArgsConstructor@AllArgsConstructor | ||
12 | +public class LimitTime { | ||
13 | + | ||
14 | + private int limitTime; | ||
15 | + | ||
16 | + @Builder.Default | ||
17 | + private TimeUnit timeUnit = TimeUnit.HOURS; | ||
18 | +} |
@@ -292,7 +292,7 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { | @@ -292,7 +292,7 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService { | ||
292 | Integer sellerUid = orderInfo.getSellerUid(); | 292 | Integer sellerUid = orderInfo.getSellerUid(); |
293 | long orderCode = orderInfo.getOrderCode(); | 293 | long orderCode = orderInfo.getOrderCode(); |
294 | int ts = DateUtil.getCurrentTimeSecond(); | 294 | int ts = DateUtil.getCurrentTimeSecond(); |
295 | - int deliveryHours = deliveryMinutesService.getDeliverMinutesThird_hours(ts);//把分钟转小时 | 295 | + int deliveryHours = deliveryMinutesService.getDeliverHoursOfLimitTime(ts, sellerOrderGoods);//把分钟转小时 |
296 | String unit = DateUtil.UNIT_HOURS; | 296 | String unit = DateUtil.UNIT_HOURS; |
297 | sellerNoticeFacade.sellerSkupPaidByBuyer(sellerOrderGoods,orderCode,deliveryHours, unit); | 297 | sellerNoticeFacade.sellerSkupPaidByBuyer(sellerOrderGoods,orderCode,deliveryHours, unit); |
298 | 298 |
@@ -107,6 +107,8 @@ public class CacheKeyBuilder { | @@ -107,6 +107,8 @@ public class CacheKeyBuilder { | ||
107 | ORDER_PAY_DETAIL("ufo:order:orderPayDetail:", "uid:{}:tabType:{}:orderCode:{}"), | 107 | ORDER_PAY_DETAIL("ufo:order:orderPayDetail:", "uid:{}:tabType:{}:orderCode:{}"), |
108 | 108 | ||
109 | BUYER_ORDER_VIOLATION_PENALTY("ufo:order:buyerOrder:violationPenalty:config",""), | 109 | BUYER_ORDER_VIOLATION_PENALTY("ufo:order:buyerOrder:violationPenalty:config",""), |
110 | + | ||
111 | + SELLER_DELIVER_LIMIT_TIME("ufo:order:seller:deliver:limitTime","") | ||
110 | ; | 112 | ; |
111 | 113 | ||
112 | private String fix; | 114 | private String fix; |
@@ -38,17 +38,21 @@ public class SellerCancelDeliverHandler implements IEventHandler<SellerCancelDel | @@ -38,17 +38,21 @@ public class SellerCancelDeliverHandler implements IEventHandler<SellerCancelDel | ||
38 | public void handle(SellerCancelDeliverEvent event) { | 38 | public void handle(SellerCancelDeliverEvent event) { |
39 | int ts = DateUtil.getCurrentTimeSecond(); | 39 | int ts = DateUtil.getCurrentTimeSecond(); |
40 | int minutes = 0; | 40 | int minutes = 0; |
41 | - | 41 | + //香港仓-海外购订单 |
42 | if (event.getOrderAttributes() == OrderAttributes.OVERSEAS_IN_STOCK.getCode()){ | 42 | if (event.getOrderAttributes() == OrderAttributes.OVERSEAS_IN_STOCK.getCode()){ |
43 | minutes = deliveryMinutesService.getDeliverOverSeasMinutes(); | 43 | minutes = deliveryMinutesService.getDeliverOverSeasMinutes(); |
44 | }else{ | 44 | }else{ |
45 | - minutes = deliveryMinutesService.getDeliverMinutesThird(ts); | 45 | + //除了海外购订单,其他所有(现货 二手 瑕疵) |
46 | + minutes = deliveryMinutesService.getDeliverMinutesThird(ts,event.getSellerOrderGoods()); | ||
46 | } | 47 | } |
47 | 48 | ||
48 | String topic = TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER; | 49 | String topic = TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER; |
49 | logger.info("Subscribe Buyer Confirm delay msg,topic {}, delay minutes {} , event {}",topic,minutes, event); | 50 | logger.info("Subscribe Buyer Confirm delay msg,topic {}, delay minutes {} , event {}",topic,minutes, event); |
50 | - | ||
51 | - tradeMqSender.send(topic, event, minutes); | 51 | + try{ |
52 | + tradeMqSender.send(topic, event, minutes); | ||
53 | + }catch (Exception ex){ | ||
54 | + logger.warn("SellerCancelDeliverHandler.handle send MQ msg fail,event {} topic {}", event, topic, ex); | ||
55 | + } | ||
52 | 56 | ||
53 | // 记录此订单的发货超时时间期限点 | 57 | // 记录此订单的发货超时时间期限点 |
54 | orderOverTimeService.insertDeliveryTime(new OrderOverTime(event.getOrderCode(), ts + minutes * 60, minutes)); | 58 | orderOverTimeService.insertDeliveryTime(new OrderOverTime(event.getOrderCode(), ts + minutes * 60, minutes)); |
@@ -23,6 +23,7 @@ public class SellerEarnestMoney2BuyerPenaltyCalculator implements PenaltyCalcula | @@ -23,6 +23,7 @@ public class SellerEarnestMoney2BuyerPenaltyCalculator implements PenaltyCalcula | ||
23 | 23 | ||
24 | private final Integer uid; | 24 | private final Integer uid; |
25 | private final Integer skup; | 25 | private final Integer skup; |
26 | + | ||
26 | private final JSONObject fee; | 27 | private final JSONObject fee; |
27 | @Setter | 28 | @Setter |
28 | @Accessors(fluent = true) | 29 | @Accessors(fluent = true) |
@@ -469,6 +469,7 @@ public class MetaConfigService { | @@ -469,6 +469,7 @@ public class MetaConfigService { | ||
469 | MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_BID_CONFIG, CacheKeyBuilder.KeyTemp.BUYER_BID_CONFIG); | 469 | MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_BID_CONFIG, CacheKeyBuilder.KeyTemp.BUYER_BID_CONFIG); |
470 | MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_BID_GOODS_FEE_RATE, CacheKeyBuilder.KeyTemp.SELLER_BID_GOODS_FEE_RATE); | 470 | MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_BID_GOODS_FEE_RATE, CacheKeyBuilder.KeyTemp.SELLER_BID_GOODS_FEE_RATE); |
471 | MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_ORDER_VIOLATION_PENALTY, CacheKeyBuilder.KeyTemp.BUYER_ORDER_VIOLATION_PENALTY); | 471 | MetaCodeCacheKeyMap.put(MetaConfigKey.BUYER_ORDER_VIOLATION_PENALTY, CacheKeyBuilder.KeyTemp.BUYER_ORDER_VIOLATION_PENALTY); |
472 | + MetaCodeCacheKeyMap.put(MetaConfigKey.SELLER_DELIVER_LIMIT_TIME, CacheKeyBuilder.KeyTemp.SELLER_DELIVER_LIMIT_TIME); | ||
472 | } | 473 | } |
473 | } | 474 | } |
474 | 475 | ||
@@ -480,4 +481,19 @@ public class MetaConfigService { | @@ -480,4 +481,19 @@ public class MetaConfigService { | ||
480 | protected static Map<String,CacheKeyBuilder.KeyTemp> findMetaCodeCacheKeyMap(){ | 481 | protected static Map<String,CacheKeyBuilder.KeyTemp> findMetaCodeCacheKeyMap(){ |
481 | return DataHold.MetaCodeCacheKeyMap; | 482 | return DataHold.MetaCodeCacheKeyMap; |
482 | } | 483 | } |
484 | + | ||
485 | + | ||
486 | + public Map<String,LimitTime> getSellerDeliverLimitTimeConfig(){ | ||
487 | + final String key = MetaConfigKey.SELLER_DELIVER_LIMIT_TIME; | ||
488 | + CacheKeyBuilder.KeyTemp kt = findMetaCodeCacheKeyMap().get(key); | ||
489 | + RedisKeyBuilder rkb = kt.builderKeyOnlyFixed(); | ||
490 | + String configVal = new DataProcesser(rkb, key, ExpiredTime.ORDER_BASE_CONFIG).getConfigVal(); | ||
491 | + Map<String,LimitTime> ltMap = new HashMap<String,LimitTime>(10); | ||
492 | + try{ | ||
493 | + ltMap = JSONObject.parseObject(configVal, new TypeReference<Map<String,LimitTime>>(){}); | ||
494 | + }catch (Exception ex){ | ||
495 | + logger.warn("in getSellerDeliverLimitTimeConfig parseObject fail, metaVal {}", configVal, ex); | ||
496 | + } | ||
497 | + return ltMap; | ||
498 | + } | ||
483 | } | 499 | } |
@@ -3,7 +3,12 @@ package com.yohoufo.order.service.proxy; | @@ -3,7 +3,12 @@ package com.yohoufo.order.service.proxy; | ||
3 | import com.yoho.core.cache.LocalCache; | 3 | import com.yoho.core.cache.LocalCache; |
4 | import com.yoho.core.config.ConfigReader; | 4 | import com.yoho.core.config.ConfigReader; |
5 | import com.yohobuy.ufo.model.order.bo.IntervalBo; | 5 | import com.yohobuy.ufo.model.order.bo.IntervalBo; |
6 | +import com.yohobuy.ufo.model.order.constants.SkupType; | ||
7 | +import com.yohoufo.dal.order.model.SellerOrderGoods; | ||
8 | +import com.yohoufo.order.model.dto.LimitTime; | ||
9 | +import com.yohoufo.order.service.impl.MetaConfigService; | ||
6 | import lombok.Getter; | 10 | import lombok.Getter; |
11 | +import org.apache.commons.collections.MapUtils; | ||
7 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
8 | import org.slf4j.LoggerFactory; | 13 | import org.slf4j.LoggerFactory; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -11,6 +16,8 @@ import org.springframework.beans.factory.annotation.Value; | @@ -11,6 +16,8 @@ import org.springframework.beans.factory.annotation.Value; | ||
11 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
12 | 17 | ||
13 | import javax.annotation.PostConstruct; | 18 | import javax.annotation.PostConstruct; |
19 | +import java.util.Map; | ||
20 | +import java.util.Objects; | ||
14 | import java.util.concurrent.TimeUnit; | 21 | import java.util.concurrent.TimeUnit; |
15 | 22 | ||
16 | /** | 23 | /** |
@@ -62,6 +69,9 @@ public class DeliveryMinutesService { | @@ -62,6 +69,9 @@ public class DeliveryMinutesService { | ||
62 | @Getter | 69 | @Getter |
63 | private int totalMinutes = 36*60; | 70 | private int totalMinutes = 36*60; |
64 | 71 | ||
72 | + @Autowired | ||
73 | + private MetaConfigService metaConfigService; | ||
74 | + | ||
65 | 75 | ||
66 | @PostConstruct | 76 | @PostConstruct |
67 | private void init() { | 77 | private void init() { |
@@ -95,15 +105,26 @@ public class DeliveryMinutesService { | @@ -95,15 +105,26 @@ public class DeliveryMinutesService { | ||
95 | return MINUTES_DELIVERNOTICE_SECOND; | 105 | return MINUTES_DELIVERNOTICE_SECOND; |
96 | } | 106 | } |
97 | 107 | ||
98 | - public int getDeliverMinutesThird(int ts){ | 108 | + public int getDeliverMinutesThird(int ts, SellerOrderGoods sellerOrderGoods){ |
109 | + | ||
110 | + Map<String,LimitTime> limitTimeMap = metaConfigService.getSellerDeliverLimitTimeConfig(); | ||
111 | + SkupType skupType = SkupType.getSkupType(sellerOrderGoods.getAttributes()); | ||
112 | + LimitTime limitTime = null; | ||
113 | + if (MapUtils.isNotEmpty(limitTimeMap) | ||
114 | + && Objects.nonNull(limitTime=limitTimeMap.get(skupType.getLocalCacheKey()))){ | ||
115 | + return limitTime.getLimitTime(); | ||
116 | + } | ||
117 | + | ||
118 | + //当前时刻在某个指定的时刻之前时,使用旧的规则 | ||
99 | if(ts<getOnlineTime()){ | 119 | if(ts<getOnlineTime()){ |
100 | return minutes_deliverNotice_third_old; | 120 | return minutes_deliverNotice_third_old; |
101 | } | 121 | } |
122 | + | ||
102 | return minutes_deliverNotice_third; | 123 | return minutes_deliverNotice_third; |
103 | } | 124 | } |
104 | 125 | ||
105 | - public int getDeliverMinutesThird_hours(int ts){ | ||
106 | - int minutes = getDeliverMinutesThird(ts); | 126 | + public int getDeliverHoursOfLimitTime(int ts, SellerOrderGoods sellerOrderGoods){ |
127 | + int minutes = getDeliverMinutesThird(ts, sellerOrderGoods); | ||
107 | return minutes/60 ; | 128 | return minutes/60 ; |
108 | } | 129 | } |
109 | 130 | ||
@@ -154,6 +175,10 @@ public class DeliveryMinutesService { | @@ -154,6 +175,10 @@ public class DeliveryMinutesService { | ||
154 | return intervalBo; | 175 | return intervalBo; |
155 | } | 176 | } |
156 | 177 | ||
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | ||
157 | public static void main(String[] args) { | 182 | public static void main(String[] args) { |
158 | for(int times=1;times<=3;times++) { | 183 | for(int times=1;times<=3;times++) { |
159 | int start = 60; | 184 | int start = 60; |
@@ -25,7 +25,7 @@ public class DeliveryMinutesServiceTest extends BaseWebTest { | @@ -25,7 +25,7 @@ public class DeliveryMinutesServiceTest extends BaseWebTest { | ||
25 | @Test | 25 | @Test |
26 | public void testGetDeliverMinutesThird(){ | 26 | public void testGetDeliverMinutesThird(){ |
27 | int ts = DateUtil.getCurrentTimeSecond(); | 27 | int ts = DateUtil.getCurrentTimeSecond(); |
28 | - int mins = deliveryMinutesService.getDeliverMinutesThird(ts); | 28 | + int mins = deliveryMinutesService.getDeliverMinutesThird(ts,null); |
29 | System.out.println("testGetDeliverMinutesThird -> " + mins); | 29 | System.out.println("testGetDeliverMinutesThird -> " + mins); |
30 | } | 30 | } |
31 | } | 31 | } |
@@ -7,12 +7,7 @@ consumer: | @@ -7,12 +7,7 @@ consumer: | ||
7 | - class: com.yohoufo.order.mq.consumer.BuyerOrderUnpaidReminderDelayMsgConsumer | 7 | - class: com.yohoufo.order.mq.consumer.BuyerOrderUnpaidReminderDelayMsgConsumer |
8 | topic: buyerOrder.unpaidReminder | 8 | topic: buyerOrder.unpaidReminder |
9 | delay: | 9 | delay: |
10 | - interval: 720 | ||
11 | - | ||
12 | - - class: com.yohoufo.order.mq.consumer.BuyerOrderUnpaidReminderDelayMsgConsumer | ||
13 | - topic: buyerOrder.unpaidReminder | ||
14 | - delay: | ||
15 | - interval: 1320 | 10 | + interval: 720,1320 |
16 | 11 | ||
17 | - class: com.yohoufo.order.mq.consumer.WaitingPayDepositBuyerOrderAutoCancelDelayMsgConsumer | 12 | - class: com.yohoufo.order.mq.consumer.WaitingPayDepositBuyerOrderAutoCancelDelayMsgConsumer |
18 | topic: waitingPayDepositBuyerOrder.autoCancel | 13 | topic: waitingPayDepositBuyerOrder.autoCancel |
@@ -27,37 +22,12 @@ consumer: | @@ -27,37 +22,12 @@ consumer: | ||
27 | - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayNDayMsgConsumer | 22 | - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayNDayMsgConsumer |
28 | topic: buyerOrder.autoCancelAfterNDay | 23 | topic: buyerOrder.autoCancelAfterNDay |
29 | delay: | 24 | delay: |
30 | - interval: 1440 | ||
31 | - | ||
32 | - - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayNDayMsgConsumer | ||
33 | - topic: buyerOrder.autoCancelAfterNDay | ||
34 | - delay: | ||
35 | - interval: 4320 | ||
36 | - | ||
37 | - - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayNDayMsgConsumer | ||
38 | - topic: buyerOrder.autoCancelAfterNDay | ||
39 | - delay: | ||
40 | - interval: 10080 | ||
41 | - | ||
42 | - - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayNDayMsgConsumer | ||
43 | - topic: buyerOrder.autoCancelAfterNDay | ||
44 | - delay: | ||
45 | - interval: 21600 | ||
46 | - | ||
47 | - - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayNDayMsgConsumer | ||
48 | - topic: buyerOrder.autoCancelAfterNDay | ||
49 | - delay: | ||
50 | - interval: 43200 | 25 | + interval: 1440,4320,10080,21600,43200 |
51 | 26 | ||
52 | - class: com.yohoufo.order.mq.consumer.SellerOrderAutoCancelDelayMsgConsumer | 27 | - class: com.yohoufo.order.mq.consumer.SellerOrderAutoCancelDelayMsgConsumer |
53 | topic: sellerOrder.autoCancel | 28 | topic: sellerOrder.autoCancel |
54 | delay: | 29 | delay: |
55 | - interval: 15 | ||
56 | - | ||
57 | - - class: com.yohoufo.order.mq.consumer.SellerOrderAutoCancelDelayMsgConsumer | ||
58 | - topic: sellerOrder.autoCancel | ||
59 | - delay: | ||
60 | - interval: 2 | 30 | + interval: 2,15 |
61 | 31 | ||
62 | - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayMsgConsumer | 32 | - class: com.yohoufo.order.mq.consumer.BuyerOrderAutoCancelDelayMsgConsumer |
63 | topic: buyerOrder.autoCancel | 33 | topic: buyerOrder.autoCancel |
@@ -74,17 +44,11 @@ consumer: | @@ -74,17 +44,11 @@ consumer: | ||
74 | delay: | 44 | delay: |
75 | interval: 1440 | 45 | interval: 1440 |
76 | 46 | ||
77 | - #卖家物流揽收情况检查 24小时 | 47 | + #卖家物流揽收情况检查 24小时 48小时 |
78 | - class: com.yohoufo.order.mq.consumer.BuyerOrderSellerDeliveryCheckMsgConsumer | 48 | - class: com.yohoufo.order.mq.consumer.BuyerOrderSellerDeliveryCheckMsgConsumer |
79 | topic: buyerOrder.sellerDeliveryCheck | 49 | topic: buyerOrder.sellerDeliveryCheck |
80 | delay: | 50 | delay: |
81 | - interval: 1440 | ||
82 | - | ||
83 | - #卖家物流揽收情况检查 48小时 | ||
84 | - - class: com.yohoufo.order.mq.consumer.BuyerOrderSellerDeliveryCheckMsgConsumer | ||
85 | - topic: buyerOrder.sellerDeliveryCheck | ||
86 | - delay: | ||
87 | - interval: 2880 | 51 | + interval: 1440,2880 |
88 | 52 | ||
89 | #- class: com.yohoufo.order.mq.consumer.BuyerOrderCancelShamDeliveryMsgConsumer | 53 | #- class: com.yohoufo.order.mq.consumer.BuyerOrderCancelShamDeliveryMsgConsumer |
90 | # topic: buyerOrder.cancelShamDeliver | 54 | # topic: buyerOrder.cancelShamDeliver |
@@ -99,22 +63,12 @@ consumer: | @@ -99,22 +63,12 @@ consumer: | ||
99 | - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer | 63 | - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer |
100 | topic: order.notDeliver | 64 | topic: order.notDeliver |
101 | delay: | 65 | delay: |
102 | - interval: 1440 | ||
103 | - | ||
104 | - - class: com.yohoufo.order.mq.consumer.NotDeliverNoticeDelayMsgConsumer | ||
105 | - topic: order.notDeliver | ||
106 | - delay: | ||
107 | - interval: 29520 | ||
108 | - | ||
109 | - - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer | ||
110 | - topic: sellerOrder.autoCancelDeliver | ||
111 | - delay: | ||
112 | - interval: 2160 | 66 | + interval: 1440,29520 |
113 | 67 | ||
114 | - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer | 68 | - class: com.yohoufo.order.mq.consumer.SellerOrderCancelDeliverDelayMsgConsumer |
115 | topic: sellerOrder.autoCancelDeliver | 69 | topic: sellerOrder.autoCancelDeliver |
116 | delay: | 70 | delay: |
117 | - interval: 30240 | 71 | + interval: 2160,30240 |
118 | 72 | ||
119 | # 平台鉴定不能确定补发优惠券回调 | 73 | # 平台鉴定不能确定补发优惠券回调 |
120 | - class: com.yohoufo.order.mq.consumer.BuyerCouponSendResultForAppraiseUnsureConsumer | 74 | - class: com.yohoufo.order.mq.consumer.BuyerCouponSendResultForAppraiseUnsureConsumer |
-
Please register or login to post a comment