This commit is contained in:
雷欧(林平凡)
2024-11-06 17:55:07 +08:00
commit 87e0e7693f
15 changed files with 1072 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

8
.idea/ApifoxUploaderProjectSetting.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ApifoxUploaderProjectSetting">
<option name="apiAccessToken" value="APS-2AIfzBc2W8qdmTsj3zVDdIlI5LyVVtcz" />
<option name="apiApiOverwriteMode" value="不导入" />
<option name="yapiTokens" value="" />
</component>
</project>

19
.idea/dataSources.xml generated Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="jd@134.175.126.60" uuid="eb8a6f9c-c8ff-4224-9875-8dd3cf91a680">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/src/main/resources/application.yml</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://134.175.126.60:33306/jd?characterEncoding=utf-8&amp;useSSL=true&amp;serverTimezone=GMT</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

7
.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@@ -0,0 +1,39 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AliWrapperTypeEquality" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,cn.hutool.http.HttpRequest,execute" />
</inspection_tool>
<inspection_tool class="DefaultAnnotationParam" enabled="true" level="INFORMATION" enabled_by_default="true" editorAttributes="INFORMATION_ATTRIBUTES" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="346" name="Java" />
</Languages>
</inspection_tool>
<inspection_tool class="JavadocDeclaration" enabled="true" level="TEXT ATTRIBUTES" enabled_by_default="true" editorAttributes="CONSIDERATION_ATTRIBUTES">
<option name="ADDITIONAL_TAGS" value="create,description" />
</inspection_tool>
<inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MismatchedJavadocCode" enabled="true" level="TEXT ATTRIBUTES" enabled_by_default="true" editorAttributes="CONSIDERATION_ATTRIBUTES" />
<inspection_tool class="unused" enabled="true" level="ERROR" enabled_by_default="true" editorAttributes="ERRORS_ATTRIBUTES" checkParameterExcludingHierarchy="false">
<option name="LOCAL_VARIABLE" value="true" />
<option name="FIELD" value="true" />
<option name="METHOD" value="true" />
<option name="CLASS" value="true" />
<option name="PARAMETER" value="true" />
<option name="REPORT_PARAMETER_FOR_PUBLIC_METHODS" value="true" />
<option name="ADD_MAINS_TO_ENTRIES" value="true" />
<option name="ADD_APPLET_TO_ENTRIES" value="true" />
<option name="ADD_SERVLET_TO_ENTRIES" value="true" />
<option name="ADD_NONJAVA_TO_ENTRIES" value="true" />
</inspection_tool>
</profile>
</component>

14
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8(202)" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

