Commit bcffcadc by huvchao@126.com

# add

order-management
parent 9029c5e9
package cn.freemud.amp.service;
import cn.freemud.amqp.MQService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* mq发送方
*/
@Service
public class ProduceMQService {
@Autowired
private MQService mqService;
private static final String routeKey = "test";
private static final String exchangeName = "test";
/**
* 发送配送状态变更信息
* @param body
*/
public void sendOfDeliveryInfo(String body) {
mqService.convertAndSend(exchangeName, routeKey, body);
}
}
package cn.freemud.enums; package cn.freemud.enums;
import com.google.common.collect.Lists;
import java.util.List;
/** /**
* All rights Reserved, Designed By www.freemud.cn * All rights Reserved, Designed By www.freemud.cn
* *
...@@ -48,4 +52,31 @@ public enum DeliveryStatus { ...@@ -48,4 +52,31 @@ public enum DeliveryStatus {
public void setDesc(String desc) { public void setDesc(String desc) {
this.desc = desc; this.desc = desc;
} }
public static DeliveryStatus getDeliveryStatusByCode(int code) {
for (DeliveryStatus obj : values()) {
if (obj.code == code) {
return obj;
}
}
return null;
}
public static boolean checkDeliveryStatueForPlatform(int status) {
DeliveryStatus deliveryStatus = DeliveryStatus.getDeliveryStatusByCode(status);
if (null == deliveryStatus) return false;
List<DeliveryStatus> targetList = Lists.newArrayList(DeliveryStatus.ALLOTRIDER,
DeliveryStatus.RIDERGETMEAL,
DeliveryStatus.RIDERSTARTDELIVERY,
DeliveryStatus.DELIVERYARRIVED,
DeliveryStatus.DELIVERYERROR,
DeliveryStatus.DELIVERYCANCEL
);
if (targetList.contains(deliveryStatus)) {
return true;
}
return false;
}
} }
package cn.freemud.service.delivery; package cn.freemud.service.delivery;
import cn.freemud.amp.service.ProduceMQService;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.dto.delivery.CallbackUrlRequestDto; import cn.freemud.entities.dto.delivery.CallbackUrlRequestDto;
import cn.freemud.entities.dto.pos.PosBaseRequestDto; import cn.freemud.entities.dto.pos.PosBaseRequestDto;
...@@ -21,10 +22,13 @@ import com.freemud.sdk.api.assortment.order.request.order.AssortmentUpdateDelive ...@@ -21,10 +22,13 @@ import com.freemud.sdk.api.assortment.order.request.order.AssortmentUpdateDelive
import com.freemud.sdk.api.assortment.order.request.order.UpdateDeliveryInfoByIdRequest; import com.freemud.sdk.api.assortment.order.request.order.UpdateDeliveryInfoByIdRequest;
import com.freemud.sdk.api.assortment.order.response.order.OrderBaseResponse; import com.freemud.sdk.api.assortment.order.response.order.OrderBaseResponse;
import com.freemud.sdk.api.assortment.order.service.OrderCenterSdkService; import com.freemud.sdk.api.assortment.order.service.OrderCenterSdkService;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map;
/** /**
* All rights Reserved, Designed By www.freemud.cn * All rights Reserved, Designed By www.freemud.cn
* *
...@@ -49,6 +53,8 @@ public class ThirdDeliveryServiceImpl implements ThirdDeliveryService { ...@@ -49,6 +53,8 @@ public class ThirdDeliveryServiceImpl implements ThirdDeliveryService {
private Orderservice orderservice; private Orderservice orderservice;
@Autowired @Autowired
private PosClient posClient; private PosClient posClient;
@Autowired
private ProduceMQService produceMQService;
@Override @Override
public BaseResponse callbackUrl(CallbackUrlRequestDto request) { public BaseResponse callbackUrl(CallbackUrlRequestDto request) {
...@@ -102,6 +108,13 @@ public class ThirdDeliveryServiceImpl implements ThirdDeliveryService { ...@@ -102,6 +108,13 @@ public class ThirdDeliveryServiceImpl implements ThirdDeliveryService {
posBaseRequestDto.setDeliveryId(request.getDeliveryId()); posBaseRequestDto.setDeliveryId(request.getDeliveryId());
sendPosService(deliveryStatus,posBaseRequestDto); sendPosService(deliveryStatus,posBaseRequestDto);
} }
// todo 发送配送信息到mq
if (DeliveryStatus.checkDeliveryStatueForPlatform(deliveryStatus)) {
String deliverDesc = DeliveryStatus.getDeliveryStatusByCode(deliveryStatus).getDesc();
Map deliveryMap = ImmutableMap.of("deliveryStatus", deliveryStatus, "orderCode", request.getOrderId(), "", request);
produceMQService.sendOfDeliveryInfo(deliveryMap.toString());
}
// else { // else {
// return ResponseUtil.error(ResponseResult.SYSTEM_ERROR.getCode(), "订单回调状态有误"); // return ResponseUtil.error(ResponseResult.SYSTEM_ERROR.getCode(), "订单回调状态有误");
// } // }
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>order-group</artifactId>
<groupId>cn.freemud</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>order-management</name>
<artifactId>order-management</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package cn.freemud.service;
public class OrderService {
}
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
<module>push-order-service</module> <module>push-order-service</module>
<module>platform-sdk</module> <module>platform-sdk</module>
<module>assortment-shoppingcart-sdk</module> <module>assortment-shoppingcart-sdk</module>
<module>order-management</module>
</modules> </modules>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment