2 Commits bd526ccf20 ... e5aa60acb8

Tác giả SHA1 Thông báo Ngày
  ct e5aa60acb8 Merge remote-tracking branch 'origin/master' 1 tuần trước cách đây
  ct fec6ff0508 update:erp(需要在sys_config增加erp配置) 1 tuần trước cách đây
42 tập tin đã thay đổi với 1123 bổ sung428 xóa
  1. 42 2
      fs-admin/src/main/java/com/fs/store/controller/FsStoreOrderController.java
  2. 44 2
      fs-admin/src/main/java/com/fs/task/StoreTask.java
  3. 106 106
      fs-common/src/main/java/com/fs/common/config/FSSysConfig.java
  4. 6 0
      fs-service-system/src/main/java/com/fs/erp/converter/ErpWdtToErpOrderMapper.java
  5. 2 1
      fs-service-system/src/main/java/com/fs/erp/domain/ErpOrder.java
  6. 3 1
      fs-service-system/src/main/java/com/fs/erp/domain/ErpRefundOrder.java
  7. 72 0
      fs-service-system/src/main/java/com/fs/erp/domain/FsErpFinishPush.java
  8. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KbStockRequest.java
  9. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KbStockResponse.java
  10. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderD1Data.java
  11. 1 2
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderData.java
  12. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderRequest.java
  13. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderResponse.java
  14. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosRefundOrderD1Data.java
  15. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosRefundOrderData.java
  16. 1 1
      fs-service-system/src/main/java/com/fs/erp/domain/KingbosRefundOrderRequest.java
  17. 22 24
      fs-service-system/src/main/java/com/fs/erp/dto/sdk/wangdian/api/WdtClient.java
  18. 2 2
      fs-service-system/src/main/java/com/fs/erp/enums/KbOrderStatusEnum.java
  19. 18 13
      fs-service-system/src/main/java/com/fs/erp/service/impl/ErpGoodsServiceImpl.java
  20. 28 21
      fs-service-system/src/main/java/com/fs/erp/service/impl/ErpOrderServiceImpl.java
  21. 8 5
      fs-service-system/src/main/java/com/fs/erp/service/impl/ErpShopServiceImpl.java
  22. 8 5
      fs-service-system/src/main/java/com/fs/erp/service/impl/ErpUserServiceImpl.java
  23. 168 54
      fs-service-system/src/main/java/com/fs/erp/service/impl/K9OrderServiceImpl.java
  24. 92 0
      fs-service-system/src/main/java/com/fs/erp/service/impl/K9StockServiceImpl.java
  25. 14 2
      fs-service-system/src/main/java/com/fs/erp/service/impl/WdtErpOrderServiceImpl.java
  26. 2 2
      fs-service-system/src/main/java/com/fs/erp/utils/SignUtils.java
  27. 2 2
      fs-service-system/src/main/java/com/fs/erp/utils/UrlUtils.java
  28. 30 0
      fs-service-system/src/main/java/com/fs/his/config/FsErpConfig.java
  29. 13 0
      fs-service-system/src/main/java/com/fs/his/utils/ConfigUtil.java
  30. 0 18
      fs-service-system/src/main/java/com/fs/kingbos/service/K9OrderService.java
  31. 0 19
      fs-service-system/src/main/java/com/fs/kingbos/service/K9StockService.java
  32. 0 49
      fs-service-system/src/main/java/com/fs/kingbos/service/impl/K9StockServiceImpl.java
  33. 30 30
      fs-service-system/src/main/java/com/fs/store/domain/FsUserAddress.java
  34. 1 1
      fs-service-system/src/main/java/com/fs/store/dto/TemplateDTO.java
  35. 62 13
      fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreCartServiceImpl.java
  36. 54 14
      fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java
  37. 12 12
      fs-service-system/src/main/resources/application-config-zkzh.yml
  38. 137 0
      fs-service-system/src/main/resources/application-druid-dev.yml
  39. 1 1
      fs-user-app/src/main/java/com/fs/app/controller/AddressController.java
  40. 90 11
      fs-user-app/src/main/java/com/fs/app/controller/CommonController.java
  41. 43 6
      fs-user-app/src/main/java/com/fs/app/controller/StoreOrderController.java
  42. 2 2
      fs-user-app/src/main/java/com/fs/app/utils/CityTreeUtil.java

+ 42 - 2
fs-admin/src/main/java/com/fs/store/controller/FsStoreOrderController.java

@@ -24,6 +24,8 @@ import com.fs.erp.domain.ErpOrderQuery;
 import com.fs.erp.dto.ErpOrderQueryRequert;
 import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.store.domain.*;
 import com.fs.store.dto.ExpressInfoDTO;
 import com.fs.store.dto.FsStoreCartDTO;
@@ -34,6 +36,7 @@ import com.fs.store.param.*;
 import com.fs.store.service.*;
 import com.fs.store.vo.*;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
