Procházet zdrojové kódy

开放接口 订单状态通知

叶君翔 před 3 roky
rodič
revize
e55cb530f6

+ 7 - 3
lb-app/src/main/java/com/ydd/app/callback/controller/MeituanDeliveryCallback.java

@@ -65,6 +65,9 @@ public class MeituanDeliveryCallback {
     @Resource
     private IDspDeliveryService iDspDeliveryService;
 
+    @Resource
+    private IShopService iShopService;
+
     /**
      * 授权
      * @param params
@@ -205,9 +208,9 @@ public class MeituanDeliveryCallback {
                 if (info.getStatus().equals(10) || info.getStatus().equals(50)){
                     shopDelivery.setBindStatus(BindStatusEnum.REFUND.status);
                     shopDelivery.setAuthMsg(info.getReject_message());
-                }else if (info.getStatus().equals(20) || info.getStatus().equals(30)){
+                } else if (info.getStatus().equals(20) || info.getStatus().equals(30)){
                     shopDelivery.setBindStatus(BindStatusEnum.CHECK.status);
-                }else if (info.getStatus().equals(40) || info.getStatus().equals(60)){
+                } else if (info.getStatus().equals(40) || info.getStatus().equals(60)){
                     shopDelivery.setBindStatus(BindStatusEnum.BIND.status);
                 }
                 iShopDeliveryService.updateById(shopDelivery);
@@ -216,8 +219,9 @@ public class MeituanDeliveryCallback {
                 Merchant merchant = iMerchantService.getById(shopDelivery.getMerchantId());
                 if (merchant != null && merchant.getAppId() != null) {
                     DspDelivery dspDelivery = iDspDeliveryService.findById(shopDelivery.getDeliveryId());
+                    Shop shop = iShopService.getById(shopDelivery.getShopId());
                     StoreStatusNotifyVo notifyVo = StoreStatusNotifyVo.builder()
-                            .shopCode(shopDelivery.getShopNo())
+                            .shopCode(shop.getCode())
                             .deliveryId(dspDelivery.getType())
                             .status(shopDelivery.getBindStatus())
                             .failMsg(shopDelivery.getAuthMsg())

+ 2 - 2
lb-app/src/main/java/com/ydd/app/service/OpenApiNotifyService.java

@@ -12,13 +12,13 @@ public interface OpenApiNotifyService {
 
     /**
      * 门店状态通知
-     * @param storeStatusNotifyVo
+     * @param storeStatusNotifyVo 通知参数
      */
     void storeStatusNotify(StoreStatusNotifyVo storeStatusNotifyVo);
 
     /**
      * 订单状态通知
-     * @param orderStatusNotifyVo
+     * @param orderStatusNotifyVo 通知参数
      */
     void orderStatusNotify(OrderStatusNotifyVo orderStatusNotifyVo);
 

+ 5 - 5
lb-app/src/main/java/com/ydd/app/service/impl/OpenApiNotifyServiceImpl.java

@@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
 import java.util.List;
 
 /**
- *  通知接口
+ *  开放平台-通知接口
  * @author 叶君翔
  * @date 2022/04/13 10:15
  */
@@ -30,8 +30,8 @@ public class OpenApiNotifyServiceImpl implements OpenApiNotifyService {
         List<Integer> durations = AppConstant.NOTIFY_INTERVAL_DURATION;
         for (int i = 0; i < durations.size(); i++) {
             // 记录推送次数, 超过规定总次数后做处理: 入库或者其他
-            storeStatusNotifyVo.setNotifyCount(i);
-            rabbitSender.sendDelay(storeStatusNotifyVo, RabbitConstant.QUEUE_DELAY_OPEN_STATUS_NOTIFY_ROUTING_KEY, durations.get(i) * 1000);
+            storeStatusNotifyVo.setNotifyCount(i + 1);
+            rabbitSender.sendDelay(storeStatusNotifyVo, RabbitConstant.QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY_ROUTING_KEY, durations.get(i) * 1000);
         }
     }
 
@@ -40,8 +40,8 @@ public class OpenApiNotifyServiceImpl implements OpenApiNotifyService {
         List<Integer> durations = AppConstant.NOTIFY_INTERVAL_DURATION;
         for (int i = 0; i < durations.size(); i++) {
             // 记录推送次数, 超过规定总次数后做处理: 入库或者其他
-            orderStatusNotifyVo.setNotifyCount(i);
-            rabbitSender.sendDelay(orderStatusNotifyVo, RabbitConstant.QUEUE_DELAY_OPEN_STATUS_NOTIFY_ROUTING_KEY, durations.get(i) * 1000);
+            orderStatusNotifyVo.setNotifyCount(i + 1);
+            rabbitSender.sendDelay(orderStatusNotifyVo, RabbitConstant.QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY_ROUTING_KEY, durations.get(i) * 1000);
         }
     }
 

+ 4 - 1
lb-app/src/main/java/com/ydd/app/vo/OrderStatusNotifyVo.java

@@ -7,6 +7,7 @@ import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
 
 /**
@@ -18,7 +19,9 @@ import java.math.BigDecimal;
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
-public class OrderStatusNotifyVo extends BaseDto {
+public class OrderStatusNotifyVo extends BaseDto implements Serializable {
+
+    private static final long serialVersionUID = -427482211926655367L;
 
     /**
      * 外部订单号

+ 5 - 1
lb-app/src/main/java/com/ydd/app/vo/StoreStatusNotifyVo.java

@@ -7,6 +7,8 @@ import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.io.Serializable;
+
 /**
  * 门店状态通知参数
  * @author 叶君翔
@@ -16,7 +18,9 @@ import lombok.NoArgsConstructor;
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
-public class StoreStatusNotifyVo extends BaseDto {
+public class StoreStatusNotifyVo extends BaseDto implements Serializable {
+
+    private static final long serialVersionUID = -2785819169627235703L;
 
     private String shopCode;
 

+ 14 - 4
lb-common/src/main/java/com/ydd/common/constant/RabbitConstant.java

@@ -8,13 +8,23 @@ package com.ydd.common.constant;
 public interface RabbitConstant {
 
     /**
-     * 开放接口 状态推送延迟队列
+     * 开放接口 门店状态推送延迟队列
      */
-    String QUEUE_DELAY_OPEN_STATUS_NOTIFY = "queue.openStatusNotify.delay";
+    String QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY = "queue.openStoreStatusNotify.delay";
 
     /**
-     * 开放接口 状态推送路由
+     * 开放接口 门店状态推送路由
      */
-    String QUEUE_DELAY_OPEN_STATUS_NOTIFY_ROUTING_KEY = "queue.openStatusNotify";
+    String QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY_ROUTING_KEY = "queue.openStoreStatusNotify";
+
+    /**
+     * 开放接口 订单状态推送延迟队列
+     */
+    String QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY = "queue.openOrderStatusNotify.delay";
+
+    /**
+     * 开放接口 订单状态推送路由
+     */
+    String QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY_ROUTING_KEY = "queue.openOrderStatusNotify";
 
 }

