Forráskód Böngészése

feat: jst ERP对接

xdd 1 hete
szülő
commit
9ca3458bba

+ 23 - 4
fs-admin/src/test/java/com/fs/store/controller/FsStorePaymentControllerTest.java

@@ -1,9 +1,14 @@
 package com.fs.store.controller;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSON;
 import com.fs.FSAdminApplication;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
+import com.fs.erp.dto.GetInitTokenRequestDTO;
+import com.fs.erp.dto.GetInitTokenResponseDTO;
+import com.fs.erp.http.JstErpHttpService;
+import com.fs.erp.utils.SignUtil;
 import com.fs.huifuPay.dto.*;
 import com.fs.pay.pay.domain.OrderResult;
 import com.fs.pay.pay.dto.OrderQueryDTO;
@@ -42,10 +47,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = FSAdminApplication.class)
@@ -81,6 +83,23 @@ public class FsStorePaymentControllerTest {
     private StoreTask storeTask;
 
 
+    @Autowired
+    private JstErpHttpService httpService;
+
+    @Test
+    public void initJstToken(){
+        GetInitTokenRequestDTO requestDTO = new GetInitTokenRequestDTO();
+        requestDTO.setAppKey("b0b7d1db226d4216a3d58df9ffa2dde5");
+        requestDTO.setGrantType("authorization_code");
+        requestDTO.setCharset("utf-8");
+        requestDTO.setCode("4xFIOC");
+        Map<String, Object> paramMap = BeanUtil.beanToMap(requestDTO);
+
+        requestDTO.setSign(SignUtil.getSign("99c4cef262f34ca882975a7064de0b87",paramMap));
+        GetInitTokenResponseDTO initToken = httpService.getInitToken(requestDTO);
+        log.info(JSON.toJSONString(initToken));
+    }
+
     /**
      * 补事务id
      */

+ 34 - 0
fs-service-system/src/main/java/com/fs/erp/dto/CommonResponse.java

@@ -0,0 +1,34 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+
+/**
+ * 通用响应DTO
+ *
+ * @author xdd
+ * @since 2025-02-27
+ * @version 1.0
+ */
+@Data
+@Accessors(chain = true)
+public class CommonResponse<T> implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 错误码
+     */
+    private Integer code;
+
+    /**
+     * 错误描述
+     */
+    private String msg;
+
+    /**
+     * 响应数据
+     */
+    private T data;
+}

+ 51 - 0
fs-service-system/src/main/java/com/fs/erp/dto/GetInitTokenRequestDTO.java

@@ -0,0 +1,51 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 获取初始化Token请求DTO
+ *
+ * @author xdd
+ * @version 1.0
+ * @date 2025-02-27
+ * @since 1.0
+ */
+@Data
+@Accessors(chain = true)
+public class GetInitTokenRequestDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 开发者应用Key
+     */
+    private String appKey;
+
+    /**
+     * 当前请求的时间戳(单位:秒)
+     */
+    private String timestamp;
+
+    /**
+     * 授权类型(固定值:authorization_code)
+     */
+    private String grantType;
+
+    /**
+     * 交互数据编码(固定值:utf-8)
+     */
+    private String charset;
+
+    /**
+     * 随机码(六位随机字符串)
+     */
+    private String code;
+
+    /**
+     * 数字签名
+     */
+    private String sign;
+}

+ 41 - 0
fs-service-system/src/main/java/com/fs/erp/dto/GetInitTokenResponseDTO.java

@@ -0,0 +1,41 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 获取初始化Token响应DTO
+ *
+ * @author xdd
+ * @version 1.0
+ * @date 2025-02-27
+ * @since 1.0
+ */
+@Data
+@Accessors(chain = true)
+public class GetInitTokenResponseDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 访问令牌
+     */
+    private String accessToken;
+
+    /**
+     * access_token访问过期时间(单位:秒)
+     */
+    private Integer expiresIn;
+
+    /**
+     * 更新令牌
+     */
+    private String refreshToken;
+
+    /**
+     * 权限范围(固定值:all)
+     */
+    private String scope;
+}

+ 296 - 0
fs-service-system/src/main/java/com/fs/erp/dto/GoodsInfoDTO.java

