|
@@ -2,6 +2,8 @@ package com.zswl.cloud.springBtach.server.core.api.video;
|
|
|
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.microservice.auth.client.content.ResultContent;
|
|
|
import com.github.microservice.auth.client.content.ResultState;
|
|
|
import com.github.microservice.core.util.net.apache.HttpClientUtil;
|
|
@@ -9,6 +11,8 @@ import com.github.microservice.core.util.net.apache.HttpModel;
|
|
|
import com.github.microservice.core.util.net.apache.MethodType;
|
|
|
import com.github.microservice.core.util.net.apache.ResponseModel;
|
|
|
import com.zswl.cloud.shop.client.dto.yqd.OrderDto;
|
|
|
+import com.zswl.cloud.shop.client.ret.CommentException;
|
|
|
+import com.zswl.cloud.shop.client.vo.yqd.CatalogVo;
|
|
|
import com.zswl.cloud.springBtach.server.core.dao.ApiLogDao;
|
|
|
import com.zswl.cloud.springBtach.server.core.domain.ApiLog;
|
|
|
import lombok.SneakyThrows;
|
|
@@ -21,6 +25,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Service
|
|
@@ -35,6 +40,11 @@ public class YqdServiceImpl {
|
|
|
private String account;
|
|
|
|
|
|
|
|
|
+ private static final String GET_CATALOG_LIST = "http://open.yiqida.cn/api/UserCommdity/GetCatalogList?timestamp=%s&userName=%s&sign=%s";
|
|
|
+
|
|
|
+ private static final String GET_COMMODITY_LIST = "http://open.yiqida.cn/api/UserCommdity/GetCommodityList?timestamp=%s&userName=%s&sign=%s";
|
|
|
+
|
|
|
+
|
|
|
@Value("${yqd.createUrl}")
|
|
|
private String createUrl;
|
|
|
|
|
@@ -44,6 +54,41 @@ public class YqdServiceImpl {
|
|
|
@Autowired
|
|
|
ApiLogDao apiLogDao;
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取商品分组
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SneakyThrows
|
|
|
+ public List<CatalogVo> getCatalog() {
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ String url = String.format(GET_CATALOG_LIST, timestamp, account, getSign(timestamp, ""));
|
|
|
+ ResponseModel request = HttpClientUtil.request(HttpModel.builder().url(url).build());
|
|
|
+ JSONObject map = JSONObject.parseObject(JSONObject.toJSONString(request.getBody()));
|
|
|
+ if (HttpStatus.HTTP_OK == (int) map.get("code")) {
|
|
|
+ Object data = map.get("data");
|
|
|
+ List<CatalogVo> catalogVos = JSONArray.parseArray(JSON.toJSONString(data), CatalogVo.class);
|
|
|
+ log.info("GoodsController syncCatalog res:{}", JSON.toJSONString(catalogVos));
|
|
|
+ return catalogVos;
|
|
|
+ } else {
|
|
|
+ throw new CommentException(map.getString("msg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ public ResponseModel requestCommodityList(String page, String size, String id) {
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ Map<String, Object> body = new HashMap<>();
|
|
|
+ body.put("page", page);
|
|
|
+ body.put("size", size);
|
|
|
+ body.put("catalogId", id);
|
|
|
+ String url = String.format(GET_COMMODITY_LIST, timestamp, account, getSign(timestamp, JSON.toJSONString(body)));
|
|
|
+ return HttpClientUtil.request(HttpModel.builder().method(MethodType.Post).url(url).body(JSON.toJSONString(body)).build());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@SneakyThrows
|
|
|
public ResultContent create(OrderDto dto) {
|
|
|
long timestamp = System.currentTimeMillis();
|