@@ -72,13 +75,48 @@ public class FsStoreOrderController extends BaseController {
     @Autowired
     private IFsStoreOrderStatusService orderStatusService;
 
-    @Autowired
-    IErpOrderService erpOrderService;
     @Autowired
     IFsStorePaymentService paymentService;
 
     @Autowired
     private ICompanyMoneyLogsService moneyLogsService;
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtOrderService;
+
+    @Autowired
+    @Qualifier("k9OrderServiceImpl")
+    private IErpOrderService k9OrderService;
+    @Autowired
+    private ConfigUtil configUtil;
+
+    private IErpOrderService getErpService(){
+        //判断是否开启erp
+        IErpOrderService erpOrderService = null;
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        Integer erpOpen = erpConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1) {
+            //判断erp类型
+            Integer erpType = erpConfig.getErpType();
+            if (erpType != null) {
+                if (erpType == 1) {
+                    //管易
+                    erpOrderService = gyOrderService;
+                } else if (erpType == 2) {
+                    //旺店通
+                    erpOrderService = wdtOrderService;
+                } else if (erpType == 3) {
+                    //旺店通
+                    erpOrderService = k9OrderService;
+                }
+            }
+        }
+        return erpOrderService;
+    }
 
     /**
      * 查询订单列表
@@ -391,6 +429,7 @@ public class FsStoreOrderController extends BaseController {
     @PreAuthorize("@ss.hasPermi('store:storeOrder:updateErpOrder')")
     @PostMapping("/updateErpOrder")
     public R updateErpOrder(@Validated @RequestBody FsStoreOrderExpressEditParam param) {
+        IErpOrderService erpOrderService = getErpService();
         FsStoreOrder order = fsStoreOrderService.selectFsStoreOrderById(param.getOrderId());
         ErpOrderQueryRequert request = new ErpOrderQueryRequert();
         request.setCode(order.getExtendOrderId());
@@ -482,6 +521,7 @@ public class FsStoreOrderController extends BaseController {
     @PreAuthorize("@ss.hasPermi('store:storeOrder:getEroOrder')")
     @GetMapping("/getEroOrder")
     public R getEroOrder(@RequestParam("extendOrderId") String extendOrderId) {
+        IErpOrderService erpOrderService = getErpService();
         ErpOrderQueryRequert request = new ErpOrderQueryRequert();
         request.setCode(extendOrderId);
         ErpOrderQueryResponse response = erpOrderService.getOrder(request);

+ 44 - 2
fs-admin/src/main/java/com/fs/task/StoreTask.java

@@ -15,6 +15,8 @@ import com.fs.erp.dto.ErpOrderQueryRequert;
 import com.fs.erp.dto.ErpOrderQueryResponse;
 import com.fs.erp.service.IErpGoodsService;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.pay.pay.domain.OrderResult;
 import com.fs.pay.pay.dto.OrderQueryDTO;
 import com.fs.pay.pay.service.PayService;
@@ -32,6 +34,7 @@ import com.fs.store.service.*;
 import com.fs.system.service.ISysConfigService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
@@ -64,8 +67,6 @@ public class StoreTask
     @Autowired
     private IFsUserService userService;
 
-    @Autowired
-    private IErpOrderService erpOrderService;
 
     @Autowired
     private PayService ybPayService;
@@ -105,6 +106,21 @@ public class StoreTask
     @Autowired
     private IFsStoreAfterSalesService fsStoreAfterSalesService;
 
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtOrderService;
+
+    @Autowired
+    @Qualifier("k9OrderServiceImpl")
+    private IErpOrderService k9OrderService;
+
+    @Autowired
+    private ConfigUtil configUtil;
+
     public void PushErp() throws ParseException {
         List<Long> ids = fsStoreOrderMapper.selectFsStoreOrderNoCreateOms();
         for (Long id : ids) {
@@ -118,6 +134,7 @@ public class StoreTask
     //每5分钟执行一次
     public void deliveryOp()
     {
+        IErpOrderService erpOrderService = getErpOrderService();
         Set<String> orders=redisTemplate.keys(DELIVERY+":*");
         for(String extndOrderId:orders){
             String orderCode=(String)redisTemplate.opsForValue().get(extndOrderId);
@@ -230,6 +247,7 @@ public class StoreTask
     }
 
     public void returnDeliveryId(){
+        IErpOrderService erpOrderService = getErpOrderService();
         List<String> list = fsStoreOrderMapper.selectErpCode();
         for (String s : list) {
             ErpOrderQueryRequert request = new ErpOrderQueryRequert();
@@ -373,6 +391,30 @@ public class StoreTask
 
     }
 
+    private IErpOrderService getErpOrderService(){
+        //判断是否开启erp
+        IErpOrderService erpOrderService = null;
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        Integer erpOpen = erpConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1) {
+            //判断erp类型
+            Integer erpType = erpConfig.getErpType();
+            if (erpType != null) {
+                if (erpType == 1) {
+                    //管易
+                    erpOrderService = gyOrderService;
+                } else if (erpType == 2) {
+                    //旺店通
+                    erpOrderService = wdtOrderService;
+                } else if (erpType == 3) {
+                    //旺店通
+                    erpOrderService = k9OrderService;
+                }
+            }
+        }
+        return erpOrderService;
+    }
+
 
 
 

+ 106 - 106
fs-common/src/main/java/com/fs/common/config/FSSysConfig.java

@@ -28,12 +28,12 @@ public class FSSysConfig
     String manuId;
     String callbackUrl;
     //erp接口
-    Integer erpOpen;//是否开启ERP
-    String erpAppKey;
-    String erpSessionKey;
-    String erpSecret;
-    String erpUrl;
-    String erpShopCode;//店铺CODE
+//    Integer erpOpen;//是否开启ERP
+//    String erpAppKey;
+//    String erpSessionKey;
+//    String erpSecret;
+//    String erpUrl;
+//    String erpShopCode;//店铺CODE
     //支付接口
     Integer payOpen;//是否开启
     String payPartnerId;
@@ -42,12 +42,12 @@ public class FSSysConfig
     String payNotifyUrl;
     String refundNotifyUrl;
     //金博erp
-    private String kingbosan;//账套名称
-    private String kingbosSecret;//金博密钥
-    private String kingbosUrl;//金博地址
-    private String corgid;//机构编码
-    private String cwarehouseCode;
-    private String cwarehouseName;
+//    private String kingbosan;//账套名称
+//    private String kingbosSecret;//金博密钥
+//    private String kingbosUrl;//金博地址
+//    private String corgid;//机构编码
+//    private String cwarehouseCode;
+//    private String cwarehouseName;
 
     public String getKdnId() {
         return kdnId;
@@ -145,53 +145,53 @@ public class FSSysConfig
         this.callbackUrl = callbackUrl;
     }
 
-    public Integer getErpOpen() {
-        return erpOpen;
-    }
-
-    public void setErpOpen(Integer erpOpen) {
-        this.erpOpen = erpOpen;
-    }
-
-    public String getErpAppKey() {
-        return erpAppKey;
-    }
-
-    public void setErpAppKey(String erpAppKey) {
-        this.erpAppKey = erpAppKey;
-    }
-
-    public String getErpSessionKey() {
-        return erpSessionKey;
-    }
-
-    public void setErpSessionKey(String erpSessionKey) {
-        this.erpSessionKey = erpSessionKey;
-    }
-
-    public String getErpSecret() {
-        return erpSecret;
-    }
-
-    public void setErpSecret(String erpSecret) {
-        this.erpSecret = erpSecret;
-    }
-
-    public String getErpUrl() {
-        return erpUrl;
-    }
-
-    public void setErpUrl(String erpUrl) {
-        this.erpUrl = erpUrl;
-    }
-
-    public String getErpShopCode() {
-        return erpShopCode;
-    }
-
-    public void setErpShopCode(String erpShopCode) {
-        this.erpShopCode = erpShopCode;
-    }
+//    public Integer getErpOpen() {
+//        return erpOpen;
+//    }
+//
+//    public void setErpOpen(Integer erpOpen) {
+//        this.erpOpen = erpOpen;
+//    }
+//
+//    public String getErpAppKey() {
+//        return erpAppKey;
+//    }
+//
+//    public void setErpAppKey(String erpAppKey) {
+//        this.erpAppKey = erpAppKey;
+//    }
+//
+//    public String getErpSessionKey() {
+//        return erpSessionKey;
+//    }
+//
+//    public void setErpSessionKey(String erpSessionKey) {
+//        this.erpSessionKey = erpSessionKey;
+//    }
+//
+//    public String getErpSecret() {
+//        return erpSecret;
+//    }
+//
+//    public void setErpSecret(String erpSecret) {
+//        this.erpSecret = erpSecret;
+//    }
+//
+//    public String getErpUrl() {
+//        return erpUrl;
+//    }
+//
+//    public void setErpUrl(String erpUrl) {
+//        this.erpUrl = erpUrl;
+//    }
+//
+//    public String getErpShopCode() {
+//        return erpShopCode;
+//    }
+//
+//    public void setErpShopCode(String erpShopCode) {
+//        this.erpShopCode = erpShopCode;
+//    }
 
     public Integer getPayOpen() {
         return payOpen;
@@ -241,51 +241,51 @@ public class FSSysConfig
         this.refundNotifyUrl = refundNotifyUrl;
     }
 
-    public String getKingbosan() {
-        return kingbosan;
-    }
-
-    public void setKingbosan(String kingbosan) {
-        this.kingbosan = kingbosan;
-    }
-
-    public String getCorgid() {
-        return corgid;
-    }
-
-    public void setCorgid(String corgid) {
-        this.corgid = corgid;
-    }
-
-    public String getKingbosUrl() {
-        return kingbosUrl;
-    }
-
-    public void setKingbosUrl(String kingbosUrl) {
-        this.kingbosUrl = kingbosUrl;
-    }
-
-    public String getKingbosSecret() {
-        return kingbosSecret;
-    }
-
-    public void setKingbosSecret(String kingbosSecret) {
-        this.kingbosSecret = kingbosSecret;
-    }
-
-    public String getCwarehouseCode() {
-        return cwarehouseCode;
-    }
-
-    public void setCwarehouseCode(String cwarehouseCode) {
-        this.cwarehouseCode = cwarehouseCode;
-    }
-
-    public String getCwarehouseName() {
-        return cwarehouseName;
-    }
-
-    public void setCwarehouseName(String cwarehouseName) {
-        this.cwarehouseName = cwarehouseName;
-    }
+//    public String getKingbosan() {
+//        return kingbosan;
+//    }
+//
+//    public void setKingbosan(String kingbosan) {
+//        this.kingbosan = kingbosan;
+//    }
+//
+//    public String getCorgid() {
+//        return corgid;
+//    }
+//
+//    public void setCorgid(String corgid) {
+//        this.corgid = corgid;
+//    }
+//
+//    public String getKingbosUrl() {
+//        return kingbosUrl;
+//    }
+//
+//    public void setKingbosUrl(String kingbosUrl) {
+//        this.kingbosUrl = kingbosUrl;
+//    }
+//
+//    public String getKingbosSecret() {
+//        return kingbosSecret;
+//    }
+//
+//    public void setKingbosSecret(String kingbosSecret) {
+//        this.kingbosSecret = kingbosSecret;
+//    }
+//
+//    public String getCwarehouseCode() {
+//        return cwarehouseCode;
+//    }
+//
+//    public void setCwarehouseCode(String cwarehouseCode) {
+//        this.cwarehouseCode = cwarehouseCode;
+//    }
+//
+//    public String getCwarehouseName() {
+//        return cwarehouseName;
+//    }
+//
+//    public void setCwarehouseName(String cwarehouseName) {
+//        this.cwarehouseName = cwarehouseName;
+//    }
 }

+ 6 - 0
fs-service-system/src/main/java/com/fs/erp/converter/ErpWdtToErpOrderMapper.java

@@ -120,10 +120,16 @@ public interface ErpWdtToErpOrderMapper {
             erpOrderQuery.setExpress_code(source.getLogisticsNo());
         }
 
+        // 订单状态
+        if(source.getTradeStatus() != null) {
+            erpOrderQuery.setDelivery_state(source.getTradeStatus());
+        }
+
         ErpDeliverys erpDeliverys = new ErpDeliverys();
         erpDeliverys.setExpress_code(source.getLogisticsCode());
         erpDeliverys.setExpress_name(source.getLogisticsName());
         erpDeliverys.setMail_no(source.getLogisticsNo());
+        erpDeliverys.setDelivery(true);
 
         erpOrderQuery.setDeliverys(new ArrayList<>(Collections.singletonList(erpDeliverys)));
         return erpOrderQuery;

+ 2 - 1
fs-service-system/src/main/java/com/fs/erp/domain/ErpOrder.java

@@ -8,7 +8,7 @@ import java.util.List;
 public class ErpOrder {
     String shop_code;
     String vip_code;
-    String platform_code;
+    String platform_code; //订单编号
     Boolean repeat_allowed;
     String warehouse_code;
     String business_man_code;
@@ -30,5 +30,6 @@ public class ErpOrder {
     String receiver_address;
     String deal_datetime;
 
+    Integer isPackage;
     List<ErpOrderPayment> payments;
 }

+ 3 - 1
fs-service-system/src/main/java/com/fs/erp/domain/ErpRefundOrder.java

@@ -9,8 +9,10 @@ public class ErpRefundOrder {
     String type_code;
     String shop_code;
     String vip_code;
-    String trade_platform_code;
+    String trade_platform_code; //订单编号
     List<ErpOrderItem> details;
 
+    //运单号
+    String deliverySn;
 
 }

+ 72 - 0
fs-service-system/src/main/java/com/fs/erp/domain/FsErpFinishPush.java

@@ -0,0 +1,72 @@
+package com.fs.erp.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * erp订单完成状态推送
+ *
+ * @author AutoGenerated
+ * @date CurrentDateTime  // 这里通常会是生成日期
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class FsErpFinishPush {
+
+    /**
+     * 主键,自增
+     */
+    private Long id;
+
+    /**
+     * 订单id,唯一标识订单
+     */
+    private Long orderId;
+
+    /**
+     * 任务状态:0-待处理,1-成功,2-失败,3-正在处理,4-已取消
+     */
+    private Integer taskStatus; // 或者使用 Byte
+
+    /**
+     * 重试次数,默认为 0
+     */
+    private Integer retryCount;
+
+    /**
+     * 上次执行时间,用于记录任务执行的最后时间
+     */
+    private Date lastExecuteTime;
+
+    /**
+     * 记录创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 记录更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 调用接口时传入的参数(JSON 格式)
+     */
+    private String params;
+
+    /**
+     * 调用接口返回的结果(JSON 格式)
+     */
+    private String result;
+
+    /**
+     * 错误信息(记录失败原因)
+     */
+    private String errorMessage;
+
+}

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KbStockRequest.java → fs-service-system/src/main/java/com/fs/erp/domain/KbStockRequest.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Builder;

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KbStockResponse.java → fs-service-system/src/main/java/com/fs/erp/domain/KbStockResponse.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosOrderD1Data.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderD1Data.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import lombok.Data;
 

+ 1 - 2
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosOrderData.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderData.java

@@ -1,9 +1,8 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import lombok.Data;
 
 import java.math.BigDecimal;