@@ -0,0 +1,296 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import java.util.List;
+import java.math.BigDecimal;
+import java.io.Serializable;
+
+/**
+ * 商品信息DTO
+ *
+ * @author xdd
+ * @date 2025-02-27
+ * @version 1.0.0
+ */
+@Data
+public class GoodsInfoDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 商品列表
+     */
+    private List<GoodsItem> items;
+
+    @Data
+    public static class GoodsItem implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 商品编码
+         */
+        private String skuId;
+
+        /**
+         * 款式编码
+         */
+        private String iId;
+
+        /**
+         * 品牌
+         */
+        private String brand;
+
+        /**
+         * 虚拟分类
+         */
+        private String vcName;
+
+        /**
+         * 商品分类
+         */
+        private String cName;
+
+        /**
+         * 基本售价
+         */
+        private BigDecimal sPrice;
+
+        /**
+         * 商品属性
+         */
+        private String itemType;
+
+        /**
+         * 长度
+         */
+        private BigDecimal l;
+
+        /**
+         * 宽度
+         */
+        private BigDecimal w;
+
+        /**
+         * 高度
+         */
+        private BigDecimal h;
+
+        /**
+         * 图片地址(款图片)
+         */
+        private String pic;
+
+        /**
+         * 大图地址
+         */
+        private String picBig;
+
+        /**
+         * 商品图片(SKU图片)
+         */
+        private String skuPic;
+
+        /**
+         * 商品名称
+         */
+        private String name;
+
+        /**
+         * 备注
+         */
+        private String remark;
+
+        /**
+         * 颜色及规格
+         */
+        private String propertiesValue;
+
+        /**
+         * 简称
+         */
+        private String shortName;
+
+        /**
+         * 重量
+         */
+        private BigDecimal weight;
+
+        /**
+         * 是否启用 -1=禁用,0=备用,1=启用
+         */
+        private Integer enabled;
+
+        /**
+         * 供应商名称
+         */
+        private String supplierName;
+
+        /**
+         * 国标码
+         */
+        private String skuCode;
+
+        /**
+         * 供应商商品编码
+         */
+        private String supplierSkuId;
+
+        /**
+         * 供应商款式编码
+         */
+        private String supplierIId;
+
+        /**
+         * 其它价格1
+         */
+        private BigDecimal otherPrice1;
+
+        /**
+         * 其它价格2
+         */
+        private BigDecimal otherPrice2;
+
+        /**
+         * 其它价格3
+         */
+        private BigDecimal otherPrice3;
+
+        /**
+         * 其它价格4
+         */
+        private BigDecimal otherPrice4;
+
+        /**
+         * 其它价格5
+         */
+        private BigDecimal otherPrice5;
+
+        /**
+         * 其它属性1
+         */
+        private String other1;
+
+        /**
+         * 其它属性2
+         */
+        private String other2;
+
+        /**
+         * 其它属性3
+         */
+        private String other3;
+
+        /**
+         * 其它属性4
+         */
+        private String other4;
+
+        /**
+         * 其它属性5
+         */
+        private String other5;
+
+        /**
+         * 禁止同步
+         */
+        private Boolean stockDisabled;
+
+        /**
+         * 成本价
+         */
+        private BigDecimal cPrice;
+
+        /**
+         * 市场价/吊牌价
+         */
+        private BigDecimal marketPrice;
+
+        /**
+         * 单位
+         */
+        private String unit;
+
+        /**
+         * 标签列表
+         */
+        private List<String> labels;
+
+        /**
+         * 是否启用生产批次
+         */
+        private Boolean batchEnabled;
+
+        /**
+         * 是否启用序列号
+         */
+        private Boolean isSeriesNumber;
+
+        /**
+         * 辅助码
+         */
+        private String otherCode;
+
+        /**
+         * 保质期天数
+         */
+        private Integer shelfLife;
+
+        /**
+         * 临期天数
+         */
+        private Integer handDay;
+
+        /**
+         * 保质期禁收天数
+         */
+        private Integer rejectLifecycle;
+
+        /**
+         * 保质期禁售天数
+         */
+        private Integer lockupLifecycle;
+
+        /**
+         * 保质期临期预警天数
+         */
+        private Integer adventLifecycle;
+
+        /**
+         * 商品类目属性
+         */
+        private CategoryProperty categoryPropertys;
+
+        /**
+         * 移除标签列表
+         */
+        private List<String> deletedlabels;
+
+        /**
+         * 生产许可证
+         */
+        private String productionLicence;
+
+        /**
+         * 采购价
+         */
+        private BigDecimal purchasePrice;
+
+        /**
+         * 是否校验组合装商品编码
+         */
+        private Boolean isNormal;
+    }
+
+    @Data
+    public static class CategoryProperty implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 年份
+         */
+        private String year;
+    }
+}