+ 10 - 0
lb-common/src/main/java/com/ydd/common/constant/RedisKeyConstant.java

@@ -42,4 +42,14 @@ public interface RedisKeyConstant {
      */
     String VALUATION_RESULT = "valuation_result:";
 
+    /**
+     * 门店状态通知
+     */
+    String STORE_STATUS_NOTIFY = "store_status_notify:";
+
+    /**
+     * 订单状态通知
+     */
+    String ORDER_STATUS_NOTIFY = "order_status_notify:";
+
 }

+ 15 - 5
lb-module/src/main/java/com/ydd/module/config/RabbitConfig.java

@@ -34,9 +34,14 @@ public class RabbitConfig {
         return new Queue(RabbitConfig.QUEUE_DELAY_WAIMAI);
     }
 
-    @Bean(RabbitConstant.QUEUE_DELAY_OPEN_STATUS_NOTIFY)
-    public Queue queueOpenStatusNotifyDelayMessage() {
-        return new Queue(RabbitConstant.QUEUE_DELAY_OPEN_STATUS_NOTIFY);
+    @Bean(RabbitConstant.QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY)
+    public Queue queueOpenStoreStatusNotifyDelayMessage() {
+        return new Queue(RabbitConstant.QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY);
+    }
+
+    @Bean(RabbitConstant.QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY)
+    public Queue queueOpenOrderStatusNotifyDelayMessage() {
+        return new Queue(RabbitConstant.QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY);
     }
 
     //创建队列
@@ -96,8 +101,13 @@ public class RabbitConfig {
     }
 
     @Bean
-    Binding bindingExchangeOpenStatusNotifyDelayMessage(@Qualifier(RabbitConstant.QUEUE_DELAY_OPEN_STATUS_NOTIFY) Queue queue, @Qualifier("delay_exchange")CustomExchange exchange) {
-        return BindingBuilder.bind(queue).to(exchange).with(RabbitConstant.QUEUE_DELAY_OPEN_STATUS_NOTIFY_ROUTING_KEY).noargs();
+    Binding bindingExchangeOpenStoreStatusNotifyDelayMessage(@Qualifier(RabbitConstant.QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY) Queue queue, @Qualifier("delay_exchange")CustomExchange exchange) {
+        return BindingBuilder.bind(queue).to(exchange).with(RabbitConstant.QUEUE_DELAY_OPEN_STORE_STATUS_NOTIFY_ROUTING_KEY).noargs();
+    }
+
+    @Bean
+    Binding bindingExchangeOpenOrderStatusNotifyDelayMessage(@Qualifier(RabbitConstant.QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY) Queue queue, @Qualifier("delay_exchange")CustomExchange exchange) {
+        return BindingBuilder.bind(queue).to(exchange).with(RabbitConstant.QUEUE_DELAY_OPEN_ORDER_STATUS_NOTIFY_ROUTING_KEY).noargs();
     }
 
 }

+ 3 - 0
lb-third/lb-third-common/src/main/java/com/ydd/third/common/vo/ResObject.java

@@ -6,6 +6,9 @@ import java.io.Serializable;
 
 @Data
 public class ResObject<T> implements Serializable {
+
+    private static final long serialVersionUID = 730713351611378233L;
+
     private Integer code = 0;
     private String msg = "OK";
     private T data;