Explorar el Código

增加店铺信息

gongfuzhu hace 8 meses
padre
commit
ea8d3bced7

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

@@ -82,38 +82,39 @@ public class KfcPublish implements ProductPublish {
             kfcShopsRequest.setOt(string);
             ShopsResponse shops = kfcApi.shops(kfcShopsRequest);
             shops.getData().forEach(it -> {
-                LocationModel locationModel = new LocationModel();
-                try {
-
-                    locationModel.setLongitude(it.getLon());
-                    locationModel.setLatitude(it.getLat());
-
-                    productCenterStream.send(List.of(
-                            ProductPushModel.builder()
-                                    .regionCode(productTriggerTask.getRegion().getCode())
-                                    .pid(it.getShopCode())
-                                    .address(it.getAddress())
-                                    .productType(ProductType.Restaurant)
-                                    .locationPoint(locationModel)
-                                    .title(it.getShopName())
-                                    .meta(Map.of("shop", it, "ot", string))
-                                    .build()));
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
+                        LocationModel locationModel = new LocationModel();
+                        try {
+
+                            locationModel.setLongitude(it.getLon());
+                            locationModel.setLatitude(it.getLat());
+
+                            productCenterStream.send(List.of(
+                                    ProductPushModel.builder()
+                                            .regionCode(productTriggerTask.getRegion().getCode())
+                                            .pid(it.getId())
+                                            .address(it.getAddress())
+                                            .productType(ProductType.Restaurant)
+                                            .locationPoint(locationModel)
+                                            .title(it.getShopName())
+                                            .meta(Map.of("shop", it, "ot", string))
+                                            .build()));
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
 
                         try {
                             JSONObject menus = kfcApi.menus(it.getId());
                             ArrayList arrayList = (ArrayList) menus.getByPath("data.menuVoList");
-                            arrayList.forEach(list-> {
+                            arrayList.forEach(list -> {
 
                                 JSONArray jsonArray = new JSONArray(list);
-                                jsonArray.forEach(item->{
+                                jsonArray.forEach(item -> {
                                     JSONObject jsonObject = (JSONObject) item;
                                     Object productId = jsonObject.get("productId");
                                     Object nameCn = jsonObject.get("nameCn");
                                     Object priceHead = jsonObject.get("priceHead");
                                     Object imageUrl = jsonObject.get("imageUrl");
+                                    jsonObject.set("shop", it);
                                     productCenterStream.send(List.of(
                                             ProductPushModel.builder()
                                                     .regionCode(productTriggerTask.getRegion().getCode())
@@ -124,16 +125,17 @@ public class KfcPublish implements ProductPublish {
                                                     .title((String) nameCn)
                                                     .cover(new String[]{(String) imageUrl})
                                                     .salePrice(new BigDecimal(String.valueOf(priceHead)).multiply(BigDecimal.valueOf(100)).longValue())
-                                                    .meta(Map.of("menus", item, "ot", string))
+                                                    .meta(Map.of("menus", jsonObject, "ot", string))
                                                     .build()));
 
                                 });
                             });
 
 
-                        }catch (Exception e){}
+                        } catch (Exception e) {
+                        }
 
-            }
+                    }
 
             );
         }