-import java.util.Date;
 
 /**
  * 金博订单实体  data

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosOrderRequest.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderRequest.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import lombok.Data;
 

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosOrderResponse.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosOrderResponse.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import lombok.Data;
 

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosRefundOrderD1Data.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosRefundOrderD1Data.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import cn.hutool.core.annotation.Alias;
 import lombok.Data;

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosRefundOrderData.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosRefundOrderData.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import cn.hutool.core.annotation.Alias;
 import lombok.Data;

+ 1 - 1
fs-service-system/src/main/java/com/fs/kingbos/domian/KingbosRefundOrderRequest.java → fs-service-system/src/main/java/com/fs/erp/domain/KingbosRefundOrderRequest.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.domian;
+package com.fs.erp.domain;
 
 import lombok.Data;
 

+ 22 - 24
fs-service-system/src/main/java/com/fs/erp/dto/sdk/wangdian/api/WdtClient.java

@@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fs.erp.dto.sdk.wangdian.utils.WebUtils;
 import com.fs.erp.dto.wdt.ErpWdtBusinessRequestParams;
+import com.fs.his.utils.ConfigUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -25,11 +26,24 @@ import java.util.Map;
 @Component
 @Slf4j
 public class WdtClient {
+	@Autowired
+	ConfigUtil configUtil;
+
+
+	private String getAppKey() {
+		return configUtil.getErpConfig().getErpWdAppKey();
+	}
+
+	private String getAppsecret() {
+		return configUtil.getErpConfig().getErpWdAppsecret();
+	}
+	private String getSid() {
+		return configUtil.getErpConfig().getErpWdSid();
+	}
+	private String getBaseUrl() {
+		return configUtil.getErpConfig().getErpWdBaseUrl();
+	}
 
-	private static String appkey;
-	private static String appsecret;
-	private static String sid;
-	private static String baseUrl;
 
 	private static volatile WdtClient wdtClient;
 
@@ -37,22 +51,6 @@ public class WdtClient {
 	private int connectTimeout = 3000;//3秒
 	private int readTimeout = 15000;//15秒
 
-	@Value("${fsConfig.erpWdAppKey}")
-	public void setAppkey(String appkey) {
-		WdtClient.appkey = appkey;
-	}
-	@Value("${fsConfig.erpWdAppsecret}")
-	public void setAppsecret(String appsecret) {
-		WdtClient.appsecret = appsecret;
-	}
-	@Value("${fsConfig.erpWdSid}")
-	public void setSid(String sid) {
-		WdtClient.sid = sid;
-	}
-	@Value("${fsConfig.erpWdBaseUrl}")
-	public void setBaseUrl(String baseUrl) {
-		WdtClient.baseUrl = baseUrl;
-	}
 
 	private WdtClient(){}
 
@@ -149,14 +147,14 @@ public class WdtClient {
 		log.info("开始执行请求,相对路径:{},请求参数:{}", relativeUrl, params);
 
 
-		params.put("appkey", appkey);
-		params.put("sid", sid);
+		params.put("appkey", getAppKey());
+		params.put("sid", getSid());
 		params.put("timestamp", Long.toString(System.currentTimeMillis()/1000));
 
-		String sign = signRequest(params, appsecret);
+		String sign = signRequest(params, getAppsecret());
 		params.put("sign", sign);
 		log.info("计算签名完成, 签名为:{}",sign);
-		String url = baseUrl + relativeUrl;
+		String url = getBaseUrl() + relativeUrl;
 		long startTime = System.currentTimeMillis();
 		String response = WebUtils.doPost(url, params, "UTF-8", connectTimeout, readTimeout, null);
 		long endTime = System.currentTimeMillis();

+ 2 - 2
fs-service-system/src/main/java/com/fs/kingbos/enums/OrderStatusEnum.java → fs-service-system/src/main/java/com/fs/erp/enums/KbOrderStatusEnum.java

@@ -1,4 +1,4 @@
-package com.fs.kingbos.enums;
+package com.fs.erp.enums;
 
 
 import lombok.AllArgsConstructor;
@@ -9,7 +9,7 @@ import lombok.NoArgsConstructor;
 @Getter
 @NoArgsConstructor
 @AllArgsConstructor
-public enum OrderStatusEnum {
+public enum KbOrderStatusEnum {
 
     /**
      * 发货失败

+ 18 - 13
fs-service-system/src/main/java/com/fs/erp/service/impl/ErpGoodsServiceImpl.java

@@ -10,6 +10,8 @@ import com.fs.erp.dto.*;
 import com.fs.erp.service.IErpGoodsService;
 import com.fs.erp.service.IErpUserService;
 import com.fs.erp.utils.CommonUtils;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -23,38 +25,40 @@ public class ErpGoodsServiceImpl implements IErpGoodsService
 {
 
     @Autowired
-    FSSysConfig sysConfig;
+    ConfigUtil configUtil;
 
 
     @Override
     public BaseResponse addGoods(ErpGoods goods) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.item.add");
         param.set("code", goods.getCode());
         param.set("name", goods.getName());
         param.set("simple_name", goods.getSimple_name());
         param.set("item_add_attribute", goods.getItem_add_attribute());
         param.set("skus", goods.getSkus());
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         BaseResponse response=JSONUtil.toBean(result, BaseResponse.class);
         return response;
     }
 
     @Override
     public ErpGoodsQueryResponse getGoods(ErpGoodsQueryRequert requert) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.items.get");
         param.set("code", requert.getCode());
         param.set("page_no", requert.getPage_no());
         param.set("page_size", requert.getPage_size());
 
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         System.out.println(result);
         ErpGoodsQueryResponse response=JSONUtil.toBean(result, ErpGoodsQueryResponse.class);
         return response;
@@ -62,16 +66,17 @@ public class ErpGoodsServiceImpl implements IErpGoodsService
 
     @Override
     public ErpGoodsStockQueryResponse getGoodsStock(ErpGoodsStockQueryRequert requert) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.new.stock.get");
         param.set("barcode", requert.getBarcode());
         param.set("page_no", requert.getPage_no());
         param.set("page_size", requert.getPage_size());
 
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         ErpGoodsStockQueryResponse response=JSONUtil.toBean(result, ErpGoodsStockQueryResponse.class);
         return response;
     }

+ 28 - 21
fs-service-system/src/main/java/com/fs/erp/service/impl/ErpOrderServiceImpl.java

@@ -11,6 +11,8 @@ import com.fs.erp.dto.*;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.erp.service.IErpShopService;
 import com.fs.erp.utils.CommonUtils;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,12 +23,13 @@ public class ErpOrderServiceImpl implements IErpOrderService
 {
     public final static Logger LOGGER = LoggerFactory.getLogger(ErpOrderServiceImpl.class);
     @Autowired
-    FSSysConfig sysConfig;
+    ConfigUtil configUtil;
     @Override
     public ErpOrderResponse addOrder(ErpOrder order) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.trade.add");
         param.set("shop_code", order.getShop_code());
         param.set("vip_code", order.getVip_code());
@@ -48,8 +51,8 @@ public class ErpOrderServiceImpl implements IErpOrderService
         param.set("receiver_district", order.getReceiver_district());
         param.set("receiver_address", order.getReceiver_address());
         param.set("deal_datetime", order.getDeal_datetime());
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         System.out.println("erp-order:"+param.toString());
         LOGGER.info("erp-order:"+param.toString());
         LOGGER.error("erp-order-result:"+result);
@@ -59,9 +62,10 @@ public class ErpOrderServiceImpl implements IErpOrderService
 
     @Override
     public ErpOrderResponse refundOrder(ErpRefundOrder order) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.trade.return.add");
         param.set("type_code", order.getType_code());
         param.set("shop_code", order.getShop_code());
@@ -69,56 +73,59 @@ public class ErpOrderServiceImpl implements IErpOrderService
         // param.set("trade_code", order.getTrade_platform_code());
         param.set("trade_platform_code", order.getTrade_platform_code());
         param.set("item_detail", order.getDetails());
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         ErpOrderResponse response=JSONUtil.toBean(result, ErpOrderResponse.class);
         return response;
     }
 
     @Override
     public ErpDeliverysResponse getDeliver(ErpDeliverysRequest request) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.trade.deliverys.get");
         param.set("code", request.getCode());
         param.set("page_no", request.getPage_no());
         param.set("page_size", request.getPage_size());
         param.set("detail_flag", request.getDetail_flag());
 
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         ErpDeliverysResponse response=JSONUtil.toBean(result, ErpDeliverysResponse.class);
         return response;
     }
 
     @Override
     public ErpOrderQueryResponse getOrder(ErpOrderQueryRequert requert) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.trade.get");
         param.set("code", requert.getCode());
         param.set("page_no", requert.getPage_no());
         param.set("page_size", requert.getPage_size());
 
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         ErpOrderQueryResponse response=JSONUtil.toBean(result, ErpOrderQueryResponse.class);
         return response;
     }
 
     @Override
     public BaseResponse refundUpdate(ErpRefundUpdateRequest request) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.trade.refund.update");
         param.set("tid", request.getTid());
         param.set("oid", request.getOid());
         param.set("refund_state", request.getRefund_state());
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         ErpOrderResponse response=JSONUtil.toBean(result, ErpOrderResponse.class);
         return response;
     }

+ 8 - 5
fs-service-system/src/main/java/com/fs/erp/service/impl/ErpShopServiceImpl.java

@@ -16,6 +16,8 @@ import com.fs.common.utils.StringUtils;
 import com.fs.erp.dto.ErpShopResponse;
 import com.fs.erp.service.IErpShopService;
 import com.fs.erp.utils.CommonUtils;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
 import com.fs.system.service.ISysConfigService;
@@ -36,16 +38,17 @@ public class ErpShopServiceImpl implements IErpShopService
 {
 
     @Autowired
-    FSSysConfig sysConfig;
+    ConfigUtil configUtil;
     @Override
     public ErpShopResponse getShop(String code) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.shop.get");
         param.set("code", code);
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         ErpShopResponse response=JSONUtil.toBean(result, ErpShopResponse.class);
         return response;
     }

+ 8 - 5
fs-service-system/src/main/java/com/fs/erp/service/impl/ErpUserServiceImpl.java

@@ -10,6 +10,8 @@ import com.fs.erp.dto.ErpShopResponse;
 import com.fs.erp.service.IErpShopService;
 import com.fs.erp.service.IErpUserService;
 import com.fs.erp.utils.CommonUtils;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.sun.org.apache.bcel.internal.generic.RETURN;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,21 +26,22 @@ public class ErpUserServiceImpl implements IErpUserService
 {
 
     @Autowired
-    FSSysConfig sysConfig;
+    ConfigUtil configUtil;
 
 
     @Override
     public BaseResponse addUser(ErpUser user) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
-        param.set("appkey", sysConfig.getErpAppKey());
-        param.set("sessionkey", sysConfig.getErpSessionKey());
+        param.set("appkey", erpConfig.getErpAppKey());
+        param.set("sessionkey", erpConfig.getErpSessionKey());
         param.set("method", "gy.erp.vip.add");
         param.set("code", user.getCode());
         param.set("name", user.getName());
         param.set("shop_code", user.getShop_code());
         param.set("receive_infos", user.getReceive_infos());
-        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
-        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
+        param.set("sign",CommonUtils.sign(param.toString(),erpConfig.getErpSecret()));
+        String result = HttpUtil.post(erpConfig.getErpUrl(), param.toString());
         BaseResponse response=JSONUtil.toBean(result, BaseResponse.class);
         return response;
     }

+ 168 - 54
fs-service-system/src/main/java/com/fs/kingbos/service/impl/K9OrderServiceImpl.java → fs-service-system/src/main/java/com/fs/erp/service/impl/K9OrderServiceImpl.java

@@ -1,23 +1,19 @@
-package com.fs.kingbos.service.impl;
+package com.fs.erp.service.impl;
 
 import cn.hutool.core.util.IdUtil;
-import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.PropertyNamingStrategy;
-import com.alibaba.fastjson.parser.ParserConfig;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.StringUtils;
-import com.fs.erp.dto.ErpOrderResponse;
-import com.fs.erp.dto.wdt.ErpWdtApiResponse;
-import com.fs.kingbos.domian.*;
-import com.fs.kingbos.enums.OrderStatusEnum;
-import com.fs.kingbos.service.K9OrderService;
-import com.fs.kingbos.util.SignUtil;
-import com.fs.kingbos.util.UrlUtil;
+import com.fs.erp.domain.*;
+import com.fs.erp.dto.*;
+import com.fs.erp.service.IErpOrderService;
+import com.fs.erp.utils.SignUtils;
+import com.fs.erp.utils.UrlUtils;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.store.domain.FsStoreOrder;
 import com.fs.store.domain.FsStoreOrderItem;
 import com.fs.store.dto.FsStoreCartDTO;
@@ -29,28 +25,24 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
-
-import java.io.IOException;
 import java.math.BigDecimal;
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import static com.fs.kingbos.enums.OrderStatusEnum.CANCELLED;
-import static com.fs.kingbos.enums.OrderStatusEnum.NO_DELIVERED;
+import static com.fs.erp.enums.KbOrderStatusEnum.CANCELLED;
+import static com.fs.erp.enums.KbOrderStatusEnum.NO_DELIVERED;
+
 
 @Service
 @Slf4j
-public class K9OrderServiceImpl implements K9OrderService {
+public class K9OrderServiceImpl implements IErpOrderService {
     public final static Logger logger = LoggerFactory.getLogger(K9OrderServiceImpl.class);
     @Autowired
-    FSSysConfig sysConfig;
+    ConfigUtil configUtil;
     @Autowired
     private FsStoreOrderMapper fsStoreOrderMapper;
     @Autowired
@@ -58,43 +50,118 @@ public class K9OrderServiceImpl implements K9OrderService {
     @Autowired
     private FsStoreProductMapper productMapper;
     @Override
-    public KingbosOrderResponse addOrder(KingbosOrderRequest request) {
-        JSONObject param = JSONUtil.createObj();
-        param.set("key", "OL");
-        param.set("data", request.getData());
-        param.set("d1_data", request.getD1_data());
-        String timeStep = System.currentTimeMillis() + "";
-        logger.info("zyp \n【金博网络订单推送参数】:"+param);
-        String sign = SignUtil.sign(param.toString(),sysConfig.getKingbosSecret(), sysConfig.getKingbosan(), timeStep);
-        String url = UrlUtil.getUrl(sysConfig.getKingbosUrl(),sign, timeStep);
-        String json = param.toString();
-        String result = HttpUtil.post(url, json);
-        logger.info("zyp \n【金博网络订单推送返回】:"+result);
-        KingbosOrderResponse response = JSONUtil.toBean(result, KingbosOrderResponse.class);
-        return response;
+    /**
+     * 推送erp订单
+     */
+    public ErpOrderResponse addOrder(ErpOrder order) {
+        return addOmsOrder(order.getPlatform_code());
     }
 
 
