Showing
4 changed files
with
34 additions
and
2 deletions
@@ -18,6 +18,9 @@ public class BuyerOrderSubmitResult { | @@ -18,6 +18,9 @@ public class BuyerOrderSubmitResult { | ||
18 | 18 | ||
19 | long orderCode; | 19 | long orderCode; |
20 | 20 | ||
21 | + //提交时间 == 订单创建时间 | ||
22 | + int submitTime; | ||
23 | + | ||
21 | SellerOrder sellerOrder; | 24 | SellerOrder sellerOrder; |
22 | 25 | ||
23 | SellerOrderGoods sellerOrderGoods; | 26 | SellerOrderGoods sellerOrderGoods; |
@@ -478,6 +478,7 @@ public class ShoppingServiceImpl implements IShoppingService { | @@ -478,6 +478,7 @@ public class ShoppingServiceImpl implements IShoppingService { | ||
478 | buyerOrder.setUid(uid); | 478 | buyerOrder.setUid(uid); |
479 | buyerOrder.setOrderCode(orderCode); | 479 | buyerOrder.setOrderCode(orderCode); |
480 | buyerOrder.setAmount(orderBuilder.getAmount()); | 480 | buyerOrder.setAmount(orderBuilder.getAmount()); |
481 | + buyerOrder.setCreateTime(submitResult.getSubmitTime()); | ||
481 | orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.CREATE, OrderStatus.HAS_PAYED)); | 482 | orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.CREATE, OrderStatus.HAS_PAYED)); |
482 | 483 | ||
483 | //clean cache | 484 | //clean cache |
@@ -169,7 +169,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | @@ -169,7 +169,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | ||
169 | SellerOrder sellerOrder = selectSellerOrder(orderBuilder); | 169 | SellerOrder sellerOrder = selectSellerOrder(orderBuilder); |
170 | 170 | ||
171 | // 3.插入订单 表buyer_order | 171 | // 3.插入订单 表buyer_order |
172 | - insertOrder(orderBuilder, sellerOrder.getUid()); | 172 | + BuyerOrder buyerOrder = insertOrder(orderBuilder, sellerOrder.getUid()); |
173 | 173 | ||
174 | // 4.插入订单商品 buyer_order_goods | 174 | // 4.插入订单商品 buyer_order_goods |
175 | insertOrderGoods(orderBuilder); | 175 | insertOrderGoods(orderBuilder); |
@@ -186,6 +186,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | @@ -186,6 +186,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | ||
186 | 186 | ||
187 | BuyerOrderSubmitResult result = BuyerOrderSubmitResult.builder() | 187 | BuyerOrderSubmitResult result = BuyerOrderSubmitResult.builder() |
188 | .orderCode(orderBuilder.getOrderCode()) | 188 | .orderCode(orderBuilder.getOrderCode()) |
189 | + .submitTime(buyerOrder.getCreateTime()) | ||
189 | .sellerOrder(sellerOrder) | 190 | .sellerOrder(sellerOrder) |
190 | .sellerOrderGoods(orderBuilder.getSellerOrderGoods()).build(); | 191 | .sellerOrderGoods(orderBuilder.getSellerOrderGoods()).build(); |
191 | 192 | ||
@@ -249,7 +250,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | @@ -249,7 +250,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | ||
249 | buyerOrderGoodsMapper.insertSelective(buyerOrderGoods); | 250 | buyerOrderGoodsMapper.insertSelective(buyerOrderGoods); |
250 | } | 251 | } |
251 | 252 | ||
252 | - private void insertOrder(OrderBuilder orderBuilder, int sellerUid) { | 253 | + private BuyerOrder insertOrder(OrderBuilder orderBuilder, int sellerUid) { |
253 | BuyerOrder buyerOrder = new BuyerOrder(); | 254 | BuyerOrder buyerOrder = new BuyerOrder(); |
254 | buyerOrder.setUid(orderBuilder.getUid()); | 255 | buyerOrder.setUid(orderBuilder.getUid()); |
255 | buyerOrder.setOrderCode(orderBuilder.getOrderCode()); | 256 | buyerOrder.setOrderCode(orderBuilder.getOrderCode()); |
@@ -273,6 +274,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | @@ -273,6 +274,7 @@ public class SubmitOrderServiceImpl implements ISubmitOrderService { | ||
273 | //活动类型 | 274 | //活动类型 |
274 | buyerOrder.setActivityType(orderBuilder.getActivityBo().getActivityType()); | 275 | buyerOrder.setActivityType(orderBuilder.getActivityBo().getActivityType()); |
275 | buyerOrderMapper.insert(buyerOrder); | 276 | buyerOrderMapper.insert(buyerOrder); |
277 | + return buyerOrder; | ||
276 | } | 278 | } |
277 | 279 | ||
278 | private void insertOrderCouponIfNeed(OrderBuilder orderBuilder) { | 280 | private void insertOrderCouponIfNeed(OrderBuilder orderBuilder) { |
1 | package com.yohoufo.order.service.listener.processor; | 1 | package com.yohoufo.order.service.listener.processor; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.google.common.collect.Lists; | 4 | import com.google.common.collect.Lists; |
5 | +import com.yoho.core.rabbitmq.YhProducer; | ||
4 | import com.yohobuy.ufo.model.order.common.OrderStatus; | 6 | import com.yohobuy.ufo.model.order.common.OrderStatus; |
5 | import com.yohoufo.common.alarm.EventBusPublisher; | 7 | import com.yohoufo.common.alarm.EventBusPublisher; |
6 | import com.yohoufo.common.alarm.SmsAlarmEvent; | 8 | import com.yohoufo.common.alarm.SmsAlarmEvent; |
@@ -16,6 +18,7 @@ import org.slf4j.Logger; | @@ -16,6 +18,7 @@ import org.slf4j.Logger; | ||
16 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
17 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
18 | 20 | ||
21 | +import javax.annotation.Resource; | ||
19 | import java.util.List; | 22 | import java.util.List; |
20 | import java.util.Objects; | 23 | import java.util.Objects; |
21 | 24 | ||
@@ -36,8 +39,12 @@ public class BuyerOrderChangeBusinessPostProcessor { | @@ -36,8 +39,12 @@ public class BuyerOrderChangeBusinessPostProcessor { | ||
36 | @Autowired | 39 | @Autowired |
37 | private BargainProxyService bargainProxyService; | 40 | private BargainProxyService bargainProxyService; |
38 | 41 | ||
42 | + @Resource( name = "ufoExpressInfoProducer") | ||
43 | + private YhProducer ufoExpressInfoProducer; | ||
44 | + | ||
39 | //业务处理器 | 45 | //业务处理器 |
40 | private List<BusinessProcessor> processors = Lists.newArrayList( | 46 | private List<BusinessProcessor> processors = Lists.newArrayList( |
47 | + new NotifyProcessor(), | ||
41 | new DefaultBusinessProcessor(), | 48 | new DefaultBusinessProcessor(), |
42 | //砍价 | 49 | //砍价 |
43 | new BargainBusinessProcessor() | 50 | new BargainBusinessProcessor() |
@@ -181,6 +188,25 @@ public class BuyerOrderChangeBusinessPostProcessor { | @@ -181,6 +188,25 @@ public class BuyerOrderChangeBusinessPostProcessor { | ||
181 | } | 188 | } |
182 | } | 189 | } |
183 | 190 | ||
191 | + | ||
192 | + /** | ||
193 | + * 下单通知 | ||
194 | + */ | ||
195 | + private class NotifyProcessor extends BusinessProcessorAdapter { | ||
196 | + private static final String TOPIC = "ufo.notify.buyerOrder"; | ||
197 | + | ||
198 | + @Override | ||
199 | + public void create(BusinessProcessorContext context) { | ||
200 | + BuyerOrder buyerOrder = context.buyerOrder; | ||
201 | + JSONObject jsonObject = new JSONObject(); | ||
202 | + jsonObject.put("uid", buyerOrder.getUid()); | ||
203 | + jsonObject.put("orderCode", buyerOrder.getOrderCode()); | ||
204 | + jsonObject.put("createTime", buyerOrder.getCreateTime()); | ||
205 | + ufoExpressInfoProducer.send(TOPIC, jsonObject); | ||
206 | + } | ||
207 | + } | ||
208 | + | ||
209 | + | ||
184 | //默认业务处理 | 210 | //默认业务处理 |
185 | private class DefaultBusinessProcessor extends BusinessProcessorAdapter { | 211 | private class DefaultBusinessProcessor extends BusinessProcessorAdapter { |
186 | @Override | 212 | @Override |
-
Please register or login to post a comment