|
@@ -1,91 +1,91 @@
|
|
|
-package com.zswl.cloud.springBtach.server.core.publish;
|
|
|
-
|
|
|
-import cn.hutool.json.JSONArray;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.github.microservice.core.util.net.apache.ResponseModel;
|
|
|
-import com.github.microservice.productcenter.client.model.ProductPushModel;
|
|
|
-import com.github.microservice.productcenter.client.model.ProductTriggerTaskModel;
|
|
|
-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.shop.client.vo.yqd.CatalogVo;
|
|
|
-import com.zswl.cloud.shop.client.vo.yqd.CommodityVo;
|
|
|
-import com.zswl.cloud.springBtach.server.core.api.video.YqdServiceImpl;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-@Slf4j
|
|
|
-@Component
|
|
|
-public class YqdPublish implements ProductPublish {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- YqdServiceImpl yqdService;
|
|
|
-
|
|
|
-
|
|
|
- @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.Recharge
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public void trigger(ProductPushService updateService, ProductTriggerTaskModel productTriggerTask) {
|
|
|
-
|
|
|
- for (CatalogVo catalogVo : yqdService.getCatalog()) {
|
|
|
- ResponseModel responseModel = yqdService.requestCommodityList("0", "100", catalogVo.getId());
|
|
|
- JSONObject entries = JSONUtil.parseObj(responseModel.getBody());
|
|
|
- JSONArray jsonArray = (JSONArray) entries.get("data");
|
|
|
- if (!jsonArray.isEmpty()) {
|
|
|
- List<CommodityVo> commodityVos = com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(jsonArray), CommodityVo.class);
|
|
|
- commodityVos.forEach(it -> {
|
|
|
- BigDecimal price = it.getPrice();
|
|
|
- BigDecimal rate = price.multiply(new BigDecimal("0.06"));
|
|
|
- BigDecimal withdraw = price.add(rate).multiply(new BigDecimal("0.0028"));
|
|
|
- price = price.add(rate).add(withdraw).setScale(2, RoundingMode.UP);
|
|
|
-
|
|
|
- productCenterStream.send(List.of(
|
|
|
- ProductPushModel.builder()
|
|
|
- .regionCode(productTriggerTask.getRegion().getCode())
|
|
|
- .pid(it.getMainId().toString())
|
|
|
- .productType(ProductType.Recharge)
|
|
|
- .cover(new String[]{it.getMainImg()})
|
|
|
- .title(it.getName())
|
|
|
- .salePrice(price.multiply(BigDecimal.valueOf(100)).longValue())
|
|
|
- .meta(Map.of("goods", it))
|
|
|
- .build()));
|
|
|
- });
|
|
|
- System.out.println(commodityVos);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
+//package com.zswl.cloud.springBtach.server.core.publish;
|
|
|
+//
|
|
|
+//import cn.hutool.json.JSONArray;
|
|
|
+//import cn.hutool.json.JSONObject;
|
|
|
+//import cn.hutool.json.JSONUtil;
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
+//import com.github.microservice.core.util.net.apache.ResponseModel;
|
|
|
+//import com.github.microservice.productcenter.client.model.ProductPushModel;
|
|
|
+//import com.github.microservice.productcenter.client.model.ProductTriggerTaskModel;
|
|
|
+//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.shop.client.vo.yqd.CatalogVo;
|
|
|
+//import com.zswl.cloud.shop.client.vo.yqd.CommodityVo;
|
|
|
+//import com.zswl.cloud.springBtach.server.core.api.video.YqdServiceImpl;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.stereotype.Component;
|
|
|
+//
|
|
|
+//import java.math.BigDecimal;
|
|
|
+//import java.math.RoundingMode;
|
|
|
+//import java.util.Collection;
|
|
|
+//import java.util.List;
|
|
|
+//import java.util.Map;
|
|
|
+//import java.util.Set;
|
|
|
+//
|
|
|
+//@Slf4j
|
|
|
+//@Component
|
|
|
+//public class YqdPublish implements ProductPublish {
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// YqdServiceImpl yqdService;
|
|
|
+//
|
|
|
+//
|
|
|
+// @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.Recharge
|
|
|
+// );
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void trigger(ProductPushService updateService, ProductTriggerTaskModel productTriggerTask) {
|
|
|
+//
|
|
|
+// for (CatalogVo catalogVo : yqdService.getCatalog()) {
|
|
|
+// ResponseModel responseModel = yqdService.requestCommodityList("0", "100", catalogVo.getId());
|
|
|
+// JSONObject entries = JSONUtil.parseObj(responseModel.getBody());
|
|
|
+// JSONArray jsonArray = (JSONArray) entries.get("data");
|
|
|
+// if (!jsonArray.isEmpty()) {
|
|
|
+// List<CommodityVo> commodityVos = com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(jsonArray), CommodityVo.class);
|
|
|
+// commodityVos.forEach(it -> {
|
|
|
+// BigDecimal price = it.getPrice();
|
|
|
+// BigDecimal rate = price.multiply(new BigDecimal("0.06"));
|
|
|
+// BigDecimal withdraw = price.add(rate).multiply(new BigDecimal("0.0028"));
|
|
|
+// price = price.add(rate).add(withdraw).setScale(2, RoundingMode.UP);
|
|
|
+//
|
|
|
+// productCenterStream.send(List.of(
|
|
|
+// ProductPushModel.builder()
|
|
|
+// .regionCode(productTriggerTask.getRegion().getCode())
|
|
|
+// .pid(it.getMainId().toString())
|
|
|
+// .productType(ProductType.Recharge)
|
|
|
+// .cover(new String[]{it.getMainImg()})
|
|
|
+// .title(it.getName())
|
|
|
+// .salePrice(price.multiply(BigDecimal.valueOf(100)).longValue())
|
|
|
+// .meta(Map.of("goods", it))
|
|
|
+// .build()));
|
|
|
+// });
|
|
|
+// System.out.println(commodityVos);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//}
|