xdd преди 2 седмици
родител
ревизия
e083277049

+ 3 - 13
fs-admin/src/main/java/com/fs/live/controller/LiveOrderController.java

@@ -48,6 +48,8 @@ import org.apache.http.util.Asserts;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -444,19 +446,7 @@ public class LiveOrderController extends BaseController
     @PreAuthorize("@ss.hasPermi('live:liveOrder:editDeliveryId')")
     @PutMapping("/editDeliveryId")
     public AjaxResult editDeliveryId(@RequestBody FsStoreDelivers deliveryDTO) {
-        LiveOrder liveOrder = liveOrderService.selectLiveOrderByOrderId(String.valueOf(deliveryDTO.getOrderId()));
-
-        Asserts.notNull(deliveryDTO.getDeliverId(),"快递号不能为空!");
-        Asserts.notNull(deliveryDTO.getDeliverSn(),"快递类型不能为空!");
-
-        liveOrder.setDeliverySn(deliveryDTO.getDeliverId());
-        liveOrder.setDeliveryCode(deliveryDTO.getDeliverSn());
-        liveOrderService.updateLiveOrder(liveOrder);
-
-
-        fsStoreDeliversService.editDeliveryId(deliveryDTO);
-        fsStoreDeliversService.syncDeliverInfo(deliveryDTO.getOrderId(),deliveryDTO.getType());
-        fsStoreDeliversService.finishOrder(deliveryDTO.getOrderId(),deliveryDTO.getType());
+        liveOrderService.editLiveOrderDeliveryId(deliveryDTO);
         return AjaxResult.success();
     }
 

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveOrderService.java

@@ -9,11 +9,13 @@ import com.fs.live.param.LiveOrderFinishParam;
 import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderListVo;
 import com.fs.live.vo.LiveOrderVo;
+import com.fs.store.domain.FsStoreDelivers;
 import com.fs.store.domain.FsStoreOrder;
 import com.fs.store.dto.FsStoreOrderComputeDTO;
 import com.fs.store.dto.LiveOrderComputeDTO;
 import com.fs.store.param.FsStoreOrderAddTuiMoneyParam;
 import com.fs.store.param.LiveOrderComputedParam;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.text.ParseException;
 import java.util.List;
@@ -32,6 +34,7 @@ public interface ILiveOrderService {
      * @return 订单
      */
     LiveOrder selectLiveOrderByOrderId(String orderId);
+    void editLiveOrderDeliveryId(@RequestBody FsStoreDelivers deliveryDTO);
 
     /**
      * 查询订单列表

+ 22 - 2
fs-service-system/src/main/java/com/fs/live/service/impl/LiveOrderServiceImpl.java

@@ -689,6 +689,26 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
         return liveOrder;
     }
 
+    @Autowired
+    private ILiveOrderService liveOrderService;
+    @Override
+    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
+    public void editLiveOrderDeliveryId(FsStoreDelivers deliveryDTO) {
+        LiveOrder liveOrder = liveOrderService.selectLiveOrderByOrderId(String.valueOf(deliveryDTO.getOrderId()));
+
+        Asserts.notNull(deliveryDTO.getDeliverId(),"快递号不能为空!");
+        Asserts.notNull(deliveryDTO.getDeliverSn(),"快递类型不能为空!");
+
+        liveOrder.setDeliverySn(deliveryDTO.getDeliverId());
+        liveOrder.setDeliveryCode(deliveryDTO.getDeliverSn());
+        liveOrderService.updateLiveOrder(liveOrder);
+
+
+        fsStoreDeliversService.editDeliveryId(deliveryDTO);
+        fsStoreDeliversService.syncDeliverInfo(deliveryDTO.getOrderId(),deliveryDTO.getType());
+        fsStoreDeliversService.finishOrder(deliveryDTO.getOrderId(),deliveryDTO.getType());
+    }
+
     /**
      * 查询订单列表
      *
@@ -1433,7 +1453,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
             if (StringUtils.equals(express.getCode(),ShipperCodeEnum.SF.getValue())) {
                 lastFourNumber = PhoneUtils.getLastFourNum(order.getUserPhone());
             }
-            expressService.subscribeEspress(order.getOrderCode(),express.getCode(),deliveryId,lastFourNumber);
+            expressService.subscribeEspress(order.getOrderCode(),express.getCode(),deliveryId,lastFourNumber,1);
         }
     }
 
@@ -1962,7 +1982,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
                         lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4);
                     }
                 }
-                expressService.subscribeEspress(existOrder.getOrderCode(),fsExpress.getCode(),deliveryId,lastFourNumber);
+                expressService.subscribeEspress(existOrder.getOrderCode(),fsExpress.getCode(),deliveryId,lastFourNumber,1);
             }
         }
     }

+ 6 - 0
fs-service-system/src/main/java/com/fs/store/domain/FsOrderExpressPush.java

@@ -29,4 +29,10 @@ public class FsOrderExpressPush {
     private String result;
     /*** 错误信息(记录失败原因) */
     private String errorMessage;
+
+    /**
+     * 0 商城订单
+     * 1 直播订单
+     */
+    private Integer type;
 }