+ 49 - 0
fs-service-system/src/main/java/com/fs/erp/dto/JstCommonRequestDTO.java

@@ -0,0 +1,49 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+
+/**
+ * 聚水潭API公共请求参数DTO
+ *
+ * @author xdd
+ * @version 1.0
+ * @since 2025-02-27
+ */
+@Data
+@Accessors(chain = true)
+public class JstCommonRequestDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * POP分配给应用的app_key
+     */
+    private String appKey;
+
+    /**
+     * 通过code获取的access_token
+     */
+    private String accessToken;
+
+    /**
+     * UNIX时间戳,单位秒,需要与聚水潭服务器时间差值在10分钟内
+     */
+    private Long timestamp;
+
+    /**
+     * 字符编码(固定值:utf-8)
+     */
+    private String charset;
+
+    /**
+     * 版本号,固定传2
+     */
+    private String version;
+
+    /**
+     * 数字签名
+     */
+    private String sign;
+}

+ 112 - 0
fs-service-system/src/main/java/com/fs/erp/dto/ProductQueryRequestDTO.java

@@ -0,0 +1,112 @@
+package com.fs.erp.dto;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * 商品查询请求DTO
+ *
+ * @author xdd
+ * @version 1.0
+ * @since 2025-02-27
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "商品查询请求对象", description = "商品查询请求参数")
+public class ProductQueryRequestDTO {
+
+    /**
+     * 第几页,从第一页开始,默认1
+     */
+    @ApiModelProperty(value = "第几页,从第一页开始,默认1", example = "1")
+    private Integer pageIndex;
+
+    /**
+     * 每页多少条,默认30,最大100
+     */
+    @ApiModelProperty(value = "每页多少条,默认30,最大100", example = "10")
+    private Integer pageSize;
+
+    /**
+     * 修改起始时间
+     */
+    @ApiModelProperty(value = "修改起始时间,和结束时间必须同时存在,时间间隔不能超过七天", example = "2021-12-01 18:34:13")
+    private String modifiedBegin;
+
+    /**
+     * 修改结束时间
+     */
+    @ApiModelProperty(value = "修改结束时间,和起始时间必须同时存在,时间间隔不能超过七天", example = "2021-12-08 18:34:13")
+    private String modifiedEnd;
+
+    /**
+     * 商品编码列表,最多20个
+     */
+    @ApiModelProperty(value = "商品编码,与修改时间不能同时为空,最多20个", example = "D0005J15101,D0005J20101")
+    private String skuIds;
+
+    /**
+     * 商品名称(精确搜索)
+     */
+    @ApiModelProperty(value = "商品名称,与修改时间不能同时为空,仅支持传一个名称(精确搜索)", example = "A01")
+    private String exactlyName;
+
+    /**
+     * 商品名称(模糊查询)
+     */
+    @ApiModelProperty(value = "商品名称,与修改时间不能同时为空,仅支持传一个名称(模糊查询)")
+    private String name;
+
+    /**
+     * 品牌列表
+     */
+    @ApiModelProperty(value = "品牌列表")
+    private List<String> brand;
+
+    /**
+     * 款式编码列表
+     */
+    @ApiModelProperty(value = "款式编码列表")
+    private List<String> iIds;
+
+    /**
+     * 查询字段类型
+     */
+    @ApiModelProperty(value = "可传created,modified。默认按照modified查询")
+    private String dateField;
+
+    /**
+     * 自定义查询字段,多个字段用逗号分开
+     */
+    @ApiModelProperty(value = "可传:purchase_price 采购价,多个字段用逗号分开")
+    private String flds;
+
+    /**
+     * 辅助码
+     */
+    @ApiModelProperty(value = "辅助码,与修改时间不能同时为空")
+    private String skuCodes;
+
+    /**
+     * 包含标签列表
+     */
+    @ApiModelProperty(value = "包含标签列表")
+    private List<String> labels;
+
+    /**
+     * 排除标签列表
+     */
+    @ApiModelProperty(value = "排除标签列表")
+    private List<String> notLabels;
+
+    /**
+     * 是否查询库容信息
+     */
+    @ApiModelProperty(value = "是否查询库容信息")
+    private Boolean loadSkuBin;
+}

