Commit 50efd703 by 吕明尚

抖音用户验卷接口调试

parent 0967fa7d
......@@ -76,32 +76,15 @@ public class TiktokServiceImpl implements TiktokService {
private static final Logger logger = LoggerFactory.getLogger(TiktokServiceImpl.class);
public static void main(String[] args) {
String result = HttpRequest.get(TiktokUrlEnum.POI_QUERY.getUrl())
.contentType("application/json")
.header("access-token", "clt.ba984ee2aebdd450c9254d8da380dfbeRoKWll1pEG34qWF0ph9kgR6EpexC")
.form("account_id", "7325762036464355343")
.form("page", 1)
.form("size", 50)
.execute().body();
JSONObject entries = new JSONObject(result);
JSONObject data = entries.getJSONObject("data");
if (!data.getStr("error_code").equals(ErrorCodeEnum.SUCCESS.getCode())) {
throw new RuntimeException(data.getStr("description"));
}
JSONArray pois = data.getJSONArray("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.setPoiId(poi.getStr("poi_id"));
tiktokPoi.setPoiName(poi.getStr("poi_name"));
tiktokPoi.setAddress(poi.getStr("address"));
tiktokPoi.setLatitude(poi.getFloat("latitude"));
tiktokPoi.setLongitude(poi.getFloat("longitude"));
tiktokPois.add(tiktokPoi);
});
System.out.println(tiktokPois);
// String result = HttpRequest.get(TiktokUrlEnum.CERTIFICATE_PREPARE.getUrl())
// .contentType("application/json")
// .header("access-token", "clt.535c504322d5cda164387eddbd878ddcGuefIe0UR368DkctG9ZzVehCOTMi")
// .form("code", "102003486992130").form("poiId", "7315287081226340378").execute().body();
// JSONObject entries = new JSONObject(result);
// JSONObject data = entries.getJSONObject("data");
// System.out.println(data);
Integer expireTime = 1737388799;
System.out.println(new Date(expireTime * 1000L));
}
@Override
public void clientToken() {
......@@ -320,6 +303,9 @@ public class TiktokServiceImpl implements TiktokService {
tiktokCouponDto.setPoiId(sStore.getTiktokPoiId());
JSONObject prepare = prepare(tiktokCouponDto);
JSONArray certificates = prepare.getJSONArray("certificates");
if (CollectionUtils.isEmpty(certificates)) {
throw new RuntimeException("该券码已被使用");
}
Object o = certificates.get(0);
JSONObject entries = new JSONObject(o);
JSONObject sku = entries.getJSONObject("sku");
......@@ -347,7 +333,7 @@ public class TiktokServiceImpl implements TiktokService {
Integer originalAmount = amount.getInt("original_amount");
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(originalAmount / 100));
//时间戳转年月日时分秒
sConsumerCoupon.setEndDate(DateUtil.date(entries.getInt("expire_time") * 1000));
sConsumerCoupon.setEndDate(new Date(entries.getInt("expire_time") * 1000L));
sConsumerCoupon.setStartDate(new Date());
LambdaQueryWrapper<SCoupon> sCouponLambdaQueryWrapper = new LambdaQueryWrapper<>();
sCouponLambdaQueryWrapper.eq(SCoupon::getTiktokSkuId, sku.getStr("sku_id"));
......
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