+ 4 - 4
fs-service-system/src/main/java/com/fs/store/mapper/FsOrderExpressPushMapper.java

@@ -11,14 +11,14 @@ public interface FsOrderExpressPushMapper {
     @Select("SELECT * FROM fs_order_express_push WHERE id = #{id}")
     FsOrderExpressPush selectById(Long id);
 
-    @Insert("INSERT INTO fs_order_express_push (order_id, task_status, retry_count, last_execute_time, create_time, update_time, params, result, error_message) " +
-            "VALUES (#{orderId}, #{taskStatus}, #{retryCount}, #{lastExecuteTime}, #{createTime}, #{updateTime}, #{params}, #{result}, #{errorMessage})")
+    @Insert("INSERT INTO fs_order_express_push (order_id, task_status, retry_count, last_execute_time, create_time, update_time, params, result, error_message,type) " +
+            "VALUES (#{orderId}, #{taskStatus}, #{retryCount}, #{lastExecuteTime}, #{createTime}, #{updateTime}, #{params}, #{result}, #{errorMessage},#{type})")
     @Options(useGeneratedKeys = true, keyProperty = "id")
     int insert(FsOrderExpressPush fsOrderExpressPush);
 
     @Update("UPDATE fs_order_express_push SET order_id = #{orderId}, task_status = #{taskStatus}, retry_count = #{retryCount}, " +
-            "last_execute_time = #{lastExecuteTime}, create_time = #{createTime}, update_time = #{updateTime}, " +
-            "params = #{params}, result = #{result}, error_message = #{errorMessage} WHERE id = #{id}")
+            "last_execute_time = #{lastExecuteTime}, create_time = #{createTime}, update_time = #{updateTime} " +
+            "params = #{params}, result = #{result}, error_message = #{errorMessage},type=#{type} WHERE id = #{id}")
     int update(FsOrderExpressPush fsOrderExpressPush);
 
     @Delete("DELETE FROM fs_order_express_push WHERE id = #{id}")

+ 1 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsExpressService.java

@@ -74,6 +74,7 @@ public interface IFsExpressService
     FsExpress selectFsExpressByName(String deliveryName);
 
     void subscribeEspress(String orderCode, String deliverySn, String deliveryId, String userPhone);
+    void subscribeEspress(String orderCode, String deliverySn, String deliveryId, String userPhone,Integer type);
 
     R parseAddress(String content);
 

+ 35 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsExpressServiceImpl.java

@@ -229,6 +229,41 @@ public class FsExpressServiceImpl implements IFsExpressService
             fsOrderExpressPush.setUpdateTime(LocalDateTime.now());
             fsOrderExpressPush.setRetryCount(0);
             fsOrderExpressPush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
+            fsOrderExpressPush.setType(0);
+            fsOrderExpressPushMapper.insert(fsOrderExpressPush);
+        } catch (Exception e) {
+            throw  new CustomException(e.getMessage());
+        }
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
+    public void subscribeEspress(String orderCode, String deliverySn, String deliveryId, String userPhone, Integer type) {
+        //处理顺丰查询轨迹需手机号码后4位
+        String requestData;
+        if (ObjectUtils.equals(deliverySn,ShipperCodeEnum.SF.getValue())) {
+            requestData = "{'OrderCode':'" + orderCode + "','ShipperCode':'" + deliverySn + "','LogisticCode':'" + deliveryId + "','CustomerName':'" + userPhone + "'}";
+        } else {
+            requestData = "{'OrderCode':'" + orderCode + "','ShipperCode':'" + deliverySn + "','LogisticCode':'" + deliveryId + "'}";
+        }
+
+        Map<String, Object> params = new HashMap<>();
+        try {
+            params.put("RequestData", URLEncoder.encode(requestData, "UTF-8"));
+            params.put("EBusinessID",sysConfig.getKdnId().trim());
+            params.put("RequestType", "8008");
+            String dataSign = encrypt(requestData, sysConfig.getKdnKeyId().trim(), "UTF-8");
+            params.put("DataSign", URLEncoder.encode(dataSign, "UTF-8"));
+            params.put("DataType", "2");
+
+            FsOrderExpressPush fsOrderExpressPush = new FsOrderExpressPush();
+            fsOrderExpressPush.setOrderId(orderCode);
+            fsOrderExpressPush.setParams(JSON.toJSONString(params));
+            fsOrderExpressPush.setCreateTime(LocalDateTime.now());
+            fsOrderExpressPush.setUpdateTime(LocalDateTime.now());
+            fsOrderExpressPush.setRetryCount(0);
+            fsOrderExpressPush.setTaskStatus(TaskStatusEnum.PENDING.getCode());
+            fsOrderExpressPush.setType(type);
             fsOrderExpressPushMapper.insert(fsOrderExpressPush);
         } catch (Exception e) {
             throw  new CustomException(e.getMessage());