添加toa-api更新日志
This commit is contained in:
parent
d9dd03d10f
commit
2e82dc2b49
|
|
@ -22,6 +22,7 @@ import com.jd.open.api.sdk.response.ware.SkuReadSearchSkuListResponse;
|
||||||
import com.jd.open.api.sdk.response.ware.WareReadSearchWare4ValidResponse;
|
import com.jd.open.api.sdk.response.ware.WareReadSearchWare4ValidResponse;
|
||||||
import com.qihang.common.common.ApiResult;
|
import com.qihang.common.common.ApiResult;
|
||||||
import com.qihang.common.common.ResultVo;
|
import com.qihang.common.common.ResultVo;
|
||||||
|
import com.qihang.common.enums.EnumShopType;
|
||||||
import com.qihang.common.enums.HttpStatus;
|
import com.qihang.common.enums.HttpStatus;
|
||||||
import com.qihang.jd.domain.JdGoods;
|
import com.qihang.jd.domain.JdGoods;
|
||||||
import com.qihang.jd.domain.JdGoodsSku;
|
import com.qihang.jd.domain.JdGoodsSku;
|
||||||
|
|
@ -133,6 +134,7 @@ public class GoodsApiController {
|
||||||
|
|
||||||
|
|
||||||
logs.setShopId(params.getShopId());
|
logs.setShopId(params.getShopId());
|
||||||
|
logs.setShopType(EnumShopType.JD.getIndex());
|
||||||
logs.setPullType("GOODS");
|
logs.setPullType("GOODS");
|
||||||
logs.setPullWay("主动拉取");
|
logs.setPullWay("主动拉取");
|
||||||
logs.setPullParams("{WareStatusValue:8,PageNo:1,PageSize:100}");
|
logs.setPullParams("{WareStatusValue:8,PageNo:1,PageSize:100}");
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ public class OrderApiController {
|
||||||
pullLasttimeService.updateById(updateLasttime);
|
pullLasttimeService.updateById(updateLasttime);
|
||||||
}
|
}
|
||||||
SysShopPullLogs logs = new SysShopPullLogs();
|
SysShopPullLogs logs = new SysShopPullLogs();
|
||||||
|
logs.setShopType(EnumShopType.JD.getIndex());
|
||||||
logs.setShopId(params.getShopId());
|
logs.setShopId(params.getShopId());
|
||||||
logs.setPullType("ORDER");
|
logs.setPullType("ORDER");
|
||||||
logs.setPullWay("主动拉取");
|
logs.setPullWay("主动拉取");
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,7 @@ public class RefundApiController {
|
||||||
|
|
||||||
SysShopPullLogs logs = new SysShopPullLogs();
|
SysShopPullLogs logs = new SysShopPullLogs();
|
||||||
logs.setShopId(params.getShopId());
|
logs.setShopId(params.getShopId());
|
||||||
|
logs.setShopType(EnumShopType.JD.getIndex());
|
||||||
logs.setPullType("REFUND");
|
logs.setPullType("REFUND");
|
||||||
logs.setPullWay("主动更新状态");
|
logs.setPullWay("主动更新状态");
|
||||||
logs.setPullParams("{ApplyTimeBegin:" + startTimeStr + ",ApplyTimeEnd:" + endTimeStr + ",PageIndex:1,PageSize:100}");
|
logs.setPullParams("{ApplyTimeBegin:" + startTimeStr + ",ApplyTimeEnd:" + endTimeStr + ",PageIndex:1,PageSize:100}");
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ public class SysShopPullLogs implements Serializable {
|
||||||
* 店铺id
|
* 店铺id
|
||||||
*/
|
*/
|
||||||
private Integer shopId;
|
private Integer shopId;
|
||||||
|
private Integer shopType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型(ORDER订单,GOODS商品,REFUN退款)
|
* 类型(ORDER订单,GOODS商品,REFUN退款)
|
||||||
|
|
@ -78,6 +79,14 @@ public class SysShopPullLogs implements Serializable {
|
||||||
this.shopId = shopId;
|
this.shopId = shopId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getShopType() {
|
||||||
|
return shopType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopType(Integer shopType) {
|
||||||
|
this.shopType = shopType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型(ORDER订单,GOODS商品,REFUN退款)
|
* 类型(ORDER订单,GOODS商品,REFUN退款)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,15 @@ import com.qihang.common.enums.HttpStatus;
|
||||||
import com.qihang.common.mq.MqMessage;
|
import com.qihang.common.mq.MqMessage;
|
||||||
import com.qihang.common.mq.MqType;
|
import com.qihang.common.mq.MqType;
|
||||||
import com.qihang.common.mq.MqUtils;
|
import com.qihang.common.mq.MqUtils;
|
||||||
|
import com.qihang.tao.domain.SysShopPullLasttime;
|
||||||
|
import com.qihang.tao.domain.SysShopPullLogs;
|
||||||
import com.qihang.tao.openApi.ApiCommon;
|
import com.qihang.tao.openApi.ApiCommon;
|
||||||
//import com.qihang.tao.api.ApiResult;
|
//import com.qihang.tao.api.ApiResult;
|
||||||
import com.qihang.tao.openApi.OrderApiHelper;
|
import com.qihang.tao.openApi.OrderApiHelper;
|
||||||
import com.qihang.tao.common.TaoRequest;
|
import com.qihang.tao.common.TaoRequest;
|
||||||
import com.qihang.tao.domain.TaoOrder;
|
import com.qihang.tao.domain.TaoOrder;
|
||||||
|
import com.qihang.tao.service.SysShopPullLasttimeService;
|
||||||
|
import com.qihang.tao.service.SysShopPullLogsService;
|
||||||
import com.qihang.tao.service.TaoOrderService;
|
import com.qihang.tao.service.TaoOrderService;
|
||||||
import com.taobao.api.ApiException;
|
import com.taobao.api.ApiException;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
|
@ -19,6 +23,9 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 淘系订单更新
|
* 淘系订单更新
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,8 +38,8 @@ public class OrderApiController {
|
||||||
private final TaoOrderService orderService;
|
private final TaoOrderService orderService;
|
||||||
private final ApiCommon apiCommon;
|
private final ApiCommon apiCommon;
|
||||||
private final MqUtils mqUtils;
|
private final MqUtils mqUtils;
|
||||||
|
private final SysShopPullLogsService pullLogsService;
|
||||||
|
private final SysShopPullLasttimeService pullLasttimeService;
|
||||||
/**
|
/**
|
||||||
* 增量更新订单
|
* 增量更新订单
|
||||||
* @param req
|
* @param req
|
||||||
|
|
@ -46,6 +53,9 @@ public class OrderApiController {
|
||||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||||
}
|
}
|
||||||
|
Date currDateTime = new Date();
|
||||||
|
long beginTime = System.currentTimeMillis();
|
||||||
|
|
||||||
var checkResult = apiCommon.checkBefore(req.getShopId());
|
var checkResult = apiCommon.checkBefore(req.getShopId());
|
||||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||||
return ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
return ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||||
|
|
@ -58,9 +68,26 @@ public class OrderApiController {
|
||||||
log.info("/**************增量更新tao订单,条件判断完成,开始更新。。。。。。****************/");
|
log.info("/**************增量更新tao订单,条件判断完成,开始更新。。。。。。****************/");
|
||||||
Long pageSize = 100l;
|
Long pageSize = 100l;
|
||||||
Long pageIndex = 1l;
|
Long pageIndex = 1l;
|
||||||
|
// 取当前时间30分钟前
|
||||||
|
// LocalDateTime endTime = LocalDateTime.now();
|
||||||
|
// LocalDateTime startTime = endTime.minus(60*24, ChronoUnit.MINUTES);
|
||||||
|
// 获取最后更新时间
|
||||||
|
LocalDateTime startTime = null;
|
||||||
|
LocalDateTime endTime = null;
|
||||||
|
SysShopPullLasttime lasttime = pullLasttimeService.getLasttimeByShop(req.getShopId(), "ORDER");
|
||||||
|
if(lasttime == null){
|
||||||
|
endTime = LocalDateTime.now();
|
||||||
|
startTime = endTime.minusDays(1);
|
||||||
|
}else{
|
||||||
|
startTime = lasttime.getLasttime().minusHours(1);//取上次结束一个小时前
|
||||||
|
endTime = startTime.plusDays(1);//取24小时
|
||||||
|
if(endTime.isAfter(LocalDateTime.now())){
|
||||||
|
endTime = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//第一次获取
|
//第一次获取
|
||||||
ApiResult<TaoOrder> upResult = OrderApiHelper.pullIncrementOrder(pageIndex, pageSize, url, appKey, appSecret, sessionKey);
|
ApiResult<TaoOrder> upResult = OrderApiHelper.pullIncrementOrder(startTime,endTime,pageIndex, pageSize, url, appKey, appSecret, sessionKey);
|
||||||
|
|
||||||
if (upResult.getCode() != 0) {
|
if (upResult.getCode() != 0) {
|
||||||
log.info("/**************主动更新tao订单:第一次获取结果失败:" + upResult.getMsg() + "****************/");
|
log.info("/**************主动更新tao订单:第一次获取结果失败:" + upResult.getMsg() + "****************/");
|
||||||
|
|
@ -94,6 +121,35 @@ public class OrderApiController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(lasttime == null){
|
||||||
|
// 新增
|
||||||
|
SysShopPullLasttime insertLasttime = new SysShopPullLasttime();
|
||||||
|
insertLasttime.setShopId(req.getShopId());
|
||||||
|
insertLasttime.setCreateTime(new Date());
|
||||||
|
insertLasttime.setLasttime(endTime);
|
||||||
|
insertLasttime.setPullType("ORDER");
|
||||||
|
pullLasttimeService.save(insertLasttime);
|
||||||
|
|
||||||
|
}else {
|
||||||
|
// 修改
|
||||||
|
SysShopPullLasttime updateLasttime = new SysShopPullLasttime();
|
||||||
|
updateLasttime.setId(lasttime.getId());
|
||||||
|
updateLasttime.setUpdateTime(new Date());
|
||||||
|
updateLasttime.setLasttime(endTime);
|
||||||
|
pullLasttimeService.updateById(updateLasttime);
|
||||||
|
}
|
||||||
|
|
||||||
|
SysShopPullLogs logs = new SysShopPullLogs();
|
||||||
|
logs.setShopType(EnumShopType.TAO.getIndex());
|
||||||
|
logs.setShopId(req.getShopId());
|
||||||
|
logs.setPullType("ORDER");
|
||||||
|
logs.setPullWay("主动拉取");
|
||||||
|
logs.setPullParams("{startTime:"+startTime+",endTime:"+endTime+"}");
|
||||||
|
logs.setPullResult("{insertSuccess:"+insertSuccess+",hasExistOrder:"+hasExistOrder+",totalError:"+totalError+"}");
|
||||||
|
logs.setPullTime(currDateTime);
|
||||||
|
logs.setDuration(System.currentTimeMillis() - beginTime);
|
||||||
|
pullLogsService.save(logs);
|
||||||
|
|
||||||
String msg = "成功,总共找到:" + upResult.getTotalRecords() + "条订单,新增:" + insertSuccess + "条,添加错误:" + totalError + "条,更新:" + hasExistOrder + "条";
|
String msg = "成功,总共找到:" + upResult.getTotalRecords() + "条订单,新增:" + insertSuccess + "条,添加错误:" + totalError + "条,更新:" + hasExistOrder + "条";
|
||||||
log.info("/**************主动更新tao订单:END:" + msg + "****************/");
|
log.info("/**************主动更新tao订单:END:" + msg + "****************/");
|
||||||
return ApiResult.build(HttpStatus.SUCCESS, msg);
|
return ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,177 @@
|
||||||
|
package com.qihang.tao.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺更新最后时间记录
|
||||||
|
* @TableName sys_shop_pull_lasttime
|
||||||
|
*/
|
||||||
|
public class SysShopPullLasttime implements Serializable {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(ORDER:订单,REFUND:退款)
|
||||||
|
*/
|
||||||
|
private Object pullType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime lasttime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
public Integer getShopId() {
|
||||||
|
return shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
public void setShopId(Integer shopId) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(ORDER:订单,REFUND:退款)
|
||||||
|
*/
|
||||||
|
public Object getPullType() {
|
||||||
|
return pullType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(ORDER:订单,REFUND:退款)
|
||||||
|
*/
|
||||||
|
public void setPullType(Object pullType) {
|
||||||
|
this.pullType = pullType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
public LocalDateTime getLasttime() {
|
||||||
|
return lasttime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
public void setLasttime(LocalDateTime lasttime) {
|
||||||
|
this.lasttime = lasttime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SysShopPullLasttime other = (SysShopPullLasttime) that;
|
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||||
|
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
||||||
|
&& (this.getPullType() == null ? other.getPullType() == null : this.getPullType().equals(other.getPullType()))
|
||||||
|
&& (this.getLasttime() == null ? other.getLasttime() == null : this.getLasttime().equals(other.getLasttime()))
|
||||||
|
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||||
|
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||||
|
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
||||||
|
result = prime * result + ((getPullType() == null) ? 0 : getPullType().hashCode());
|
||||||
|
result = prime * result + ((getLasttime() == null) ? 0 : getLasttime().hashCode());
|
||||||
|
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||||
|
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
sb.append(", shopId=").append(shopId);
|
||||||
|
sb.append(", pullType=").append(pullType);
|
||||||
|
sb.append(", lasttime=").append(lasttime);
|
||||||
|
sb.append(", createTime=").append(createTime);
|
||||||
|
sb.append(", updateTime=").append(updateTime);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,242 @@
|
||||||
|
package com.qihang.tao.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新日志表
|
||||||
|
* @TableName sys_shop_pull_logs
|
||||||
|
*/
|
||||||
|
public class SysShopPullLogs implements Serializable {
|
||||||
|
/**
|
||||||
|
* 主键Id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
private Integer shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台id
|
||||||
|
*/
|
||||||
|
private Integer shopType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(ORDER订单,GOODS商品,REFUND退款)
|
||||||
|
*/
|
||||||
|
private Object pullType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取方式(主动拉取、定时任务)
|
||||||
|
*/
|
||||||
|
private String pullWay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取参数
|
||||||
|
*/
|
||||||
|
private String pullParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取结果
|
||||||
|
*/
|
||||||
|
private String pullResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取时间
|
||||||
|
*/
|
||||||
|
private Date pullTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗时(毫秒)
|
||||||
|
*/
|
||||||
|
private Long duration;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键Id
|
||||||
|
*/
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键Id
|
||||||
|
*/
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
public Integer getShopId() {
|
||||||
|
return shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
public void setShopId(Integer shopId) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台id
|
||||||
|
*/
|
||||||
|
public Integer getShopType() {
|
||||||
|
return shopType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台id
|
||||||
|
*/
|
||||||
|
public void setShopType(Integer shopType) {
|
||||||
|
this.shopType = shopType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(ORDER订单,GOODS商品,REFUND退款)
|
||||||
|
*/
|
||||||
|
public Object getPullType() {
|
||||||
|
return pullType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型(ORDER订单,GOODS商品,REFUND退款)
|
||||||
|
*/
|
||||||
|
public void setPullType(Object pullType) {
|
||||||
|
this.pullType = pullType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取方式(主动拉取、定时任务)
|
||||||
|
*/
|
||||||
|
public String getPullWay() {
|
||||||
|
return pullWay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取方式(主动拉取、定时任务)
|
||||||
|
*/
|
||||||
|
public void setPullWay(String pullWay) {
|
||||||
|
this.pullWay = pullWay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取参数
|
||||||
|
*/
|
||||||
|
public String getPullParams() {
|
||||||
|
return pullParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取参数
|
||||||
|
*/
|
||||||
|
public void setPullParams(String pullParams) {
|
||||||
|
this.pullParams = pullParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取结果
|
||||||
|
*/
|
||||||
|
public String getPullResult() {
|
||||||
|
return pullResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取结果
|
||||||
|
*/
|
||||||
|
public void setPullResult(String pullResult) {
|
||||||
|
this.pullResult = pullResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取时间
|
||||||
|
*/
|
||||||
|
public Date getPullTime() {
|
||||||
|
return pullTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取时间
|
||||||
|
*/
|
||||||
|
public void setPullTime(Date pullTime) {
|
||||||
|
this.pullTime = pullTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗时(毫秒)
|
||||||
|
*/
|
||||||
|
public Long getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 耗时(毫秒)
|
||||||
|
*/
|
||||||
|
public void setDuration(Long duration) {
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SysShopPullLogs other = (SysShopPullLogs) that;
|
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||||
|
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
||||||
|
&& (this.getShopType() == null ? other.getShopType() == null : this.getShopType().equals(other.getShopType()))
|
||||||
|
&& (this.getPullType() == null ? other.getPullType() == null : this.getPullType().equals(other.getPullType()))
|
||||||
|
&& (this.getPullWay() == null ? other.getPullWay() == null : this.getPullWay().equals(other.getPullWay()))
|
||||||
|
&& (this.getPullParams() == null ? other.getPullParams() == null : this.getPullParams().equals(other.getPullParams()))
|
||||||
|
&& (this.getPullResult() == null ? other.getPullResult() == null : this.getPullResult().equals(other.getPullResult()))
|
||||||
|
&& (this.getPullTime() == null ? other.getPullTime() == null : this.getPullTime().equals(other.getPullTime()))
|
||||||
|
&& (this.getDuration() == null ? other.getDuration() == null : this.getDuration().equals(other.getDuration()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||||
|
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
||||||
|
result = prime * result + ((getShopType() == null) ? 0 : getShopType().hashCode());
|
||||||
|
result = prime * result + ((getPullType() == null) ? 0 : getPullType().hashCode());
|
||||||
|
result = prime * result + ((getPullWay() == null) ? 0 : getPullWay().hashCode());
|
||||||
|
result = prime * result + ((getPullParams() == null) ? 0 : getPullParams().hashCode());
|
||||||
|
result = prime * result + ((getPullResult() == null) ? 0 : getPullResult().hashCode());
|
||||||
|
result = prime * result + ((getPullTime() == null) ? 0 : getPullTime().hashCode());
|
||||||
|
result = prime * result + ((getDuration() == null) ? 0 : getDuration().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
sb.append(", shopId=").append(shopId);
|
||||||
|
sb.append(", shopType=").append(shopType);
|
||||||
|
sb.append(", pullType=").append(pullType);
|
||||||
|
sb.append(", pullWay=").append(pullWay);
|
||||||
|
sb.append(", pullParams=").append(pullParams);
|
||||||
|
sb.append(", pullResult=").append(pullResult);
|
||||||
|
sb.append(", pullTime=").append(pullTime);
|
||||||
|
sb.append(", duration=").append(duration);
|
||||||
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.qihang.tao.mapper;
|
||||||
|
|
||||||
|
import com.qihang.tao.domain.SysShopPullLasttime;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qilip
|
||||||
|
* @description 针对表【sys_shop_pull_lasttime(店铺更新最后时间记录)】的数据库操作Mapper
|
||||||
|
* @createDate 2024-03-17 19:45:11
|
||||||
|
* @Entity com.qihang.tao.domain.SysShopPullLasttime
|
||||||
|
*/
|
||||||
|
public interface SysShopPullLasttimeMapper extends BaseMapper<SysShopPullLasttime> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.qihang.tao.mapper;
|
||||||
|
|
||||||
|
import com.qihang.tao.domain.SysShopPullLogs;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qilip
|
||||||
|
* @description 针对表【sys_shop_pull_logs(更新日志表)】的数据库操作Mapper
|
||||||
|
* @createDate 2024-03-17 19:45:11
|
||||||
|
* @Entity com.qihang.tao.domain.SysShopPullLogs
|
||||||
|
*/
|
||||||
|
public interface SysShopPullLogsMapper extends BaseMapper<SysShopPullLogs> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@ import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -119,12 +120,10 @@ public class OrderApiHelper {
|
||||||
* @return
|
* @return
|
||||||
* @throws ApiException
|
* @throws ApiException
|
||||||
*/
|
*/
|
||||||
public static ApiResult<TaoOrder> pullIncrementOrder(Long pageNo, Long pageSize, String url, String appKey, String appSecret, String sessionKey) throws ApiException {
|
public static ApiResult<TaoOrder> pullIncrementOrder(LocalDateTime startTime,LocalDateTime endTime,Long pageNo, Long pageSize, String url, String appKey, String appSecret, String sessionKey) throws ApiException {
|
||||||
log.info("=======开增量拉取订单{}=========",LocalDateTime.now());
|
String startTimeStr = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
// 取当前时间30分钟前
|
String endTimeStr = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
LocalDateTime endTime = LocalDateTime.now();
|
log.info("=======开始全量拉取TAO订单{},参数日期:{}-{}=========",LocalDateTime.now(),startTimeStr,endTimeStr);
|
||||||
LocalDateTime startTime = endTime.minus(60*24, ChronoUnit.MINUTES);
|
|
||||||
|
|
||||||
|
|
||||||
TaobaoClient client = new DefaultTaobaoClient(url, appKey, appSecret);
|
TaobaoClient client = new DefaultTaobaoClient(url, appKey, appSecret);
|
||||||
TradesSoldIncrementGetRequest req = new TradesSoldIncrementGetRequest();
|
TradesSoldIncrementGetRequest req = new TradesSoldIncrementGetRequest();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.qihang.tao.service;
|
||||||
|
|
||||||
|
import com.qihang.tao.domain.SysShopPullLasttime;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qilip
|
||||||
|
* @description 针对表【sys_shop_pull_lasttime(店铺更新最后时间记录)】的数据库操作Service
|
||||||
|
* @createDate 2024-03-17 19:45:11
|
||||||
|
*/
|
||||||
|
public interface SysShopPullLasttimeService extends IService<SysShopPullLasttime> {
|
||||||
|
SysShopPullLasttime getLasttimeByShop(Integer shopId,String pullType);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.qihang.tao.service;
|
||||||
|
|
||||||
|
import com.qihang.tao.domain.SysShopPullLogs;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qilip
|
||||||
|
* @description 针对表【sys_shop_pull_logs(更新日志表)】的数据库操作Service
|
||||||
|
* @createDate 2024-03-17 19:45:11
|
||||||
|
*/
|
||||||
|
public interface SysShopPullLogsService extends IService<SysShopPullLogs> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.qihang.tao.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.qihang.tao.domain.SysShopPullLasttime;
|
||||||
|
import com.qihang.tao.service.SysShopPullLasttimeService;
|
||||||
|
import com.qihang.tao.mapper.SysShopPullLasttimeMapper;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qilip
|
||||||
|
* @description 针对表【sys_shop_pull_lasttime(店铺更新最后时间记录)】的数据库操作Service实现
|
||||||
|
* @createDate 2024-03-17 19:45:11
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class SysShopPullLasttimeServiceImpl extends ServiceImpl<SysShopPullLasttimeMapper, SysShopPullLasttime>
|
||||||
|
implements SysShopPullLasttimeService{
|
||||||
|
private final SysShopPullLasttimeMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysShopPullLasttime getLasttimeByShop(Integer shopId, String pullType) {
|
||||||
|
List<SysShopPullLasttime> sysShopPullLasttimes = mapper.selectList(new LambdaQueryWrapper<SysShopPullLasttime>().eq(SysShopPullLasttime::getShopId, shopId).eq(SysShopPullLasttime::getPullType, pullType));
|
||||||
|
if(sysShopPullLasttimes != null && !sysShopPullLasttimes.isEmpty()) return sysShopPullLasttimes.get(0);
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.qihang.tao.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.qihang.tao.domain.SysShopPullLogs;
|
||||||
|
import com.qihang.tao.service.SysShopPullLogsService;
|
||||||
|
import com.qihang.tao.mapper.SysShopPullLogsMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author qilip
|
||||||
|
* @description 针对表【sys_shop_pull_logs(更新日志表)】的数据库操作Service实现
|
||||||
|
* @createDate 2024-03-17 19:45:11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysShopPullLogsServiceImpl extends ServiceImpl<SysShopPullLogsMapper, SysShopPullLogs>
|
||||||
|
implements SysShopPullLogsService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -290,4 +290,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return userMapper.deleteUserById(userId);
|
return userMapper.deleteUserById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkUserDataScope(Long userId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.qihang.tao.mapper.SysShopPullLasttimeMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.qihang.tao.domain.SysShopPullLasttime">
|
||||||
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||||
|
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||||
|
<result property="pullType" column="pull_type" jdbcType="OTHER"/>
|
||||||
|
<result property="lasttime" column="lasttime" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,shop_id,pull_type,
|
||||||
|
lasttime,create_time,update_time
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.qihang.tao.mapper.SysShopPullLogsMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.qihang.tao.domain.SysShopPullLogs">
|
||||||
|
<id property="id" column="id" jdbcType="BIGINT"/>
|
||||||
|
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||||
|
<result property="shopType" column="shop_type" jdbcType="INTEGER"/>
|
||||||
|
<result property="pullType" column="pull_type" jdbcType="OTHER"/>
|
||||||
|
<result property="pullWay" column="pull_way" jdbcType="VARCHAR"/>
|
||||||
|
<result property="pullParams" column="pull_params" jdbcType="VARCHAR"/>
|
||||||
|
<result property="pullResult" column="pull_result" jdbcType="VARCHAR"/>
|
||||||
|
<result property="pullTime" column="pull_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="duration" column="duration" jdbcType="BIGINT"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,shop_id,shop_type,
|
||||||
|
pull_type,pull_way,pull_params,
|
||||||
|
pull_result,pull_time,duration
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue