|
@@ -1,8 +1,18 @@
|
|
|
package com.zswl.cloud.springBtach.server.boot;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.github.microservice.auth.client.content.ResultContent;
|
|
|
import com.github.microservice.auth.client.service.EnterpriseService;
|
|
|
+import com.github.microservice.core.util.net.apache.ResponseModel;
|
|
|
+import com.github.microservice.productcenter.client.model.LocationModel;
|
|
|
+import com.github.microservice.productcenter.client.model.ProductPushModel;
|
|
|
+import com.github.microservice.productcenter.client.stream.ProductCenterStream;
|
|
|
+import com.github.microservice.productcenter.client.type.ProductType;
|
|
|
import com.xiaoju.open.oil.commons.config.OilConfig;
|
|
|
import com.xiaoju.open.oil.core.QueryClient;
|
|
|
import com.xiaoju.open.oil.core.QueryClientFactory;
|
|
@@ -22,20 +32,20 @@ import com.zhongshu.payment.client.service.v2.PaymentService2;
|
|
|
import com.zhongshu.payment.client.type.Channel;
|
|
|
import com.zswl.cloud.shop.client.service.GoodsService;
|
|
|
import com.zswl.cloud.shop.client.service.ShopService;
|
|
|
+import com.zswl.cloud.shop.client.vo.yqd.CatalogVo;
|
|
|
+import com.zswl.cloud.shop.client.vo.yqd.CommodityVo;
|
|
|
+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.request.SubmitOrderRequest;
|
|
|
import com.zswl.cloud.springBatch.client.model.dfy.Hotel.response.AddOrderResponse;
|
|
|
+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.Hotel.response.SubmitOrderResponse;
|
|
|
-import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.PrivilegeTicketListRequest;
|
|
|
-import com.zswl.cloud.springBatch.client.model.dfy.Ticket.request.ScenicDetailRequest;
|
|
|
-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.springBatch.client.model.qiuxiang.OrderRequest;
|
|
|
-import com.zswl.cloud.springBatch.client.model.xiaoju.ActivityModel;
|
|
|
-import com.zswl.cloud.springBatch.client.model.ypp.kfc.response.CityListResponse;
|
|
|
import com.zswl.cloud.springBatch.client.service.DfyHotelService;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.dfy.DomesticHotelApi;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.dfy.TicketApi;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.qiuxiang.QiuXiangApi;
|
|
|
+import com.zswl.cloud.springBtach.server.core.api.video.YqdServiceImpl;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.ypp.KfcApi;
|
|
|
import com.zswl.cloud.springBtach.server.core.api.ypp.YppApi;
|
|
|
import com.zswl.cloud.springBtach.server.core.controller.TestSpringBatch;
|
|
@@ -43,6 +53,7 @@ import com.zswl.cloud.springBtach.server.core.dao.XiaoJuActivityReceiverDao;
|
|
|
import com.zswl.cloud.springBtach.server.core.service.PaymentService;
|
|
|
import com.zswl.cloud.springBtach.server.core.service.impl.DfyTicketServiceImpl;
|
|
|
import com.zswl.cloud.springBtach.server.core.service.impl.OrderServiceImpl;
|
|
|
+import com.zswl.cloud.springBtach.server.core.service.impl.RechargeServiceImpl;
|
|
|
import com.zswl.cloud.springBtach.server.core.service.impl.XiaoJuServiceImpl;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.junit.jupiter.api.Test;
|
|
@@ -52,7 +63,11 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@SpringBootTest
|
|
|
@Log4j2
|
|
@@ -83,6 +98,16 @@ public class ServerApplicationTests {
|
|
|
@Autowired
|
|
|
TicketApi diFengYunApi;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ YqdServiceImpl yqdService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RechargeServiceImpl rechargeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProductCenterStream productCenterStream;
|
|
|
+
|
|
|
@Autowired
|
|
|
DfyHotelService dfyHotelService;
|
|
|
@Autowired
|
|
@@ -91,34 +116,39 @@ public class ServerApplicationTests {
|
|
|
private XiaoJuActivityReceiverDao xiaoJuActivityReceiverDao;
|
|
|
@Autowired
|
|
|
private KfcApi kfcApi;
|
|
|
+ @Autowired
|
|
|
+ private YppApi yppApi;
|
|
|
|
|
|
- @Test
|
|
|
- public void dfy() {
|
|
|
-
|
|
|
-
|
|
|
- ScenicListRequest scenic = new ScenicListRequest();
|
|
|
- scenic.setKey("南京");
|
|
|
- scenic.setPage(1);
|
|
|
- scenic.setPageSize(10);
|
|
|
-
|
|
|
-
|
|
|
- ScenicListResponse scenicListResponse = diFengYunApi.scenicList(scenic);
|
|
|
- System.out.println(JSONUtil.toJsonStr(scenicListResponse));
|
|
|
-
|
|
|
-
|
|
|
- ScenicDetailRequest scenicDetailRequest = new ScenicDetailRequest();
|
|
|
- scenicDetailRequest.setScenicId("poi1745");
|
|
|
-
|
|
|
-// ScenicDetailResponse scenicDetailResponse = diFengYunApi.scenicDetail(scenicDetailRequest);
|
|
|
-// System.out.println(JSONUtil.toJsonStr(scenicDetailResponse));
|
|
|
-
|
|
|
- PrivilegeTicketListRequest privilegeTicketListRequest = new PrivilegeTicketListRequest();
|
|
|
- privilegeTicketListRequest.setPage(1);
|
|
|
- privilegeTicketListRequest.setPageSize(20);
|
|
|
-
|
|
|
-// PrivilegeTicketListResponse scenicListResponse = diFengYunApi.privilegeTicketList(privilegeTicketListRequest);
|
|
|
-// System.out.println(JSONUtil.toJsonStr(scenicListResponse));
|
|
|
|
|
|
+ @Test
|
|
|
+ public void dfy() throws Exception {
|
|
|
+ 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 -> {
|
|
|
+
|
|
|
+ Integer mainId = it.getMainId();
|
|
|
+ String mainImg = it.getMainImg();
|
|
|
+ String name = it.getName();
|
|
|
+ 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);
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println(mainId);
|
|
|
+ System.out.println(mainImg);
|
|
|
+ System.out.println(name);
|
|
|
+ System.out.println(price);
|
|
|
+
|
|
|
+ });
|
|
|
+ System.out.println(commodityVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -134,13 +164,12 @@ public class ServerApplicationTests {
|
|
|
// System.out.println(JSONUtil.toJsonStr(cancelOrderResponse));
|
|
|
|
|
|
|
|
|
- orderService2.orderInfo("1798294662177759232");
|
|
|
+ orderService2.orderInfo("1798294662177759232");
|
|
|
ResultContent<List<GoodsResultModel>> listResultContent = orderService2.goodsDetail("1798294662177759232");
|
|
|
GoodsResultModel goodsResultModel = listResultContent.getContent().get(0);
|
|
|
BigDecimal payAmount = goodsResultModel.getPayAmount();
|
|
|
|
|
|
- String extend = goodsResultModel.getExtend();
|
|
|
- AddOrderResponse.Datas bean = JSONUtil.toBean(extend, AddOrderResponse.Datas.class);
|
|
|
+ AddOrderResponse.Datas bean = JSONUtil.toBean(goodsResultModel.getExtend(), AddOrderResponse.Datas.class);
|
|
|
|
|
|
|
|
|
SubmitOrderRequest submitOrderRequest = new SubmitOrderRequest();
|
|
@@ -158,7 +187,75 @@ public class ServerApplicationTests {
|
|
|
|
|
|
@Test
|
|
|
public void test3() {
|
|
|
- CityListResponse cityListResponse = kfcApi.cityList();
|
|
|
+ String name = "贵阳";
|
|
|
+ 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;
|
|
|
+ log.info("地区:", dest);
|
|
|
+
|
|
|
+ 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 -> {
|
|
|
+ System.out.println(it);
|
|
|
+ try {
|
|
|
+ String hotelId = it.getHotelId();
|
|
|
+ String chineseName = it.getChineseName();
|
|
|
+ String picture = it.getPicture();
|
|
|
+ BigDecimal price = it.getPrice();
|
|
|
+ Double latitude = it.getLatitude();
|
|
|
+ Double longitude = it.getLongitude();
|
|
|
+ LocationModel locationModel = new LocationModel(longitude, latitude);
|
|
|
+ productCenterStream.send(List.of(ProductPushModel.builder()
|
|
|
+ .regionCode("520101")
|
|
|
+ .pid(hotelId)
|
|
|
+ .productType(ProductType.Hotel)
|
|
|
+ .cover(new String[]{picture})
|
|
|
+ .salePrice(price.longValue())
|
|
|
+ .title(chineseName)
|
|
|
+ .meta(Map.of("hotel", it))
|
|
|
+ .locationPoint(locationModel)
|
|
|
+// .expireTimeSecond(60 * 60 * 24)
|
|
|
+ .build()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ start += limit;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|