+ 405 - 0
fs-service-system/src/main/java/com/fs/erp/dto/ProductResponseDTO.java

@@ -0,0 +1,405 @@
+package com.fs.erp.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 商品信息响应DTO
+ *
+ * @author xdd
+ * @date 2025-02-27
+ * @version 1.0
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProductResponseDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 每页多少条
+     */
+    private Integer pageSize;
+
+    /**
+     * 第几页
+     */
+    private Integer pageIndex;
+
+    /**
+     * 总条数
+     */
+    private Integer dataCount;
+
+    /**
+     * 总页数
+     */
+    private Integer pageCount;
+
+    /**
+     * 是否有下一页
+     */
+    private Boolean hasNext;
+
+    /**
+     * 数据集合
+     */
+    private List<ProductInfo> datas;
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class ProductInfo implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 商品编码
+         */
+        private String skuId;
+
+        /**
+         * 款式编码
+         */
+        private String iId;
+
+        /**
+         * 商品名称
+         */
+        private String name;
+
+        /**
+         * 商品简称
+         */
+        private String shortName;
+
+        /**
+         * 销售价
+         */
+        private BigDecimal salePrice;
+
+        /**
+         * 成本价
+         */
+        private BigDecimal costPrice;
+
+        /**
+         * 颜色规格
+         */
+        private String propertiesValue;
+
+        /**
+         * 颜色
+         */
+        private String color;
+
+        /**
+         * 类目id
+         */
+        private Integer cId;
+
+        /**
+         * 分类
+         */
+        private String category;
+
+        /**
+         * 大图地址
+         */
+        private String picBig;
+
+        /**
+         * 图片地址
+         */
+        private String pic;
+
+        /**
+         * 是否启用,0:备用,1:启用,-1:禁用
+         */
+        private Integer enabled;
+
+        /**
+         * 重量
+         */
+        private BigDecimal weight;
+
+        /**
+         * 市场价
+         */
+        private BigDecimal marketPrice;
+
+        /**
+         * 品牌
+         */
+        private String brand;
+
+        /**
+         * 供应商编号
+         */
+        private String supplierId;
+
+        /**
+         * 供应商名称
+         */
+        private String supplierName;
+
+        /**
+         * 修改时间
+         */
+        private String modified;
+
+        /**
+         * 国标码
+         */
+        private String skuCode;
+
+        /**
+         * 供应商商品编码
+         */
+        private String supplierSkuId;
+
+        /**
+         * 供应商商品款号
+         */
+        private String supplierIId;
+
+        /**
+         * 虚拟分类
+         */
+        private String vcName;
+
+        /**
+         * 商品类型
+         */
+        private String skuType;
+
+        /**
+         * 创建者
+         */
+        private Integer creator;
+
+        /**
+         * 创建时间
+         */
+        private String created;
+
+        /**
+         * 备注
+         */
+        private String remark;
+
+        /**
+         * 商品属性,成品,半成品,原材料,包材
+         */
+        private String itemType;
+
+        /**
+         * 是否禁止同步,0=启用同步,1=禁用同步,2=部分禁用
+         */
+        private Integer stockDisabled;
+
+        /**
+         * 单位
+         */
+        private String unit;
+
+        /**
+         * 保质期
+         */
+        private Integer shelfLife;
+
+        /**
+         * 商品标签,多个标签时以逗号分隔
+         */
+        private String labels;
+
+        /**
+         * 生产许可证
+         */
+        private String productionLicence;
+
+        /**
+         * 长
+         */
+        private BigDecimal l;
+
+        /**
+         * 宽
+         */
+        private BigDecimal w;
+
+        /**
+         * 高
+         */
+        private BigDecimal h;
+
+        /**
+         * 是否开启序列号
+         */
+        private Boolean isSeriesNumber;
+
+        /**
+         * 其他价格1
+         */
+        private BigDecimal otherPrice1;
+
+        /**
+         * 其他价格2
+         */
+        private BigDecimal otherPrice2;
+
+        /**
+         * 其他价格3
+         */
+        private BigDecimal otherPrice3;
+
+        /**
+         * 其他价格4
+         */
+        private BigDecimal otherPrice4;
+
+        /**
+         * 其他价格5
+         */
+        private BigDecimal otherPrice5;
+
+        /**
+         * 其他价格6
+         */
+        private BigDecimal otherPrice6;
+
+        /**
+         * 其他价格7
+         */
+        private BigDecimal otherPrice7;
+
+        /**
+         * 其他价格8
+         */
+        private BigDecimal otherPrice8;
+
+        /**
+         * 其他价格9
+         */
+        private BigDecimal otherPrice9;
+
+        /**
+         * 其他价格10
+         */
+        private BigDecimal otherPrice10;
+
+        /**
+         * 其他属性1
+         */
+        private String other1;
+
+        /**
+         * 其他属性2
+         */
+        private String other2;
+
+        /**
+         * 其他属性3
+         */
+        private String other3;
+
+        /**
+         * 其他属性4
+         */
+        private String other4;
+
+        /**
+         * 其他属性5
+         */
+        private String other5;
+
+        /**
+         * 其他属性6
+         */
+        private String other6;
+
+        /**
+         * 其他属性7
+         */
+        private String other7;
+
+        /**
+         * 其他属性8
+         */
+        private String other8;
+
+        /**
+         * 其他属性9
+         */
+        private String other9;
+
+        /**
+         * 其他属性10
+         */
+        private String other10;
+
+        /**
+         * 链接同步状态
+         */
+        private String stockType;
+
+        /**
+         * 辅助码
+         */
+        private String skuCodes;
+
+        /**
+         * 唯一id,系统自增id(若商品编码有被修改可以用此字段判断唯一)
+         */
+        private Integer autoid;
+
+        /**
+         * 是否开启生产批次开关
+         */
+        private String batchEnabled;
+
+        /**
+         * 主仓位
+         */
+        private String bin;
+
+        /**
+         * 补充仓位
+         */
+        private String otherBin;
+
+        /**
+         * 库容下限
+         */
+        private BigDecimal minQty;
+
+        /**
+         * 库容上限
+         */
+        private BigDecimal maxQty;
+
+        /**
+         * 溢出数量
+         */
+        private BigDecimal overflowQty;
+
+        /**
+         * 标准装箱数量
+         */
+        private BigDecimal packQty;
+
+        /**
+         * 标准装箱体积
+         */
+        private BigDecimal packVolume;
+    }
+}

