This commit is contained in:
parent
4ad191833e
commit
c802dd8af0
|
|
@ -1,4 +1,4 @@
|
|||
package com.qihang.tao.controller;
|
||||
package com.qihang.common.api;
|
||||
|
||||
public class ShopApiParams {
|
||||
private String appKey;
|
||||
|
|
@ -6,6 +6,15 @@ public class ShopApiParams {
|
|||
private String accessToken;
|
||||
private String apiRequestUrl;
|
||||
private String tokenRequestUrl;
|
||||
private String serverUrl;
|
||||
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
public String getTokenRequestUrl() {
|
||||
return tokenRequestUrl;
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.qihang.common.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApiResult<T> {
|
||||
private T data;
|
||||
private int code;
|
||||
private String msg;
|
||||
private Integer totalRecords;
|
||||
private List<T> list;
|
||||
public static <T> ApiResult<T> build(int code ,String msg){
|
||||
ApiResult<T> result = new ApiResult<>();
|
||||
result.setCode(code);
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> ApiResult<T> build(int code ,String msg,T data){
|
||||
ApiResult<T> result = new ApiResult<>();
|
||||
result.setCode(code);
|
||||
result.setMsg(msg);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> ApiResult<T> build(int totalRecords , List<T> list){
|
||||
ApiResult<T> result = new ApiResult<>();
|
||||
result.setCode(0);
|
||||
result.setMsg("SUCCESS");
|
||||
result.totalRecords = totalRecords;
|
||||
result.setList(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
// public ApiResult(Integer totalRecords, List<T> list) {
|
||||
// this.code = 0;
|
||||
// this.msg = "SUCCESS";
|
||||
// this.totalRecords = totalRecords;
|
||||
// this.list = list;
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.qihang.tao.common;
|
||||
package com.qihang.common.enums;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
|
|
@ -1,12 +1,17 @@
|
|||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<!-- <parent>-->
|
||||
<!-- <groupId>com.qihang</groupId>-->
|
||||
<!-- <artifactId>qihang-oms</artifactId>-->
|
||||
<!-- <version>1.0-SNAPSHOT</version>-->
|
||||
<!-- </parent>-->
|
||||
<parent>
|
||||
<groupId>com.qihang</groupId>
|
||||
<artifactId>qihang-oms</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.qihang.jd</groupId>
|
||||
<artifactId>jd-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
|
@ -77,6 +82,12 @@
|
|||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.9.13</version> <!-- jd-sdk依赖 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package com.qihang.jd.common;
|
||||
|
||||
import com.qihang.common.api.ShopApiParams;
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.enums.EnumShopType;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
|
||||
import com.qihang.jd.domain.SysPlatform;
|
||||
import com.qihang.jd.service.SysPlatformService;
|
||||
import com.qihang.jd.service.SysShopService;
|
||||
//import com.qihang.tao.common.ServerConfig;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Component
|
||||
public class ApiCommon {
|
||||
private final SysShopService shopService;
|
||||
private final SysPlatformService platformService;
|
||||
// private final ServerConfig serverConfig;
|
||||
/**
|
||||
* 更新前的检查
|
||||
*
|
||||
* @param shopId
|
||||
* @return
|
||||
* @throws
|
||||
*/
|
||||
public ApiResult<ShopApiParams> checkBefore(Integer shopId) {
|
||||
var shop = shopService.selectShopById(shopId);
|
||||
if (shop == null) {
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有找到店铺");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR,"参数错误,没有找到店铺");
|
||||
}
|
||||
|
||||
if (shop.getType() != EnumShopType.JD.getIndex()) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是淘系店铺");
|
||||
}
|
||||
SysPlatform platform = platformService.selectById(EnumShopType.JD.getIndex());
|
||||
|
||||
if(!StringUtils.hasText(platform.getAppKey())) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "平台配置错误,没有找到AppKey");
|
||||
}
|
||||
if(!StringUtils.hasText(platform.getAppSecret())) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到AppSercet");
|
||||
}
|
||||
if(!StringUtils.hasText(platform.getRedirectUri())) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到RedirectUri");
|
||||
}
|
||||
if(!StringUtils.hasText(platform.getServerUrl())) {
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到ServerUrl");
|
||||
}
|
||||
|
||||
// if(shop.getSellerId() == null || shop.getSellerId() <= 0) {
|
||||
// return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到SellerUserId");
|
||||
// }
|
||||
|
||||
ShopApiParams params = new ShopApiParams();
|
||||
params.setAppKey(platform.getAppKey());
|
||||
params.setAppSecret(platform.getAppSecret());
|
||||
params.setAccessToken(shop.getAccessToken());
|
||||
params.setTokenRequestUrl(platform.getRedirectUri());
|
||||
params.setApiRequestUrl(shop.getApiRequestUrl());
|
||||
params.setServerUrl(platform.getServerUrl());
|
||||
if (!StringUtils.hasText(shop.getAccessToken())) {
|
||||
|
||||
return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权", params);
|
||||
}
|
||||
|
||||
/****************先查询卖家对不对***************/
|
||||
// TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
|
||||
// UserSellerGetRequest reqSeller = new UserSellerGetRequest();
|
||||
// reqSeller.setFields("nick,user_id");
|
||||
// UserSellerGetResponse rsp = client.execute(reqSeller, sessionKey);
|
||||
// if(StringUtils.hasText(rsp.getErrorCode())){
|
||||
// if(rsp.getErrorCode().equals("27")){
|
||||
// return new ApiResult<>(EnumResultVo.TokenFail.getIndex(), "Token已过期,请重新授权",params);
|
||||
// }
|
||||
// else if(rsp.getErrorCode().equals("11")){
|
||||
// if(rsp.getSubCode().equals("isv.permission-api-package-limit"))
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "请检查淘宝用户API:taobao.user.seller.get是否具有访问权限",params);
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), rsp.getSubCode(),params);
|
||||
// }
|
||||
// else if(rsp.getErrorCode().equals("25")){
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "无效签名!请检查SessionKey、appKey、appSecret是否匹配",params);
|
||||
// } else
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误!"+(StringUtils.hasText(rsp.getSubMsg()) ? rsp.getSubMsg(): rsp.getMsg()));
|
||||
// }
|
||||
// if(rsp.getUser() == null || rsp.getUser().getUserId() == null){
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误!请设置店铺SellerUserId值!",params);
|
||||
// }
|
||||
// else if (shop.getSellerUserId().longValue() != rsp.getUser().getUserId().longValue()) {
|
||||
// return new ApiResult<>(EnumResultVo.TokenFail.getIndex(), "当前用户是:" + rsp.getUser().getNick() + ",请重新授权",params);
|
||||
// }
|
||||
return ApiResult.build(HttpStatus.SUCCESS,"",params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.qihang.jd.common;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PullRequest {
|
||||
private Integer shopId;//店铺Id
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.qihang.jd.controller;
|
||||
|
||||
import com.jd.open.api.sdk.DefaultJdClient;
|
||||
import com.jd.open.api.sdk.JdClient;
|
||||
import com.jd.open.api.sdk.request.order.PopOrderEnSearchRequest;
|
||||
import com.jd.open.api.sdk.request.refundapply.PopAfsRefundapplyQuerylistRequest;
|
||||
import com.jd.open.api.sdk.request.ware.SkuReadSearchSkuListRequest;
|
||||
import com.jd.open.api.sdk.request.ware.WareReadSearchWare4ValidRequest;
|
||||
import com.jd.open.api.sdk.response.order.PopOrderEnSearchResponse;
|
||||
import com.jd.open.api.sdk.response.refundapply.PopAfsRefundapplyQuerylistResponse;
|
||||
import com.jd.open.api.sdk.response.ware.SkuReadSearchSkuListResponse;
|
||||
import com.jd.open.api.sdk.response.ware.WareReadSearchWare4ValidResponse;
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.jd.common.ApiCommon;
|
||||
import com.qihang.jd.common.PullRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RequestMapping("/order")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class OrderApiController {
|
||||
private final ApiCommon apiCommon;
|
||||
@RequestMapping(value = "/pull_order", method = RequestMethod.POST)
|
||||
public Object pullGoodsList(@RequestBody PullRequest params) throws Exception {
|
||||
if (params.getShopId() == null || params.getShopId() <= 0) {
|
||||
// return ApiResul new ApiResult(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
var checkResult = apiCommon.checkBefore(params.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||
}
|
||||
String accessToken = checkResult.getData().getAccessToken();
|
||||
String serverUrl = checkResult.getData().getServerUrl();
|
||||
String appKey = checkResult.getData().getAppKey();
|
||||
String appSecret = checkResult.getData().getAppSecret();
|
||||
// String accessToken = "8abd974c62c34778935b34b5952e6f68izdk";
|
||||
// String appKey="FB4CC3688E6F9065D4FF510A53BB60FF";
|
||||
// String appSecret="40e8c8b2427f4e6db8f4a39af27d719e";
|
||||
|
||||
JdClient client=new DefaultJdClient(serverUrl,accessToken,appKey,appSecret);
|
||||
//https://open.jd.com/home/home/#/doc/api?apiCateId=55&apiId=4246&apiName=jingdong.pop.order.search
|
||||
// PopOrderSearchRequest request=new PopOrderSearchRequest();
|
||||
// request.setStartDate("2024-2-14 10:00:00");
|
||||
// request.setEndDate("2024-3-4 12:00:00");
|
||||
// request.setOrderState("TRADE_CANCELED");
|
||||
// request.setOptionalFields("itemInfoList,orderId,isShipmenttype,scDT,idSopShipmenttype,orderStartTime,consigneeInfo");
|
||||
// request.setPage("1");
|
||||
// request.setPageSize("20");
|
||||
// request.setSortType(1);
|
||||
// request.setDateType(0);
|
||||
// PopOrderSearchResponse response=client.execute(request);
|
||||
// System.out.println(response);
|
||||
|
||||
PopOrderEnSearchRequest request =new PopOrderEnSearchRequest();
|
||||
request.setStartDate("2020-04-04 00:20:35");
|
||||
request.setEndDate("2020-04-04 00:20:35");
|
||||
request.setOrderState("21");
|
||||
// request.setOptionalFields("orderId,venderId");
|
||||
// request.setSourceId("JOS");
|
||||
request.setOptionalFields("itemInfoList,orderId,isShipmenttype,scDT,idSopShipmenttype,orderStartTime,consigneeInfo");
|
||||
request.setPage("1");
|
||||
request.setPageSize("10");
|
||||
request.setSortType(1);
|
||||
request.setDateType(0);
|
||||
PopOrderEnSearchResponse response=client.execute(request);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
package com.qihang.jd.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName sys_platform
|
||||
*/
|
||||
public class SysPlatform implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 平台名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 平台编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 平台回调uri
|
||||
*/
|
||||
private String redirectUri;
|
||||
|
||||
/**
|
||||
* 接口访问地址
|
||||
*/
|
||||
private String serverUrl;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台名
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台名
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台编码
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台编码
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getAppSecret() {
|
||||
return appSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setAppSecret(String appSecret) {
|
||||
this.appSecret = appSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台回调uri
|
||||
*/
|
||||
public String getRedirectUri() {
|
||||
return redirectUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台回调uri
|
||||
*/
|
||||
public void setRedirectUri(String redirectUri) {
|
||||
this.redirectUri = redirectUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口访问地址
|
||||
*/
|
||||
public String getServerUrl() {
|
||||
return serverUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口访问地址
|
||||
*/
|
||||
public void setServerUrl(String serverUrl) {
|
||||
this.serverUrl = serverUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SysPlatform other = (SysPlatform) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()))
|
||||
&& (this.getAppKey() == null ? other.getAppKey() == null : this.getAppKey().equals(other.getAppKey()))
|
||||
&& (this.getAppSecret() == null ? other.getAppSecret() == null : this.getAppSecret().equals(other.getAppSecret()))
|
||||
&& (this.getRedirectUri() == null ? other.getRedirectUri() == null : this.getRedirectUri().equals(other.getRedirectUri()))
|
||||
&& (this.getServerUrl() == null ? other.getServerUrl() == null : this.getServerUrl().equals(other.getServerUrl()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
|
||||
result = prime * result + ((getAppKey() == null) ? 0 : getAppKey().hashCode());
|
||||
result = prime * result + ((getAppSecret() == null) ? 0 : getAppSecret().hashCode());
|
||||
result = prime * result + ((getRedirectUri() == null) ? 0 : getRedirectUri().hashCode());
|
||||
result = prime * result + ((getServerUrl() == null) ? 0 : getServerUrl().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(", name=").append(name);
|
||||
sb.append(", code=").append(code);
|
||||
sb.append(", appKey=").append(appKey);
|
||||
sb.append(", appSecret=").append(appSecret);
|
||||
sb.append(", redirectUri=").append(redirectUri);
|
||||
sb.append(", serverUrl=").append(serverUrl);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,417 @@
|
|||
package com.qihang.jd.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据中心-店铺
|
||||
* @TableName sys_shop
|
||||
*/
|
||||
public class SysShop implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 对应第三方平台Id
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 店铺url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态(1正常2已删除)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Long modifyOn;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 第三方平台店铺id,淘宝天猫开放平台使用
|
||||
*/
|
||||
private Long sellerId;
|
||||
|
||||
/**
|
||||
* Appkey
|
||||
*/
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* Appsercet
|
||||
*/
|
||||
private String appSercet;
|
||||
|
||||
/**
|
||||
* 第三方平台sessionKey(access_token)
|
||||
*/
|
||||
private String accessToken;
|
||||
|
||||
/**
|
||||
* 到期
|
||||
*/
|
||||
private Long expiresIn;
|
||||
|
||||
/**
|
||||
* access_token开始时间
|
||||
*/
|
||||
private Long accessTokenBegin;
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
private String refreshToken;
|
||||
|
||||
/**
|
||||
* 刷新token过期时间
|
||||
*/
|
||||
private Long refreshTokenTimeout;
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
private String apiRequestUrl;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺名
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应第三方平台Id
|
||||
*/
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对应第三方平台Id
|
||||
*/
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺url
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(1正常2已删除)
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(1正常2已删除)
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
public Long getModifyOn() {
|
||||
return modifyOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
public void setModifyOn(Long modifyOn) {
|
||||
this.modifyOn = modifyOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台店铺id,淘宝天猫开放平台使用
|
||||
*/
|
||||
public Long getSellerId() {
|
||||
return sellerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台店铺id,淘宝天猫开放平台使用
|
||||
*/
|
||||
public void setSellerId(Long sellerId) {
|
||||
this.sellerId = sellerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appkey
|
||||
*/
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appkey
|
||||
*/
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appsercet
|
||||
*/
|
||||
public String getAppSercet() {
|
||||
return appSercet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appsercet
|
||||
*/
|
||||
public void setAppSercet(String appSercet) {
|
||||
this.appSercet = appSercet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台sessionKey(access_token)
|
||||
*/
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方平台sessionKey(access_token)
|
||||
*/
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 到期
|
||||
*/
|
||||
public Long getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 到期
|
||||
*/
|
||||
public void setExpiresIn(Long expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* access_token开始时间
|
||||
*/
|
||||
public Long getAccessTokenBegin() {
|
||||
return accessTokenBegin;
|
||||
}
|
||||
|
||||
/**
|
||||
* access_token开始时间
|
||||
*/
|
||||
public void setAccessTokenBegin(Long accessTokenBegin) {
|
||||
this.accessTokenBegin = accessTokenBegin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
public String getRefreshToken() {
|
||||
return refreshToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*/
|
||||
public void setRefreshToken(String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token过期时间
|
||||
*/
|
||||
public Long getRefreshTokenTimeout() {
|
||||
return refreshTokenTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token过期时间
|
||||
*/
|
||||
public void setRefreshTokenTimeout(Long refreshTokenTimeout) {
|
||||
this.refreshTokenTimeout = refreshTokenTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
public String getApiRequestUrl() {
|
||||
return apiRequestUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求url
|
||||
*/
|
||||
public void setApiRequestUrl(String apiRequestUrl) {
|
||||
this.apiRequestUrl = apiRequestUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SysShop other = (SysShop) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
|
||||
&& (this.getUrl() == null ? other.getUrl() == null : this.getUrl().equals(other.getUrl()))
|
||||
&& (this.getSort() == null ? other.getSort() == null : this.getSort().equals(other.getSort()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getModifyOn() == null ? other.getModifyOn() == null : this.getModifyOn().equals(other.getModifyOn()))
|
||||
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
|
||||
&& (this.getSellerId() == null ? other.getSellerId() == null : this.getSellerId().equals(other.getSellerId()))
|
||||
&& (this.getAppKey() == null ? other.getAppKey() == null : this.getAppKey().equals(other.getAppKey()))
|
||||
&& (this.getAppSercet() == null ? other.getAppSercet() == null : this.getAppSercet().equals(other.getAppSercet()))
|
||||
&& (this.getAccessToken() == null ? other.getAccessToken() == null : this.getAccessToken().equals(other.getAccessToken()))
|
||||
&& (this.getExpiresIn() == null ? other.getExpiresIn() == null : this.getExpiresIn().equals(other.getExpiresIn()))
|
||||
&& (this.getAccessTokenBegin() == null ? other.getAccessTokenBegin() == null : this.getAccessTokenBegin().equals(other.getAccessTokenBegin()))
|
||||
&& (this.getRefreshToken() == null ? other.getRefreshToken() == null : this.getRefreshToken().equals(other.getRefreshToken()))
|
||||
&& (this.getRefreshTokenTimeout() == null ? other.getRefreshTokenTimeout() == null : this.getRefreshTokenTimeout().equals(other.getRefreshTokenTimeout()))
|
||||
&& (this.getApiRequestUrl() == null ? other.getApiRequestUrl() == null : this.getApiRequestUrl().equals(other.getApiRequestUrl()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
|
||||
result = prime * result + ((getUrl() == null) ? 0 : getUrl().hashCode());
|
||||
result = prime * result + ((getSort() == null) ? 0 : getSort().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getModifyOn() == null) ? 0 : getModifyOn().hashCode());
|
||||
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
|
||||
result = prime * result + ((getSellerId() == null) ? 0 : getSellerId().hashCode());
|
||||
result = prime * result + ((getAppKey() == null) ? 0 : getAppKey().hashCode());
|
||||
result = prime * result + ((getAppSercet() == null) ? 0 : getAppSercet().hashCode());
|
||||
result = prime * result + ((getAccessToken() == null) ? 0 : getAccessToken().hashCode());
|
||||
result = prime * result + ((getExpiresIn() == null) ? 0 : getExpiresIn().hashCode());
|
||||
result = prime * result + ((getAccessTokenBegin() == null) ? 0 : getAccessTokenBegin().hashCode());
|
||||
result = prime * result + ((getRefreshToken() == null) ? 0 : getRefreshToken().hashCode());
|
||||
result = prime * result + ((getRefreshTokenTimeout() == null) ? 0 : getRefreshTokenTimeout().hashCode());
|
||||
result = prime * result + ((getApiRequestUrl() == null) ? 0 : getApiRequestUrl().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(", name=").append(name);
|
||||
sb.append(", type=").append(type);
|
||||
sb.append(", url=").append(url);
|
||||
sb.append(", sort=").append(sort);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", modifyOn=").append(modifyOn);
|
||||
sb.append(", remark=").append(remark);
|
||||
sb.append(", sellerId=").append(sellerId);
|
||||
sb.append(", appKey=").append(appKey);
|
||||
sb.append(", appSercet=").append(appSercet);
|
||||
sb.append(", accessToken=").append(accessToken);
|
||||
sb.append(", expiresIn=").append(expiresIn);
|
||||
sb.append(", accessTokenBegin=").append(accessTokenBegin);
|
||||
sb.append(", refreshToken=").append(refreshToken);
|
||||
sb.append(", refreshTokenTimeout=").append(refreshTokenTimeout);
|
||||
sb.append(", apiRequestUrl=").append(apiRequestUrl);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.qihang.jd.mapper;
|
||||
|
||||
import com.qihang.jd.domain.SysPlatform;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_platform】的数据库操作Mapper
|
||||
* @createDate 2024-03-04 18:43:05
|
||||
* @Entity com.qihang.jd.domain.SysPlatform
|
||||
*/
|
||||
public interface SysPlatformMapper extends BaseMapper<SysPlatform> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.qihang.jd.mapper;
|
||||
|
||||
import com.qihang.jd.domain.SysShop;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_shop(数据中心-店铺)】的数据库操作Mapper
|
||||
* @createDate 2024-03-04 18:43:05
|
||||
* @Entity com.qihang.jd.domain.SysShop
|
||||
*/
|
||||
public interface SysShopMapper extends BaseMapper<SysShop> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.qihang.jd.service;
|
||||
|
||||
import com.qihang.jd.domain.SysPlatform;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_platform】的数据库操作Service
|
||||
* @createDate 2024-03-04 18:43:05
|
||||
*/
|
||||
public interface SysPlatformService extends IService<SysPlatform> {
|
||||
SysPlatform selectById(Integer id);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.qihang.jd.service;
|
||||
|
||||
import com.qihang.jd.domain.SysShop;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_shop(数据中心-店铺)】的数据库操作Service
|
||||
* @createDate 2024-03-04 18:43:05
|
||||
*/
|
||||
public interface SysShopService extends IService<SysShop> {
|
||||
SysShop selectShopById(Integer shopId);
|
||||
|
||||
void updateSessionKey(Integer shopId,String sessionKey);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.qihang.jd.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qihang.jd.domain.SysPlatform;
|
||||
import com.qihang.jd.service.SysPlatformService;
|
||||
import com.qihang.jd.mapper.SysPlatformMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_platform】的数据库操作Service实现
|
||||
* @createDate 2024-03-04 18:43:05
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class SysPlatformServiceImpl extends ServiceImpl<SysPlatformMapper, SysPlatform>
|
||||
implements SysPlatformService{
|
||||
private final SysPlatformMapper mapper;
|
||||
@Override
|
||||
public SysPlatform selectById(Integer id) {
|
||||
return mapper.selectById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.qihang.jd.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qihang.jd.domain.SysShop;
|
||||
import com.qihang.jd.service.SysShopService;
|
||||
import com.qihang.jd.mapper.SysShopMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author TW
|
||||
* @description 针对表【sys_shop(数据中心-店铺)】的数据库操作Service实现
|
||||
* @createDate 2024-03-04 18:43:05
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
public class SysShopServiceImpl extends ServiceImpl<SysShopMapper, SysShop>
|
||||
implements SysShopService{
|
||||
private SysShopMapper mapper;
|
||||
@Override
|
||||
public SysShop selectShopById(Integer shopId) {
|
||||
return mapper.selectById(shopId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSessionKey(Integer shopId, String sessionKey) {
|
||||
SysShop shop = new SysShop();
|
||||
shop.setId(shopId);
|
||||
shop.setAccessToken(sessionKey);
|
||||
mapper.updateById(shop);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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.jd.mapper.SysPlatformMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.qihang.jd.domain.SysPlatform">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="code" column="code" jdbcType="VARCHAR"/>
|
||||
<result property="appKey" column="app_key" jdbcType="VARCHAR"/>
|
||||
<result property="appSecret" column="app_secret" jdbcType="VARCHAR"/>
|
||||
<result property="redirectUri" column="redirect_uri" jdbcType="VARCHAR"/>
|
||||
<result property="serverUrl" column="server_url" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,code,
|
||||
app_key,app_secret,redirect_uri,
|
||||
server_url
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?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.jd.mapper.SysShopMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.qihang.jd.domain.SysShop">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="INTEGER"/>
|
||||
<result property="url" column="url" jdbcType="VARCHAR"/>
|
||||
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||
<result property="modifyOn" column="modify_on" jdbcType="BIGINT"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="sellerId" column="seller_id" jdbcType="BIGINT"/>
|
||||
<result property="appKey" column="app_key" jdbcType="VARCHAR"/>
|
||||
<result property="appSercet" column="app_sercet" jdbcType="VARCHAR"/>
|
||||
<result property="accessToken" column="access_token" jdbcType="VARCHAR"/>
|
||||
<result property="expiresIn" column="expires_in" jdbcType="BIGINT"/>
|
||||
<result property="accessTokenBegin" column="access_token_begin" jdbcType="BIGINT"/>
|
||||
<result property="refreshToken" column="refresh_token" jdbcType="VARCHAR"/>
|
||||
<result property="refreshTokenTimeout" column="refresh_token_timeout" jdbcType="BIGINT"/>
|
||||
<result property="apiRequestUrl" column="api_request_url" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,type,
|
||||
url,sort,status,
|
||||
modify_on,remark,seller_id,
|
||||
app_key,app_sercet,access_token,
|
||||
expires_in,access_token_begin,refresh_token,
|
||||
refresh_token_timeout,api_request_url
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
package com.qihang.tao.api;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.tao.common.EnumShopType;
|
||||
import com.qihang.common.enums.EnumShopType;
|
||||
import com.qihang.tao.common.ServerConfig;
|
||||
import com.qihang.tao.controller.ShopApiParams;
|
||||
import com.qihang.common.api.ShopApiParams;
|
||||
import com.qihang.tao.domain.SysPlatform;
|
||||
import com.qihang.tao.service.SysPlatformService;
|
||||
import com.qihang.tao.service.SysShopService;
|
||||
|
|
@ -24,29 +25,29 @@ public class ApiCommon {
|
|||
* @return
|
||||
* @throws ApiException
|
||||
*/
|
||||
public com.qihang.tao.common.ApiResult<ShopApiParams> checkBefore(Integer shopId) throws ApiException {
|
||||
public ApiResult<ShopApiParams> checkBefore(Integer shopId) throws ApiException {
|
||||
var shop = shopService.selectShopById(shopId);
|
||||
if (shop == null) {
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有找到店铺");
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR,"参数错误,没有找到店铺");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR,"参数错误,没有找到店铺");
|
||||
}
|
||||
|
||||
if (shop.getType() != EnumShopType.TAO.getIndex()) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是淘系店铺");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,店铺不是淘系店铺");
|
||||
}
|
||||
SysPlatform platform = platformService.selectById(EnumShopType.TAO.getIndex());
|
||||
|
||||
if(!StringUtils.hasText(platform.getAppKey())) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "平台配置错误,没有找到AppKey");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "平台配置错误,没有找到AppKey");
|
||||
}
|
||||
if(!StringUtils.hasText(platform.getAppSecret())) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到AppSercet");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到AppSercet");
|
||||
}
|
||||
if(!StringUtils.hasText(shop.getApiRequestUrl())) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到ApiRequestUrl");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到ApiRequestUrl");
|
||||
}
|
||||
if(shop.getSellerId() == null || shop.getSellerId() <= 0) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到SellerUserId");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "第三方平台配置错误,没有找到SellerUserId");
|
||||
}
|
||||
|
||||
ShopApiParams params = new ShopApiParams();
|
||||
|
|
@ -58,7 +59,7 @@ public class ApiCommon {
|
|||
|
||||
if (!StringUtils.hasText(shop.getAccessToken())) {
|
||||
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权", params);
|
||||
return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权", params);
|
||||
}
|
||||
|
||||
/****************先查询卖家对不对***************/
|
||||
|
|
@ -86,7 +87,7 @@ public class ApiCommon {
|
|||
// else if (shop.getSellerUserId().longValue() != rsp.getUser().getUserId().longValue()) {
|
||||
// return new ApiResult<>(EnumResultVo.TokenFail.getIndex(), "当前用户是:" + rsp.getUser().getNick() + ",请重新授权",params);
|
||||
// }
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.SUCCESS,"",params);
|
||||
return ApiResult.build(HttpStatus.SUCCESS,"",params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,65 +1,65 @@
|
|||
package com.qihang.tao.api;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 淘宝开放平台订单更新结果
|
||||
*/
|
||||
public class ApiResult<T> {
|
||||
private Integer code;//代码 0成功其他错误
|
||||
private String msg;//错误信息
|
||||
private Integer totalRecords;//总记录数
|
||||
private List<T> list;//订单
|
||||
|
||||
public ApiResult(Integer code, String msg, Integer totalRecords, List<T> list) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.totalRecords = totalRecords;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public ApiResult(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.totalRecords = 0;
|
||||
this.list = null;
|
||||
}
|
||||
|
||||
public ApiResult(Integer totalRecords, List<T> list) {
|
||||
this.code = 0;
|
||||
this.msg = "SUCCESS";
|
||||
this.totalRecords = totalRecords;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Integer getTotalRecords() {
|
||||
return totalRecords;
|
||||
}
|
||||
|
||||
public void setTotalRecords(Integer totalRecords) {
|
||||
this.totalRecords = totalRecords;
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<T> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
//package com.qihang.tao.api;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 淘宝开放平台订单更新结果
|
||||
// */
|
||||
//public class ApiResult<T> {
|
||||
// private Integer code;//代码 0成功其他错误
|
||||
// private String msg;//错误信息
|
||||
// private Integer totalRecords;//总记录数
|
||||
// private List<T> list;//订单
|
||||
//
|
||||
// public ApiResult(Integer code, String msg, Integer totalRecords, List<T> list) {
|
||||
// this.code = code;
|
||||
// this.msg = msg;
|
||||
// this.totalRecords = totalRecords;
|
||||
// this.list = list;
|
||||
// }
|
||||
//
|
||||
// public ApiResult(Integer code, String msg) {
|
||||
// this.code = code;
|
||||
// this.msg = msg;
|
||||
// this.totalRecords = 0;
|
||||
// this.list = null;
|
||||
// }
|
||||
//
|
||||
// public ApiResult(Integer totalRecords, List<T> list) {
|
||||
// this.code = 0;
|
||||
// this.msg = "SUCCESS";
|
||||
// this.totalRecords = totalRecords;
|
||||
// this.list = list;
|
||||
// }
|
||||
//
|
||||
// public Integer getCode() {
|
||||
// return code;
|
||||
// }
|
||||
//
|
||||
// public void setCode(Integer code) {
|
||||
// this.code = code;
|
||||
// }
|
||||
//
|
||||
// public String getMsg() {
|
||||
// return msg;
|
||||
// }
|
||||
//
|
||||
// public void setMsg(String msg) {
|
||||
// this.msg = msg;
|
||||
// }
|
||||
//
|
||||
// public Integer getTotalRecords() {
|
||||
// return totalRecords;
|
||||
// }
|
||||
//
|
||||
// public void setTotalRecords(Integer totalRecords) {
|
||||
// this.totalRecords = totalRecords;
|
||||
// }
|
||||
//
|
||||
// public List<T> getList() {
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// public void setList(List<T> list) {
|
||||
// this.list = list;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.qihang.tao.api;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.tao.domain.TaoGoods;
|
||||
import com.qihang.tao.domain.TaoGoodsSku;
|
||||
import com.qihang.tao.domain.TaoOrder;
|
||||
|
|
@ -33,7 +34,7 @@ public class GoodsApiHelper {
|
|||
req.setPageSize(pageSize);
|
||||
ItemsOnsaleGetResponse rsp = client.execute(req, sessionKey);
|
||||
if (rsp.getItems() == null) {
|
||||
return new ApiResult(0, new ArrayList());
|
||||
return ApiResult.build(0, new ArrayList());
|
||||
}
|
||||
List<TaoGoods> goodsList = new ArrayList<>();
|
||||
for (Item item : rsp.getItems()) {
|
||||
|
|
@ -64,7 +65,7 @@ public class GoodsApiHelper {
|
|||
goods.setSkus(pullSku(client, sessionKey, item.getNumIid()));
|
||||
goodsList.add(goods);
|
||||
}
|
||||
return new ApiResult(rsp.getTotalResults().intValue(), goodsList);
|
||||
return ApiResult.build(rsp.getTotalResults().intValue(), goodsList);
|
||||
}
|
||||
|
||||
private static List<TaoGoodsSku> pullSku(TaobaoClient client, String sessionKey, Long numIid) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.qihang.tao.api;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
|
||||
|
||||
import com.qihang.tao.api.ApiResult;
|
||||
//import com.qihang.tao.api.ApiResult;
|
||||
import com.qihang.tao.api.OrderAssembleHelper;
|
||||
import com.qihang.tao.domain.TaoOrder;
|
||||
import com.taobao.api.ApiException;
|
||||
|
|
@ -66,12 +67,14 @@ public class OrderApiHelper {
|
|||
// System.out.println(rsp.getBody());
|
||||
if(StringUtils.hasText(rsp.getErrorCode())){
|
||||
if(rsp.getErrorCode().equals("27")){
|
||||
return new ApiResult(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权");
|
||||
// return new ApiResult(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权");
|
||||
return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权");
|
||||
}
|
||||
}
|
||||
if (rsp.getTrades() == null) {
|
||||
//接口查询错误
|
||||
return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
// return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
return ApiResult.build(HttpStatus.ERROR, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
}
|
||||
|
||||
//组合的订单列表
|
||||
|
|
@ -103,7 +106,8 @@ public class OrderApiHelper {
|
|||
}
|
||||
}
|
||||
|
||||
return new ApiResult(rsp.getTotalResults().intValue(), orderList);
|
||||
// return new ApiResult(rsp.getTotalResults().intValue(), orderList);
|
||||
return ApiResult.build(rsp.getTotalResults().intValue(), orderList);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -145,10 +149,12 @@ public class OrderApiHelper {
|
|||
if (rsp.getTrades() == null) {
|
||||
if (!StringUtils.isEmpty(rsp.getErrorCode())) {
|
||||
//接口查询错误
|
||||
return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
// return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
return ApiResult.build(HttpStatus.ERROR,"接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
}
|
||||
log.info("========增量拉取订单:无订单,{}==========",LocalDateTime.now());
|
||||
return new ApiResult(0, new ArrayList());
|
||||
// return new ApiResult(0, new ArrayList());
|
||||
return ApiResult.build(0,new ArrayList<>());
|
||||
}
|
||||
|
||||
//组合的订单列表
|
||||
|
|
@ -169,7 +175,8 @@ public class OrderApiHelper {
|
|||
orderList.add(OrderAssembleHelper.assembleOrder(trade));
|
||||
}
|
||||
}
|
||||
return new ApiResult(orderList.size(), orderList);
|
||||
// return new ApiResult(orderList.size(), orderList);
|
||||
return ApiResult.build(orderList.size(),orderList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.qihang.tao.api;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.common.utils.DateUtils;
|
||||
import com.qihang.common.utils.StringUtils;
|
||||
import com.qihang.tao.domain.TaoRefund;
|
||||
|
|
@ -62,10 +64,10 @@ public class RefundApiHelper {
|
|||
if (rsp.getRefunds() == null) {
|
||||
if (!org.springframework.util.StringUtils.isEmpty(rsp.getErrorCode())) {
|
||||
//接口查询错误
|
||||
return new ApiResult(500, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
return ApiResult.build(HttpStatus.ERROR, "接口调用错误:" + rsp.getMsg() + rsp.getSubMsg());
|
||||
}
|
||||
log.info("========增量拉取退款:无退款,{}==========", LocalDateTime.now());
|
||||
return new ApiResult(0, new ArrayList());
|
||||
return ApiResult.build(0, new ArrayList());
|
||||
}
|
||||
|
||||
//查到了数据
|
||||
|
|
@ -99,7 +101,7 @@ public class RefundApiHelper {
|
|||
list.add(refund);
|
||||
}
|
||||
}
|
||||
return new ApiResult(list.size(), list);
|
||||
return ApiResult.build(list.size(), list);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
package com.qihang.tao.common;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApiResult<T> {
|
||||
private T data;
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public static <T> ApiResult<T> build(int code ,String msg){
|
||||
ApiResult<T> result = new ApiResult<>();
|
||||
result.setCode(code);
|
||||
result.setMsg(msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> ApiResult<T> build(int code ,String msg,T data){
|
||||
ApiResult<T> result = new ApiResult<>();
|
||||
result.setCode(code);
|
||||
result.setMsg(msg);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//package com.qihang.tao.common;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
//import com.qihang.common.enums.HttpStatus;
|
||||
//import lombok.Data;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//@Data
|
||||
//public class ApiResult<T> {
|
||||
// private T data;
|
||||
// private int code;
|
||||
// private String msg;
|
||||
//
|
||||
// public static <T> ApiResult<T> build(int code ,String msg){
|
||||
// ApiResult<T> result = new ApiResult<>();
|
||||
// result.setCode(code);
|
||||
// result.setMsg(msg);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// public static <T> ApiResult<T> build(int code ,String msg,T data){
|
||||
// ApiResult<T> result = new ApiResult<>();
|
||||
// result.setCode(code);
|
||||
// result.setMsg(msg);
|
||||
// result.setData(data);
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.qihang.tao.controller;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.common.EnumResultVo;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.tao.api.ApiCommon;
|
||||
import com.qihang.tao.api.ApiResult;
|
||||
import com.qihang.tao.api.GoodsApiHelper;
|
||||
import com.qihang.tao.api.OrderApiHelper;
|
||||
import com.qihang.tao.common.TaoRequest;
|
||||
|
|
@ -44,11 +44,11 @@ public class GoodsApiController {
|
|||
@RequestMapping(value = "/pull_goods", method = RequestMethod.POST)
|
||||
public ApiResult<Integer> pullGoodsList(@RequestBody TaoRequest req) throws Exception {
|
||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||
return new ApiResult(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
var checkResult = apiCommon.checkBefore(req.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return new ApiResult(checkResult.getCode(), checkResult.getMsg());
|
||||
return ApiResult.build(checkResult.getCode(), checkResult.getMsg());
|
||||
}
|
||||
String sessionKey = checkResult.getData().getAccessToken();
|
||||
String url = checkResult.getData().getApiRequestUrl();
|
||||
|
|
@ -98,8 +98,8 @@ public class GoodsApiController {
|
|||
}
|
||||
|
||||
String msg = "成功,总共找到:" + listApiResult.getTotalRecords() + "条订单,新增:" + insertSuccess + "条,添加错误:" + totalError + "条,更新:" + hasExistOrder + "条";
|
||||
return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(), msg);
|
||||
|
||||
// return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(), msg);
|
||||
return ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.qihang.tao.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.qihang.tao.common.ApiResult;
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.tao.common.PageQuery;
|
||||
import com.qihang.tao.common.PageResult;
|
||||
import com.qihang.tao.domain.TaoGoods;
|
||||
|
|
|
|||
|
|
@ -1,23 +1,18 @@
|
|||
package com.qihang.tao.controller;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.common.EnumResultVo;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.tao.api.ApiCommon;
|
||||
import com.qihang.tao.api.ApiResult;
|
||||
//import com.qihang.tao.api.ApiResult;
|
||||
import com.qihang.tao.api.OrderApiHelper;
|
||||
import com.qihang.tao.common.EnumShopType;
|
||||
import com.qihang.tao.common.ServerConfig;
|
||||
import com.qihang.tao.common.TaoRequest;
|
||||
import com.qihang.tao.domain.SysPlatform;
|
||||
import com.qihang.tao.domain.TaoOrder;
|
||||
import com.qihang.tao.service.SysPlatformService;
|
||||
import com.qihang.tao.service.SysShopService;
|
||||
import com.qihang.tao.service.TaoOrderService;
|
||||
import com.taobao.api.ApiException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
|
|
@ -41,14 +36,14 @@ public class OrderApiController {
|
|||
*/
|
||||
@GetMapping("/pull_order_tao")
|
||||
@ResponseBody
|
||||
public com.qihang.tao.common.ApiResult<Object> pullIncrementOrder(TaoRequest req) throws ApiException {
|
||||
public ApiResult<Object> pullIncrementOrder(TaoRequest req) throws ApiException {
|
||||
log.info("/**************增量拉取tao订单****************/");
|
||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
var checkResult = apiCommon.checkBefore(req.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return com.qihang.tao.common.ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||
return ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||
}
|
||||
String sessionKey = checkResult.getData().getAccessToken();
|
||||
String url = checkResult.getData().getApiRequestUrl();
|
||||
|
|
@ -62,12 +57,12 @@ public class OrderApiController {
|
|||
//第一次获取
|
||||
ApiResult<TaoOrder> upResult = OrderApiHelper.pullIncrementOrder(pageIndex, pageSize, url, appKey, appSecret, sessionKey);
|
||||
|
||||
if (upResult.getCode().intValue() != 0) {
|
||||
if (upResult.getCode() != 0) {
|
||||
log.info("/**************主动更新tao订单:第一次获取结果失败:" + upResult.getMsg() + "****************/");
|
||||
if(upResult.getCode().intValue() == HttpStatus.UNAUTHORIZED){
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权",checkResult.getData());
|
||||
if(upResult.getCode() == HttpStatus.UNAUTHORIZED){
|
||||
return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权",checkResult.getData());
|
||||
}
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.SYSTEM_EXCEPTION, upResult.getMsg());
|
||||
return ApiResult.build(HttpStatus.SYSTEM_EXCEPTION, upResult.getMsg());
|
||||
}
|
||||
|
||||
log.info("/**************主动更新tao订单:第一次获取结果:总记录数" + upResult.getTotalRecords() + "****************/");
|
||||
|
|
@ -94,7 +89,7 @@ public class OrderApiController {
|
|||
|
||||
String msg = "成功,总共找到:" + upResult.getTotalRecords() + "条订单,新增:" + insertSuccess + "条,添加错误:" + totalError + "条,更新:" + hasExistOrder + "条";
|
||||
log.info("/**************主动更新tao订单:END:" + msg + "****************/");
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||
return ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -106,14 +101,14 @@ public class OrderApiController {
|
|||
*/
|
||||
@GetMapping("/pull_order_tao_all")
|
||||
@ResponseBody
|
||||
public com.qihang.tao.common.ApiResult<Object> orderPull(TaoRequest req) throws ApiException {
|
||||
public ApiResult<Object> orderPull(TaoRequest req) throws ApiException {
|
||||
log.info("/**************主动更新tao订单****************/");
|
||||
if (req.getShopId() == null || req.getShopId() <= 0) {
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
var checkResult = apiCommon.checkBefore(req.getShopId());
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return com.qihang.tao.common.ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||
return ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData());
|
||||
}
|
||||
String sessionKey = checkResult.getData().getAccessToken();
|
||||
String url = checkResult.getData().getApiRequestUrl();
|
||||
|
|
@ -157,12 +152,12 @@ public class OrderApiController {
|
|||
//第一次获取
|
||||
ApiResult<TaoOrder> upResult = OrderApiHelper.pullOrder(pageIndex, pageSize, url, appKey, appSecret, sessionKey);
|
||||
|
||||
if (upResult.getCode().intValue() != 0) {
|
||||
if (upResult.getCode() != 0) {
|
||||
log.info("/**************主动更新tao订单:第一次获取结果失败:" + upResult.getMsg() + "****************/");
|
||||
if(upResult.getCode().intValue() == HttpStatus.UNAUTHORIZED){
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权",checkResult.getData());
|
||||
if(upResult.getCode() == HttpStatus.UNAUTHORIZED){
|
||||
return ApiResult.build(HttpStatus.UNAUTHORIZED, "Token已过期,请重新授权",checkResult.getData());
|
||||
}
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.SYSTEM_EXCEPTION, upResult.getMsg());
|
||||
return ApiResult.build(HttpStatus.SYSTEM_EXCEPTION, upResult.getMsg());
|
||||
}
|
||||
|
||||
log.info("/**************主动更新tao订单:第一次获取结果:总记录数" + upResult.getTotalRecords() + "****************/");
|
||||
|
|
@ -215,7 +210,7 @@ public class OrderApiController {
|
|||
}
|
||||
String msg = "成功,总共找到:" + upResult.getTotalRecords() + "条订单,新增:" + insertSuccess + "条,添加错误:" + totalError + "条,更新:" + hasExistOrder + "条";
|
||||
log.info("/**************主动更新tao订单:END:" + msg + "****************/");
|
||||
return com.qihang.tao.common.ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||
return ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.qihang.tao.controller;
|
||||
|
||||
import com.qihang.common.common.ApiResult;
|
||||
import com.qihang.common.common.EnumResultVo;
|
||||
import com.qihang.common.enums.HttpStatus;
|
||||
import com.qihang.tao.api.ApiCommon;
|
||||
import com.qihang.tao.api.ApiResult;
|
||||
import com.qihang.tao.api.RefundApiHelper;
|
||||
import com.qihang.tao.common.TaoRequest;
|
||||
import com.qihang.tao.domain.TaoRefund;
|
||||
|
|
@ -44,13 +44,14 @@ public class RefundApiController {
|
|||
public ApiResult<String> refundOrderPull(@RequestBody TaoRequest taoRequest) throws ApiException {
|
||||
log.info("/**************主动更新tao退货订单****************/");
|
||||
if (taoRequest.getShopId() == null || taoRequest.getShopId() <= 0) {
|
||||
return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有店铺Id");
|
||||
// return new ApiResult<>(EnumResultVo.ParamsError.getIndex(), "参数错误,没有店铺Id");
|
||||
return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id");
|
||||
}
|
||||
Integer shopId = taoRequest.getShopId();
|
||||
var checkResult = apiCommon.checkBefore(shopId);
|
||||
|
||||
if (checkResult.getCode() != HttpStatus.SUCCESS) {
|
||||
return new ApiResult<>(checkResult.getCode(), checkResult.getMsg());
|
||||
return ApiResult.build(checkResult.getCode(), checkResult.getMsg());
|
||||
}
|
||||
|
||||
String sessionKey = checkResult.getData().getAccessToken();
|
||||
|
|
@ -65,9 +66,10 @@ public class RefundApiController {
|
|||
//第一次获取
|
||||
ApiResult<TaoRefund> upResult = RefundApiHelper.pullRefund(pageIndex, pageSize, url, appKey, appSecret, sessionKey);
|
||||
|
||||
if (upResult.getCode().intValue() != 0) {
|
||||
if (upResult.getCode() != 0) {
|
||||
log.info("/**************主动更新tao退货订单:第一次获取结果失败:" + upResult.getMsg() + "****************/");
|
||||
return new ApiResult<>(EnumResultVo.SystemException.getIndex(), upResult.getMsg());
|
||||
// return new ApiResult<>(EnumResultVo.SystemException.getIndex(), upResult.getMsg());
|
||||
return ApiResult.build(HttpStatus.ERROR ,upResult.getMsg());
|
||||
}
|
||||
|
||||
log.info("/**************主动更新tao退货订单:第一次获取结果:总记录数" + upResult.getTotalRecords() + "****************/");
|
||||
|
|
@ -95,7 +97,8 @@ public class RefundApiController {
|
|||
|
||||
String msg = "成功,总共找到:" + upResult.getTotalRecords() + "条订单,新增:" + insertSuccess + "条,添加错误:" + totalError + "条,更新:" + hasExistOrder + "条";
|
||||
log.info("/**************主动更新tao订单:END:" + msg + "****************/");
|
||||
return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(), msg);
|
||||
// return new ApiResult<>(EnumResultVo.SUCCESS.getIndex(), msg);
|
||||
return ApiResult.build(HttpStatus.SUCCESS, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue