Commit 50efd703 by 吕明尚

抖音用户验卷接口调试

parent 0967fa7d
...@@ -76,32 +76,15 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -76,32 +76,15 @@ public class TiktokServiceImpl implements TiktokService {
private static final Logger logger = LoggerFactory.getLogger(TiktokServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(TiktokServiceImpl.class);
public static void main(String[] args) { public static void main(String[] args) {
String result = HttpRequest.get(TiktokUrlEnum.POI_QUERY.getUrl()) // String result = HttpRequest.get(TiktokUrlEnum.CERTIFICATE_PREPARE.getUrl())
.contentType("application/json") // .contentType("application/json")
.header("access-token", "clt.ba984ee2aebdd450c9254d8da380dfbeRoKWll1pEG34qWF0ph9kgR6EpexC") // .header("access-token", "clt.535c504322d5cda164387eddbd878ddcGuefIe0UR368DkctG9ZzVehCOTMi")
.form("account_id", "7325762036464355343") // .form("code", "102003486992130").form("poiId", "7315287081226340378").execute().body();
.form("page", 1) // JSONObject entries = new JSONObject(result);
.form("size", 50) // JSONObject data = entries.getJSONObject("data");
.execute().body(); // System.out.println(data);
JSONObject entries = new JSONObject(result); Integer expireTime = 1737388799;
JSONObject data = entries.getJSONObject("data"); System.out.println(new Date(expireTime * 1000L));
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);
} }
@Override @Override
public void clientToken() { public void clientToken() {
...@@ -320,6 +303,9 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -320,6 +303,9 @@ public class TiktokServiceImpl implements TiktokService {
tiktokCouponDto.setPoiId(sStore.getTiktokPoiId()); tiktokCouponDto.setPoiId(sStore.getTiktokPoiId());
JSONObject prepare = prepare(tiktokCouponDto); JSONObject prepare = prepare(tiktokCouponDto);
JSONArray certificates = prepare.getJSONArray("certificates"); JSONArray certificates = prepare.getJSONArray("certificates");
if (CollectionUtils.isEmpty(certificates)) {
throw new RuntimeException("该券码已被使用");
}
Object o = certificates.get(0); Object o = certificates.get(0);
JSONObject entries = new JSONObject(o); JSONObject entries = new JSONObject(o);
JSONObject sku = entries.getJSONObject("sku"); JSONObject sku = entries.getJSONObject("sku");
...@@ -347,7 +333,7 @@ public class TiktokServiceImpl implements TiktokService { ...@@ -347,7 +333,7 @@ public class TiktokServiceImpl implements TiktokService {
Integer originalAmount = amount.getInt("original_amount"); Integer originalAmount = amount.getInt("original_amount");
sConsumerCoupon.setSubPrice(BigDecimal.valueOf(originalAmount / 100)); 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()); sConsumerCoupon.setStartDate(new Date());
LambdaQueryWrapper<SCoupon> sCouponLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SCoupon> sCouponLambdaQueryWrapper = new LambdaQueryWrapper<>();
sCouponLambdaQueryWrapper.eq(SCoupon::getTiktokSkuId, sku.getStr("sku_id")); 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