gongfuzhu 9 月之前
父節點
當前提交
5d96d9892a

+ 1 - 1
SpringBatchServiceClient/src/main/java/com/zswl/cloud/springBatch/client/model/dfy/Hotel/request/HotelListRequest.java

@@ -45,7 +45,7 @@ public class HotelListRequest extends DfyBaseData {
     @Data
     @NoArgsConstructor
     @AllArgsConstructor
-    public class FilterInfo {
+    public static class FilterInfo {
         // 起始位置,配合limit可以实现分页,如0代表第一页,i*limit代表第(i+1)页 i=1,2....n 正整数
         private Integer start;
 

+ 4 - 3
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/controller/OrderController.java

@@ -9,6 +9,7 @@ import com.github.microservice.auth.client.content.ResultState;
 import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.helper.AuthHelper;
 import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.payment.client.model.CountModel;
 import com.zhongshu.payment.client.model.order.*;
 import com.zhongshu.payment.client.model.order.v2.CreateOrder2Model;
 import com.zhongshu.payment.client.model.order.v2.OrderResult2Model;
@@ -269,10 +270,10 @@ public class OrderController {
     }
 
     @ApiOperation("平台_统计")
-    @RequestMapping(value = "platform/count", method = RequestMethod.GET)
+    @RequestMapping(value = "platform/count", method = RequestMethod.POST)
     @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform)
-    public ResultContent count() {
-        return orderServiceImp.count();
+    public ResultContent count(@RequestBody @Valid CountModel countModel) {
+        return orderServiceImp.count(countModel);
     }
 
 

+ 26 - 15
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/publish/CinemaPublish.java

@@ -10,6 +10,7 @@ import com.github.microservice.productcenter.client.model.ProductTriggerTaskMode
 import com.github.microservice.productcenter.client.model.RegionModel;
 import com.github.microservice.productcenter.client.publish.ProductPublish;
 import com.github.microservice.productcenter.client.service.ProductPushService;
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
 import com.github.microservice.productcenter.client.type.ProductType;
 import com.github.microservice.productcenter.client.type.RegionType;
 import com.zswl.cloud.springBtach.server.core.api.ypp.YppApi;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -27,6 +29,9 @@ import java.util.stream.Collectors;
 @Component
 public class CinemaPublish implements ProductPublish {
 
+    @Autowired
+    private ProductCenterStream productCenterStream;
+
     @Autowired
     YppApi yppApi;
 
@@ -65,21 +70,27 @@ public class CinemaPublish implements ProductPublish {
         JSONObject entries = yppApi.cinemas("9", null, null, null, null);
         JSONArray data = (JSONArray) entries.getByPath("data");
         data.forEach(it -> {
-            JSONObject entry = JSONUtil.parseObj(it);
-            System.out.println(entry);
-            String cinemaCode = entry.get("cinemaCode").toString();
-            String names = entry.get("name").toString();
-            BigDecimal lng = (BigDecimal) entry.get("lng");
-            BigDecimal lat = (BigDecimal) entry.get("lat");
-            updateService.push(
-                    ProductPushModel.builder()
-                            .regionCode(productTriggerTask.getRegion().getCode())
-                            .pid(cinemaCode)
-                            .productType(ProductType.Cinema)
-                            .title(names)
-                            .locationPoint(LocationModel.builder().longitude(lng.doubleValue()).latitude(lat.doubleValue()).build())
-                            .meta(Map.of("cinemas", entries))
-                            .build());
+            try {
+                JSONObject entry = JSONUtil.parseObj(it);
+                System.out.println(entry);
+                String cinemaCode = entry.get("cinemaCode").toString();
+                String names = entry.get("name").toString();
+                BigDecimal lng = (BigDecimal) entry.get("lng");
+                BigDecimal lat = (BigDecimal) entry.get("lat");
+                productCenterStream.send(List.of(
+                        ProductPushModel.builder()
+                                .regionCode(productTriggerTask.getRegion().getCode())
+                                .pid(cinemaCode)
+                                .productType(ProductType.Cinema)
+                                .title(names)
+                                .locationPoint(LocationModel.builder().longitude(lng.doubleValue()).latitude(lat.doubleValue()).build())
+                                .meta(Map.of("cinemas", entries))
+                                .build()
+                ));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
         });
 
 

+ 102 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/publish/ComingMoviePublish.java

@@ -0,0 +1,102 @@
+package com.zswl.cloud.springBtach.server.core.publish;
+
+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.ProductPushModel;
+import com.github.microservice.productcenter.client.model.ProductTriggerTaskModel;
+import com.github.microservice.productcenter.client.model.RegionModel;
+import com.github.microservice.productcenter.client.publish.ProductPublish;
+import com.github.microservice.productcenter.client.service.ProductPushService;
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
+import com.github.microservice.productcenter.client.type.ProductType;
+import com.github.microservice.productcenter.client.type.RegionType;
+import com.zswl.cloud.springBtach.server.core.api.ypp.YppApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class ComingMoviePublish implements ProductPublish {
+
+    @Autowired
+    YppApi yppApi;
+
+    @Autowired
+    private ProductCenterStream productCenterStream;
+
+    @Override
+    public String regionCode() {
+        return null;
+    }
+
+    @Override
+    public Collection<RegionType> regionType() {
+        return Set.of(RegionType.City);
+    }
+
+    @Override
+    public Collection<ProductType> productTypes() {
+        return Set.of(
+                ProductType.MovieTicket
+        );
+    }
+
+
+    @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()));
+//
+
+        RegionModel region = productTriggerTask.getRegion();
+        String name = region.getName();
+        String s = collect.get(name);
+        if (ObjectUtil.isEmpty(s)) {
+            throw new RuntimeException("地区信息不匹配");
+        }
+
+
+        JSONObject entries = yppApi.coming_movies(s);
+        JSONArray movies = (JSONArray) entries.getByPath("data.movies");
+        if (movies.isEmpty()) {
+            return;
+        }
+
+        movies.forEach(it -> {
+            try {
+                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();
+                productCenterStream.send(List.of(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()));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        });
+
+
+    }
+}

+ 124 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/publish/HotelPublish.java

@@ -0,0 +1,124 @@
+package com.zswl.cloud.springBtach.server.core.publish;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.NumberUtil;
+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;
+import com.github.microservice.productcenter.client.publish.ProductPublish;
+import com.github.microservice.productcenter.client.service.ProductPushService;
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
+import com.github.microservice.productcenter.client.type.ProductType;
+import com.github.microservice.productcenter.client.type.RegionType;
+import com.zswl.cloud.springBatch.client.model.dfy.Hotel.request.HotelListRequest;
+import com.zswl.cloud.springBatch.client.model.dfy.Hotel.request.QueryNewRequest;
+import com.zswl.cloud.springBatch.client.model.dfy.Hotel.response.HotelListResponse;
+import com.zswl.cloud.springBatch.client.model.dfy.Hotel.response.QueryNewResponse;
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.ScenicListRequest;
+import com.zswl.cloud.springBatch.client.model.dfy.Ticket.response.ScenicListResponse;
+import com.zswl.cloud.springBtach.server.core.api.dfy.DomesticHotelApi;
+import com.zswl.cloud.springBtach.server.core.api.dfy.TicketApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class HotelPublish implements ProductPublish {
+
+    @Autowired
+    TicketApi ticketApi;
+
+    @Autowired
+    DomesticHotelApi domesticHotelApi;
+
+    @Autowired
+    private ProductCenterStream productCenterStream;
+
+    @Override
+    public String regionCode() {
+        return null;
+    }
+
+    @Override
+    public Collection<RegionType> regionType() {
+        return Set.of(RegionType.City);
+    }
+
+    @Override
+    public Collection<ProductType> productTypes() {
+        return Set.of(
+                ProductType.Hotel
+        );
+    }
+
+
+    @Override
+    public void trigger(ProductPushService updateService, ProductTriggerTaskModel productTriggerTask) {
+
+
+        RegionModel region = productTriggerTask.getRegion();
+        String name = region.getName();
+        QueryNewRequest queryNewRequest = new QueryNewRequest();
+        queryNewRequest.setKeywords(name);
+        QueryNewResponse queryNewResponse = domesticHotelApi.queryNew(queryNewRequest);
+        QueryNewResponse.Datas data = queryNewResponse.getData();
+        List<QueryNewResponse.Dest> destinationSuggests = data.getDestinationSuggests();
+        for (QueryNewResponse.Dest dest : destinationSuggests.stream().filter(it -> !it.getPoiType().equals(Integer.valueOf(7))).collect(Collectors.toList())) {
+            int start = 0;
+            int limit = 30;
+
+            while (true) {
+                HotelListRequest hotelListRequest = new HotelListRequest();
+                hotelListRequest.setStart(start);
+                hotelListRequest.setLimit(limit);
+                hotelListRequest.setCityName(dest.getCityName());
+                hotelListRequest.setCityCode(dest.getCityCode());
+                Date date = new Date();
+                String inDate = DateUtil.format(date, "yyyy-MM-dd");
+                DateTime dateTime = DateUtil.offsetDay(date, 1);
+                long time = dateTime.getTime();
+                String oute = DateUtil.format(new Date(time), "yyyy-MM-dd");
+                hotelListRequest.setCheckInDate(inDate);
+                hotelListRequest.setCheckOutDate(oute);
+                HotelListRequest.FilterInfo filterInfo = new HotelListRequest.FilterInfo();
+                hotelListRequest.setFilter(filterInfo);
+
+
+                HotelListResponse hotelListResponse = domesticHotelApi.hotelList(hotelListRequest);
+                if (!hotelListResponse.getSuccess()) {
+                    return;
+                }
+                HotelListResponse.Datas data1 = hotelListResponse.getData();
+                if (data1.getHotelList().isEmpty()) {
+                    return;
+                }
+                data1.getHotelList().forEach(it -> {
+                            String hotelId = it.getHotelId();
+                            String chineseName = it.getChineseName();
+                            String picture = it.getPicture();
+                            BigDecimal price = it.getPrice();
+                            productCenterStream.send(List.of(ProductPushModel.builder()
+                                    .regionCode(productTriggerTask.getRegion().getCode())
+                                    .pid(hotelId)
+                                    .productType(ProductType.Hotel)
+                                    .cover(new String[]{picture})
+                                    .salePrice(price.longValue())
+                                    .title(chineseName)
+                                    .meta(Map.of("hotel", it))
+//                            .expireTimeSecond(60 * 60 * 24)
+                                    .build()));
+                        }
+                );
+                start += limit;
+            }
+
+        }
+    }
+}

+ 27 - 17
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/publish/MoviePublish.java

@@ -9,6 +9,7 @@ import com.github.microservice.productcenter.client.model.ProductTriggerTaskMode
 import com.github.microservice.productcenter.client.model.RegionModel;
 import com.github.microservice.productcenter.client.publish.ProductPublish;
 import com.github.microservice.productcenter.client.service.ProductPushService;
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
 import com.github.microservice.productcenter.client.type.ProductType;
 import com.github.microservice.productcenter.client.type.RegionType;
 import com.zswl.cloud.springBtach.server.core.api.ypp.YppApi;
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -28,6 +30,9 @@ public class MoviePublish implements ProductPublish {
     @Autowired
     YppApi yppApi;
 
+    @Autowired
+    private ProductCenterStream productCenterStream;
+
     @Override
     public String regionCode() {
         return null;
@@ -49,7 +54,7 @@ public class MoviePublish implements ProductPublish {
     @Override
     public void trigger(ProductPushService updateService, ProductTriggerTaskModel productTriggerTask) {
 
-        var cityId = productTriggerTask.getScheduledTask().getParameter().get("cityId");
+//        var cityId = productTriggerTask.getScheduledTask().getParameter().get("cityId");
 
         JSONObject citys = yppApi.get_citys();
         JSONArray byPath = (JSONArray) citys.getByPath("data");
@@ -70,22 +75,27 @@ public class MoviePublish implements ProductPublish {
             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()));
+        movies.forEach(it -> {
+            try {
+                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();
+                productCenterStream.send(List.of(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()));
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        });
 
 
     }

+ 30 - 21
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/publish/TicketPublish.java

@@ -6,6 +6,7 @@ import com.github.microservice.productcenter.client.model.ProductTriggerTaskMode
 import com.github.microservice.productcenter.client.model.RegionModel;
 import com.github.microservice.productcenter.client.publish.ProductPublish;
 import com.github.microservice.productcenter.client.service.ProductPushService;
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
 import com.github.microservice.productcenter.client.type.ProductType;
 import com.github.microservice.productcenter.client.type.RegionType;
 import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.ScenicListRequest;
@@ -28,6 +29,9 @@ public class TicketPublish implements ProductPublish {
     @Autowired
     TicketApi ticketApi;
 
+    @Autowired
+    private ProductCenterStream productCenterStream;
+
     @Override
     public String regionCode() {
         return null;
@@ -66,29 +70,34 @@ public class TicketPublish implements ProductPublish {
             if (rows.isEmpty()) {
                 return;
             }
-            List<ProductPushModel> scenic = rows.stream().parallel().map(it -> {
-                System.out.println(it);
-                LocationModel locationModel = new LocationModel();
-                String glocation = it.getGlocation();
-                if (!glocation.isEmpty()) {
-                    String[] split = glocation.split(",");
-
-                    locationModel.setLatitude(Double.parseDouble(split[0]));
-                    locationModel.setLongitude(Double.parseDouble(split[1]));
+            rows.forEach(it -> {
+
+                try {
+                    System.out.println(it);
+                    LocationModel locationModel = new LocationModel();
+                    String glocation = it.getGlocation();
+                    if (!glocation.isEmpty()) {
+                        String[] split = glocation.split(",");
+
+                        locationModel.setLatitude(Double.parseDouble(split[0]));
+                        locationModel.setLongitude(Double.parseDouble(split[1]));
+                    }
+                    productCenterStream.send(List.of(
+                            ProductPushModel.builder()
+                                    .regionCode(productTriggerTask.getRegion().getCode())
+                                    .pid(it.getScenicId())
+                                    .productType(ProductType.Scenic)
+                                    .cover(new String[]{it.getNewPicUrl()})
+                                    .title(it.getScenicName())
+                                    .meta(Map.of("scenic", it))
+                                    .locationPoint(locationModel)
+                                    .build()));
+                } catch (Exception e) {
+                    e.printStackTrace();
                 }
 
-                return ProductPushModel.builder()
-                        .regionCode(productTriggerTask.getRegion().getCode())
-                        .pid(it.getScenicId())
-                        .productType(ProductType.Scenic)
-                        .cover(new String[]{it.getNewPicUrl()})
-                        .title(it.getScenicName())
-                        .meta(Map.of("scenic", it))
-                        .locationPoint(locationModel)
-                        .build();
-            }).collect(Collectors.toList());
-
-            updateService.push(scenic);
+
+            });
 
             page++;
 

+ 3 - 2
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/service/impl/OrderServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.json.JSONUtil;
 import com.github.microservice.auth.client.content.ResultContent;
 import com.github.microservice.auth.client.content.ResultState;
 import com.github.microservice.auth.security.helper.AuthHelper;
+import com.zhongshu.payment.client.model.CountModel;
 import com.zhongshu.payment.client.model.order.AdminSeachOrderModel;
 import com.zhongshu.payment.client.model.order.UserSeachOrderModel;
 import com.zhongshu.payment.client.model.order.v2.*;
@@ -189,8 +190,8 @@ public class OrderServiceImpl implements OrderService {
         return orderService2.adminOrderDetail(orderNo);
     }
 
-    public ResultContent count() {
-        return orderService2.count();
+    public ResultContent count(CountModel countModel) {
+        return orderService2.count(countModel);
     }