Browse Source

FIX: 快递鸟兼容直播订房

xdd 2 weeks ago
parent
commit
a0bd83f6c4

+ 28 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveOrderController.java

@@ -21,6 +21,7 @@ import com.fs.erp.dto.ErpOrderQueryRequert;
 import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.erp.utils.ErpContextHolder;
+import com.fs.express.FsStoreDeliversService;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.domain.LiveOrderItem;
 import com.fs.live.domain.LiveOrderLogs;
@@ -33,6 +34,7 @@ import com.fs.live.service.ILiveOrderService;
 import com.fs.live.vo.LiveGoodsVo;
 import com.fs.live.vo.LiveOrderPaymentVo;
 import com.fs.live.vo.LiveOrderVo;
+import com.fs.store.domain.FsStoreDelivers;
 import com.fs.store.domain.FsStoreOrder;
 import com.fs.store.domain.FsStoreOrderStatus;
 import com.fs.store.domain.FsUser;
@@ -101,6 +103,8 @@ public class LiveOrderController extends BaseController
 //    @Qualifier("wdtErpOrderServiceImpl")
 //    private IErpOrderService wdtOrderService;
 
+    @Autowired
+    private FsStoreDeliversService fsStoreDeliversService;
     /**
      * 查询订单列表
      */
@@ -427,6 +431,30 @@ public class LiveOrderController extends BaseController
         return liveOrderService.finishOrder(param.getOrderId());
     }
 
+    /**
+     * 修改物流
+     * @param deliveryDTO
+     * @return AjaxResult
+     */
+    @Log(title = "修改物流", businessType = BusinessType.UPDATE)
+    @PreAuthorize("@ss.hasPermi('store:storeOrder:editDeliveryId')")
+    @PutMapping("/editDeliveryId")
+    public AjaxResult editDeliveryId(@RequestBody FsStoreDelivers deliveryDTO) {
+        LiveOrder liveOrder = liveOrderService.selectLiveOrderByOrderId(String.valueOf(deliveryDTO.getOrderId()));
+
+        liveOrder.setDeliverySn(deliveryDTO.getDeliverId());
+        liveOrder.setDeliveryName(deliveryDTO.getDeliverName());
+        liveOrder.setDeliveryCode(deliveryDTO.getDeliverSn());
+        liveOrderService.updateLiveOrder(liveOrder);
+
+
+        fsStoreDeliversService.editDeliveryId(deliveryDTO);
+        fsStoreDeliversService.syncDeliverInfo(deliveryDTO.getOrderId(),deliveryDTO.getType());
+        fsStoreDeliversService.finishOrder(deliveryDTO.getOrderId(),deliveryDTO.getType());
+        return AjaxResult.success();
+    }
+
+
     @Log(title = "手动推管易", businessType = BusinessType.INSERT)
     @ApiOperation("创建ERP订单")
 //    @PreAuthorize("@ss.hasPermi('store:storeOrder:createErpOrder')")

+ 17 - 4
fs-service-system/src/main/java/com/fs/express/impl/FsStoreDeliversServiceImpl.java

@@ -264,15 +264,28 @@ public class FsStoreDeliversServiceImpl implements FsStoreDeliversService {
         if(ObjectUtil.isNull(deliveryDTO.getId())){
             deliveryDTO.setStatus(0);
             deliveryDTO.setStateEx(0);
-            FsStoreOrder fsStoreOrder = orderService.selectFsStoreOrderById(deliveryDTO.getOrderId());
-            if(ObjectUtil.isNotNull(fsStoreOrder)){
-                deliveryDTO.setOrderCode(fsStoreOrder.getOrderCode());
+            String userPhone = null;
+            if(ObjectUtil.equal(deliveryDTO.getType(),1)) {
+                LiveOrder liveOrder = liveOrderService.selectLiveOrderByOrderId(String.valueOf(deliveryDTO.getOrderId()));
+                if(ObjectUtil.isNotNull(liveOrder)){
+                    deliveryDTO.setOrderCode(liveOrder.getOrderCode());
+                    userPhone = liveOrder.getUserPhone();
+                }
+            } else {
+                // 如果没有类型默认为0
+                FsStoreOrder fsStoreOrder = orderService.selectFsStoreOrderById(deliveryDTO.getOrderId());
+                if(ObjectUtil.isNotNull(fsStoreOrder)){
+                    deliveryDTO.setOrderCode(fsStoreOrder.getOrderCode());
+                    userPhone = fsStoreOrder.getUserPhone();
+                }
             }
 
+
             fsStoreDeliversMapper.insert(deliveryDTO);
 
             //新增的要订阅快递鸟监控
-            String lastFourNum = PhoneUtils.getLastFourNum(fsStoreOrder.getUserPhone());
+            Asserts.notNull(userPhone,"订单手机号不能为空!");
+            String lastFourNum = PhoneUtils.getLastFourNum(userPhone);
             expressService.subscribeEspress(deliveryDTO.getOrderCode(),
                     deliveryDTO.getDeliverSn(),
                     deliveryDTO.getDeliverId(),lastFourNum);