Authored by sailing-PC\sailing

fix

... ... @@ -259,6 +259,9 @@
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.BuyerOrder">
update buyer_order
set uid = #{uid,jdbcType=INTEGER},
... ...
package com.yohoufo.order.common;
import com.google.common.collect.Lists;
import java.util.Arrays;
import java.util.List;
... ... @@ -27,4 +29,50 @@ public class ActionStatusHold {
return sellerCanCancelStatus;
}
static List<Integer> BuyerCanDelStatusList = Arrays.asList(
OrderStatus.DONE.getCode(),
OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),//鉴权不通过
OrderStatus.WAITING_RECEIVE.getCode(),//
OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
OrderStatus.BUYER_CANCEL_TIMEOUT.getCode()
);
public static List<Integer> getBuyerCanDelStatusList(){
return BuyerCanDelStatusList;
}
private final static List<Integer> SellerCanDelBuyerStatusList = Lists.newArrayList(
OrderStatus.DONE.getCode(),
OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode(),
OrderStatus.SEND_OUT_TIMEOUT.getCode(),
OrderStatus.CHECKING_FAKE.getCode(),
OrderStatus.WAITING_RECEIVE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
OrderStatus.BUYER_CANCEL_TIMEOUT.getCode());
public static List<Integer> getSellerCanDelBuyerStatusList(){
return SellerCanDelBuyerStatusList;
}
private final static List<Integer> sellerCanDelStatusList = Lists.newArrayList(
SellerOrderStatus.PLAY_SELF.getCode(),
SellerOrderStatus.SELf_CANCEL_PAY.getCode(),
SellerOrderStatus.TIMEOUT_CANCEL.getCode(),
SellerOrderStatus.FINISH.getCode()
);
public static List<Integer> getSellerCanDelStatusList(){
return sellerCanDelStatusList;
}
}
... ...
... ... @@ -136,6 +136,19 @@ public class BuyerOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).message("取消成功").build();
}
/**
* 取消订单
*/
@RequestMapping(params = "method=ufo.buyer.delete")
@ResponseBody
public ApiResponse delete(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid) {
LOG.info("method ufo.buyer.delete in, orderCode is {}, uid is {}", orderCode, uid);
boolean data = buyerOrderService.delete(uid, orderCode);
LOG.info("method ufo.buyer.delete out, orderCode is {}, uid is {}", orderCode, uid);
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("取消成功").build();
}
/**
* 确认收货
... ...
package com.yohoufo.order.event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chenchao on 2018/9/30.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BuyerConfirmEvent extends Event{
private int uid;
private long orderCode;
}
... ...
package com.yohoufo.order.event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chenchao on 2018/9/30.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SellerCancelDeliverEvent extends Event {
private int uid;
private long orderCode;
}
... ...
... ... @@ -12,4 +12,17 @@ public interface TopicConstants {
String BUYER_ORDER_AUTO_CANCEL = "buyer_order_autoCancel";
/**
* 买家订单自动确认
* 7天自动确认
*/
String BUYER_ORDER_AUTO_CONFIRM = "buyerOrder.autoConfirm";
/**
* 48小时
* 卖家发货超时
*/
String SELLER_ORDER_AUTO_CANCEL_DELIVER = "sellerOrder.autoCancelDeliver";
}
... ...
package com.yohoufo.order.mq.consumer;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yohoufo.order.mq.TopicConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* Created by chenchao on 2018/9/30.
*/
@Component
public class BuyerOrderConfirmDelayMsgConsumer implements YhConsumer {
final Logger logger = LoggerFactory.getLogger(getClass());
public String getMessageTopic() {
return TopicConstants.BUYER_ORDER_AUTO_CONFIRM;
}
@Override
public void handleMessage(Object o) throws Exception {
logger.info("topic {}, msg {} ", getMessageTopic(), o);
}
}
... ...
package com.yohoufo.order.mq.consumer;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yohoufo.order.mq.TopicConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* Created by chenchao on 2018/9/30.
*/
@Component
public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
final Logger logger = LoggerFactory.getLogger(getClass());
public String getMessageTopic() {
return TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER;
}
@Override
public void handleMessage(Object o) throws Exception {
logger.info("topic {}, msg {} ", getMessageTopic(), o);
}
}
... ...
... ... @@ -30,4 +30,7 @@ public interface IBuyerOrderService extends IOrderListService, IOrderDetailServi
* @return
*/
OrderSummaryResp selectOrderNumByUid(int uid);
boolean delete(int uid, long orderCode);
}
... ...
package com.yohoufo.order.service.handler;
import com.google.common.eventbus.Subscribe;
import com.yohoufo.order.event.BuyerConfirmEvent;
import com.yohoufo.order.event.IEventHandler;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.mq.producer.TradeMqSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by chenchao on 2018/9/30.
*/
@Component
public class BuyerConfirmHandler implements IEventHandler<BuyerConfirmEvent> {
final Logger logger = LoggerFactory.getLogger(getClass());
public static final int DELAY_MINUTES_7_DAYS = 24 * 60 * 7;
@Autowired
private TradeMqSender tradeMqSender;
@Override
@Subscribe
public void handle(BuyerConfirmEvent event) {
logger.info("Subscribe Buyer Confirm delay msg, event {}", event);
tradeMqSender.send(TopicConstants.BUYER_ORDER_AUTO_CONFIRM, event, DELAY_MINUTES_7_DAYS);
}
}
... ...
package com.yohoufo.order.service.handler;
import com.google.common.eventbus.Subscribe;
import com.yohoufo.order.event.IEventHandler;
import com.yohoufo.order.event.SellerCancelDeliverEvent;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.mq.producer.TradeMqSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by chenchao on 2018/9/30.
*/
@Component
public class SellerCancelDeliverHandler implements IEventHandler<SellerCancelDeliverEvent> {
private final Logger logger = LoggerFactory.getLogger(getClass());
public static final int DELAY_MINUTES_48_HOURS = 48 * 60 ;
@Autowired
private TradeMqSender tradeMqSender;
@Override
@Subscribe
public void handle(SellerCancelDeliverEvent event) {
logger.info("Subscribe Buyer Confirm delay msg, event {}", event);
tradeMqSender.send(TopicConstants.SELLER_ORDER_AUTO_CANCEL_DELIVER, event, DELAY_MINUTES_48_HOURS);
}
}
... ...
... ... @@ -9,9 +9,7 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.OrderStatus;
import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.common.*;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
... ... @@ -23,6 +21,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
public class BuyerOrderServiceImpl implements IBuyerOrderService {
... ... @@ -178,4 +178,33 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
Integer num = buyerOrderMapper.selectOrderNumByUid(uid);
return null == num ? new OrderSummaryResp("buy", 0) : new OrderSummaryResp("buy", num);
}
@Override
public boolean delete(int uid, long orderCode) {
if (uid < 0
|| orderCode < 0){
logger.warn("buyer delete, uid or orderCode empty, uid {}, orderCode {}", uid, orderCode);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(buyerOrder)){
logger.warn("buyer delete, order not exist, uid {}, orderCode {}", uid, orderCode);
return false;
}
Integer status;
if(ActionStatusHold.getBuyerCanDelStatusList().contains(status=buyerOrder.getStatus())){
BuyerOrder target = new BuyerOrder();
target.setId(buyerOrder.getId());
target.setBuyerOrderStatus(DelStatus.IS_DEL.getCode());
return buyerOrderMapper.updateByPrimaryKeySelective(target) == 1;
}else{
logger.warn("buyer delete fail, order status {}", status);
}
return false;
}
}
... ...
package com.yohoufo.order.service.impl;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.response.UserAddressRspBO;
... ... @@ -26,13 +15,7 @@ import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.common.CancelType;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.common.OrderCodeType;
import com.yohoufo.order.common.OrderStatus;
import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.common.TabType;
import com.yohoufo.order.common.*;
import com.yohoufo.order.convert.AddressInfoConvertor;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.event.ErpCancelSellerOrderEvent;
... ... @@ -61,6 +44,13 @@ import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import com.yohoufo.product.model.GoodsSize;
import com.yohoufo.product.model.ProductInfo;
import com.yohoufo.product.response.StorageDataResp;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Objects;
/**
* Created by chenchao on 2018/9/13.
... ... @@ -69,16 +59,6 @@ import com.yohoufo.product.response.StorageDataResp;
@Slf4j
public class SellerOrderService implements IOrderListService, IOrderDetailService {
private final static List<Integer> sellerCanDelStatusList = Lists.newArrayList(
SellerOrderStatus.PLAY_SELF.getCode(),
SellerOrderStatus.SELf_CANCEL_PAY.getCode(),
SellerOrderStatus.TIMEOUT_CANCEL.getCode(),
SellerOrderStatus.FINISH.getCode());
private final static List<Integer> buyerCanDelStatusList = Lists.newArrayList(
OrderStatus.DONE.getCode(),
OrderStatus.BUYER_CANCEL_BEFORE_PAY.getCode(),
OrderStatus.BUYER_CANCEL_TIMEOUT.getCode());
@Autowired
private SellerOrderMapper sellerOrderMapper;
... ... @@ -394,15 +374,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
private void checkBuyCanDelStatus(Integer status) {
if (!buyerCanDelStatusList.contains(status)) {
if (!ActionStatusHold.getSellerCanDelBuyerStatusList().contains(status)) {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}
private void checkSellCanDelStatus(Integer status) {
if (!sellerCanDelStatusList.contains(status)) {
if (!ActionStatusHold.getSellerCanDelStatusList().contains(status)) {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}
... ...