|
@@ -4,18 +4,23 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONConfig;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.zswl.cloud.springBatch.client.model.request.CreateOrder2Request;
|
|
|
import com.zswl.cloud.springBatch.client.model.request.CreateOrdereRquest;
|
|
|
import com.zswl.cloud.springBatch.client.model.request.OrderListRequest;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.ypp.request.SessionRequest;
|
|
|
import com.zswl.cloud.springBtach.server.core.helper.RedisHelper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.Assert;
|
|
|
+import org.springframework.web.util.UriComponentsBuilder;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
//接口地址 https://apifox.com/apidoc/shared-48c64918-c4ce-49f4-b846-d23855299d7a/doc-2590155
|
|
|
@Component
|
|
@@ -42,8 +47,8 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject order_detail(String orderId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/order_detail?id=" + orderId);
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/order_detail?id=" + orderId);
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -55,8 +60,8 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject pay_order(String orderId, String mobile) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/pay_order?id=" + orderId + "&test=&mobile=" + mobile);
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/pay_order?id=" + orderId + "&test=&mobile=" + mobile);
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -79,8 +84,8 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject get_order(String orderId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/get_order?id=" + orderId);
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/get_order?id=" + orderId);
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -115,8 +120,14 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject movies(String cityId, String pageIndex, String pageSize) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/movies?cityId=" + cityId + "&pageIndex=" + pageIndex + "&pageSize=" + pageSize);
|
|
|
- return entries;
|
|
|
+ String baseUrl = "https://channel.youpiaopiao.cn/api/movie/movies";
|
|
|
+
|
|
|
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl);
|
|
|
+ builder.queryParam("cityId", cityId);
|
|
|
+ builder.queryParam("pageIndex", pageIndex);
|
|
|
+ builder.queryParam("pageSize", pageSize);
|
|
|
+ String entries = httpGet(builder.build().toUriString());
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -127,8 +138,8 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject coming_movies(String cityId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/coming_movies?cityId=" + cityId);
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/coming_movies?cityId=" + cityId);
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -139,8 +150,8 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject movie_detail(String movieId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/movie_detail?movieId=" + movieId);
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/movie_detail?movieId=" + movieId);
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -150,9 +161,18 @@ public class YppApi {
|
|
|
* @param movieId
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject movie_cinemas(String cityId, String movieId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/movie_cinemas?cityId=" + cityId + "&movieId=" + movieId);
|
|
|
- return entries;
|
|
|
+ public JSONObject movie_cinemas(String cityId, String movieId, String day, String lat, String lng) {
|
|
|
+ String baseUrl = "https://channel.youpiaopiao.cn/api/movie/movie_cinemas";
|
|
|
+
|
|
|
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl);
|
|
|
+ builder.queryParam("cityId", cityId);
|
|
|
+ builder.queryParam("movieId", movieId);
|
|
|
+ builder.queryParam("day", day);
|
|
|
+ builder.queryParam("lat", lat);
|
|
|
+ builder.queryParam("lng", lng);
|
|
|
+
|
|
|
+ String entries = httpGet(builder.build().toUriString());
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -168,8 +188,20 @@ public class YppApi {
|
|
|
*/
|
|
|
|
|
|
public JSONObject cinemas(String cityId, String districtId, String brandId, String lat, String lng) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/cinemas?cityId=" + cityId + "&districtId=" + districtId + "&brandId=" + brandId + "&lat=" + lat + brandId + "&lng=" + lng);
|
|
|
- return entries;
|
|
|
+
|
|
|
+ String baseUrl = "https://channel.youpiaopiao.cn/api/movie/cinemas";
|
|
|
+
|
|
|
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl);
|
|
|
+ builder.queryParam("cityId", cityId);
|
|
|
+ builder.queryParam("districtId", districtId);
|
|
|
+ builder.queryParam("brandId", brandId);
|
|
|
+ builder.queryParam("cityId", cityId);
|
|
|
+ builder.queryParam("lat", lat);
|
|
|
+ builder.queryParam("lng", lng);
|
|
|
+ String entries = httpGet(builder.build().toUriString());
|
|
|
+ JSONConfig jsonConfig = JSONConfig.create();
|
|
|
+ jsonConfig.setIgnoreError(true);
|
|
|
+ return JSONUtil.parseObj(entries, jsonConfig);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -180,8 +212,8 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject cinema_filter(String cityId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/cinema_filter?cityId=" + cityId);
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/cinema_filter?cityId=" + cityId);
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -191,8 +223,10 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject get_citys() {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/get_citys");
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/get_citys");
|
|
|
+ JSONConfig jsonConfig = JSONConfig.create();
|
|
|
+ jsonConfig.setIgnoreError(true);
|
|
|
+ return JSONUtil.parseObj(entries, jsonConfig);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -202,12 +236,17 @@ public class YppApi {
|
|
|
*
|
|
|
* @param movieId
|
|
|
* @param cinemaId
|
|
|
- * @param currentMovieId
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject cinema_shows(String movieId, String cinemaId, String currentMovieId) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/cinema_shows?cinemaId=cinemaId" + cinemaId + "&movieId=" + movieId + "¤tMovieId=" + currentMovieId);
|
|
|
- return entries;
|
|
|
+ public JSONObject cinema_shows(String movieId, String cinemaId) {
|
|
|
+ String baseUrl = "https://channel.youpiaopiao.cn/api/movie/cinema_shows";
|
|
|
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl);
|
|
|
+ builder.queryParam("movieId", movieId);
|
|
|
+ builder.queryParam("cinemaId", cinemaId);
|
|
|
+
|
|
|
+
|
|
|
+ String entries = httpGet(builder.build().toUriString());
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -220,8 +259,16 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject session(String sessionId, String cinemaId, String movieId, String sid) {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/session?sessionId=" + sessionId + "&cinemaId=" + cinemaId + "&movieId=" + movieId + "&sid=" + sid);
|
|
|
- return entries;
|
|
|
+
|
|
|
+ String baseUrl = "https://channel.youpiaopiao.cn/api/movie/session";
|
|
|
+
|
|
|
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl);
|
|
|
+ builder.queryParam("sessionId", sessionId);
|
|
|
+ builder.queryParam("cinemaId", cinemaId);
|
|
|
+ builder.queryParam("movieId", movieId);
|
|
|
+ builder.queryParam("sid", sid);
|
|
|
+ String entries = httpGet(builder.build().toUriString());
|
|
|
+ return JSONUtil.parseObj(entries);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -230,11 +277,13 @@ public class YppApi {
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject ad_configs() {
|
|
|
- JSONObject entries = httpGet("https://channel.youpiaopiao.cn/api/movie/ad_configs");
|
|
|
- return entries;
|
|
|
+ String entries = httpGet("https://channel.youpiaopiao.cn/api/movie/ad_configs");
|
|
|
+ JSONConfig jsonConfig = JSONConfig.create();
|
|
|
+ jsonConfig.setIgnoreError(true);
|
|
|
+ return JSONUtil.parseObj(entries, jsonConfig);
|
|
|
}
|
|
|
|
|
|
- private JSONObject httpGet(String url) {
|
|
|
+ private String httpGet(String url) {
|
|
|
String token = getoken();
|
|
|
HttpRequest get = HttpUtil.createGet(url);
|
|
|
HttpResponse execute = get.header("Authorization", token).execute();
|
|
@@ -243,7 +292,7 @@ public class YppApi {
|
|
|
Integer code = (Integer) entries.get("code");
|
|
|
Assert.isTrue(execute.isOk(), "飘飘响应错误");
|
|
|
Assert.isTrue(code.equals(0), String.valueOf(entries.get("message")));
|
|
|
- return JSONUtil.parseObj(body);
|
|
|
+ return body;
|
|
|
|
|
|
}
|
|
|
|