-    //运单号已获取到
+    /**
+     * 退款
+     * @param order
+     * @return
+     */
+    @Override
+    public ErpOrderResponse refundOrder(ErpRefundOrder order){
+        if (order != null){
+            String deliverySn = order.getDeliverySn();
+            String orderCode = order.getTrade_platform_code();
+            if (StringUtils.isNotBlank(orderCode)){
+                if (StringUtils.isBlank(deliverySn)){
+                    //未获取订单号
+                    return refundOmsOrder2(orderCode);
+                } else {
+                    //已获取订单号
+                    return refundOrder1(orderCode);
+                }
+            }
+        }
+        return null;
+    }
+
+    private KingbosRefundOrderRequest getKingbosRefundOrderRequest(String orderCode) {
+        FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderCode);
+        if (order != null){
+            logger.debug("【金博网络退货单】开始构建订单数据,订单号: {}", orderCode);
+            KingbosRefundOrderRequest request = new KingbosRefundOrderRequest();
+            KingbosRefundOrderData data = new KingbosRefundOrderData();
+            data.setCorderSource("MALL");
+            String extendOrderId = order.getExtendOrderId();
+            data.setCasId(extendOrderId);
+            data.setCoId(extendOrderId);
+            request.setData(data);
+            // 3. 构建订单明细数据
+            List<KingbosRefundOrderD1Data> d1Datas = new ArrayList<>();
+
+
+            List<KingbosRefundOrderD1Data> d1_data = new ArrayList<>();
+            FsStoreOrderItem query = new FsStoreOrderItem();
+            query.setOrderId(order.getId());
+            List<FsStoreOrderItem> orderItems = storeOrderItemService.selectFsStoreOrderItemList(query);
+
+
+            d1_data = orderItems.stream()
+                    .map(item -> buildRefundOrderDetailItem(extendOrderId))
+                    .collect(Collectors.toList());
+            request.setD1_data(d1_data);
+            logger.info("【金博网络退货单】订单明细数据构建完成,明细数量: {}", d1Datas.size());
+        }
+        return null;
+    }
+
+    @Override
+    public ErpDeliverysResponse getDeliver(ErpDeliverysRequest param) {
+        return null;
+    }
+
     @Override
