|
@@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.github.microservice.productcenter.client.model.LocationModel;
|
|
|
import com.github.microservice.productcenter.client.model.ProductPushModel;
|
|
|
import com.github.microservice.productcenter.client.model.ProductTriggerTaskModel;
|
|
|
import com.github.microservice.productcenter.client.model.RegionModel;
|
|
@@ -17,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
@@ -51,6 +49,8 @@ public class MoviePublish implements ProductPublish {
|
|
|
@Override
|
|
|
public void trigger(ProductPushService updateService, ProductTriggerTaskModel productTriggerTask) {
|
|
|
|
|
|
+ var cityId = productTriggerTask.getScheduledTask().getParameter().get("cityId");
|
|
|
+
|
|
|
JSONObject citys = yppApi.get_citys();
|
|
|
JSONArray byPath = (JSONArray) citys.getByPath("data");
|
|
|
Map<String, String> collect = byPath.stream().collect(Collectors.toMap(it -> JSONUtil.parseObj(it).get("name").toString(), it -> JSONUtil.parseObj(it).get("cityId").toString()));
|
|
@@ -63,33 +63,30 @@ public class MoviePublish implements ProductPublish {
|
|
|
throw new RuntimeException("地区信息不匹配");
|
|
|
}
|
|
|
|
|
|
- int page = 1;
|
|
|
- while (true) {
|
|
|
- JSONObject entries = yppApi.movies(s, String.valueOf(page), "20");
|
|
|
- JSONArray movies = (JSONArray) entries.getByPath("data.movies");
|
|
|
- if (movies.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- byPath.forEach(it -> {
|
|
|
- JSONObject entry = JSONUtil.parseObj(it);
|
|
|
- String movieName = entry.get("name").toString();
|
|
|
- String movieCode = entry.get("movieCode").toString();
|
|
|
- String posterUrl = entry.get("posterUrl").toString();
|
|
|
- ProductPushModel.builder()
|
|
|
- .regionCode(productTriggerTask.getRegion().getCode())
|
|
|
- .pid(movieCode)
|
|
|
- .productType(ProductType.MovieTicket)
|
|
|
- .cover(new String[]{posterUrl})
|
|
|
- .title(movieName)
|
|
|
- .meta(Map.of("movies", entry))
|
|
|
- .build();
|
|
|
-
|
|
|
- });
|
|
|
- page++;
|
|
|
|
|
|
+ JSONObject entries = yppApi.movies(s, "0", "100");
|
|
|
+ JSONArray movies = (JSONArray) entries.getByPath("data.movies");
|
|
|
+ if (movies.isEmpty()) {
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ updateService.push(movies.stream().parallel().map(it -> {
|
|
|
+ JSONObject entry = JSONUtil.parseObj(it);
|
|
|
+ System.out.println(entry);
|
|
|
+ String movieName = entry.get("name").toString();
|
|
|
+ String movieCode = entry.get("movieCode").toString();
|
|
|
+ String posterUrl = entry.get("posterUrl").toString();
|
|
|
+ return ProductPushModel.builder()
|
|
|
+ .regionCode(productTriggerTask.getRegion().getCode())
|
|
|
+ .pid(movieCode)
|
|
|
+ .productType(ProductType.MovieTicket)
|
|
|
+ .cover(new String[]{posterUrl})
|
|
|
+ .title(movieName)
|
|
|
+ .meta(Map.of("movies", entry))
|
|
|
+ .expireTimeSecond(60*60*24)
|
|
|
+ .build();
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|