Bladeren bron

接入微走订单推送优化
微走发货回调同步接口

lk 1 week geleden
bovenliggende
commit
6e494784c6

+ 56 - 0
fs-admin/src/main/java/com/fs/third/controller/WeizouController.java

@@ -0,0 +1,56 @@
+package com.fs.third.controller;
+
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.his.domain.FsStoreOrder;
+import com.fs.his.service.IFsStoreOrderService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+import static com.fs.his.utils.PhoneUtil.decryptPhone;
+
+@RestController
+@RequestMapping("/third/weizou")
+public class WeizouController extends BaseController {
+    @Autowired
+    private IFsStoreOrderService fsStoreOrderService;
+    /**
+     * 微走发货同步接口
+     */
+    @PostMapping("/sendGoodsThirdParty")
+    public AjaxResult sendGoodsThirdParty(@RequestBody Map map) {
+        String thirdPartySecret = (String) map.get("thirdPartySecret");
+        String s = decryptPhone(thirdPartySecret);
+        if (!s.equals("weizou_send_goods_call_back")) {
+            return error("认证失败,请核验参数");
+        }
+        FsStoreOrder fsStoreOrder = new FsStoreOrder();
+        if (map.get("orderCode") == null) {
+            return error("参数异常请核验参数");
+        }
+        fsStoreOrder.setOrderId(Long.valueOf((String) map.get("orderCode")));
+        fsStoreOrder.setOperator("微走发货同步");
+// 校验物流单号
+        if (map.get("deliverySn") == null) {
+            return error("参数异常请核验参数:deliverySn不能为空");
+        }
+        fsStoreOrder.setDeliverySn((String) map.get("deliverySn"));
+// 校验物流代码
+        if (map.get("deliveryCode") == null) {
+            return error("参数异常请核验参数:deliveryCode不能为空");
+        }
+        fsStoreOrder.setDeliveryCode((String) map.get("deliveryCode"));
+// 校验物流名称
+        if (map.get("deliveryName") == null) {
+            return error("参数异常请核验参数:deliveryName不能为空");
+        }
+        fsStoreOrder.setDeliveryName((String) map.get("deliveryName"));
+
+        return toAjax(fsStoreOrderService.sendGoods(fsStoreOrder, "微走发货同步"));
+    }
+}

+ 1 - 0
fs-framework/src/main/java/com/fs/framework/config/SecurityConfig.java

@@ -145,6 +145,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/course/userVideo/videoTranscode").anonymous()
                 .antMatchers("/erp/call/**").anonymous()
+                .antMatchers("/third/weizou/**").anonymous()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 1 - 1
fs-service/src/main/java/com/fs/erp/domain/WeizouApiPushOrderParam.java

@@ -134,7 +134,7 @@ public class WeizouApiPushOrderParam {
     private String orderMedia;
 
     /**
-     * 额外订单号(对应平台的订单号)
+     * 额外订单号 填写orderId!!!
      */
     @NotNull(message = "额外订单号不能为空")
     private String extendOrderId;

+ 15 - 4
fs-service/src/main/java/com/fs/erp/utils/WeizouApiClient.java

@@ -40,18 +40,29 @@ public class WeizouApiClient {
     @Qualifier("redisTemplate")
     private RedisTemplate redisTemplateInstance;
 
+    @Value("${weizou.baseUrl:https://test-api.weizou.com:9702}")
+    private String baseUrlInstance;
+
+    @Value("${weizou.appId:005fcddb9b664eeca80a13b62e823b63}")
+    private String appIdInstance;
+
+    @Value("${weizou.appSecret:a6cd645383a3405d842ce00da106ded0}")
+    private String appSecretInstance;
     // 3. @PostConstruct 将实例赋值给静态变量
     @PostConstruct
     public void initStatic() {
         redisTemplate = this.redisTemplateInstance;
         log.info("RedisTemplate 静态初始化完成");
+        BASE_URL = this.baseUrlInstance;
+        APP_ID = this.appIdInstance;
+        APP_SECRET = this.appSecretInstance;
+        log.info("配置加载完成:BASE_URL={}, APP_ID={}", BASE_URL, APP_ID);
     }
 
-    private static final String BASE_URL = "https://test-api.weizou.com:9702"; // TODO: 替换为文档中的正式环境地址
-
+    private static String BASE_URL; // TODO: 替换为文档中的正式环境地址
     // TODO: 替换为平台提供的实际应用ID和密钥
-    private static final String APP_ID = "005fcddb9b664eeca80a13b62e823b63";
-    private static final String APP_SECRET = "a6cd645383a3405d842ce00da106ded0";
+    private static  String APP_ID ;
+    private static  String APP_SECRET;
 
     private static final String WEIZOU_API_CLIENT_KEY = "weizou:api:client:key";
 

+ 1 - 0
fs-service/src/main/java/com/fs/his/domain/FsStoreOrder.java

@@ -266,5 +266,6 @@ public class FsStoreOrder extends BaseEntity
     private BigDecimal billPrice;
     private String erpPhone;
     private Integer doctorType2Confirm;
+    private String operator;
 
 }

+ 1 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -630,6 +630,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
         Logs.setOrderId(fsStoreOrder.getOrderId());
         Logs.setChangeTime(new DateTime());
         Logs.setChangeType("delivery_goods");
+        Optional.ofNullable(fsStoreOrder.getOperator()).ifPresent(Logs::setOperator);
         fsStoreOrderLogsMapper.insertFsStoreOrderLogs(Logs);
         String lastFourNumber = "";
         if (order.getDeliveryCode().equals(ShipperCodeEnum.SF.getValue())) {