+ 51 - 0
fs-service-system/src/main/java/com/fs/erp/dto/ProductUploadResponseDTO.java

@@ -0,0 +1,51 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 商品上传响应数据DTO
+ * 用于封装商品上传后的响应信息
+ *
+ * @author xdd
+ * @since 2025-02-27
+ * @version 1.0
+ */
+@Data
+@Accessors(chain = true)
+public class ProductUploadResponseDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 上传结果列表
+     */
+    private List<ProductUploadDetail> datas;
+
+    /**
+     * 商品上传详情
+     */
+    @Data
+    @Accessors(chain = true)
+    public static class ProductUploadDetail implements Serializable {
+
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * 是否上传成功
+         */
+        private String isSuccess;
+
+        /**
+         * 商品编码
+         */
+        private String skuId;
+
+        /**
+         * 执行信息
+         */
+        private String msg;
+    }
+}

+ 36 - 0
fs-service-system/src/main/java/com/fs/erp/dto/ProductUploadResultDTO.java

@@ -0,0 +1,36 @@
+package com.fs.erp.dto;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+
+/**
+ * 商品上传结果DTO
+ *
+ * @author xdd
+ * @date 2025-02-27
+ * @version 1.0
+ * @since 1.0
+ */
+@Data
+@Accessors(chain = true)
+public class ProductUploadResultDTO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 是否上传成功
+     */
+    private String isSuccess;
+
+    /**
+     * 商品编码
+     */
+    private String skuId;
+
+    /**
+     * 执行信息
+     */
+    private String msg;
+
+}