-    public KingbosOrderResponse refundOrder(KingbosRefundOrderRequest request) {
+    public ErpOrderQueryResponse getOrder(ErpOrderQueryRequert param) {
+        return null;
+    }
+
+    @Override
+    public BaseResponse refundUpdate(ErpRefundUpdateRequest param) {
+        return null;
+    }
+
+
+    /**
+     * 退款 运单号已获取到
+     * @param orderCode
+     * @return
+     */
+    private ErpOrderResponse refundOrder1(String orderCode) {
+        KingbosRefundOrderRequest request = getKingbosRefundOrderRequest(orderCode);
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         JSONObject param = JSONUtil.createObj();
         param.set("key", "WR");
         param.set("data", request.getData());
         param.set("d1_data", request.getD1_data());
         String timeStep = System.currentTimeMillis() + "";
-        String sign = SignUtil.sign(param.toString(),sysConfig.getKingbosSecret(), sysConfig.getKingbosan(), timeStep);
-        String url = UrlUtil.getUrl(sysConfig.getKingbosUrl(),sign, timeStep);
+        String sign = SignUtils.sign(param.toString(),erpConfig.getKingbosSecret(), erpConfig.getKingbosan(), timeStep);
+        String url = UrlUtils.getUrl(erpConfig.getKingbosUrl(),sign, timeStep);
         String result = HttpUtil.post(url, param.toString());
         logger.info("zyp \n【金博网络退货单】:"+result);
         KingbosOrderResponse response = JSONUtil.toBean(result, KingbosOrderResponse.class);
-        return response;
+        log.info("订单推送成功: {}", response);
+        ErpOrderResponse erpOrderResponse = new ErpOrderResponse();
+        erpOrderResponse.setCode(response.getCbilid());
+        return erpOrderResponse;
     }
 
-    @Override
-    public ErpOrderResponse addOmsOrder(Long orderId) {
+
+
+
+    /**
+     * 退款 运单号未获取到  改状态
+     * @param orderCode 订单编号
+     * @return
+     */
+    private ErpOrderResponse refundOmsOrder2(String orderCode) {
         try {
-            KingbosOrderResponse response = this.createOmsOrder(orderId, NO_DELIVERED.getCode());
+            KingbosOrderResponse response = createOmsOrder(orderCode, CANCELLED.getCode());
             if (response.getIsSuccess()){
                 log.info("订单推送成功: {}", response);
                 ErpOrderResponse erpOrderResponse = new ErpOrderResponse();
@@ -109,11 +176,14 @@ public class K9OrderServiceImpl implements K9OrderService {
         return new ErpOrderResponse();
     }
 
-    //运单号未获取到  改状态
-    @Override
-    public ErpOrderResponse refundOmsOrder(Long orderId) {
+    /**
+     * 通过订单编号推送订单 解析金博结果
+     * @param orderCode
+     * @return
+     */
+    private ErpOrderResponse addOmsOrder(String orderCode) {
         try {
-            KingbosOrderResponse response = this.createOmsOrder(orderId, CANCELLED.getCode());
+            KingbosOrderResponse response = this.createOmsOrder(orderCode, NO_DELIVERED.getCode());
             if (response.getIsSuccess()){
                 log.info("订单推送成功: {}", response);
                 ErpOrderResponse erpOrderResponse = new ErpOrderResponse();
@@ -129,11 +199,18 @@ public class K9OrderServiceImpl implements K9OrderService {
     }
 
 
-    private KingbosOrderResponse createOmsOrder(Long orderId,String orderStatus){
-        logger.info("【金博网络订单】开始创建订单,订单ID: {}", orderId);
+    /**
+     * 组装参数得到金博结果
+     * @param orderCode
+     * @param orderStatus
+     * @return
+     */
+    private KingbosOrderResponse createOmsOrder(String orderCode,String orderStatus){
+        logger.info("【金博网络订单】开始创建订单,订单Code: {}", orderCode);
         try {
             // 1. 获取订单信息并验证
-            FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderById(orderId);
+            FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderByOrderCode(orderCode);
+            logger.info("【金博网络订单】订单信息获取成功,订单id: {}", order.getId());
             logger.info("【金博网络订单】订单信息获取成功,订单号: {}", order.getOrderCode());
 
             // 2. 构建金博订单数据
@@ -157,13 +234,20 @@ public class K9OrderServiceImpl implements K9OrderService {
 //                logger.error("【金博网络订单】创建订单失败,订单ID: {}, 错误信息: {}", orderId, response.getErrmsg());
 //            }
         } catch (Exception e) {
-            logger.error("【金博网络订单】创建订单失败,订单ID: {}, 错误信息: {}", orderId, e.getMessage(), e);
+            logger.error("【金博网络订单】创建订单失败,订单Code: {}, 错误信息: {}", orderCode, e.getMessage(), e);
             throw e;
         }
     }
 
 
+    /**
+     * 组装订单推送参数
+     * @param order
+     * @param orderStatus
+     * @return
+     */
     private KingbosOrderData buildKingbosOrderData(FsStoreOrder order,String orderStatus) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         logger.debug("【金博网络订单】开始构建订单数据,订单号: {}", order.getOrderCode());
         KingbosOrderData data = new KingbosOrderData();
         // 设置基础信息
@@ -201,8 +285,8 @@ public class K9OrderServiceImpl implements K9OrderService {
         setReceiverInfo(data, order);
 
         // 设置仓库信息
-        data.setCwarehouse_code(sysConfig.getCwarehouseCode());
-        data.setCwarehouse_name(sysConfig.getCwarehouseName());
+        data.setCwarehouse_code(erpConfig.getCwarehouseCode());
+        data.setCwarehouse_name(erpConfig.getCwarehouseName());
 
         // 设置货到付款信息
         if (!order.getPayType().equals("1")) {
@@ -254,6 +338,13 @@ public class K9OrderServiceImpl implements K9OrderService {
         return d1Datas;
     }
 
+    private KingbosRefundOrderD1Data buildRefundOrderDetailItem(String orderId) {
+        KingbosRefundOrderD1Data item = new KingbosRefundOrderD1Data();
+        item.setCasId(orderId);
+        item.setCorderSource("MALL");
+        return item;
+    }
+
     private KingbosOrderD1Data buildOrderDetailItem(FsStoreOrderItem orderItem, String orderId) {
         FsStoreCartDTO cartDTO = JSONUtil.toBean(orderItem.getJsonInfo(), FsStoreCartDTO.class);
         BigDecimal quantity = new BigDecimal(orderItem.getNum());
@@ -274,6 +365,12 @@ public class K9OrderServiceImpl implements K9OrderService {
         return item;
     }
 
+    /**
+     * 发送请求
+     * @param data
+     * @param d1Datas
+     * @return
+     */
     private KingbosOrderResponse sendOrderRequest(KingbosOrderData data, List<KingbosOrderD1Data> d1Datas) {
         logger.info("【金博网络订单】开始发送订单请求,金博订单号: {}", data.getCo_id());
         KingbosOrderRequest request = new KingbosOrderRequest();
@@ -281,7 +378,7 @@ public class K9OrderServiceImpl implements K9OrderService {
         request.setD1_data(d1Datas);
 
         try {
-            KingbosOrderResponse response = this.addOrder(request);
+            KingbosOrderResponse response = addErpOrder(request);
             logger.info("【金博网络订单】订单请求发送成功,金博订单号: {}, 响应结果: {}", data.getCo_id(), response);
             return response;
         } catch (Exception e) {
@@ -289,4 +386,21 @@ public class K9OrderServiceImpl implements K9OrderService {
             throw e;
         }
     }
+
+    private KingbosOrderResponse addErpOrder(KingbosOrderRequest request) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        JSONObject param = JSONUtil.createObj();
+        param.set("key", "OL");
+        param.set("data", request.getData());
+        param.set("d1_data", request.getD1_data());
+        String timeStep = System.currentTimeMillis() + "";
+        logger.info("zyp \n【金博网络订单推送参数】:"+param);
+        String sign = SignUtils.sign(param.toString(),erpConfig.getKingbosSecret(), erpConfig.getKingbosan(), timeStep);
+        String url = UrlUtils.getUrl(erpConfig.getKingbosUrl(),sign, timeStep);
+        String json = param.toString();
+        String result = HttpUtil.post(url, json);
+        logger.info("zyp \n【金博网络订单推送返回】:"+result);
+        KingbosOrderResponse response = JSONUtil.toBean(result, KingbosOrderResponse.class);
+        return response;
+    }
 }

+ 92 - 0
fs-service-system/src/main/java/com/fs/erp/service/impl/K9StockServiceImpl.java

@@ -0,0 +1,92 @@
+package com.fs.erp.service.impl;
+
+import cn.hutool.crypto.SignUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.config.FSSysConfig;
+import com.fs.common.exception.CustomException;
+import com.fs.common.exception.ServiceException;
+import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.http.HttpUtils;
+import com.fs.erp.domain.ErpGoods;
+import com.fs.erp.domain.ErpGoodsStock;
+import com.fs.erp.domain.KbStockRequest;
+import com.fs.erp.domain.KbStockResponse;
+import com.fs.erp.dto.*;
+import com.fs.erp.service.IErpGoodsService;
+import com.fs.erp.utils.SignUtils;
+import com.fs.erp.utils.UrlUtils;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+
+@Service
+@Slf4j
+@AllArgsConstructor
+public class K9StockServiceImpl implements IErpGoodsService {
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+    @Override
+    public BaseResponse addGoods(ErpGoods goods) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsQueryResponse getGoods(ErpGoodsQueryRequert param) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsStockQueryResponse getGoodsStock(ErpGoodsStockQueryRequert param) {
+        String barcode = param.getBarcode();
+        KbStockRequest request = KbStockRequest.builder().goodsCode(barcode).build();
+        KbStockResponse kbStockResponse = getStock(request);
+        ErpGoodsStockQueryResponse response = new ErpGoodsStockQueryResponse();
+
+        if(kbStockResponse.getSuccess()){
+            ArrayList<ErpGoodsStock> erpGoodsStocks = new ArrayList<>();
+            ErpGoodsStock erpGoodsStock = new ErpGoodsStock();
+            Integer stocks = kbStockResponse.getStock();
+            erpGoodsStock.setBarcode(barcode);
+            erpGoodsStock.setQty(stocks.toString());
+            erpGoodsStock.setSalable_qty(stocks.toString());
+            erpGoodsStocks.add(erpGoodsStock);
+            response.setStocks(erpGoodsStocks);
+        } else {
+            throw new CustomException("库存不足");
+        }
+        return response;
+    }
+
+    /**
+     * 查看库存
+     * @param request 参数
+     * @return  KbStockResponse
+     * @throws ServiceException 异常
+     */
+    private KbStockResponse getStock(KbStockRequest request) throws ServiceException {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        // 构造参数
+        String timeStep = System.currentTimeMillis() + "";
+        if (StringUtils.isBlank(request.getStockCode())) {
+            request.setStockCode(erpConfig.getCwarehouseCode());
+        }
+        String json = JSON.toJSONString(request);
+        String sign = SignUtils.sign(json, erpConfig.getKingbosSecret(), erpConfig.getKingbosan(), timeStep);
+        String url = erpConfig.getKingbosUrl().replace("do=k9save", "do=k9view");
+        url = UrlUtils.getUrl(url, sign, timeStep);
+
+        // 发送请求
+        log.info("\n【金博网络】: getStock send request url: {}", url);
+        String result = HttpUtils.doPost(url, json);
+        log.info("\n【金博网络】: getStock res:{}", result);
+        return JSONObject.parseObject(result, KbStockResponse.class);
+    }
+}

+ 14 - 2
fs-service-system/src/main/java/com/fs/erp/service/impl/WdtErpOrderServiceImpl.java

@@ -16,6 +16,9 @@ import com.fs.erp.dto.sdk.wangdian.api.WdtClient;
 import com.fs.erp.dto.sdk.wangdian.enums.*;
 import com.fs.erp.dto.wdt.*;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.store.domain.FsStoreOrder;
 import com.fs.store.domain.FsStoreProduct;
 import com.fs.store.service.IFsStoreOrderItemService;
@@ -53,8 +56,11 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
     @Autowired
     private IFsStoreProductService fsStoreProductService;
 
-    @Value("${fsConfig.erpWdShopCode}")
-    private String shopCode;
+//    @Value("${fsConfig.erpWdShopCode}")
+//    private String shopCode;
+
+    @Autowired
+    ConfigUtil configUtil;
 
     /**
      * 普通推送
@@ -76,6 +82,9 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
      * @return
      */
     private ErpOrderResponse getErpOrderResponse(ErpOrder order,Integer type) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        String shopCode = erpConfig.getErpWdShopCode();
+
         WdtClient client = WdtClient.getInstance();
         //测试环境sid、appkey、密钥请到旺店通开放平台-自助对接-申请测试环境内查看,测试环境url=https://sandbox.wangdian.cn/openapi2/
         //调用正式环境时请将sid、appkey、appsecret切换为实际参数,参数在旺店通开放平台-自助对接-应用管理内应用状态为已上线的应用中查看,调用正式环境注意切换正式环境url=https://api.wangdian.cn/openapi2/
@@ -255,6 +264,9 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
 
     @Override
     public BaseResponse refundUpdate(ErpRefundUpdateRequest param) {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        String shopCode = erpConfig.getErpWdShopCode();
+
         log.info("退款单更新: {}", param);
         FsStoreOrder fsStoreOrder = fsStoreOrderService.selectFsStoreOrderByOrderCode(param.getTid());
 

+ 2 - 2
fs-service-system/src/main/java/com/fs/kingbos/util/SignUtil.java → fs-service-system/src/main/java/com/fs/erp/utils/SignUtils.java

@@ -1,9 +1,9 @@
-package com.fs.kingbos.util;
+package com.fs.erp.utils;
 
 
 import com.fs.ad.yk.utils.Md5Util;
 
-public class SignUtil {
+public class SignUtils {
 
     public static String sign(String data, String secret, String name, String timestamp) {
         String enValue = "kingbos" + secret + timestamp + name + "zy01" + data;

+ 2 - 2
fs-service-system/src/main/java/com/fs/kingbos/util/UrlUtil.java → fs-service-system/src/main/java/com/fs/erp/utils/UrlUtils.java

@@ -1,11 +1,11 @@
-package com.fs.kingbos.util;
+package com.fs.erp.utils;
 
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 
 
-public class UrlUtil {
+public class UrlUtils {
     public static String getUrl(String url, String sign, String timeStep) {
         String updatedUrl = updateURLParams(url, "timestep", timeStep);
         updatedUrl = updateURLParams(updatedUrl, "sign", sign);

+ 30 - 0
fs-service-system/src/main/java/com/fs/his/config/FsErpConfig.java

@@ -0,0 +1,30 @@
+package com.fs.his.config;
+
+import lombok.Data;
+
+@Data
+public class FsErpConfig {
+    //erp接口
+    Integer erpOpen;//是否开启ERP
+    Integer erpType;//1:管易 2:旺店通 3:金博
+    //管易
+    String erpAppKey;
+    String erpSessionKey;
+    String erpSecret;
+    String erpUrl;
+    String erpShopCode;//店铺CODE
+    //erp旺店通
+    String erpWdAppKey;
+    String erpWdAppsecret;
+    String erpWdSid;
+    String erpWdShopCode;
+    String erpWdBaseUrl;
+    String erpWarehouseCode;
+    //金博
+    String kingbosan;//账套名称
+    String kingbosSecret;//金博密钥
+    String kingbosUrl;//金博地址
+    String corgid;//机构编码
+    String cwarehouseCode;
+    String cwarehouseName;
+}

+ 13 - 0
fs-service-system/src/main/java/com/fs/his/utils/ConfigUtil.java

@@ -1,6 +1,7 @@
 package com.fs.his.utils;
 
 import com.alibaba.fastjson.JSON;
+import com.fs.his.config.FsErpConfig;
 import com.fs.his.config.FsSysConfig;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.mapper.SysConfigMapper;
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
 @Service
 public class ConfigUtil {
     FsSysConfig fsSysConfig;
+    FsErpConfig fsErpConfig;
     @Autowired
     SysConfigMapper sysConfigMapper;
     public FsSysConfig getSysConfig(){
@@ -23,4 +25,15 @@ public class ConfigUtil {
             return this.fsSysConfig ;
         }
     }
+    public FsErpConfig getErpConfig(){
+        if (this.fsErpConfig==null){
+            SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("erp.config");
+            String configValue = sysConfig.getConfigValue();
+            FsErpConfig config = JSON.parseObject(configValue, FsErpConfig.class);
+            this.fsErpConfig=config;
+            return this.fsErpConfig;
+        }else {
+            return this.fsErpConfig ;
+        }
+    }
 }

+ 0 - 18
fs-service-system/src/main/java/com/fs/kingbos/service/K9OrderService.java

@@ -1,18 +0,0 @@
-package com.fs.kingbos.service;
-
-import com.fs.erp.dto.ErpOrderResponse;
-import com.fs.kingbos.domian.KingbosOrderRequest;
-import com.fs.kingbos.domian.KingbosOrderResponse;
-import com.fs.kingbos.domian.KingbosRefundOrderRequest;
-
-import java.text.ParseException;
-
-public interface K9OrderService {
-    KingbosOrderResponse addOrder(KingbosOrderRequest request);
-
-    KingbosOrderResponse refundOrder(KingbosRefundOrderRequest request);
-
-    ErpOrderResponse addOmsOrder(Long orderId);
-
-    ErpOrderResponse refundOmsOrder(Long orderId);
-}

+ 0 - 19
fs-service-system/src/main/java/com/fs/kingbos/service/K9StockService.java

@@ -1,19 +0,0 @@
-package com.fs.kingbos.service;
-
-import com.fs.common.exception.ServiceException;
-import com.fs.kingbos.domian.KbStockRequest;
-import com.fs.kingbos.domian.KbStockResponse;
-
-/**
- * 库存服务
- */
-public interface K9StockService {
-
-    /**
-     * 查看库存
-     * @param request 入参
-     * @return  KbStockResponse
-     * @throws ServiceException 异常
-     */
-    KbStockResponse getStock(KbStockRequest request) throws ServiceException;
-}

+ 0 - 49
fs-service-system/src/main/java/com/fs/kingbos/service/impl/K9StockServiceImpl.java

@@ -1,49 +0,0 @@
-package com.fs.kingbos.service.impl;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.fs.common.config.FSSysConfig;
-import com.fs.common.exception.ServiceException;
-import com.fs.common.utils.StringUtils;
-import com.fs.common.utils.http.HttpUtils;
-import com.fs.kingbos.domian.KbStockRequest;
-import com.fs.kingbos.domian.KbStockResponse;
-import com.fs.kingbos.service.K9StockService;
-import com.fs.kingbos.util.SignUtil;
-import com.fs.kingbos.util.UrlUtil;
-import lombok.AllArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-@Service
-@Slf4j
-@AllArgsConstructor
-public class K9StockServiceImpl implements K9StockService {
-
-    private final FSSysConfig sysConfig;
-
-    /**
-     * 查看库存
-     * @param request 参数
-     * @return  KbStockResponse
-     * @throws ServiceException 异常
-     */
-    @Override
-    public KbStockResponse getStock(KbStockRequest request) throws ServiceException {
-        // 构造参数
-        String timeStep = System.currentTimeMillis() + "";
-        if (StringUtils.isBlank(request.getStockCode())) {
-            request.setStockCode(sysConfig.getCwarehouseCode());
-        }
-        String json = JSON.toJSONString(request);
-        String sign = SignUtil.sign(json, sysConfig.getKingbosSecret(), sysConfig.getKingbosan(), timeStep);
-        String url = sysConfig.getKingbosUrl().replace("do=k9save", "do=k9view");
-        url = UrlUtil.getUrl(url, sign, timeStep);
-
-        // 发送请求
-        log.info("\n【金博网络】: getStock send request url: {}", url);
-        String result = HttpUtils.doPost(url, json);
-        log.info("\n【金博网络】: getStock res:{}", result);
-        return JSONObject.parseObject(result, KbStockResponse.class);
-    }
-}

+ 30 - 30
fs-service-system/src/main/java/com/fs/store/domain/FsUserAddress.java

@@ -7,7 +7,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 用户地址对象 fs_user_address
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
@@ -40,7 +40,7 @@ public class FsUserAddress extends BaseEntity
 
     /** $column.columnComment */
     @Excel(name = "收货人所在市")
-    private Long cityId;
+    private String cityId;
 
     /** 收货人所在区 */
     @Excel(name = "收货人所在区")
@@ -70,129 +70,129 @@ public class FsUserAddress extends BaseEntity
     @Excel(name = "是否删除")
     private Integer isDel;
 
-    public void setId(Long id) 
+    public void setId(Long id)
     {
         this.id = id;
     }
 
-    public Long getId() 
+    public Long getId()
     {
         return id;
     }
-    public void setUserId(Long userId) 
+    public void setUserId(Long userId)
     {
         this.userId = userId;
     }
 
-    public Long getUserId() 
+    public Long getUserId()
     {
         return userId;
     }
-    public void setRealName(String realName) 
+    public void setRealName(String realName)
     {
         this.realName = realName.trim();
     }
 
-    public String getRealName() 
+    public String getRealName()
     {
         return realName;
     }
-    public void setPhone(String phone) 
+    public void setPhone(String phone)
     {
         this.phone = phone.trim();
     }
 
-    public String getPhone() 
+    public String getPhone()
     {
         return phone;
     }
-    public void setProvince(String province) 
+    public void setProvince(String province)
     {
         this.province = province;
     }
 
-    public String getProvince() 
+    public String getProvince()
     {
         return province;
     }
-    public void setCity(String city) 
+    public void setCity(String city)
     {
         this.city = city;
     }
 
-    public String getCity() 
+    public String getCity()
     {
         return city;
     }
-    public void setCityId(Long cityId) 
+    public void setCityId(String cityId)
     {
         this.cityId = cityId;
     }
 
-    public Long getCityId() 
+    public String getCityId()
     {
         return cityId;
     }
-    public void setDistrict(String district) 
+    public void setDistrict(String district)
     {
         this.district = district;
     }
 
-    public String getDistrict() 
+    public String getDistrict()
     {
         return district;
     }
-    public void setDetail(String detail) 
+    public void setDetail(String detail)
     {
         this.detail = detail.trim();
     }
 
-    public String getDetail() 
+    public String getDetail()
     {
         return detail;
     }
-    public void setPostCode(String postCode) 
+    public void setPostCode(String postCode)
     {
         this.postCode = postCode;
     }
 
-    public String getPostCode() 
+    public String getPostCode()
     {
         return postCode;
     }
-    public void setLongitude(String longitude) 
+    public void setLongitude(String longitude)
     {
         this.longitude = longitude;
     }
 
-    public String getLongitude() 
+    public String getLongitude()
     {
         return longitude;
     }
-    public void setLatitude(String latitude) 
+    public void setLatitude(String latitude)
     {
         this.latitude = latitude;
     }
 
-    public String getLatitude() 
+    public String getLatitude()
     {
         return latitude;
     }
-    public void setIsDefault(Integer isDefault) 
+    public void setIsDefault(Integer isDefault)
     {
         this.isDefault = isDefault;
     }
 
-    public Integer getIsDefault() 
+    public Integer getIsDefault()
     {
         return isDefault;
     }
-    public void setIsDel(Integer isDel) 
+    public void setIsDel(Integer isDel)
     {
         this.isDel = isDel;
     }
 
-    public Integer getIsDel() 
+    public Integer getIsDel()
     {
         return isDel;
     }

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/dto/TemplateDTO.java

@@ -17,5 +17,5 @@ public class TemplateDTO {
     private Double continues;
     private BigDecimal continuePrice;
     private Long tempId;
-    private Long cityId;
+    private String cityId;
 }

+ 62 - 13
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreCartServiceImpl.java

@@ -6,10 +6,14 @@ import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.erp.dto.ErpGoodsStockQueryRequert;
+import com.fs.erp.dto.ErpGoodsStockQueryResponse;
+import com.fs.erp.dto.ErpRefundUpdateRequest;
 import com.fs.erp.service.IErpGoodsService;
-import com.fs.kingbos.domian.KbStockRequest;
-import com.fs.kingbos.domian.KbStockResponse;
-import com.fs.kingbos.service.K9StockService;
+import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.store.domain.FsStoreCart;
 import com.fs.store.domain.FsStoreProductAttrValue;
 import com.fs.store.domain.FsStoreProductGroup;
@@ -26,6 +30,7 @@ import com.fs.store.service.IFsStoreCartService;
 import com.fs.store.vo.FsStoreCartVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
@@ -49,10 +54,21 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
     private FsStoreProductAttrValueMapper valueMapper;
     @Autowired
     private FsStoreProductGroupMapper productGroupMapper;
+    @Qualifier("erpGoodsServiceImpl")
+    private IErpGoodsService gyGoodsService;
+
     @Autowired
-    IErpGoodsService goodsService;
+    @Qualifier("wdtErpGoodsServiceImpl")
+    private IErpGoodsService wdtErpGoodsService;
+
     @Autowired
-    private K9StockService k9StockService;
+    @Qualifier("k9StockServiceImpl")
+    private IErpGoodsService k9StockService;
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+
 
     /**
      * 查询购物车
@@ -208,14 +224,17 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
 
     @Override
     public void checkProductStock(Long productId, Long productAttrValueId) {
+        IErpGoodsService goodsService = getErpService();
         log.info("检查库存 {} {}",productId,productAttrValueId);
         FsStoreProductAttrValue productAttrValue=valueMapper.selectFsStoreProductAttrValueById(productAttrValueId);
         if(StringUtils.isEmpty(productAttrValue.getGroupBarCode())){
             //单品
-            KbStockRequest request = KbStockRequest.builder().goodsCode(productAttrValue.getBarCode()).build();
-            KbStockResponse response = k9StockService.getStock(request);
-            if(response.getSuccess()){
-                int stocks = response.getStock();
+            ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
+            queryRequert.setBarcode(productAttrValue.getGroupBarCode());
+            ErpGoodsStockQueryResponse goodsStock = goodsService.getGoodsStock(queryRequert);
+            if(goodsStock != null && goodsStock.getStocks() != null && !goodsStock.getStocks().isEmpty()){
+
+                int stocks = Integer.valueOf(goodsStock.getStocks().get(0).getSalable_qty());
 
                 if(stocks<=0){
                     productAttrValue.setStock(0);
@@ -235,6 +254,7 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
             else{
                 throw new CustomException("未获取到库存");
             }
+
         }
         else{
             //组合码
@@ -246,10 +266,12 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
                 if(productGroupDTOS!=null){
                     for(StoreProductGroupDTO dto:productGroupDTOS){
                         FsStoreProductAttrValue attrValue=valueMapper.selectFsStoreProductAttrValueById(dto.getId());
-                        KbStockRequest request = KbStockRequest.builder().goodsCode(attrValue.getBarCode()).build();
-                        KbStockResponse response = k9StockService.getStock(request);
-                        if(response.getSuccess()){
-                            Integer stocks = response.getStock();
+                        ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
+                        queryRequert.setBarcode(attrValue.getGroupBarCode());
+                        ErpGoodsStockQueryResponse goodsStock = goodsService.getGoodsStock(queryRequert);
+                        if(goodsStock != null && goodsStock.getStocks() != null && !goodsStock.getStocks().isEmpty()){
+                            int stocks = Integer.valueOf(goodsStock.getStocks().get(0).getSalable_qty());
+
 
                             if(stocks<=0){
                                 attrValue.setStock(0);
@@ -293,4 +315,31 @@ public class FsStoreCartServiceImpl implements IFsStoreCartService
         return  fsStoreCartMapper.selectFsStoreCartCount(param);
     }
 
+    private IErpGoodsService getErpService(){
+        //判断是否开启erp
+        IErpGoodsService goodsService = null;
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        Integer erpOpen = erpConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1) {
+            //判断erp类型
+            Integer erpType = erpConfig.getErpType();
+            if (erpType != null) {
+
+
+                if (erpType == 1) {
+                    //管易
+                    goodsService = gyGoodsService;
+                } else if (erpType == 2) {
+                    //旺店通
+                    goodsService = wdtErpGoodsService;
+                } else if (erpType == 3) {
+                    //旺店通
+                    goodsService = k9StockService;
+                }
+            }
+        }
+        return goodsService;
+    }
+
+
 }

+ 54 - 14
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -41,11 +41,13 @@ import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.erp.domain.*;
 import com.fs.erp.dto.*;
+import com.fs.erp.service.IErpGoodsService;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
-import com.fs.kingbos.service.K9OrderService;
 import com.fs.pay.pay.domain.RefundResult;
 import com.fs.pay.pay.service.PayService;
 import com.fs.store.config.StoreConfig;
@@ -76,6 +78,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.aop.framework.AopContext;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationEventPublisher;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -145,8 +148,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     private IPayService payService;
     @Autowired
     private FSSysConfig sysConfig;
+
     @Autowired
-    IErpOrderService erpOrderService;
+    private ConfigUtil configUtil;
     @Autowired
     IFsStorePaymentService paymentService;
 
@@ -189,8 +193,18 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     private WxPayService wxPayService;
     @Autowired
     private WxPayProperties wxPayProperties;
-    @Value("${fsConfig.erpWarehouseCode}")
-    private String wareHouseCode;
+
+    @Autowired
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtOrderService;
+
+    @Autowired
+    @Qualifier("k9OrderServiceImpl")
+    private IErpOrderService k9OrderService;
     /**
      * 查询订单
      *
@@ -1333,17 +1347,16 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     }
 
 
-    @Autowired
-    private K9OrderService k9OrderService;
     @Override
     public void createOmsOrder(Long orderId) throws ParseException {
+        IErpOrderService erpOrderService = getErpService();
         FsStoreOrder order=fsStoreOrderMapper.selectFsStoreOrderById(orderId);
         if(!StringUtils.isEmpty(order.getExtendOrderId())&&order.getStatus()!=1){
             return;
         }
-//        ErpOrder erpOrder = getErpOrder(order);
-//        ErpOrderResponse response= erpOrderService.addOrder(erpOrder);
-        ErpOrderResponse response= k9OrderService.addOmsOrder(order.getId());
+        ErpOrder erpOrder = getErpOrder(order);
+        ErpOrderResponse response= erpOrderService.addOrder(erpOrder);
+//        ErpOrderResponse response= k9OrderService.addOmsOrder(order.getId());
 
         //写入日志
         logger.info("ErpCreate:"+order.getOrderCode()+":"+JSONUtil.toJsonStr(response));
@@ -1357,6 +1370,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 
     @Override
     public ErpOrder getErpOrder(FsStoreOrder order) throws ParseException {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
         ErpOrder erpOrder=new ErpOrder();
         if (order.getCompanyId()!=null){
             erpOrder.setVip_code(order.getUserId().toString()+ order.getCompanyId().toString());
@@ -1368,13 +1382,13 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 //            erpOrder.setWarehouse_code("CQDS001");
 //        }
 //        else{
-            erpOrder.setWarehouse_code(wareHouseCode);
+            erpOrder.setWarehouse_code(erpConfig.getErpWarehouseCode());
 //        }
 //        if(order.getStoreHouseCode().equals("YDSP001")){
 //            erpOrder.setShop_code("RunDayWuHan");
 //        }
 //        else{
-            erpOrder.setShop_code(sysConfig.getErpShopCode());
+            erpOrder.setShop_code(erpConfig.getErpShopCode());
 //        }
 //      erpOrder.setPost_fee(order.getTotalPostage().doubleValue());
         erpOrder.setSeller_memo(order.getMark());
@@ -1719,6 +1733,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     @Override
     @Transactional
     public R refundOrderMoney(Long orderId) {
+        IErpOrderService erpOrderService = getErpService();
         FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderById(orderId);
         if(order.getStatus()==-2){
             return R.error("已退款");
@@ -1837,6 +1852,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
 
     @Override
     public R updateExpress(FsStoreOrderExpressEditParam param) {
+        IErpOrderService erpOrderService = getErpService();
         FsStoreOrder order = fsStoreOrderMapper.selectFsStoreOrderById(param.getOrderId());
         if(order.getStatus()!=1){
             return R.error("只有待发货状态可以同步");
@@ -2299,10 +2315,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
             if (userAddress.getCityId() == null) {
                 return storePostage;
             }
-            Long cityId = userAddress.getCityId();
-            List<Long> citys = new ArrayList<>();
+            String cityId = userAddress.getCityId();
+            List<String> citys = new ArrayList<>();
             citys.add(cityId);
-            citys.add(0l);//城市包括默认
+            citys.add("0");//城市包括默认
             List<Long> tempIds = cartInfo
                     .stream()
                     .map(FsStoreCartQueryVO::getTempId)
@@ -2553,4 +2569,28 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     public List<FsStoreOrder> selectFsStoreOrderStatisticsByUserId(List<Long> fsUserIdList) {
         return fsStoreOrderMapper.selectFsStoreOrderStatisticsByUserId(fsUserIdList);
     }
+
+    private IErpOrderService getErpService(){
+        //判断是否开启erp
+        IErpOrderService erpOrderService = null;
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        Integer erpOpen = erpConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1) {
+            //判断erp类型
+            Integer erpType = erpConfig.getErpType();
+            if (erpType != null) {
+                if (erpType == 1) {
+                    //管易
+                    erpOrderService = gyOrderService;
+                } else if (erpType == 2) {
+                    //旺店通
+                    erpOrderService = wdtOrderService;
+                } else if (erpType == 3) {
+                    //旺店通
+                    erpOrderService = k9OrderService;
+                }
+            }
+        }
+        return erpOrderService;
+    }
 }

+ 12 - 12
fs-service-system/src/main/resources/application-config-zkzh.yml

@@ -14,20 +14,20 @@ fsConfig:
   erpUrl: http://v2.api.guanyierp.com/rest/erp_open
   erpShopCode: test
   #ERP-hc
-  erpWdAppKey: beiliyou2-test
-  erpWdAppsecret: 6ec212f06
-  erpWdSid: apidevnew2
-  erpWdShopCode: beiliyou2-test
-  erpWdBaseUrl: https://api.wangdian.cn/openapi2/
-  erpWarehouseCode: beiliyou2-test
+#  erpWdAppKey: beiliyou2-test
+#  erpWdAppsecret: 6ec212f06
+#  erpWdSid: apidevnew2
+#  erpWdShopCode: beiliyou2-test
+#  erpWdBaseUrl: https://api.wangdian.cn/openapi2/
+#  erpWarehouseCode: beiliyou2-test
 
   #金博ERP
-  kingbosan: "陕西中康"
-  kingbosSecret: 12CA1038CE8A45D1BA325898A3F2F029
-  kingbosUrl: http://zkyf888.gnway.cc:53868/?an=陕西中康&do=k9save&timestep=&sign=&corgid=zy01
-  corgid: zy01
-  cwarehouseCode: "CK01"
-  cwarehouseName: "合格仓"
+#  kingbosan: "陕西中康"
+#  kingbosSecret: 12CA1038CE8A45D1BA325898A3F2F029
+#  kingbosUrl: http://zkyf888.gnway.cc:53868/?an=陕西中康&do=k9save&timestep=&sign=&corgid=zy01
+#  corgid: zy01
+#  cwarehouseCode: "CK01"
+#  cwarehouseName: "合格仓"
   #第三方支付配置
   payOpen: 1
   payPartnerId: 22051909542647100020

+ 137 - 0
fs-service-system/src/main/resources/application-druid-dev.yml

@@ -0,0 +1,137 @@
+# 数据源配置
+spring:
+  # redis 配置
+  redis:
+    # 地址
+    host: 127.0.0.1
+    # 端口,默认为6379
+    port: 6379
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 30s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+    database: 0
+  datasource:
+    mysql:
+      type: com.alibaba.druid.pool.DruidDataSource
+      driverClassName: com.mysql.cj.jdbc.Driver
+      druid:
+        # 主库数据源
+        master:
+          url: jdbc:mysql://139.186.77.83:3306/ylrz_scrm?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+          username: Rtroot
+          password: Rtroot
+        # 从库数据源
+        slave:
+          # 从数据源开关/默认关闭
+          enabled: false
+          url:
+          username:
+          password:
+        # 初始连接数
+        initialSize: 5
+        # 最小连接池数量
+        minIdle: 10
+        # 最大连接池数量
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        # 配置一个连接在池中最大生存的时间,单位是毫秒
+        maxEvictableIdleTimeMillis: 900000
+        # 配置检测连接是否有效
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        webStatFilter:
+          enabled: true
+        statViewServlet:
+          enabled: true
+          # 设置白名单,不填则允许所有访问
+          allow:
+          url-pattern: /druid/*
+          # 控制台管理用户名和密码
+          login-username: fs
+          login-password: 123456
+        filter:
+          stat:
+            enabled: true
+            # 慢SQL记录
+            log-slow-sql: true
+            slow-sql-millis: 1000
+            merge-sql: true
+          wall:
+            config:
+              multi-statement-allow: true
+    sop:
+      type: com.alibaba.druid.pool.DruidDataSource
+      driverClassName: com.mysql.cj.jdbc.Driver
+      druid:
+        # 主库数据源
+        master:
+          url: jdbc:mysql://139.186.77.83:3306/sop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+          username: Rtroot
+          password: Rtroot
+        # 初始连接数
+        initialSize: 5
+        # 最小连接池数量
+        minIdle: 10
+        # 最大连接池数量
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        # 配置一个连接在池中最大生存的时间,单位是毫秒
+        maxEvictableIdleTimeMillis: 900000
+        # 配置检测连接是否有效
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        webStatFilter:
+          enabled: true
+        statViewServlet:
+          enabled: true
+          # 设置白名单,不填则允许所有访问
+          allow:
+          url-pattern: /druid/*
+          # 控制台管理用户名和密码
+          login-username: fs
+          login-password: 123456
+        filter:
+          stat:
+            enabled: true
+            # 慢SQL记录
+            log-slow-sql: true
+            slow-sql-millis: 1000
+            merge-sql: true
+          wall:
+            config:
+              multi-statement-allow: true
+rocketmq:
+  name-server: rmq-1243b25nj.rocketmq.gz.public.tencenttdmq.com:8080 # RocketMQ NameServer 地址
+  producer:
+    group: my-producer-group
+    access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+    secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey
+  consumer:
+    group: test-group
+    access-key: ak1243b25nj17d4b2dc1a03 # 替换为实际的 accessKey
+    secret-key: sk08a7ea1f9f4b0237 # 替换为实际的 secretKey

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/AddressController.java

@@ -61,7 +61,7 @@ public class AddressController extends  AppBaseController {
             cityVO.setPid(city.getParentId());
             cityVOS.add(cityVO);
         }
-        return R.ok().put("data", CityTreeUtil.list2TreeConverter(cityVOS, 0));
+        return R.ok().put("data", CityTreeUtil.list2TreeConverter(cityVOS, "0"));
 
     }
 

+ 90 - 11
fs-user-app/src/main/java/com/fs/app/controller/CommonController.java

@@ -20,7 +20,9 @@ import com.fs.erp.service.IErpGoodsService;
 import com.fs.erp.service.IErpOrderService;
 import com.fs.erp.service.IErpShopService;
 import com.fs.erp.service.IErpUserService;
+import com.fs.his.config.FsErpConfig;
 import com.fs.his.param.WxSendRedPacketParam;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.pay.pay.domain.OrderResult;
 import com.fs.pay.pay.dto.OrderQueryDTO;
 import com.fs.pay.pay.service.PayService;
@@ -48,6 +50,7 @@ import org.apache.commons.io.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.validation.annotation.Validated;
@@ -68,8 +71,6 @@ public class CommonController extends AppBaseController {
 	Logger logger = LoggerFactory.getLogger(CommonController.class);
 	@Autowired
     JwtUtils jwtUtils;
-	@Autowired
-	private ServerConfig serverConfig;
 	@Autowired
 	private ISysDictDataService dictDataService;
 
@@ -85,26 +86,43 @@ public class CommonController extends AppBaseController {
 	@Autowired
 	FSSysConfig fsSysConfig;
 	@Autowired
+	ConfigUtil configUtil;
+	@Autowired
 	IErpShopService erpShopService;
 	@Autowired
 	IErpUserService userService;
 	@Autowired
 	IPayService payService;
 	@Autowired
-	IErpOrderService erpOrderService;
-	@Autowired
-	IErpGoodsService goodsService;
-	@Autowired
 	PayService ybPayService;
 	@Autowired
 	private IFsWechatTemplateService wechatTemplateService;
+	@Autowired
+	@Qualifier("erpOrderServiceImpl")
+	private IErpOrderService gyOrderService;
+
+	@Autowired
+	@Qualifier("wdtErpOrderServiceImpl")
+	private IErpOrderService wdtOrderService;
+
+	@Autowired
+	@Qualifier("k9OrderServiceImpl")
+	private IErpOrderService k9OrderService;
 
+	@Qualifier("erpGoodsServiceImpl")
+	private IErpGoodsService gyGoodsService;
 
 	@Autowired
-	private RedisTemplate redisTemplate;
+	@Qualifier("wdtErpGoodsServiceImpl")
+	private IErpGoodsService wdtErpGoodsService;
+
+	@Autowired
+	@Qualifier("k9StockServiceImpl")
+	private IErpGoodsService k9StockService;
 
 	@Autowired
-	private FSSysConfig sysConfig;
+	private RedisTemplate redisTemplate;
+
 
 	@Autowired
 	private IFsExpressService expressService;
@@ -173,6 +191,7 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErpDeliverys")
 	public R testErpDeliverys(@RequestBody  ErpDeliverysRequest request) throws Exception
 	{
+		IErpOrderService erpOrderService = getErpOrderService();
 		request.setDetail_flag(true);
 		return R.ok().put("data", erpOrderService.getDeliver(request));
 	}
@@ -180,6 +199,7 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErpGetOrder")
 	public R testErpGetOrder(@RequestBody ErpOrderQueryRequert request) throws Exception
 	{
+		IErpOrderService erpOrderService = getErpOrderService();
 		return R.ok().put("data", erpOrderService.getOrder(request));
 	}
 
@@ -187,6 +207,7 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErpGetGoods")
 	public R testErpGetGoods(@RequestBody ErpGoodsQueryRequert request) throws Exception
 	{
+		IErpGoodsService goodsService = getErpGoodService();
 		return R.ok().put("data", goodsService.getGoods(request));
 	}
 
@@ -194,6 +215,7 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErpGetGoodsStock")
 	public R testErpGetGoodsStock(@RequestBody ErpGoodsStockQueryRequert request) throws Exception
 	{
+		IErpGoodsService goodsService = getErpGoodService();
 		return R.ok().put("data", goodsService.getGoodsStock(request));
 	}
 
@@ -204,8 +226,10 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testRefundErp")
 	public R testRefundErp() throws Exception
 	{
+		IErpOrderService erpOrderService = getErpOrderService();
+		FsErpConfig erpConfig = configUtil.getErpConfig();
 		ErpRefundOrder order=new ErpRefundOrder();
-		order.setShop_code(fsSysConfig.getErpShopCode());
+		order.setShop_code(erpConfig.getErpShopCode());
 		order.setVip_code("10000");
 		order.setType_code("001");
 		order.setTrade_platform_code("202211111110");
@@ -259,6 +283,7 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErpGoods")
 	public R testErpGoods() throws Exception
 	{
+		IErpGoodsService goodsService = getErpGoodService();
 		ErpGoods goods=new ErpGoods();
 		goods.setCode("11");
 		goods.setName("测试商品");
@@ -282,8 +307,10 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErp")
 	public R testErp() throws Exception
 	{
+		IErpOrderService erpOrderService = getErpOrderService();
+		FsErpConfig erpConfig = configUtil.getErpConfig();
 		ErpOrder order=new ErpOrder();
-		order.setShop_code(fsSysConfig.getErpShopCode());
+		order.setShop_code(erpConfig.getErpShopCode());
 		order.setVip_code("10000");
 		order.setPlatform_code("202211111110");
 		order.setWarehouse_code("CQDS001");
@@ -320,6 +347,7 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testRefundErp1")
 	public R testRefundErp1() throws Exception
 	{
+		IErpOrderService erpOrderService = getErpOrderService();
 		ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
 		request.setTid("1546383973272256512");
 		request.setOid("1546383973272256512");
@@ -330,10 +358,11 @@ public class CommonController extends AppBaseController {
 	@PostMapping("testErpAddUser")
 	public R testErpAddUser() throws Exception
 	{
+		FsErpConfig erpConfig = configUtil.getErpConfig();
 		ErpUser user=new ErpUser();
 		user.setCode("test001");
 		user.setName("测试001");
-		user.setShop_code(fsSysConfig.getErpShopCode());
+		user.setShop_code(erpConfig.getErpShopCode());
 		List<ErpUserAddress> receive_infos=new ArrayList<>();
 		ErpUserAddress address=new ErpUserAddress();
 		// address.setAddress("详细地址");
@@ -658,6 +687,56 @@ public class CommonController extends AppBaseController {
 //		return R.ok();
 //	}
 
+	private IErpOrderService getErpOrderService(){
+		//判断是否开启erp
+		IErpOrderService erpOrderService = null;
+		FsErpConfig erpConfig = configUtil.getErpConfig();
+		Integer erpOpen = erpConfig.getErpOpen();
+		if (erpOpen != null && erpOpen == 1) {
+			//判断erp类型
+			Integer erpType = erpConfig.getErpType();
+			if (erpType != null) {
+				if (erpType == 1) {
+					//管易
+					erpOrderService = gyOrderService;
+				} else if (erpType == 2) {
+					//旺店通
+					erpOrderService = wdtOrderService;
+				} else if (erpType == 3) {
+					//旺店通
+					erpOrderService = k9OrderService;
+				}
+			}
+		}
+		return erpOrderService;
+	}
+
+	private IErpGoodsService getErpGoodService(){
+		//判断是否开启erp
+		IErpGoodsService goodsService = null;
+		FsErpConfig erpConfig = configUtil.getErpConfig();
+		Integer erpOpen = erpConfig.getErpOpen();
+		if (erpOpen != null && erpOpen == 1) {
+			//判断erp类型
+			Integer erpType = erpConfig.getErpType();
+			if (erpType != null) {
+
+
+				if (erpType == 1) {
+					//管易
+					goodsService = gyGoodsService;
+				} else if (erpType == 2) {
+					//旺店通
+					goodsService = wdtErpGoodsService;
+				} else if (erpType == 3) {
+					//旺店通
+					goodsService = k9StockService;
+				}
+			}
+		}
+		return goodsService;
+	}
+
 
 
 

+ 43 - 6
fs-user-app/src/main/java/com/fs/app/controller/StoreOrderController.java

@@ -17,10 +17,11 @@ import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.ip.IpUtils;
 import com.fs.erp.service.IErpOrderService;
+import com.fs.his.config.FsErpConfig;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.service.HuiFuService;
-import com.fs.kingbos.service.K9OrderService;
 import com.fs.pay.pay.domain.OrderResult;
 import com.fs.pay.pay.dto.OrderQueryDTO;
 import com.fs.pay.pay.service.PayService;
@@ -51,6 +52,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -61,8 +63,6 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 
-import static com.fs.kingbos.enums.OrderStatusEnum.NO_DELIVERED;
-
 
 @Api("商城接口")
 @RestController
@@ -108,13 +108,50 @@ public class StoreOrderController extends  AppBaseController {
     @Autowired
     private HuiFuService huiFuService;
     @Autowired
-    K9OrderService k9OrderService;
+    @Qualifier("erpOrderServiceImpl")
+    private IErpOrderService gyOrderService;
+
+    @Autowired
+    @Qualifier("wdtErpOrderServiceImpl")
+    private IErpOrderService wdtOrderService;
+
+    @Autowired
+    @Qualifier("k9OrderServiceImpl")
+    private IErpOrderService k9OrderService;
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+    private IErpOrderService getErpService(){
+        //判断是否开启erp
+        IErpOrderService erpOrderService = null;
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        Integer erpOpen = erpConfig.getErpOpen();
+        if (erpOpen != null && erpOpen == 1) {
+            //判断erp类型
+            Integer erpType = erpConfig.getErpType();
+            if (erpType != null) {
+                if (erpType == 1) {
+                    //管易
+                    erpOrderService = gyOrderService;
+                } else if (erpType == 2) {
+                    //旺店通
+                    erpOrderService = wdtOrderService;
+                } else if (erpType == 3) {
+                    //旺店通
+                    erpOrderService = k9OrderService;
+                }
+            }
+        }
+        return erpOrderService;
+    }
 
 
     @ApiOperation("测试ERP")
     @GetMapping("/test")
     public R test(){
-        k9OrderService.addOmsOrder(172L);
+        IErpOrderService erpOrderService = getErpService();
+//        erpOrderService.addOmsOrder(172L);
 //        k9OrderService.refundOmsOrder(172L);
         return R.ok();
     }
@@ -123,7 +160,7 @@ public class StoreOrderController extends  AppBaseController {
     @ApiOperation("测试ERP")
     @GetMapping("/test2")
     public R test2(){
-        k9OrderService.refundOmsOrder(172L);
+//        k9OrderService.refundOmsOrder(172L);
 //        k9OrderService.refundOmsOrder(172L);
         return R.ok();
     }

+ 2 - 2
fs-user-app/src/main/java/com/fs/app/utils/CityTreeUtil.java

@@ -16,13 +16,13 @@ public class CityTreeUtil {
      * @param parentId
      * @return
      */
-    public static List<CityVO> list2TreeConverter(List<CityVO> list, int parentId) {
+    public static List<CityVO> list2TreeConverter(List<CityVO> list, String parentId) {
         List<CityVO> returnList = new ArrayList<>();
 
         for (CityVO res : list) {
             //判断对象是否为根节点
 
-            if (Integer.parseInt(res.getPid()) == parentId) {
+            if (res.getPid().equals(parentId)) {
                 //该节点为根节点,开始递归
 
                 //通过递归为节点设置childList