〇、场景
1、紧接上篇 Java——聚水潭API调用(SDK)Sku商品信息
2、需求:调用聚水潭Orders API接口拉取数据,并存入到本地数据库。
3、技术:Spring Boot + MyBatis-Plus + MySQL
一、SDK调用说明
1、聚水潭开放平台SDK集成了API的请求封装、摘要签名,以及简单的响应解释等功能,使用SDK可以轻松完成API的调用,API结果的获取。
2、SDK只能用于API接口的调用,不能用于授权接口的调用。
通过该链接地址访问SDK详细说明,并下载SDK。链接: link,或访问聚水潭官方文档。
二、Orders订单信息API
环境 | Http请求地址 |
---|---|
正式环境 | https://openapi.jushuitan.com/open/orders/single/query |
测试环境 | https://dev-api.jushuitan.com/open/orders/single/query |
三、将下载后的SDK Jar包添加至项目中
打开 File 菜单,点击 Project Structure,点击 Modules,点击 Dependencies,点击 + 号,选择
JARs or Directories...
,找到下载SDK Jar包,点击OK添加成功
四、上代码
1、pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.13</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
2、MySQL数据表
-- 聚水潭Access_Token
CREATE TABLE access_token (
id BIGINT(20) PRIMARY KEY COMMENT 'id',
expires_in VARCHAR(20) comment 'access_token有效期',
access_token VARCHAR(255) comment '访问令牌',
scope VARCHAR(20) comment '固定值all',
refresh_token VARCHAR(255) comment '更新令牌',
expiration_time VARCHAR(20) comment '过期时间'
);
-- 聚水潭订单
CREATE TABLE orders (
id VARCHAR(20) PRIMARY KEY COMMENT 'id',
o_id VARCHAR(30) comment '聚水潭订单号',
so_id VARCHAR(30) comment '线上订单号',
l_id VARCHAR(30) comment '快递单号',
order_date VARCHAR(30) comment '订单日期',
type VARCHAR(25) comment '订单类型',
shop_id VARCHAR(30) comment '店铺编号',
shop_name VARCHAR(30) comment '店铺名称',
order_from VARCHAR(25) comment '订单来源',
order_status VARCHAR(25) comment '订单状态',
shop_status VARCHAR(25) comment '平台订单状态',
co_id VARCHAR(20) comment '公司编号',
lc_id VARCHAR(20) comment '物流公司编号',
logistics_company VARCHAR(20) comment '快递公司',
wms_co_id VARCHAR(20) comment '发货仓编码',
pay_amount DOUBLE comment '应付金额',
paid_amount DOUBLE comment '实际支付金额',
modified VARCHAR(30) comment '修改时间',
longTime LONG comment '长时间',
referrer_id VARCHAR(30) comment '主播id',
labels VARCHAR(200) comment '标签',
remark VARCHAR(500) comment '备注',
create_date VARCHAR(30) comment '创建日期',
isSyn TINYINT(1) comment '是否同步'
);
-- 聚水潭订单明细
CREATE TABLE orders_detail (
id VARCHAR(20) PRIMARY KEY COMMENT 'id',
seq BIGINT(20) comment '序号',
parent_id VARCHAR(20) comment '父id',
o_id VARCHAR(30) comment '聚水潭订单号',
sku_id VARCHAR(30) comment '商品编码',
sku_na