2024-03-13 17:37:56 +08:00
|
|
|
|
package com.qihang.pdd.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.pdd.pop.sdk.http.PopClient;
|
|
|
|
|
|
import com.pdd.pop.sdk.http.PopHttpClient;
|
|
|
|
|
|
import com.pdd.pop.sdk.http.api.pop.request.PddMallInfoGetRequest;
|
|
|
|
|
|
import com.pdd.pop.sdk.http.api.pop.response.PddMallInfoGetResponse;
|
2024-03-24 18:22:08 +08:00
|
|
|
|
import com.qihang.common.common.ResultVo;
|
2024-03-13 18:36:50 +08:00
|
|
|
|
import com.qihang.common.enums.HttpStatus;
|
2024-03-13 17:37:56 +08:00
|
|
|
|
|
|
|
|
|
|
public class PddApiUtils {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取店铺信息(原则上所有api调用之前都需要调用一下该方法)
|
|
|
|
|
|
* @param clientId
|
|
|
|
|
|
* @param clientSecret
|
|
|
|
|
|
* @param accessToken
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2024-03-24 18:22:08 +08:00
|
|
|
|
public static ResultVo<PddMallInfoGetResponse.MallInfoGetResponse> getShopInfo(String clientId, String clientSecret, String accessToken) throws Exception {
|
2024-03-13 17:37:56 +08:00
|
|
|
|
|
|
|
|
|
|
PopClient client = new PopHttpClient(clientId, clientSecret);
|
|
|
|
|
|
|
|
|
|
|
|
PddMallInfoGetRequest request = new PddMallInfoGetRequest();
|
|
|
|
|
|
PddMallInfoGetResponse response = client.syncInvoke(request, accessToken);
|
|
|
|
|
|
if (response.getErrorResponse() == null) {
|
2024-03-14 16:21:27 +08:00
|
|
|
|
// 刷新一下token
|
|
|
|
|
|
|
2024-03-24 18:22:08 +08:00
|
|
|
|
return ResultVo.success( response.getMallInfoGetResponse());
|
2024-03-13 17:37:56 +08:00
|
|
|
|
} else if (response.getErrorResponse().getErrorCode().intValue() == 10019) {
|
2024-03-24 18:22:08 +08:00
|
|
|
|
return ResultVo.error(HttpStatus.UNAUTHORIZED, "Token过期");
|
2024-03-13 17:37:56 +08:00
|
|
|
|
}else
|
2024-03-24 18:22:08 +08:00
|
|
|
|
return ResultVo.error(HttpStatus.ERROR, "接口调用失败:"+response.getErrorResponse().getErrorMsg());
|
2024-03-13 17:37:56 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|