Commit 84096b67 by 刘宇峰

去掉子订单校验

1 parent f1c440d3
......@@ -11,7 +11,7 @@ public interface BizMessageTypeEnum {
public enum MessageTypeEnum implements BaseEnum<MessageTypeEnum, Integer> {
//消息类型:1:商品消息 2:销售订单消息 3:售后订单
GOODS(1, "商品消息"),
ORDER(2, "已揽件"),
ORDER(2, "销售订单消息"),
AFTER_SALES_ORDER(3, "售后订单"),
;
private final Integer value;
......@@ -22,8 +22,8 @@ public interface BizMessageTypeEnum {
return text;
}
public static MessageTypeEnum getByValue(Integer value){
if (value == null){
public static MessageTypeEnum getByValue(Integer value) {
if (value == null) {
return null;
}
for (MessageTypeEnum enums : MessageTypeEnum.values()) {
......@@ -69,8 +69,8 @@ public interface BizMessageTypeEnum {
return text;
}
public static MessageSmallTypeEnum getByValue(Integer value){
if (value == null){
public static MessageSmallTypeEnum getByValue(Integer value) {
if (value == null) {
return null;
}
for (MessageSmallTypeEnum enums : MessageSmallTypeEnum.values()) {
......
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.modules.entity.*;
import cn.com.glsx.admin.modules.entity.AfterSalesOrder;
import cn.com.glsx.admin.modules.entity.AfterSalesOrderGoods;
import cn.com.glsx.admin.modules.entity.AfterSalesOrderRedeliveryExpress;
import cn.com.glsx.admin.modules.entity.Goods;
import cn.com.glsx.admin.modules.enums.AfterSalesOrderStatusEnum;
import cn.com.glsx.admin.modules.mapper.*;
import cn.com.glsx.admin.modules.model.cloudcrane.request.CreateAfterSalesOrderRequest;
......@@ -11,7 +14,6 @@ import cn.com.glsx.admin.modules.model.cloudcrane.response.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.exception.ServiceException;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
......@@ -72,30 +74,30 @@ public class OrderAfterSalesService {
*/
@Transactional(rollbackFor = Exception.class)
public CreateAfterSalesOrderResponse createAfterSalesOrder(CreateAfterSalesOrderRequest req) {
OrderChild orderChild = orderChildMapper.selectByOrderCode(req.getOrderCode());
if (Objects.isNull(orderChild)) {
throw ServiceException.create("40004", "子订单不存在");
}
// OrderChild orderChild = orderChildMapper.selectByOrderCode(req.getOrderCode());
// if (Objects.isNull(orderChild)) {
// throw ServiceException.create("40004", "子订单不存在");
// }
//1、新建云中鹤售后订单
CreateAfterSalesOrderResponse response = cloudCraneService.createAfterSalesOrder(req);
//2、新建本地售后订单
AfterSalesOrder asOrder = buildLocalAfterSalesOrder(req, orderChild);
AfterSalesOrder asOrder = buildLocalAfterSalesOrder(req);
asOrder.setReturnOrderCode(response.getReturnOrderCode());
afterSalesOrderMapper.insert(asOrder);
//3、新增售后订单商品
AfterSalesOrderGoods asOrderGoods = buildAfterSalesOrderGoods(req, orderChild);
AfterSalesOrderGoods asOrderGoods = buildAfterSalesOrderGoods(req);
asOrderGoods.setReturnOrderCode(response.getReturnOrderCode());//云中鹤售后订单编号
afterSalesOrderGoodsMapper.insert(asOrderGoods);
return response;
}
private AfterSalesOrder buildLocalAfterSalesOrder(CreateAfterSalesOrderRequest req, OrderChild orderChild) {
private AfterSalesOrder buildLocalAfterSalesOrder(CreateAfterSalesOrderRequest req) {
AfterSalesOrder asOrder = new AfterSalesOrder();
asOrder.setTparOrderCode(orderChild.getTparOrderCode());
asOrder.setParentOrderCode(orderChild.getParentOrderCode());
asOrder.setOrderCode(orderChild.getOrderCode());
// asOrder.setTparOrderCode(req.getTparOrderCode());
// asOrder.setParentOrderCode(req.getParentOrderCode());
asOrder.setOrderCode(req.getOrderCode());
asOrder.setTparReturnOrderCode(req.getTparReturnOrderCode());
//售后类型(1001:退货退款(有货物寄回),1002:仅退款(无货物寄回),1003:退货换货)
asOrder.setReturnType(req.getReturnType());
......@@ -121,11 +123,11 @@ public class OrderAfterSalesService {
return asOrder;
}
public AfterSalesOrderGoods buildAfterSalesOrderGoods(CreateAfterSalesOrderRequest req, OrderChild orderChild) {
public AfterSalesOrderGoods buildAfterSalesOrderGoods(CreateAfterSalesOrderRequest req) {
AfterSalesOrderGoods asOrderGoods = new AfterSalesOrderGoods();
asOrderGoods.setTparOrderCode(orderChild.getTparOrderCode());
asOrderGoods.setParentOrderCode(orderChild.getParentOrderCode());
asOrderGoods.setOrderCode(orderChild.getOrderCode());
// asOrderGoods.setTparOrderCode(req.getTparOrderCode());
// asOrderGoods.setParentOrderCode(req.getParentOrderCode());
asOrderGoods.setOrderCode(req.getOrderCode());
asOrderGoods.setTparReturnOrderCode(req.getTparReturnOrderCode());//客户方售后订单编号
asOrderGoods.setReturnQty(req.getApplyQty());//买家提交售后申请退换货数量
asOrderGoods.setActualReceiveQty(0);//云中鹤仓库实际收到寄回的商品数量
......
......@@ -190,14 +190,16 @@ public class OrderChildService {
try {
OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
if (Objects.isNull(orderChild)) {
throw CloudCraneException.create("40001", "子订单不存在");
log.info("子订单{}不存在,待同步", request.getOrderCode());
//todo 1008 延迟同步子订单
//this.createOrderChild(request.getTparOrderCode(), request.getParentOrderCode());
} else {
//云中鹤订单状态(1002:待审核,1003:审核不通过,1004:已取消(交易失败),1005:订单异常,1006:待处理,1007:待发货,1008:已发货,1009:已完成(交易成功),1010:售后处理中,1012订单关闭
orderChild.setOrderStatus(request.getOrderStatus());
orderChild.setUpdatedDate(new Date());
orderChildMapper.updateByPrimaryKeySelective(orderChild);
}
//云中鹤订单状态(1002:待审核,1003:审核不通过,1004:已取消(交易失败),1005:订单异常,1006:待处理,1007:待发货,1008:已发货,1009:已完成(交易成功),1010:售后处理中,1012订单关闭
orderChild.setOrderStatus(request.getOrderStatus());
orderChild.setUpdatedDate(new Date());
orderChildMapper.updateByPrimaryKeySelective(orderChild);
BizOrderNotifyMessage message = buildOrderStatusNotice(orderChild);
BizOrderNotifyMessage message = buildOrderStatusNotice(request);
goodsService.sendKafka(message);
} catch (Exception e) {
e.printStackTrace();
......@@ -212,10 +214,10 @@ public class OrderChildService {
*/
public void logisticsStatusNotice(LogisticsStatusNoticeRequest request) {
try {
OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
if (Objects.isNull(orderChild)) {
throw CloudCraneException.create("40002", "子订单不存在");
}
// OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
// if (Objects.isNull(orderChild)) {
// throw CloudCraneException.create("40002", "子订单不存在");
// }
//订单发货物流状态信息(1000:待揽件,1001:已揽件,1002:运输中,1003:已签收,1004:拒收),在订单状态为已发货(orderStatus等于1008、1009)时,才有物流状态信息
OrderLogistic orderLogistic = orderLogisticMapper.selectByOrderCode(request.getOrderCode());
if (Objects.isNull(orderLogistic)) {
......@@ -225,7 +227,7 @@ public class OrderChildService {
orderLogistic.setUpdatedDate(new Date());
orderLogisticMapper.updateByPrimaryKeySelective(orderLogistic);
BizOrderNotifyMessage message = buildLogisticsStatusNotice(orderChild, orderLogistic);
BizOrderNotifyMessage message = buildLogisticsStatusNotice(request, orderLogistic);
goodsService.sendKafka(message);
} catch (Exception e) {
e.printStackTrace();
......@@ -240,15 +242,15 @@ public class OrderChildService {
*/
public void orderDeliverNotice(OrderDeliverNoticeRequest request) {
try {
OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
if (Objects.isNull(orderChild)) {
throw CloudCraneException.create("40003", "子订单不存在");
}
// OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
// if (Objects.isNull(orderChild)) {
// throw CloudCraneException.create("40003", "子订单不存在");
// }
OrderLogistic orderLogistic = orderLogisticMapper.selectByOrderCode(request.getOrderCode());
if (Objects.isNull(orderLogistic)) {
orderLogistic = new OrderLogistic();
orderLogistic.setTparOrderCode(orderChild.getTparOrderCode());
orderLogistic.setParentOrderCode(orderChild.getParentOrderCode());
orderLogistic.setTparOrderCode(request.getTparOrderCode());
orderLogistic.setParentOrderCode(request.getParentOrderCode());
orderLogistic.setOrderCode(request.getOrderCode());
orderLogistic.setExpressCode(request.getExpressCode());
orderLogistic.setExpressName(request.getExpressName());
......@@ -258,7 +260,7 @@ public class OrderChildService {
orderLogisticMapper.insert(orderLogistic);
}
BizOrderNotifyMessage message = buildLogisticsStatusNotice(orderChild, orderLogistic);
BizOrderNotifyMessage message = buildLogisticsStatusNotice(request, orderLogistic);
goodsService.sendKafka(message);
} catch (Exception e) {
e.printStackTrace();
......@@ -273,10 +275,10 @@ public class OrderChildService {
*/
public void returnOrderNotice(ReturnOrderNoticeRequest request) {
try {
OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
if (Objects.isNull(orderChild)) {
throw CloudCraneException.create("40004", "子订单不存在");
}
// OrderChild orderChild = orderChildMapper.selectByOrderCode(request.getOrderCode());
// if (Objects.isNull(orderChild)) {
// throw CloudCraneException.create("40004", "子订单不存在");
// }
// 售后订单状态(1000:待审核,1001:待收货,1002:已收货,1003:已退款,1004:已生成新订单,1005:已取消,1006:退款异常,1007:商品退回,1008:审核不通过,1010:换货新订单待收货,1011:换货新订单已签收)
// 说明: 当returnType=1001和1003 时(退货退款与退货换货)才有值,其他售后类型时为空
AfterSalesOrder afterSalesOrder = afterSalesOrderMapper.selectByReturnOrderCode(request.getReturnOrderCode());
......@@ -294,7 +296,7 @@ public class OrderChildService {
afterSalesOrder.setUpdatedDate(new Date());
afterSalesOrderMapper.updateByPrimaryKeySelective(afterSalesOrder);
BizOrderNotifyMessage message = buildReturnOrderNotice(orderChild, afterSalesOrder);
BizOrderNotifyMessage message = buildReturnOrderNotice(request, afterSalesOrder);
goodsService.sendKafka(message);
} catch (Exception e) {
e.printStackTrace();
......@@ -326,14 +328,41 @@ public class OrderChildService {
return message;
}
private BizOrderNotifyMessage buildLogisticsStatusNotice(OrderChild orderChild, OrderLogistic orderLogistic) {
private BizOrderNotifyMessage buildOrderStatusNotice(OrderStatusNoticeRequest request) {
BizOrderNotifyMessage message = BizOrderNotifyMessage.builder()
.messageType(BizMessageTypeEnum.MessageTypeEnum.ORDER.getValue())
.orderCode(request.getOrderCode())
.tparOrderCode(request.getTparOrderCode())
.parentOrderCode(request.getParentOrderCode())
.orderStatus(request.getOrderStatus())
.time(DateUtils.currentDateTime())
.build();
message.setMessageSmallType(2009);
return message;
}
private BizOrderNotifyMessage buildLogisticsStatusNotice(OrderDeliverNoticeRequest request, OrderLogistic orderLogistic) {
BizOrderNotifyMessage message = BizOrderNotifyMessage.builder()
.messageType(BizMessageTypeEnum.MessageTypeEnum.ORDER.getValue())
.messageSmallType(BizMessageTypeEnum.MessageSmallTypeEnum.ORDER_DELIVERED.getValue())
.orderCode(request.getOrderCode())
.tparOrderCode(request.getTparOrderCode())
.parentOrderCode(request.getParentOrderCode())
.expressCode(orderLogistic.getExpressCode())
.expressName(orderLogistic.getExpressName())
.expressNumber(orderLogistic.getShipmentCode())
.time(DateUtils.currentDateTime())
.build();
return message;
}
private BizOrderNotifyMessage buildLogisticsStatusNotice(LogisticsStatusNoticeRequest orderChild, OrderLogistic orderLogistic) {
BizOrderNotifyMessage message = BizOrderNotifyMessage.builder()
.messageType(BizMessageTypeEnum.MessageTypeEnum.ORDER.getValue())
.messageSmallType(BizMessageTypeEnum.MessageSmallTypeEnum.ORDER_DELIVERED.getValue())
.orderCode(orderChild.getOrderCode())
.tparOrderCode(orderChild.getTparOrderCode())
.parentOrderCode(orderChild.getParentOrderCode())
.orderStatus(orderChild.getOrderStatus())
.expressCode(orderLogistic.getExpressCode())
.expressName(orderLogistic.getExpressName())
.expressNumber(orderLogistic.getShipmentCode())
......@@ -374,4 +403,18 @@ public class OrderChildService {
return message;
}
private BizOrderNotifyMessage buildReturnOrderNotice(ReturnOrderNoticeRequest request, AfterSalesOrder afterSalesOrder) {
BizOrderNotifyMessage message = BizOrderNotifyMessage.builder()
.messageType(BizMessageTypeEnum.MessageTypeEnum.AFTER_SALES_ORDER.getValue())
.orderCode(request.getOrderCode())
.parentOrderCode(request.getParentOrderCode())
.tparReturnOrderCode(afterSalesOrder.getTparReturnOrderCode())
.returnOrderCode(afterSalesOrder.getReturnOrderCode())
.returnOrderStatus(afterSalesOrder.getReturnStatus())
.time(DateUtils.currentDateTime())
.build();
message.setMessageSmallType(3009);
return message;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!