Authored by sailing-PC\sailing

fix

@@ -259,6 +259,9 @@ @@ -259,6 +259,9 @@
259 </set> 259 </set>
260 where id = #{id,jdbcType=INTEGER} 260 where id = #{id,jdbcType=INTEGER}
261 </update> 261 </update>
  262 +
  263 +
  264 +
262 <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.BuyerOrder"> 265 <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
263 update buyer_order 266 update buyer_order
264 set uid = #{uid,jdbcType=INTEGER}, 267 set uid = #{uid,jdbcType=INTEGER},
1 package com.yohoufo.order.common; 1 package com.yohoufo.order.common;
2 2
  3 +import com.google.common.collect.Lists;
  4 +
3 import java.util.Arrays; 5 import java.util.Arrays;
4 import java.util.List; 6 import java.util.List;
5 7
@@ -27,4 +29,50 @@ public class ActionStatusHold { @@ -27,4 +29,50 @@ public class ActionStatusHold {
27 29
28 return sellerCanCancelStatus; 30 return sellerCanCancelStatus;
29 } 31 }
  32 +
  33 +
  34 + static List<Integer> BuyerCanDelStatusList = Arrays.asList(
  35 + OrderStatus.DONE.getCode(),
  36 +
  37 + OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
  38 + OrderStatus.SEND_OUT_TIMEOUT.getCode(),
  39 + OrderStatus.CHECKING_FAKE.getCode(),//鉴权不通过
  40 + OrderStatus.WAITING_RECEIVE.getCode(),//
  41 +
  42 + OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
  43 + OrderStatus.BUYER_CANCEL_TIMEOUT.getCode()
  44 + );
  45 +
  46 + public static List<Integer> getBuyerCanDelStatusList(){
  47 + return BuyerCanDelStatusList;
  48 + }
  49 +
  50 + private final static List<Integer> SellerCanDelBuyerStatusList = Lists.newArrayList(
  51 + OrderStatus.DONE.getCode(),
  52 +
  53 + OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
  54 + OrderStatus.SEND_OUT_TIMEOUT.getCode(),
  55 + OrderStatus.CHECKING_FAKE.getCode(),
  56 + OrderStatus.WAITING_RECEIVE.getCode(),
  57 +
  58 + OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
  59 + OrderStatus.BUYER_CANCEL_TIMEOUT.getCode());
  60 +
  61 +
  62 + public static List<Integer> getSellerCanDelBuyerStatusList(){
  63 + return SellerCanDelBuyerStatusList;
  64 + }
  65 +
  66 +
  67 + private final static List<Integer> sellerCanDelStatusList = Lists.newArrayList(
  68 + SellerOrderStatus.PLAY_SELF.getCode(),
  69 + SellerOrderStatus.SELf_CANCEL_PAY.getCode(),
  70 + SellerOrderStatus.TIMEOUT_CANCEL.getCode(),
  71 + SellerOrderStatus.FINISH.getCode()
  72 + );
  73 +
  74 +
  75 + public static List<Integer> getSellerCanDelStatusList(){
  76 + return sellerCanDelStatusList;
  77 + }
30 } 78 }
@@ -136,6 +136,19 @@ public class BuyerOrderController { @@ -136,6 +136,19 @@ public class BuyerOrderController {
136 return new ApiResponse.ApiResponseBuilder().code(200).message("取消成功").build(); 136 return new ApiResponse.ApiResponseBuilder().code(200).message("取消成功").build();
137 } 137 }
138 138
  139 + /**
  140 + * 取消订单
  141 + */
  142 +
  143 + @RequestMapping(params = "method=ufo.buyer.delete")
  144 + @ResponseBody
  145 + public ApiResponse delete(@RequestParam("orderCode") long orderCode,
  146 + @RequestParam("uid") int uid) {
  147 + LOG.info("method ufo.buyer.delete in, orderCode is {}, uid is {}", orderCode, uid);
  148 + boolean data = buyerOrderService.delete(uid, orderCode);
  149 + LOG.info("method ufo.buyer.delete out, orderCode is {}, uid is {}", orderCode, uid);
  150 + return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("取消成功").build();
  151 + }
