Просмотр исходного кода

暂时注释企得宝ERP接入代码

skyline 2 недель назад
Родитель
Сommit
7bdd7fe0c4

+ 30 - 26
haha-admin/src/main/java/com/haha/admin/config/QdbSdkConfig.java

@@ -1,45 +1,49 @@
 package com.haha.admin.config;
 
-import com.qdb.sdk.QdbClient;
-import com.qdb.sdk.QdbConfig;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
+// TODO: 企得宝 ERP SDK - 暂未对接,后续接入时取消注释
+// import com.qdb.sdk.QdbClient;
+// import com.qdb.sdk.QdbConfig;
+// import lombok.extern.slf4j.Slf4j;
+// import org.springframework.beans.factory.annotation.Value;
+// import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+// import org.springframework.context.annotation.Bean;
+// import org.springframework.context.annotation.Configuration;
 
 /**
  * 企得宝 ERP SDK 配置类
  */
-@Slf4j
-@Configuration
+// TODO: 企得宝 ERP SDK - 暂未对接,后续接入时取消注释
+// @Slf4j
+// @Configuration
 public class QdbSdkConfig {
 
-    @Value("${qdb.client-id:}")
+    // TODO: 企得宝 ERP SDK - 暂未对接,后续接入时取消注释
+    // @Value("${qdb.client-id:}")
     private String clientId;
 
-    @Value("${qdb.client-secret:}")
+    // @Value("${qdb.client-secret:}")
     private String clientSecret;
 
-    @Value("${qdb.api-url:https://api.7debao.com/router/api}")
+    // @Value("${qdb.api-url:https://api.7debao.com/router/api}")
     private String apiUrl;
 
     /**
+     * TODO: 企得宝ERP SDK - 暂未对接,后续接入时取消注释
      * 创建企得宝ERP SDK客户端Bean
      * 仅在配置了 client-id 和 client-secret 时才创建
      */
-    @Bean
-    @ConditionalOnProperty(prefix = "qdb", name = {"client-id", "client-secret"})
-    public QdbClient qdbClient() {
-        QdbConfig config = QdbConfig.builder()
-                .clientId(clientId)
-                .clientSecret(clientSecret)
-                .apiUrl(apiUrl)
-                .build();
-
-        config.validate();
-
-        log.info("企得宝ERP SDK 初始化成功, clientId: {}", clientId);
-        return new QdbClient(config);
-    }
+    // @Bean
+    // @ConditionalOnProperty(prefix = "qdb", name = {"client-id", "client-secret"})
+    // public QdbClient qdbClient() {
+    //     QdbConfig config = QdbConfig.builder()
+    //             .clientId(clientId)
+    //             .clientSecret(clientSecret)
+    //             .apiUrl(apiUrl)
+    //             .build();
+    //
+    //     config.validate();
+    //
+    //     log.info("企得宝ERP SDK 初始化成功, clientId: {}", clientId);
+    //     return new QdbClient(config);
+    // }
 }

+ 3 - 1
haha-service/pom.xml

@@ -34,12 +34,14 @@
             <artifactId>haha-sdk</artifactId>
         </dependency>
 
-        <!-- 企得宝 ERP SDK -->
+        <!-- TODO: 企得宝 ERP SDK - 暂未对接,后续接入时取消注释 -->
+        <!--
         <dependency>
             <groupId>com.qdb</groupId>
             <artifactId>qdb-sdk</artifactId>
             <version>1.0.0</version>
         </dependency>
+        -->
 
         <!-- Spring Boot Web - provided scope -->
         <dependency>

+ 9 - 72
haha-service/src/main/java/com/haha/service/impl/ReplenishmentOrderServiceImpl.java

@@ -14,9 +14,10 @@ import com.haha.entity.dto.ReplenishmentOrderUpdateDTO;
 import com.haha.mapper.ReplenishmentOrderItemMapper;
 import com.haha.mapper.ReplenishmentOrderMapper;
 import com.haha.service.ReplenishmentOrderService;