+ 43 - 0
fs-service-system/src/main/java/com/fs/erp/http/JstErpHttpService.java

@@ -0,0 +1,43 @@
+package com.fs.erp.http;
+
+import com.fs.erp.dto.*;
+
+/**
+ * JST ERP 接口服务类
+ */
+public interface JstErpHttpService {
+    /**
+     * 获取access_token、refresh_token
+     *
+     * 开放平台对token的过期时间默认设置为<strong>30天</strong>
+     * 过期前12小时内调用才会有效,
+     * 调用成功后生成新的access_token原access_token有5分钟的过期时间,5分钟后失效
+     * @param dto 请求参数
+     * @return GetInitTokenResponseDTO
+     */
+    GetInitTokenResponseDTO getInitToken(GetInitTokenRequestDTO dto);
+
+    /**
+     * 更新access_token、refresh_token
+     * 开放平台对token的过期时间默认设置为30天,如开发者的token过期未换,无法再调用更新token这个接口需要返回上一步骤重新授权。
+     * 15天内刷新无效,刷新成功后原access_token有5分钟的过期时间
+     * @param dto 请求参数
+     * @return GetInitTokenResponseDTO
+     */
+    GetInitTokenResponseDTO refreshToken(GetInitTokenRequestDTO dto);
+
+    /**
+     * 普通商品资料上传
+     * @param dto 请求参数
+     * @return ProductUploadResultDTO
+     */
+    ProductUploadResultDTO uploadGoods(GoodsInfoDTO dto);
+
+    /**
+     * 普通商品资料查询(按sku查询)
+     * @param dto 请求参数
+     * @return ProductResponseDTO
+     */
+    ProductResponseDTO queryGoods(ProductQueryRequestDTO dto);
+
+}

+ 71 - 0
fs-service-system/src/main/java/com/fs/erp/http/JstErpHttpServiceImpl.java

@@ -0,0 +1,71 @@
+package com.fs.erp.http;
+
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+import com.fs.erp.dto.*;
+import org.apache.commons.lang.ObjectUtils;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class JstErpHttpServiceImpl implements JstErpHttpService{
+
+    private static final String BASE_URL = "https://openapi.jushuitan.com/";
+    /**
+     * 获取access_token、refresh_token url
+     */
+    private static final String GET_INIT_TOKEN_URL = BASE_URL+"openWeb/auth/getInitToken";
+
+    /**
+     * 更新access_token、refresh_token url
+     */
+    private static final String REFRESH_TOKEN_URL = BASE_URL+"openWeb/auth/refreshToken";
+
+
+    @Override
+    public GetInitTokenResponseDTO getInitToken(GetInitTokenRequestDTO dto) {
+        String post = HttpUtil.post(GET_INIT_TOKEN_URL, JSON.toJSONString(dto));
+
+        TypeReference<CommonResponse<GetInitTokenResponseDTO>> typeReference = new TypeReference<CommonResponse<GetInitTokenResponseDTO>>(){};
+        CommonResponse<GetInitTokenResponseDTO> response = JSON.parseObject(post, typeReference);
+        if(ObjectUtils.notEqual(response.getCode(),0)) {
+            throw new RuntimeException("请求接口失败!原因:"+response.getMsg());
+        }
+        return response.getData();
+    }
+
+    @Override
+    public GetInitTokenResponseDTO refreshToken(GetInitTokenRequestDTO dto) {
+        String post = HttpUtil.post(REFRESH_TOKEN_URL, JSON.toJSONString(dto));
+        TypeReference<CommonResponse<GetInitTokenResponseDTO>> typeReference = new TypeReference<CommonResponse<GetInitTokenResponseDTO>>(){};
+        CommonResponse<GetInitTokenResponseDTO> response = JSON.parseObject(post, typeReference);
+        if(ObjectUtils.notEqual(response.getCode(),0)) {
+            throw new RuntimeException("请求接口失败!原因:"+response.getMsg());
+        }
+        return response.getData();
+    }
+
+    @Override
+    public ProductUploadResultDTO uploadGoods(GoodsInfoDTO dto) {
+
+        String post = HttpUtil.post(BASE_URL + "/open/jushuitan/itemsku/upload", JSON.toJSONString(dto));
+        TypeReference<CommonResponse<ProductUploadResultDTO>> typeReference = new TypeReference<CommonResponse<ProductUploadResultDTO>>(){};
+        CommonResponse<ProductUploadResultDTO> response = JSON.parseObject(post, typeReference);
+        if(ObjectUtils.notEqual(response.getCode(),0)) {
+            throw new RuntimeException("请求接口失败!原因:"+response.getMsg());
+        }
+        return response.getData();
+    }
+
+    @Override
+    public ProductResponseDTO queryGoods(ProductQueryRequestDTO dto) {
+        String post = HttpUtil.post(BASE_URL + "/open/sku/query", JSON.toJSONString(dto));
+        TypeReference<CommonResponse<ProductResponseDTO>> typeReference = new TypeReference<CommonResponse<ProductResponseDTO>>(){};
+        CommonResponse<ProductResponseDTO> response = JSON.parseObject(post, typeReference);
+        if(ObjectUtils.notEqual(response.getCode(),0)) {
+            throw new RuntimeException("请求接口失败!原因:"+response.getMsg());
+        }
+        return response.getData();
+    }
+}