139 152
140 /** 153 /**
141 * 确认收货 154 * 确认收货
  1 +package com.yohoufo.order.event;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +import lombok.NoArgsConstructor;
  6 +import lombok.experimental.Builder;
  7 +
  8 +/**
  9 + * Created by chenchao on 2018/9/30.
  10 + */
  11 +@Data
  12 +@Builder
  13 +@NoArgsConstructor
  14 +@AllArgsConstructor
  15 +public class BuyerConfirmEvent extends Event{
  16 +
  17 + private int uid;
  18 +
  19 + private long orderCode;
  20 +}
  1 +package com.yohoufo.order.event;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Data;
  5 +import lombok.NoArgsConstructor;
  6 +import lombok.experimental.Builder;
  7 +
  8 +/**
  9 + * Created by chenchao on 2018/9/30.
  10 + */
  11 +@Data
  12 +@Builder
  13 +@NoArgsConstructor
  14 +@AllArgsConstructor
  15 +public class SellerCancelDeliverEvent extends Event {
  16 +
  17 + private int uid;
  18 +
  19 + private long orderCode;
  20 +}
@@ -12,4 +12,17 @@ public interface TopicConstants { @@ -12,4 +12,17 @@ public interface TopicConstants {
12 12
13 13
14 String BUYER_ORDER_AUTO_CANCEL = "buyer_order_autoCancel"; 14 String BUYER_ORDER_AUTO_CANCEL = "buyer_order_autoCancel";
  15 + /**
  16 + * 买家订单自动确认
  17 + * 7天自动确认
  18 + */
  19 + String BUYER_ORDER_AUTO_CONFIRM = "buyerOrder.autoConfirm";
  20 +
  21 + /**
  22 + * 48小时
  23 + * 卖家发货超时
  24 + */
  25 + String SELLER_ORDER_AUTO_CANCEL_DELIVER = "sellerOrder.autoCancelDeliver";
  26 +
  27 +
15 } 28 }
  1 +package com.yohoufo.order.mq.consumer;
  2 +
  3 +import com.yoho.core.rabbitmq.YhConsumer;
  4 +import com.yohoufo.order.mq.TopicConstants;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * Created by chenchao on 2018/9/30.
  11 + */
  12 +@Component
  13 +public class BuyerOrderConfirmDelayMsgConsumer implements YhConsumer {
  14 +
  15 + final Logger logger = LoggerFactory.getLogger(getClass());
  16 +
  17 + public String getMessageTopic() {
  18 +
  19 + return TopicConstants.BUYER_ORDER_AUTO_CONFIRM;
  20 + }
  21 +
  22 +
  23 + @Override
  24 + public void handleMessage(Object o) throws Exception {
  25 + logger.info("topic {}, msg {} ", getMessageTopic(), o);
  26 + }
  27 +}
  1 +package com.yohoufo.order.mq.consumer;
  2 +
  3 +import com.yoho.core.rabbitmq.YhConsumer;
  4 +import com.yohoufo.order.mq.TopicConstants;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * Created by chenchao on 2018/9/30.
  11 + */
  12 +@Component
  13 +public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
  14 +
  15 + final Logger logger = LoggerFactory.getLogger(getClass());
  16 +
  17 + public String getMessageTopic() {
  18 +
  19 + return TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER;
  20 + }
  21 +
  22 +
  23 +
  24 + @Override
  25 + public void handleMessage(Object o) throws Exception {
  26 + logger.info("topic {}, msg {} ", getMessageTopic(), o);
  27 + }
  28 +}