96
pom.xml Normal file
View File

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 项目基本信息 -->
<groupId>com.example</groupId>
<artifactId>springboot-hql-web</artifactId>
<version>1.0-SNAPSHOT</version>
<name>SpringBootHQLWeb</name>
<description>Spring Boot with HQL and Web support</description>
<!-- Java 版本 -->
<properties>
<java.version>1.8</java.version>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<!-- 依赖管理 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- 项目依赖 -->
<dependencies>
<!-- Spring Boot Starter Web用于REST API和MVC -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Spring Boot Starter Data JPA包含Hibernate -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- MySQL 数据库驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Spring Boot Starter Test测试依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 京东依赖-->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.2</version>
</dependency>
<!--fastjson-->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
<!-- Maven 插件 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,20 @@
package cn.van;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* @author Leo
* @version 1.0
* @create 2024/11/6 10:17
* @description
*/
@SpringBootApplication
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -0,0 +1,608 @@
package cn.van.business.model;
/**
* @author Leo
* @version 1.0
* @create 2024/11/6 10:52
* @description
*/
import com.jd.open.api.sdk.domain.kplunion.OrderService.response.query.GoodsInfo;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "order_rows")
public class OrderRowVO {
@Id
@Column(name = "id")
private String id;
@Column(name = "order_id")
private Long orderId;
@Column(name = "parent_id")
private Long parentId;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "order_time")
private Date orderTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "finish_time")
private Date finishTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "modify_time")
private Date modifyTime;
@Column(name = "order_emt")
private Integer orderEmt;
@Column(name = "plus")
private Integer plus;
@Column(name = "union_id")
private Long unionId;
@Column(name = "sku_id")
private Long skuId;
@Column(name = "sku_name")
private String skuName;
@Column(name = "sku_num")
private Integer skuNum;
@Column(name = "sku_return_num")
private Integer skuReturnNum;
@Column(name = "sku_frozen_num")
private Integer skuFrozenNum;
@Column(name = "price")
private Double price;
@Column(name = "commission_rate")
private Double commissionRate;
@Column(name = "sub_side_rate")
private Double subSideRate;
@Column(name = "subsidy_rate")
private Double subsidyRate;
@Column(name = "final_rate")
private Double finalRate;
@Column(name = "estimate_cos_price")
private Double estimateCosPrice;
@Column(name = "estimate_fee")
private Double estimateFee;
@Column(name = "actual_cos_price")
private Double actualCosPrice;
@Column(name = "actual_fee")
private Double actualFee;
@Column(name = "valid_code")
private Integer validCode;
@Column(name = "trace_type")
private Integer traceType;
@Column(name = "position_id")
private Long positionId;
@Column(name = "site_id")
private Long siteId;
@Column(name = "union_alias")
private String unionAlias;
@Column(name = "pid")
private String pid;
@Column(name = "cid1")
private Long cid1;
@Column(name = "cid2")
private Long cid2;
@Column(name = "cid3")
private Long cid3;
@Column(name = "sub_union_id")
private String subUnionId;
@Column(name = "union_tag")
private String unionTag;
@Column(name = "pop_id")
private Long popId;
@Column(name = "ext1")
private String ext1;
@Column(name = "pay_month")
private String payMonth;
@Column(name = "cp_act_id")
private Long cpActId;
@Column(name = "union_role")
private Integer unionRole;
@Column(name = "gift_coupon_ocs_amount")
private Double giftCouponOcsAmount;
@Column(name = "gift_coupon_key")
private String giftCouponKey;
@Column(name = "balance_ext")
private String balanceExt;
@Column(name = "sign")
private String sign;
@Column(name = "pro_price_amount")
private Double proPriceAmount;
@Column(name = "rid")
private Long rid;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "goods_info_id", referencedColumnName = "id")
private GoodsInfo goodsInfo;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "category_info_id", referencedColumnName = "id")
private CategoryInfoVO categoryInfoVO;
@Column(name = "express_status")
private Integer expressStatus;
@Column(name = "channel_id")
private Long channelId;
@Column(name = "sku_tag")
private String skuTag;
@Column(name = "item_id")
private String itemId;
@Column(name = "caller_item_id")
private String callerItemId;
@Column(name = "order_tag")
private String orderTag;
public OrderRowVO() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public Date getOrderTime() {
return orderTime;
}
public void setOrderTime(Date orderTime) {
this.orderTime = orderTime;
}
public Date getFinishTime() {
return finishTime;
}
public void setFinishTime(Date finishTime) {
this.finishTime = finishTime;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Integer getOrderEmt() {
return orderEmt;
}
public void setOrderEmt(Integer orderEmt) {
this.orderEmt = orderEmt;
}
public Integer getPlus() {
return plus;
}
public void setPlus(Integer plus) {
this.plus = plus;
}
public Long getUnionId() {
return unionId;
}
public void setUnionId(Long unionId) {
this.unionId = unionId;
}
public Long getSkuId() {
return skuId;
}
public void setSkuId(Long skuId) {
this.skuId = skuId;
}
public String getSkuName() {
return skuName;
}
public void setSkuName(String skuName) {
this.skuName = skuName;
}
public Integer getSkuNum() {
return skuNum;
}
public void setSkuNum(Integer skuNum) {
this.skuNum = skuNum;
}
public Integer getSkuReturnNum() {
return skuReturnNum;
}
public void setSkuReturnNum(Integer skuReturnNum) {
this.skuReturnNum = skuReturnNum;
}
public Integer getSkuFrozenNum() {
return skuFrozenNum;
}
public void setSkuFrozenNum(Integer skuFrozenNum) {
this.skuFrozenNum = skuFrozenNum;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public Double getCommissionRate() {
return commissionRate;
}
public void setCommissionRate(Double commissionRate) {
this.commissionRate = commissionRate;
}
public Double getSubSideRate() {
return subSideRate;
}
public void setSubSideRate(Double subSideRate) {
this.subSideRate = subSideRate;
}
public Double getSubsidyRate() {
return subsidyRate;
}
public void setSubsidyRate(Double subsidyRate) {
this.subsidyRate = subsidyRate;
}
public Double getFinalRate() {
return finalRate;
}
public void setFinalRate(Double finalRate) {
this.finalRate = finalRate;
}
public Double getEstimateCosPrice() {
return estimateCosPrice;
}
public void setEstimateCosPrice(Double estimateCosPrice) {
this.estimateCosPrice = estimateCosPrice;
}
public Double getEstimateFee() {
return estimateFee;
}
public void setEstimateFee(Double estimateFee) {
this.estimateFee = estimateFee;
}
public Double getActualCosPrice() {
return actualCosPrice;
}
public void setActualCosPrice(Double actualCosPrice) {
this.actualCosPrice = actualCosPrice;
}
public Double getActualFee() {
return actualFee;
}
public void setActualFee(Double actualFee) {
this.actualFee = actualFee;
}
public Integer getValidCode() {
return validCode;
}
public void setValidCode(Integer validCode) {
this.validCode = validCode;
}
public Integer getTraceType() {
return traceType;
}
public void setTraceType(Integer traceType) {
this.traceType = traceType;
}
public Long getPositionId() {
return positionId;
}
public void setPositionId(Long positionId) {
this.positionId = positionId;
}
public Long getSiteId() {
return siteId;
}
public void setSiteId(Long siteId) {
this.siteId = siteId;
}
public String getUnionAlias() {
return unionAlias;
}
public void setUnionAlias(String unionAlias) {
this.unionAlias = unionAlias;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public Long getCid1() {
return cid1;
}
public void setCid1(Long cid1) {
this.cid1 = cid1;
}
public Long getCid2() {
return cid2;
}
public void setCid2(Long cid2) {
this.cid2 = cid2;
}
public Long getCid3() {
return cid3;
}
public void setCid3(Long cid3) {
this.cid3 = cid3;
}
public String getSubUnionId() {
return subUnionId;
}
public void setSubUnionId(String subUnionId) {
this.subUnionId = subUnionId;
}
public String getUnionTag() {
return unionTag;
}
public void setUnionTag(String unionTag) {
this.unionTag = unionTag;
}
public Long getPopId() {
return popId;
}
public void setPopId(Long popId) {
this.popId = popId;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getPayMonth() {
return payMonth;
}
public void setPayMonth(String payMonth) {
this.payMonth = payMonth;
}
public Long getCpActId() {
return cpActId;
}
public void setCpActId(Long cpActId) {
this.cpActId = cpActId;
}
public Integer getUnionRole() {
return unionRole;
}
public void setUnionRole(Integer unionRole) {
this.unionRole = unionRole;
}
public Double getGiftCouponOcsAmount() {
return giftCouponOcsAmount;
}
public void setGiftCouponOcsAmount(Double giftCouponOcsAmount) {
this.giftCouponOcsAmount = giftCouponOcsAmount;
}
public String getGiftCouponKey() {
return giftCouponKey;
}
public void setGiftCouponKey(String giftCouponKey) {
this.giftCouponKey = giftCouponKey;
}
public String getBalanceExt() {
return balanceExt;
}
public void setBalanceExt(String balanceExt) {
this.balanceExt = balanceExt;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public Double getProPriceAmount() {
return proPriceAmount;
}
public void setProPriceAmount(Double proPriceAmount) {
this.proPriceAmount = proPriceAmount;
}
public Long getRid() {
return rid;
}
public void setRid(Long rid) {
this.rid = rid;
}
public GoodsInfo getGoodsInfo() {
return goodsInfo;
}
public void setGoodsInfo(GoodsInfo goodsInfo) {
this.goodsInfo = goodsInfo;
}
public CategoryInfo getCategoryInfo() {
return categoryInfo;
}
public void setCategoryInfo(CategoryInfo categoryInfo) {
this.categoryInfo = categoryInfo;
}
public Integer getExpressStatus() {
return expressStatus;
}
public void setExpressStatus(Integer expressStatus) {
this.expressStatus = expressStatus;
}
public Long getChannelId() {
return channelId;
}
public void setChannelId(Long channelId) {
this.channelId = channelId;
}
public String getSkuTag() {
return skuTag;
}
public void setSkuTag(String skuTag) {
this.skuTag = skuTag;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getCallerItemId() {
return callerItemId;
}
public void setCallerItemId(String callerItemId) {
this.callerItemId = callerItemId;
}
public String getOrderTag() {
return orderTag;
}
public void setOrderTag(String orderTag) {
this.orderTag = orderTag;
}
}

View File

@@ -0,0 +1,28 @@
package cn.van.business.repository;
/**
* @author Leo
* @version 1.0
* @create 2024/11/6 14:44
* @description
*/
import cn.van.business.model.OrderRow;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrderRowRepository extends JpaRepository<OrderRow, String> {
// 这里可以根据需要添加自定义的查询方法,例如:
// 根据订单号查询订单行
List<OrderRow> findByOrderId(long orderId);
// 根据SKU ID 和订单号查询订单行
List<OrderRow> findBySkuIdAndOrderId(long skuId, long orderId);
// 根据有效码查询订单行
List<OrderRow> findByValidCode(int validCode);
}

View File

@@ -0,0 +1,114 @@
package cn.van.business.util;
import cn.van.business.model.OrderRow;
import cn.van.business.repository.OrderRowRepository;
import com.jd.open.api.sdk.DefaultJdClient;
import com.jd.open.api.sdk.JdClient;
import com.jd.open.api.sdk.domain.kplunion.OrderService.request.query.OrderRowReq;
import com.jd.open.api.sdk.domain.kplunion.OrderService.response.query.OrderRowResp;
import com.jd.open.api.sdk.request.kplunion.UnionOpenOrderRowQueryRequest;
import com.jd.open.api.sdk.response.kplunion.UnionOpenOrderRowQueryResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author Leo
* @version 1.0
* @create 2024/11/5 17:40
* @description
*/
@Component
public class JDUtils {
private static final String SERVER_URL =
"https://api.jd.com/routerjson";
private static final String APP_KEY =
"98e21c89ae5610240ec3f5f575f86a59";
private static final String SECRET_KEY =
"3dcb6b23a1104639ac433fd07adb6dfb";
@Autowired
private StringRedisTemplate redisTemplate;
@Autowired
private OrderRowRepository orderRowRepository;
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 写两个方法,一个拉最新的订单。一个拉历史订单
*/
@Scheduled(cron = "0 0 * * * ?")
public void getHistoryOrder() {
// 因为只能一小时一小时的拉取订单,所以要循环的倒推去拉取历史订单,存到数据库
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// 当前是2024-10-10 11:46:00 , 则生成一个 2024-10-10 11:00:00
}
@Scheduled(cron = "0 * * * * ?")
public void getNewOrder() throws Exception {
//一分钟一分钟拉取 2020-01-02 21:23:00
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = sdf.format(new Date(System.currentTimeMillis() - 1000 * 60));
String endTime = sdf.format(new Date());
UnionOpenOrderRowQueryResponse response = getUnionOpenOrderRowQueryResponse(startTime, endTime);
int code = response.getQueryResult().getCode();
System.out.println("响应码:" + code);
if (code == 200) {
if (response.getQueryResult().getCode() == 200) {
OrderRowResp[] orderRowResps = response.getQueryResult().getData();
if (orderRowResps == null) {
return;
}
for (OrderRowResp orderRowResp : orderRowResps) {
// 固化到数据库
OrderRow orderRow = new OrderRow();
orderRow.setOrderId(orderRowResp.getOrderId());
orderRow.setSkuId(orderRowResp.getSkuId());
orderRow.setSkuName(orderRowResp.getSkuName());
orderRowRepository.save(orderRowResp);
}
}
}
}
/**
* 获取订单列表
*
* @param startTime 开始时间
* @param endTime 结束时间
* @return
* @throws Exception
*/
public UnionOpenOrderRowQueryResponse getUnionOpenOrderRowQueryResponse(String startTime, String endTime) throws Exception {
String accessToken = "";
JdClient client = new DefaultJdClient(SERVER_URL, accessToken, APP_KEY, SECRET_KEY);
UnionOpenOrderRowQueryRequest request = new UnionOpenOrderRowQueryRequest();
OrderRowReq orderReq = new OrderRowReq();
orderReq.setPageIndex(1);
orderReq.setPageSize(200);
orderReq.setStartTime(startTime);
orderReq.setEndTime(endTime);
orderReq.setType(1);
request.setOrderReq(orderReq);
request.setVersion("1.0");
request.setSignmethod("md5");
// 时间戳格式为yyyy-MM-dd HH:mm:ss时区为GMT+8。API服务端允许客户端请求最大时间误差为10分钟
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
request.setTimestamp(simpleDateFormat.format(date));
return client.execute(request);
}
}

Binary file not shown.

View File

@@ -0,0 +1,67 @@
server:
port: 36888
spring:
application:
name: wxSend
profiles:
active: dev
#数据源配置
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://134.175.126.60:33306/jd?characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8
username: root
password: mysql_7sjTXH
#redis配置
redis:
host: 134.175.126.60
port: 36379
database: 7
timeout: 1800000
lettuce:
pool:
max-active: 20
#最大阻塞等待时间(负数表示没限制)
max-wait: -1
max-idle: 5
min-idle: 0
password: redis_6PZ52S # 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 20MB
# 设置总上传的文件大小
max-request-size: 20MB
#MyWebMvcConfig中开启@EnableWebMvc则失效
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
# # 对象字段为null不显示
# default-property-inclusion: non_null
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: 5c6649a39f184678af3580795a7307d9
# 令牌有效期(单位分钟)
expireTime: 1440
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# 日志配置
logging:
level:
cn.van333: debug
org.springframework: warn