+ 26 - 0
fs-service-system/src/main/java/com/fs/erp/service/impl/JSTErpGoodsServiceImpl.java

@@ -0,0 +1,26 @@
+package com.fs.erp.service.impl;
+
+import com.fs.erp.domain.ErpGoods;
+import com.fs.erp.dto.*;
+import com.fs.erp.service.IErpGoodsService;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+
+@Service
+@Primary
+public class JSTErpGoodsServiceImpl implements IErpGoodsService {
+    @Override
+    public BaseResponse addGoods(ErpGoods goods) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsQueryResponse getGoods(ErpGoodsQueryRequert param) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsStockQueryResponse getGoodsStock(ErpGoodsStockQueryRequert param) {
+        return null;
+    }
+}

+ 86 - 0
fs-service-system/src/main/java/com/fs/erp/utils/SignUtil.java

@@ -0,0 +1,86 @@
+package com.fs.erp.utils;
+
+import com.fs.common.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+@Slf4j
+public class SignUtil {
+    private SignUtil() {}
+
+    public static String getSign(String app_secret, Map<String, Object> params) {
+        try {
+            String sortedStr = getSortedParamStr(params);
+            String paraStr = app_secret + sortedStr;
+
+            return createSign(paraStr);
+        } catch (UnsupportedEncodingException e) {
+            log.warn("getSign UnsupportedEncodingException ", e);
+        }
+
+        return StringUtils.EMPTY;
+    }
+
+    /**
+     * 构造自然排序请求参数
+     *
+     * @param params 请求
+     * @return 字符串
+     */
+    private static String getSortedParamStr(Map<String, Object> params) throws UnsupportedEncodingException {
+        Set<String> sortedParams = new TreeSet<>(params.keySet());
+
+        StringBuilder strB = new StringBuilder();
+        // 排除sign和空值参数
+        for (String key : sortedParams) {
+            if ("sign".equalsIgnoreCase(key)) {
+                continue;
+            }
+
+            String value = String.valueOf(params.get(key));
+
+            if (StringUtils.isNotEmpty(value)) {
+                strB.append(key).append(value);
+            }
+        }
+        return strB.toString();
+    }
+
+    /**
+     * 生成新sign
+     *
+     * @param str 字符串
+     * @return String
+     */
+    private static String createSign(String str) {
+        if (str == null || str.length() == 0) {
+            return null;
+        }
+        char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+        try {
+            MessageDigest mdTemp = MessageDigest.getInstance("MD5");
+            mdTemp.update(str.getBytes("UTF-8"));
+
+            byte[] md = mdTemp.digest();
+            int j = md.length;
+            char[] buf = new char[j * 2];
+            int k = 0;
+            int i = 0;
+            while (i < j) {
+                byte byte0 = md[i];
+                buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
+                buf[k++] = hexDigits[byte0 & 0xf];
+                i++;
+            }
+            return new String(buf);
+        } catch (Exception e) {
+            log.warn("create sign was failed", e);
+            return null;
+        }
+    }
+}