@@ -30,4 +30,7 @@ public interface IBuyerOrderService extends IOrderListService, IOrderDetailServi @@ -30,4 +30,7 @@ public interface IBuyerOrderService extends IOrderListService, IOrderDetailServi
30 * @return 30 * @return
31 */ 31 */
32 OrderSummaryResp selectOrderNumByUid(int uid); 32 OrderSummaryResp selectOrderNumByUid(int uid);
  33 +
  34 +
  35 + boolean delete(int uid, long orderCode);
33 } 36 }
  1 +package com.yohoufo.order.service.handler;
  2 +
  3 +import com.google.common.eventbus.Subscribe;
  4 +import com.yohoufo.order.event.BuyerConfirmEvent;
  5 +import com.yohoufo.order.event.IEventHandler;
  6 +import com.yohoufo.order.mq.TopicConstants;
  7 +import com.yohoufo.order.mq.producer.TradeMqSender;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +/**
  14 + * Created by chenchao on 2018/9/30.
  15 + */
  16 +@Component
  17 +public class BuyerConfirmHandler implements IEventHandler<BuyerConfirmEvent> {
  18 +
  19 + final Logger logger = LoggerFactory.getLogger(getClass());
  20 +
  21 + public static final int DELAY_MINUTES_7_DAYS = 24 * 60 * 7;
  22 + @Autowired
  23 + private TradeMqSender tradeMqSender;
  24 + @Override
  25 + @Subscribe
  26 + public void handle(BuyerConfirmEvent event) {
  27 + logger.info("Subscribe Buyer Confirm delay msg, event {}", event);
  28 +
  29 + tradeMqSender.send(TopicConstants.BUYER_ORDER_AUTO_CONFIRM, event, DELAY_MINUTES_7_DAYS);
  30 + }
  31 +}
  1 +package com.yohoufo.order.service.handler;
  2 +
  3 +import com.google.common.eventbus.Subscribe;
  4 +import com.yohoufo.order.event.IEventHandler;
  5 +import com.yohoufo.order.event.SellerCancelDeliverEvent;
  6 +import com.yohoufo.order.mq.TopicConstants;
  7 +import com.yohoufo.order.mq.producer.TradeMqSender;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Component;
  12 +
  13 +/**
  14 + * Created by chenchao on 2018/9/30.
  15 + */
  16 +@Component
  17 +public class SellerCancelDeliverHandler implements IEventHandler<SellerCancelDeliverEvent> {
  18 +
  19 + private final Logger logger = LoggerFactory.getLogger(getClass());
  20 + public static final int DELAY_MINUTES_48_HOURS = 48 * 60 ;
  21 +
  22 + @Autowired
  23 + private TradeMqSender tradeMqSender;
  24 +
  25 + @Override
  26 + @Subscribe
  27 + public void handle(SellerCancelDeliverEvent event) {
  28 + logger.info("Subscribe Buyer Confirm delay msg, event {}", event);
  29 +
  30 + tradeMqSender.send(TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER, event, DELAY_MINUTES_48_HOURS);
  31 + }
  32 +}
@@ -9,9 +9,7 @@ import com.yohoufo.dal.order.model.BuyerOrder; @@ -9,9 +9,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
9 import com.yohoufo.dal.order.model.BuyerOrderGoods; 9 import com.yohoufo.dal.order.model.BuyerOrderGoods;
10 import com.yohoufo.dal.order.model.SellerOrder; 10 import com.yohoufo.dal.order.model.SellerOrder;
11 import com.yohoufo.dal.order.model.SellerOrderGoods; 11 import com.yohoufo.dal.order.model.SellerOrderGoods;
12 -import com.yohoufo.order.common.OrderStatus;  
13 -import com.yohoufo.order.common.SellerOrderStatus;  
14 -import com.yohoufo.order.common.SkupStatus; 12 +import com.yohoufo.order.common.*;
15 import com.yohoufo.order.model.request.OrderListRequest; 13 import com.yohoufo.order.model.request.OrderListRequest;
16 import com.yohoufo.order.model.request.OrderRequest; 14 import com.yohoufo.order.model.request.OrderRequest;
17 import com.yohoufo.order.model.response.OrderDetailInfo; 15 import com.yohoufo.order.model.response.OrderDetailInfo;
@@ -23,6 +21,8 @@ import org.slf4j.LoggerFactory; @@ -23,6 +21,8 @@ import org.slf4j.LoggerFactory;
23 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.stereotype.Service; 22 import org.springframework.stereotype.Service;
25 23
  24 +import java.util.Objects;
  25 +
