|
@@ -1,6 +1,8 @@
|
|
|
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 com.github.microservice.productcenter.client.model.LocationModel;
|
|
|
import com.github.microservice.productcenter.client.model.ProductPushModel;
|
|
|
import com.github.microservice.productcenter.client.model.ProductTriggerTaskModel;
|
|
@@ -18,6 +20,7 @@ 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;
|
|
|
|
|
@@ -79,8 +82,9 @@ public class KfcPublish implements ProductPublish {
|
|
|
kfcShopsRequest.setOt(string);
|
|
|
ShopsResponse shops = kfcApi.shops(kfcShopsRequest);
|
|
|
shops.getData().forEach(it -> {
|
|
|
+ LocationModel locationModel = new LocationModel();
|
|
|
try {
|
|
|
- LocationModel locationModel = new LocationModel();
|
|
|
+
|
|
|
locationModel.setLongitude(it.getLon());
|
|
|
locationModel.setLatitude(it.getLat());
|
|
|
|
|
@@ -98,7 +102,40 @@ public class KfcPublish implements ProductPublish {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
+ try {
|
|
|
+ JSONObject menus = kfcApi.menus(it.getId());
|
|
|
+ ArrayList arrayList = (ArrayList) menus.getByPath("data.menuVoList");
|
|
|
+ arrayList.forEach(list-> {
|
|
|
+
|
|
|
+ JSONArray jsonArray = new JSONArray(list);
|
|
|
+ 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");
|
|
|
+ productCenterStream.send(List.of(
|
|
|
+ ProductPushModel.builder()
|
|
|
+ .regionCode(productTriggerTask.getRegion().getCode())
|
|
|
+ .pid((String) productId)
|
|
|
+ .address(it.getAddress())
|
|
|
+ .productType(ProductType.RestaurantFood)
|
|
|
+ .locationPoint(locationModel)
|
|
|
+ .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))
|
|
|
+ .build()));
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }catch (Exception e){}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
}
|