-import com.qdb.sdk.QdbClient;
-import com.qdb.sdk.model.request.OrderGoods;
-import com.qdb.sdk.model.request.OrderSaveRequest;
+// TODO: 企得宝 ERP SDK - 暂未对接,后续接入时取消注释
+// import com.qdb.sdk.QdbClient;
+// import com.qdb.sdk.model.request.OrderGoods;
+// import com.qdb.sdk.model.request.OrderSaveRequest;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,7 +31,6 @@ import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.stream.Collectors;
 
 /**
  * 补货单服务实现
@@ -44,8 +44,9 @@ public class ReplenishmentOrderServiceImpl extends ServiceImpl<ReplenishmentOrde
     private final ReplenishmentOrderMapper orderMapper;
     private final ReplenishmentOrderItemMapper orderItemMapper;
 
-    @Autowired(required = false)
-    private QdbClient qdbClient;
+    // TODO: 企得宝 ERP SDK - 暂未对接,后续接入时取消注释
+    // @Autowired(required = false)
+    // private QdbClient qdbClient;
 
     @Override
     public IPage<ReplenishmentOrder> getPage(ReplenishmentOrderQueryDTO queryDTO) {
@@ -273,76 +274,12 @@ public class ReplenishmentOrderServiceImpl extends ServiceImpl<ReplenishmentOrde
     @Override
     @Transactional(rollbackFor = Exception.class)
     public ReplenishmentOrder syncToErp(Long id) {
+        // TODO: 企得宝 ERP SDK - 暂未对接,后续接入时实现
+        log.warn("syncToErp 暂未实现: id={}", id);
         ReplenishmentOrder order = getById(id);
         if (order == null) {
             throw new BusinessException(404, "补货单不存在");
         }
-        if (order.getStatus() != ReplenishmentOrderStatusEnum.SUBMITTED.getCode()) {
-            throw new BusinessException(400, "仅已提交状态的补货单可同步到ERP");
-        }
-
-        if (qdbClient == null) {
-            throw new BusinessException(500, "ERP客户端未配置,无法同步");
-        }
-
-        List<ReplenishmentOrderItem> items = orderItemMapper.selectByOrderId(id);
-        if (items.isEmpty()) {
-            throw new BusinessException(400, "补货单明细为空,无法同步");
-        }
-
-        // 构建订单商品列表
-        List<OrderGoods> goodsList = items.stream().map(item -> {
-            BigDecimal price = item.getUnitPrice() != null ? item.getUnitPrice() : BigDecimal.ZERO;
-            BigDecimal qty = BigDecimal.valueOf(item.getPlannedQuantity());
-            return OrderGoods.builder()
-                    .platformGoodsCode(item.getProductCode() != null ? item.getProductCode() : "")
-                    .platformGoodsName(item.getProductName() != null ? item.getProductName() : "")
-                    .quantity(qty)
-                    .price(price)
-                    .realPrice(price)
-                    .build();
-        }).collect(Collectors.toList());
-
-        // 构建订单上传请求
-        // TODO: shopId 需要映射为 ERP 系统中的店铺ID,当前暂用设备关联的门店ID
-        // TODO: receiver* 收件人信息需从设备/门店地址中获取,当前暂不填充
-        // TODO: warehouseName 需确认与 ERP 仓库名称一致
-        OrderSaveRequest request = OrderSaveRequest.builder()
-                .shopId(order.getShopId())
-                .tradeNo(order.getOrderNo())
-                .platformTradeStatus("02")
-                .platformRefundStatus("0")
-                .orderTypeCode("3")
-                .postAmount(BigDecimal.ZERO)
-                .payAmount(order.getTotalAmount() != null ? order.getTotalAmount() : BigDecimal.ZERO)
-                // TODO: 从设备/门店信息中获取收件人地址
-                // .receiverProvince(null)
-                // .receiverCity(null)
-                // .receiverDistrict(null)
-                // .receiverAddress(null)
-                // .receiverName(null)
-                // .receiverMobile(null)
-                .ordersGoods(goodsList)
-                .buyerMessage(order.getRemark())
-                .sellerMessage("设备补货单: " + order.getDeviceId())
-                // TODO: 确认仓库名称与 ERP 一致
-                .warehouseName(order.getWarehouseName())
-                .build();
-
-        try {
-            qdbClient.getOrderApi().saveOrder(request);
-
-            order.setStatus(ReplenishmentOrderStatusEnum.SYNCED_TO_ERP.getCode());
-            order.setErpSyncTime(LocalDateTime.now());
-            order.setUpdateTime(LocalDateTime.now());
-            updateById(order);
-
-            log.info("补货单同步ERP成功: id={}, orderNo={}", id, order.getOrderNo());
-        } catch (Exception e) {
-            log.error("补货单同步ERP失败: id={}, orderNo={}, error={}", id, order.getOrderNo(), e.getMessage());
-            throw new BusinessException(500, "ERP同步失败: " + e.getMessage());
-        }
-
         fillStatusLabel(order);
         return order;
     }