26 @Service 26 @Service
27 public class BuyerOrderServiceImpl implements IBuyerOrderService { 27 public class BuyerOrderServiceImpl implements IBuyerOrderService {
28 28
@@ -178,4 +178,33 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -178,4 +178,33 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
178 Integer num = buyerOrderMapper.selectOrderNumByUid(uid); 178 Integer num = buyerOrderMapper.selectOrderNumByUid(uid);
179 return null == num ? new OrderSummaryResp("buy", 0) : new OrderSummaryResp("buy", num); 179 return null == num ? new OrderSummaryResp("buy", 0) : new OrderSummaryResp("buy", num);
180 } 180 }
  181 +
  182 +
  183 +
  184 +
  185 + @Override
  186 + public boolean delete(int uid, long orderCode) {
  187 + if (uid < 0
  188 + || orderCode < 0){
  189 + logger.warn("buyer delete, uid or orderCode empty, uid {}, orderCode {}", uid, orderCode);
  190 + throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
  191 + }
  192 + BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
  193 + if (Objects.isNull(buyerOrder)){
  194 + logger.warn("buyer delete, order not exist, uid {}, orderCode {}", uid, orderCode);
  195 + return false;
  196 + }
  197 + Integer status;
  198 + if(ActionStatusHold.getBuyerCanDelStatusList().contains(status=buyerOrder.getStatus())){
  199 + BuyerOrder target = new BuyerOrder();
  200 + target.setId(buyerOrder.getId());
  201 + target.setBuyerOrderStatus(DelStatus.IS_DEL.getCode());
  202 + return buyerOrderMapper.updateByPrimaryKeySelective(target) == 1;
  203 + }else{
  204 + logger.warn("buyer delete fail, order status {}", status);
  205 + }
  206 +
  207 +
  208 + return false;
  209 + }
