Commit 561312a5 by 吕明尚

根据商品id查询商品详情

parent f9c38b04
......@@ -9,6 +9,8 @@ public enum TiktokUrlEnum {
CERTIFICATE_GET("https://open.douyin.com/goodlife/v1/fulfilment/certificate/get/", "券状态查询"),
POI_QUERY("https://open.douyin.com/goodlife/v1/shop/poi/query/", "查询门店信息"),
ONLINE_QUERY("https://open.douyin.com/goodlife/v1/akte/goods/product/online/query/", "查询商品线上数据列表"),
ONLINE_GET("https://open.douyin.com/goodlife/v1/akte/goods/product/online/get/", "查询商品线上数据"),
//查询商品线上数据
;
private String url;
private String name;
......
......@@ -51,9 +51,14 @@ public class TiktokController {
return tiktokService.poiQuery(tiktokCouponDto);
}
//查询所有线上商品数据列表
@GetMapping("/online/query")
public Object onlineQuery(OnlineQueryDto onlineQueryDto) {
return tiktokService.onlineQuery(onlineQueryDto);
}
@GetMapping("/online/query")
public Object onlineGet(String productIds, String accountId) {
return tiktokService.onlineGet(productIds, accountId);
}
}
......@@ -20,4 +20,6 @@ public interface TiktokService {
Object poiQuery(TiktokCouponDto tiktokCouponDto);
Object onlineQuery(OnlineQueryDto onlineQueryDto);
Object onlineGet(String productIds, String accountId);
}
......@@ -13,10 +13,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.core.redis.RedisUtil;
import share.common.enums.ErrorCodeEnum;
import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.TiktokUrlEnum;
import share.common.enums.VerifyResultsEnum;
import share.common.enums.*;
import share.system.domain.vo.OnlineQueryDto;
import share.system.domain.vo.TiktokCouponDto;
import share.system.service.TiktokService;
......@@ -211,16 +208,15 @@ public class TiktokServiceImpl implements TiktokService {
@Override
public Object onlineQuery(OnlineQueryDto onlineQueryDto) {
String accessToken = obtain();
String result = HttpRequest.post(TiktokUrlEnum.ONLINE_QUERY.getUrl())
String result = HttpRequest.get(TiktokUrlEnum.ONLINE_QUERY.getUrl())
.contentType("application/json")
.header("access-token", accessToken)
.form("cursor", onlineQueryDto.getCursor())
.form("count", onlineQueryDto.getCount())
.form("count", 20)
.form("status", onlineQueryDto.getStatus())
.form("account_id", onlineQueryDto.getAccountId())
.form("goods_creator_type", onlineQueryDto.getGoodsCreatorType())
.form("query_all_poi", onlineQueryDto.getQueryAllPoi())
.form("goods_query_type", onlineQueryDto.getGoodsQueryType())
.form("goods_creator_type", 1)
.form("query_all_poi", YesNoEnum.yes.getFlag())
.execute().body();
JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data");
......@@ -248,6 +244,30 @@ public class TiktokServiceImpl implements TiktokService {
return data.getJSONArray("records");
}
@Override
public Object onlineGet(String productIds, String accountId) {
String accessToken = obtain();
String result = HttpRequest.get(TiktokUrlEnum.ONLINE_QUERY.getUrl())
.contentType("application/json")
.header("access-token", accessToken)
.form("product_ids", productIds)
.form("account_id", accountId)
.execute().body();
JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data");
JSONArray productOnlines = data.getJSONArray("product_onlines");
productOnlines.forEach(e -> {
JSONObject product = new JSONObject(e);
//查询在线状态为在线的
if (product.getInt("online_status").equals(YesNoEnum.yes.getIndex())) {
JSONObject jsonObject = product.getJSONObject("product");
}
});
return null;
}
public String obtain() {
String o;
o = redisUtil.get(ReceiptRdeisEnum.TIKTOK_CLIENT_TOKEN.getValue());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment