Commit bc308363 by 吕明尚

增加Tiktok实体类

parent f2ba6e18
......@@ -5,7 +5,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.system.domain.vo.OnlineQueryDto;
import share.system.domain.vo.TiktokCouponDto;
import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import share.system.service.TiktokService;
import java.util.List;
......@@ -47,7 +48,7 @@ public class TiktokController {
}
@GetMapping("/poi/query")
public Object poiQuery(TiktokCouponDto tiktokCouponDto) {
public List<TiktokPoi> poiQuery(TiktokCouponDto tiktokCouponDto) {
return tiktokService.poiQuery(tiktokCouponDto);
}
......
package share.system.domain.tiktok;
import lombok.Data;
//查询商品线上数据列表中的店铺类
@Data
public class Poi {
private String supplier_ext_id;
private String poi_id;
private Integer supplier_id;
}
package share.system.domain.tiktok;
public class Sku {
private String supplier_ext_id;
}
package share.system.domain.tiktok;
import lombok.Data;
import java.util.List;
import java.util.Map;
//查询商品线上数据列表中的商品类
@Data
public class TicktokProduct {
private String product_id;
private String out_id;
private String product_name;
private String category_full_name;
private Integer category_id;
private Integer product_type;
private Integer biz_line;
private String account_name;
private Integer sold_start_time;
private Integer sold_end_time;
private Integer create_time;
private Integer update_time;
private List<Poi> pois;
private Map<String, String> attr_key_value_map;
}
package share.system.domain.tiktok;
import lombok.Data;
@Data
public class TiktokPoi {
//抖音门店 ID
private String poi_id;
//抖音门店名称
private String poi_name;
//门店地址
private String address;
//门店坐标 - 纬度
private Float latitude;
//门店坐标 - 经度
private Float longitude;
public TiktokPoi() {
}
public TiktokPoi(String poi_id, String poi_name, String address, Float latitude, Float longitude) {
this.poi_id = poi_id;
this.poi_name = poi_name;
this.address = address;
this.latitude = latitude;
this.longitude = longitude;
}
}
package share.system.service;
import cn.hutool.json.JSONArray;
import share.system.domain.vo.OnlineQueryDto;
import share.system.domain.vo.TiktokCouponDto;
import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import java.util.List;
......@@ -17,7 +17,7 @@ public interface TiktokService {
String certificateGet(TiktokCouponDto tiktokCouponDto);
Object poiQuery(TiktokCouponDto tiktokCouponDto);
List<TiktokPoi> poiQuery(TiktokCouponDto tiktokCouponDto);
Object onlineQuery(OnlineQueryDto onlineQueryDto);
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpGlobalConfig;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.github.pagehelper.util.StringUtil;
......@@ -15,9 +14,11 @@ import org.springframework.stereotype.Service;
import share.common.core.redis.RedisUtil;
import share.common.enums.*;
import share.system.domain.vo.OnlineQueryDto;
import share.system.domain.vo.TiktokCouponDto;
import share.system.domain.tiktok.TiktokCouponDto;
import share.system.domain.tiktok.TiktokPoi;
import share.system.service.TiktokService;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -169,7 +170,7 @@ public class TiktokServiceImpl implements TiktokService {
}
@Override
public Object poiQuery(TiktokCouponDto tiktokCouponDto) {
public List<TiktokPoi> poiQuery(TiktokCouponDto tiktokCouponDto) {
String accessToken = obtain();
// String url = "https://open.douyin.com/goodlife/v1/shop/poi/query/";
String result = null;
......@@ -193,16 +194,22 @@ public class TiktokServiceImpl implements TiktokService {
JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data");
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
return data.getStr("description");
throw new RuntimeException(data.getStr("description"));
}
JSONArray pois = data.getJSONArray("pois");
Object o = pois.get(0);
JSONObject object = new JSONObject(o);
//门店信息
JSONObject poi = object.getJSONObject("poi");
//生活服务商家账户信息
JSONObject rootAccount = object.getJSONObject("root_account");
return pois;
List<TiktokPoi> tiktokPois = new ArrayList<>();
List<JSONObject> list = pois.toList(JSONObject.class);
list.stream().forEach(e -> {
JSONObject poi = e.getJSONObject("poi");
TiktokPoi tiktokPoi = new TiktokPoi();
tiktokPoi.setPoi_id(poi.getStr("poi_id"));
tiktokPoi.setPoi_name(poi.getStr("poi_name"));
tiktokPoi.setAddress(poi.getStr("address"));
tiktokPoi.setLatitude(poi.getFloat("latitude"));
tiktokPoi.setLongitude(poi.getFloat("longitude"));
tiktokPois.add(tiktokPoi);
});
return tiktokPois;
}
@Override
......@@ -211,9 +218,8 @@ public class TiktokServiceImpl implements TiktokService {
String result = HttpRequest.get(TiktokUrlEnum.ONLINE_QUERY.getUrl())
.contentType("application/json")
.header("access-token", accessToken)
.form("cursor", onlineQueryDto.getCursor())
.form("count", 20)
.form("status", onlineQueryDto.getStatus())
.form("status", 1)
.form("account_id", onlineQueryDto.getAccountId())
.form("goods_creator_type", 1)
.form("query_all_poi", YesNoEnum.yes.getFlag())
......
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