181 } 210 }
1 package com.yohoufo.order.service.impl; 1 package com.yohoufo.order.service.impl;
2 2
3 -import java.math.BigDecimal;  
4 -import java.util.List;  
5 -import java.util.Objects;  
6 -  
7 -import lombok.extern.slf4j.Slf4j;  
8 -  
9 -import org.apache.commons.lang3.StringUtils;  
10 -import org.springframework.beans.factory.annotation.Autowired;  
11 -import org.springframework.stereotype.Service;  
12 -  
13 -import com.google.common.collect.Lists;  
14 import com.yoho.error.ServiceError; 3 import com.yoho.error.ServiceError;
15 import com.yoho.error.exception.ServiceException; 4 import com.yoho.error.exception.ServiceException;
16 import com.yoho.service.model.response.UserAddressRspBO; 5 import com.yoho.service.model.response.UserAddressRspBO;
@@ -26,13 +15,7 @@ import com.yohoufo.dal.order.BuyerOrderMapper; @@ -26,13 +15,7 @@ import com.yohoufo.dal.order.BuyerOrderMapper;
26 import com.yohoufo.dal.order.SellerOrderMapper; 15 import com.yohoufo.dal.order.SellerOrderMapper;
27 import com.yohoufo.dal.order.model.BuyerOrder; 16 import com.yohoufo.dal.order.model.BuyerOrder;
28 import com.yohoufo.dal.order.model.SellerOrder; 17 import com.yohoufo.dal.order.model.SellerOrder;
29 -import com.yohoufo.order.common.CancelType;  
30 -import com.yohoufo.order.common.DelStatus;  
31 -import com.yohoufo.order.common.OrderCodeType;  
32 -import com.yohoufo.order.common.OrderStatus;  
33 -import com.yohoufo.order.common.SellerOrderStatus;  
34 -import com.yohoufo.order.common.SkupStatus;  
35 -import com.yohoufo.order.common.TabType; 18 +import com.yohoufo.order.common.*;
36 import com.yohoufo.order.convert.AddressInfoConvertor; 19 import com.yohoufo.order.convert.AddressInfoConvertor;
37 import com.yohoufo.order.convert.SellerOrderConvertor; 20 import com.yohoufo.order.convert.SellerOrderConvertor;
38 import com.yohoufo.order.event.ErpCancelSellerOrderEvent; 21 import com.yohoufo.order.event.ErpCancelSellerOrderEvent;
@@ -61,6 +44,13 @@ import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta; @@ -61,6 +44,13 @@ import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
61 import com.yohoufo.product.model.GoodsSize; 44 import com.yohoufo.product.model.GoodsSize;
62 import com.yohoufo.product.model.ProductInfo; 45 import com.yohoufo.product.model.ProductInfo;
63 import com.yohoufo.product.response.StorageDataResp; 46 import com.yohoufo.product.response.StorageDataResp;
  47 +import lombok.extern.slf4j.Slf4j;
  48 +import org.apache.commons.lang3.StringUtils;
  49 +import org.springframework.beans.factory.annotation.Autowired;
  50 +import org.springframework.stereotype.Service;
  51 +
  52 +import java.math.BigDecimal;
  53 +import java.util.Objects;
64 54
65 /** 55 /**
66 * Created by chenchao on 2018/9/13. 56 * Created by chenchao on 2018/9/13.
@@ -69,16 +59,6 @@ import com.yohoufo.product.response.StorageDataResp; @@ -69,16 +59,6 @@ import com.yohoufo.product.response.StorageDataResp;
69 @Slf4j 59 @Slf4j
70 public class SellerOrderService implements IOrderListService, IOrderDetailService { 60 public class SellerOrderService implements IOrderListService, IOrderDetailService {
71 61
72 - private final static List<Integer> sellerCanDelStatusList = Lists.newArrayList(  
73 - SellerOrderStatus.PLAY_SELF.getCode(),  
74 - SellerOrderStatus.SELf_CANCEL_PAY.getCode(),  
75 - SellerOrderStatus.TIMEOUT_CANCEL.getCode(),  
76 - SellerOrderStatus.FINISH.getCode());  
77 -  
78 - private final static List<Integer> buyerCanDelStatusList = Lists.newArrayList(  
79 - OrderStatus.DONE.getCode(),  
80 - OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),  
81 - OrderStatus.BUYER_CANCEL_TIMEOUT.getCode());  
82 62
83 @Autowired 63 @Autowired
84 private SellerOrderMapper sellerOrderMapper; 64 private SellerOrderMapper sellerOrderMapper;
@@ -394,15 +374,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -394,15 +374,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
394 } 374 }
395 375
396 private void checkBuyCanDelStatus(Integer status) { 376 private void checkBuyCanDelStatus(Integer status) {
397 - if (!buyerCanDelStatusList.contains(status)) { 377 + if (!ActionStatusHold.getSellerCanDelBuyerStatusList().contains(status)) {
398 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 378 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
399 } 379 }
400 -  
401 } 380 }
402 381
403 382
404 private void checkSellCanDelStatus(Integer status) { 383 private void checkSellCanDelStatus(Integer status) {
405 - if (!sellerCanDelStatusList.contains(status)) { 384 + if (!ActionStatusHold.getSellerCanDelStatusList().contains(status)) {
406 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); 385 throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
407 } 386 }
408 } 387 }