yumeng 2 éve
szülő
commit
ee121480b2
21 módosított fájl, 1225 hozzáadás és 190 törlés
  1. 708 0
      ruixuan-common/src/main/java/com/ruixuan/common/utils/KsHttpUtils.java
  2. 0 0
      ruixuan-launch/src/main/resources/mapper/launch/ICityService.xml
  3. 7 1
      ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemCollectSamplesController.java
  4. 35 14
      ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemListController.java
  5. 69 0
      ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouAccessToken.java
  6. 59 0
      ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemCategory.java
  7. 6 6
      ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemCollectSamples.java
  8. 18 67
      ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemList.java
  9. 8 0
      ruixuan-live/src/main/java/com/ruixuan/isc/mapper/AccessTokenMapper.java
  10. 5 0
      ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouItemListMapper.java
  11. 2 0
      ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java
  12. 2 0
      ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouItemListService.java
  13. 33 28
      ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/AccessTokenServiceImpl.java
  14. 66 0
      ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/CityMap.java
  15. 2 2
      ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java
  16. 148 37
      ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemListServiceImpl.java
  17. 7 0
      ruixuan-live/src/main/resources/mapper/isc/AccessTokenMapper.xml
  18. 9 9
      ruixuan-live/src/main/resources/mapper/isc/KuaishouItemCollectSamplesMapper.xml
  19. 36 25
      ruixuan-live/src/main/resources/mapper/isc/KuaishouItemListMapper.xml
  20. 3 0
      ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml
  21. 2 1
      ruixuan-system/src/main/java/com/ruixuan/system/mapper/SysRoleMapper.java

+ 708 - 0
ruixuan-common/src/main/java/com/ruixuan/common/utils/KsHttpUtils.java

@@ -0,0 +1,708 @@
+package com.ruixuan.common.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fontbox.ttf.CmapSubtable;
+import org.apache.fontbox.ttf.GlyphData;
+import org.apache.fontbox.ttf.TTFParser;
+import org.apache.fontbox.ttf.TrueTypeFont;
+import org.apache.http.*;
+import org.apache.http.client.CookieStore;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.cookie.BasicClientCookie;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.util.EntityUtils;
+
+
+import javax.net.ssl.SSLContext;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.*;
+
+
+@Slf4j
+public class KsHttpUtils {
+
+    //发送响应流方法
+    public static void setResponseHeader(HttpServletResponse response, String fileName) {
+        try {
+            fileName = new String(fileName.getBytes(), StandardCharsets.UTF_8);
+            //response.setContentType("application/octet-stream;charset=ISO8859-1");
+            response.setContentType("application/vnd.ms-excel;charset=gb2312");
+
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
+            response.addHeader("Pargam", "no-cache");
+            response.addHeader("Cache-Control", "no-cache");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    public static JSONObject bytedanceGetRequest(String accessToken, String url, JSONObject params) {
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "GET";
+            }
+        };
+        httpEntity.setHeader("Access-Token", accessToken);
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(url));
+            httpEntity.setEntity(new StringEntity(params.toJSONString(), ContentType.APPLICATION_JSON));
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(12000).setConnectTimeout(12000).build();
+            httpEntity.setConfig(requestConfig);
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuilder result = new StringBuilder();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+                return JSONObject.parseObject(result.toString());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                if (client != null) {
+                    client.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+
+
+    public static CookieStore COOKIESTORE = new BasicCookieStore();
+    /**
+     * setProxy(new HttpHost("106.125.239.179", 4245))
+     */
+    public static Map<String, Map<String, String>> fontsMap = new HashMap<>();
+    public static String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36";
+
+    public static CloseableHttpClient createSslClientDefault() {
+        try {
+            SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
+                //信任所有证书
+                @Override
+                public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+                    return true;
+                }
+            }).build();
+            RequestConfig globalConfig = RequestConfig.custom().setConnectTimeout(30000).setSocketTimeout(30000).setCookieSpec(CookieSpecs.STANDARD).build();
+            SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(sslContext);
+            return HttpClients.custom().setDefaultCookieStore(COOKIESTORE).setDefaultRequestConfig(globalConfig).setConnectionReuseStrategy((response, context) -> false).setSSLSocketFactory(sslFactory).build();
+        } catch (Exception e) {
+            log.error("处理Https证书异常", e);
+        }
+        return HttpClients.createDefault();
+    }
+
+    public static String httpPostFormRequest(String url, Map<String, Object> param, Map<String, String> headers) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            if (headers != null) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
+            }
+            List<NameValuePair> paramList = new ArrayList<NameValuePair>();
+            if (param != null) {
+                for (String key : param.keySet()) {
+                    BasicNameValuePair basicNameValuePair = new BasicNameValuePair(key, String.valueOf(param.get(key)));
+                    paramList.add(basicNameValuePair);
+                }
+                // 第二步:我们发现Entity是一个接口,所以只能找实现类,发现实现类又需要一个集合,集合的泛型是NameValuePair类型
+                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramList);
+                // 第一步:通过setEntity 将我们的entity对象传递过去
+                httppost.setEntity(formEntity);
+            }
+
+            HttpEntity respentity;
+
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostFormRequest(newUrl, param, headers);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+    public static String httpPostParamRequest(String url, Map<String, Object> param, Map<String, String> headers) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            if (headers != null) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
+            }
+            List<NameValuePair> paramList = new ArrayList<NameValuePair>();
+            for (String key : param.keySet()) {
+                BasicNameValuePair basicNameValuePair = new BasicNameValuePair(key, String.valueOf(param.get(key)));
+                paramList.add(basicNameValuePair);
+            }
+
+            // 第二步:我们发现Entity是一个接口,所以只能找实现类,发现实现类又需要一个集合,集合的泛型是NameValuePair类型
+            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramList);
+            // 第一步:通过setEntity 将我们的entity对象传递过去
+            httppost.setEntity(formEntity);
+            httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
+            HttpEntity respentity;
+
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostParamRequest(newUrl, param, headers);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+    public static String httpPostRequest(String url, Map<String, Object> param, Map<String, String> headers) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+            if (headers != null && headers.size() > 0) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
+            }
+            if (param != null && param.size() > 0) {
+                httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
+            }
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(300 * 1000).setConnectTimeout(300 * 1000).build();
+            httppost.setConfig(requestConfig);
+            HttpEntity respentity;
+
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostRequest(newUrl, param, headers);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+    public static String httpPostNoParamRequest(String url) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+            HttpEntity respentity;
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostNoParamRequest(newUrl);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+
+    public static String httpPostRequestTest(String url, String body, Map<String, String> headers) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+            if (!Check.isNull(headers)) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
+            }
+
+            httppost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
+            HttpEntity respentity;
+
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostRequestTest(newUrl, body, headers);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+
+    public static String kuaiShouhttpPostRequest(String url, String body, Map<String, String> headers) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build();
+            httppost.setConfig(requestConfig);
+            if (!Check.isNullMap(headers)) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
+            }
+
+            httppost.setHeader("User-Agent", USER_AGENT);
+            if (!Check.isNull(body)) {
+                httppost.setEntity(new StringEntity(body, Charset.forName("UTF-8")));
+            }
+            HttpEntity respentity;
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+
+    public static String httpPostRequest(String url, JSONObject params, Map<String, String> headers) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+            for (String key : headers.keySet()) {
+                httppost.setHeader(key, headers.get(key));
+            }
+            httppost.setEntity(new StringEntity(params.toJSONString(), Charset.forName("UTF-8")));
+            HttpEntity respentity;
+
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostRequest(newUrl, params, headers);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+
+
+    public static String postKuaishouVideoUrl(String url, String uid, String photoId) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        String paramBody = "{\"operationName\":\"FeedQuery\",\"variables\":{\"principalId\":\"" + uid + "\",\"photoId\":\"" + photoId + "\"},\"query\":\"query FeedQuery($principalId: String, $photoId: String) {\\n  feedById(principalId: $principalId, photoId: $photoId) {\\n    currentWork {\\n                 timestamp\\n           __typename\\n    }\\n       __typename\\n  }\\n}\\n\"}";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+//            for (String key : headers.keySet()) {
+//                httppost.setHeader(key, headers.get(key));
+//            }
+            httppost.setEntity(new StringEntity(paramBody, Charset.forName("UTF-8")));
+            HttpEntity respentity;
+
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+
+            respentity = response.getEntity();
+            strReturn = EntityUtils.toString(respentity);
+            return strReturn;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+    public static String getKuaishouShareUrl(String url) {
+        HttpClient httpClient = HttpClientBuilder.create().build();
+        HttpResponse response = null;
+        HttpGet httpGet = new HttpGet(url);
+        httpGet.setConfig(RequestConfig.custom().setRedirectsEnabled(false).build());
+        String result = null;
+        try {
+            httpGet.setHeader("User-Agent", USER_AGENT);
+            httpGet.setHeader("Accept-Encoding", "gzip, deflate, br");
+            httpGet.setHeader("Connection", "keep-alive");
+            httpGet.setHeader("Host", "yongzhou.s.gifshow.com");
+            httpGet.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
+            httpGet.setHeader("Upgrade-Insecure-Requests", "1");
+            httpGet.setHeader("Accept-Language", "zh-CN,zh;q=0.9");
+            response = httpClient.execute(httpGet);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return newUrl;
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public static String httpGetRequest(String url) {
+        HttpClient httpClient = createSslClientDefault();
+        HttpResponse response = null;
+        HttpGet httpGet = new HttpGet(url);
+        String result = null;
+        try {
+            httpGet.setHeader("User-Agent", USER_AGENT);
+            response = httpClient.execute(httpGet);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpGetRequest(newUrl);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                String line = null;
+                StringBuilder builder = new StringBuilder();
+                while ((line = reader.readLine()) != null) {
+                    builder.append(line);
+                }
+                result = builder.toString();
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public static String httpRequest(String url, String strParams) throws Exception {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+
+            HttpPost httppost = new HttpPost(url);
+            httppost.addHeader("Content-Type", "application/json");
+            httppost.setEntity(new StringEntity(strParams, Charset.forName("UTF-8")));
+            HttpEntity respentity;
+            HttpResponse response = httpClient.execute(httppost);
+            respentity = response.getEntity();
+            strReturn = EntityUtils.toString(respentity);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+    public static String httpRequest(String url, CookieStore cookies, Map<String, String> parameterMap) throws Exception {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("Content-Type", "application/json");
+            UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(
+                    getParam(parameterMap), "UTF-8");
+            httppost.setEntity(postEntity);
+            HttpEntity respentity;
+            HttpResponse response = httpClient.execute(httppost);
+            respentity = response.getEntity();
+            strReturn = EntityUtils.toString(respentity);
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
+    public static List<NameValuePair> getParam(Map parameterMap) {
+        List<NameValuePair> param = new ArrayList<>();
+        Iterator it = parameterMap.entrySet().iterator();
+        while (it.hasNext()) {
+            Map.Entry parmEntry = (Map.Entry) it.next();
+            param.add(new BasicNameValuePair((String) parmEntry.getKey(),
+                    (String) parmEntry.getValue()));
+        }
+        return param;
+    }
+
+    public static HttpClient getHttpclient() {
+        RequestConfig defaultRequestConfig = RequestConfig.custom().setSocketTimeout(180000).setConnectTimeout(30000)
+                .setConnectionRequestTimeout(30000).setStaleConnectionCheckEnabled(true).build();
+        CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build();
+        return httpclient;
+    }
+
+    public static String callingGraph(String url, String json) {
+        HttpClient httpClient = createSslClientDefault();
+        HttpResponse response = null;
+        HttpPost httpPost = new HttpPost(url);
+        List<Cookie> list = COOKIESTORE.getCookies();
+        httpPost.setHeader("Content-Type", "application/json");
+        String result = null;
+
+        try {
+            StringEntity entity = new StringEntity(json, "utf-8");
+            httpPost.setHeader("User-Agent", USER_AGENT);
+            httpPost.setEntity(entity);
+            response = httpClient.execute(httpPost);
+            BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+            String line = null;
+            StringBuilder builder = new StringBuilder();
+            while ((line = reader.readLine()) != null) {
+                builder.append(line);
+            }
+            result = builder.toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public static Map<String, Integer> KUAISHOUNUMBERMAP;
+
+    public static Integer getKuaishouNumber(String key) {
+        if (KUAISHOUNUMBERMAP == null) {
+            KUAISHOUNUMBERMAP = new HashMap<>();
+//            kuaishouNumberMap.put("32.0#-6.0#526.0#729.0",0);//735
+//            kuaishouNumberMap.put("98.0#13.0#363.0#726.0",1);//713
+//            kuaishouNumberMap.put("32.0#13.0#527.0#732.0",2);//719
+//            kuaishouNumberMap.put("25.0#-6.0#525.0#730.0",3);//736
+//            kuaishouNumberMap.put("26.0#13.0#536.0#731.0",4);//718
+//            kuaishouNumberMap.put("33.0#-5.0#526.0#717.0",5);//722
+//            kuaishouNumberMap.put("39.0#-5.0#530.0#732.0",6);//737
+//            kuaishouNumberMap.put("38.0#13.0#536.0#717.0",7);//704
+//            kuaishouNumberMap.put("33.0#-7.0#525.0#731.0",8);//738
+//            kuaishouNumberMap.put("37.0#-7.0#521.0#730.0",9);//737
+            KUAISHOUNUMBERMAP.put("494.0#735.0", 0);
+            KUAISHOUNUMBERMAP.put("265.0#713.0", 1);
+            KUAISHOUNUMBERMAP.put("495.0#719.0", 2);
+            KUAISHOUNUMBERMAP.put("500.0#736.0", 3);
+            KUAISHOUNUMBERMAP.put("510.0#718.0", 4);
+            KUAISHOUNUMBERMAP.put("493.0#722.0", 5);
+            KUAISHOUNUMBERMAP.put("491.0#737.0", 6);
+            KUAISHOUNUMBERMAP.put("498.0#704.0", 7);
+            KUAISHOUNUMBERMAP.put("492.0#738.0", 8);
+            KUAISHOUNUMBERMAP.put("484.0#737.0", 9);
+        }
+        return KUAISHOUNUMBERMAP.get(key);
+    }
+
+    public static void kuaishouTtf(String ttfName) {
+        try {
+            // 创建URL
+            URL url = new URL("https://static.yximgs.com/udata/pkg/kuaishou-front-end-live/" + ttfName);
+
+            URLConnection urlconn = url.openConnection();
+
+            TTFParser ttfParser = new TTFParser();
+            TrueTypeFont ttf = ttfParser.parse(urlconn.getInputStream());
+            GlyphData[] datas = ttf.getGlyph().getGlyphs();
+            CmapSubtable[] tables = ttf.getCmap().getCmaps();
+            CmapSubtable table = tables[0];
+            Map<String, String> fontMap = new HashMap<>();
+            for (int i = 0; i <= 13; i++) {
+                GlyphData data = datas[i];
+                if (data != null) {
+                    float fx = data.getBoundingBox().getLowerLeftX();
+                    float fy = data.getBoundingBox().getLowerLeftY();
+                    float rx = data.getBoundingBox().getUpperRightX();
+                    float ry = data.getBoundingBox().getUpperRightY();
+                    Integer num = getKuaishouNumber(String.valueOf(rx - fx) + "#" + String.valueOf(ry - fy));
+                    fontMap.put(String.valueOf((char) table.getCharCodes(i).get(0).intValue()), String.valueOf(num));
+                }
+            }
+            fontsMap.put(ttfName, fontMap);
+            for (GlyphData data : datas) {
+                if (data != null) {
+                    float fx = data.getBoundingBox().getLowerLeftX();
+                    float fy = data.getBoundingBox().getLowerLeftY();
+                    float rx = data.getBoundingBox().getUpperRightX();
+                    float ry = data.getBoundingBox().getUpperRightY();
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+/*    public static String mapParamsSortToStringBySeperator(TreeMap<String, Object> treeMap, String seperator) {
+        String result = "";
+        if (null != treeMap && !treeMap.isEmpty()) {
+            for (Map.Entry<String, Object> entry : treeMap.entrySet()) {
+                String key = entry.getKey();
+                String value = UrlEncoded.encodeString((String) entry.getValue().toString());
+                result += (key + "=" + value + seperator);
+            }
+            if (result.length() > 0) {
+                result = result.substring(0, result.length() - seperator.length());
+            }
+        }
+        return result;
+    }*/
+
+//    public static String httpGetRequest(String url, Map<String, String> headers, TreeMap<String, Object> params) {
+//        HttpClient httpClient = createSslClientDefault();
+//        String strReturn = "";
+//        try {
+//            String uri = url + "?" + mapParamsSortToStringBySeperator(params, "&");
+//            System.err.println(uri);
+//            HttpGet httpGet = new HttpGet(uri);
+//            if (headers != null) {
+//                Iterator<String> keyIter = headers.keySet().iterator();
+//                while (keyIter.hasNext()) {
+//                    String curKey = keyIter.next();
+//                    if (curKey != null && headers.get(curKey) != null) {
+//                        httpGet.addHeader(curKey, headers.get(curKey));
+//                    }
+//                }
+//            }
+//            HttpEntity respentity;
+//            HttpResponse response = httpClient.execute(httpGet);
+//            respentity = response.getEntity();
+//            strReturn = EntityUtils.toString(respentity);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error(e.getMessage());
+//        }
+//        return strReturn;
+//    }
+
+
+
+
+
+
+
+
+
+
+    public static String KuaiShouttpGetRequest(String url, Map<String, Object> params, Map<String, String> headers) throws Exception {
+        HttpClient httpclient = getHttpclient();
+        String strReturn = "";
+        try {
+
+
+            StringBuilder postBody = new StringBuilder();
+            for (Map.Entry<String, Object> entry : params.entrySet()) {
+                if (entry.getValue() == null) {
+                    continue;
+                }
+                postBody.append(entry.getKey()).append("=").append(URLEncoder.encode(entry.getValue().toString(),
+                        "utf-8")).append("&");
+            }
+            if (!params.isEmpty()) {
+                postBody.deleteCharAt(postBody.length() - 1);
+            }
+
+            HttpGet httpget = new HttpGet(url + "?" + postBody);
+            if (headers != null) {
+                Iterator<String> keyIter = headers.keySet().iterator();
+                while (keyIter.hasNext()) {
+                    String curKey = keyIter.next();
+                    if (curKey != null && headers.get(curKey) != null) {
+                        httpget.addHeader(curKey, headers.get(curKey));
+                    }
+                }
+            }
+            HttpEntity respentity;
+            HttpResponse response = httpclient.execute(httpget);
+            respentity = response.getEntity();
+            strReturn = EntityUtils.toString(respentity);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return strReturn;
+    }
+
+
+}

ruixuan-launch/src/main/resources/mapper/launch/KuaishouLaunchCampaignAutoStrategyMapper.xml → ruixuan-launch/src/main/resources/mapper/launch/ICityService.xml


+ 7 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemCollectSamplesController.java

@@ -101,6 +101,7 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             List<KuaishouItemCollectSamples> list = kuaishouItemCollectSamplesService.selectKuaishouItemCollectSamplesList(requestMap);
             return getDataTable(list);
         } catch (Exception e) {
+            e.printStackTrace();
             tableDataInfo.setCode(-1);
             tableDataInfo.setMsg(e.getMessage());
         }
@@ -138,6 +139,7 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             returnJson.put("message", "success");
             returnJson.put("preview", previewJson);
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
         }
@@ -164,6 +166,7 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             returnJson.put("code", 0);
             returnJson.put("message", "领样信息增加成功");
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
         }
@@ -229,6 +232,7 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             returnJson.put("code", 0);
             returnJson.put("message", "修改成功");
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
         }
@@ -259,6 +263,7 @@ public class KuaishouItemCollectSamplesController extends BaseController {
             returnJson.put("code", 0);
             returnJson.put("message", "调用成功");
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
         }
@@ -297,13 +302,14 @@ public class KuaishouItemCollectSamplesController extends BaseController {
                 if (!Check.isNull(data)) {
                     express.setExpressData(data.toJSONString());
                 }
-              //  kuaishouItemCollectSamplesService.replaceExpress(express);
+                kuaishouItemCollectSamplesService.replaceExpress(express);
             }
             subscribeResp.setResult(Boolean.TRUE);
             subscribeResp.setReturnCode("200");
             subscribeResp.setMessage("回调成功");
 
         } catch (Exception e) {
+            e.printStackTrace();
             subscribeResp.setResult(Boolean.FALSE);
             subscribeResp.setReturnCode("-1");
             subscribeResp.setMessage(e.getMessage());

+ 35 - 14
ruixuan-live/src/main/java/com/ruixuan/isc/controller/KuaishouItemListController.java

@@ -4,24 +4,24 @@ package com.ruixuan.isc.controller;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.kuaishou.merchant.open.api.KsMerchantApiException;
 import com.ruixuan.common.annotation.Log;
 import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.domain.AjaxResult;
 import com.ruixuan.common.core.page.TableDataInfo;
 import com.ruixuan.common.enums.BusinessType;
 import com.ruixuan.common.utils.Check;
-import com.ruixuan.common.utils.DateUtils;
 import com.ruixuan.isc.entity.KuaishouItemList;
 import com.ruixuan.isc.service.IAccessTokenService;
 import com.ruixuan.isc.service.IKuaishouItemListService;
+import com.ruixuan.isc.service.impl.CityMap;
 import com.ruixuan.system.service.ISysDeptService;
 import com.ruixuan.system.service.ISysRoleService;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -48,8 +48,7 @@ public class KuaishouItemListController extends BaseController {
     @GetMapping("/accessToken")
     @ApiOperation(value = "商品列表")
     public void accessToken() {
-        // accessTokenService.getAccessToken();
-        //   accessTokenService.getCodeAccessToken();
+        accessTokenService.refreshAccessToken();
     }
 
 
@@ -60,11 +59,9 @@ public class KuaishouItemListController extends BaseController {
             @ApiParam("商品ID") @RequestParam(value = "itemId", required = false) Long itemId) {
         JSONObject returnJson = new JSONObject();
         try {
-
             if (Check.isNull(activityId)) {
                 throw new Exception("请传入活动ID");
             }
-
             if (Check.isNull(itemId)) {
                 throw new Exception("请传入商品ID");
             }
@@ -74,9 +71,9 @@ public class KuaishouItemListController extends BaseController {
             }
             returnJson = kuaishouItemListService.getItemDetail(activityId, itemId, accessToken);
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
-            // dataInfo.setCode(-1);
         }
         return returnJson;
     }
@@ -111,6 +108,7 @@ public class KuaishouItemListController extends BaseController {
             List<KuaishouItemList> list = kuaishouItemListService.getItemList(requestMap);
             dataInfo = getDataTable(list);
         } catch (Exception e) {
+            e.printStackTrace();
             dataInfo.setMsg(e.getMessage());
             dataInfo.setCode(-1);
         }
@@ -121,10 +119,9 @@ public class KuaishouItemListController extends BaseController {
     @GetMapping("/checkItem")
     @ApiOperation(value = "检查此商品是否被绑定")
     @PostMapping
-    public JSONObject checkItem(@RequestBody KuaishouItemList kuaishouItemList) {
+    public JSONObject checkItem(Long itemId) {
         JSONObject returnJson = new JSONObject();
         try {
-            Long itemId = kuaishouItemList.getItemId();
             if (Check.isNull(itemId)) {
                 throw new Exception("请传入商品ID");
             }
@@ -133,10 +130,11 @@ public class KuaishouItemListController extends BaseController {
                 returnJson.put("code", 0);
                 returnJson.put("message", "true");
             } else {
-                returnJson.put("code", -1);
+                returnJson.put("code", 1);
                 returnJson.put("message", "此商品已被:" + itemInfo.getUserName() + "绑定!");
             }
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
         }
@@ -144,11 +142,9 @@ public class KuaishouItemListController extends BaseController {
     }
 
 
-    @GetMapping("/insertItem")
+    @PostMapping("/insertItem")
     @ApiOperation(value = "商品列表")
-    @PostMapping
     public JSONObject insertItem(@RequestBody KuaishouItemList kuaishouItemList) {
-
         JSONObject returnJson = new JSONObject();
         try {
             Long itemId = kuaishouItemList.getItemId();
@@ -160,6 +156,7 @@ public class KuaishouItemListController extends BaseController {
             returnJson.put("message", "添加成功");
 
         } catch (Exception e) {
+            e.printStackTrace();
             returnJson.put("code", -1);
             returnJson.put("message", e.getMessage());
         }
@@ -177,6 +174,22 @@ public class KuaishouItemListController extends BaseController {
         return toAjax(kuaishouItemListService.updateKuaishouItemList(kuaishouItemList));
     }
 
+
+    @Log(title = "获取省份")
+    @GetMapping("/getProvince")
+    @ResponseBody
+    public JSONArray getProvince() {
+        return CityMap.getProvince();
+    }
+
+
+    @Log(title = "获取城市")
+    @GetMapping("/getCity")
+    @ResponseBody
+    public String getCity(String province) {
+        return CityMap.getCity(province);
+    }
+
     /**
      * 删除
      */
@@ -186,5 +199,13 @@ public class KuaishouItemListController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] itemIds) {
         return toAjax(kuaishouItemListService.deleteKuaishouItemListByItemIds(itemIds));
     }
+
+
+
+    @GetMapping("/addCategoryId")
+    public void addCategoryId() throws KsMerchantApiException {
+        kuaishouItemListService.addCategoryId();
+    }
+
 }
 

+ 69 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouAccessToken.java

@@ -0,0 +1,69 @@
+package com.ruixuan.isc.entity;
+
+import com.ruixuan.common.core.domain.BaseEntity;
+
+public class KuaishouAccessToken extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+    private String accessToken;
+    private String refreshToken;
+    private String appKey;
+    private String appSecret;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getAccessToken() {
+        return accessToken;
+    }
+
+    public void setAccessToken(String accessToken) {
+        this.accessToken = accessToken;
+    }
+
+    public String getRefreshToken() {
+        return refreshToken;
+    }
+
+    public void setRefreshToken(String refreshToken) {
+        this.refreshToken = refreshToken;
+    }
+
+    public String getAppKey() {
+        return appKey;
+    }
+
+    public void setAppKey(String appKey) {
+        this.appKey = appKey;
+    }
+
+    public String getAppSecret() {
+        return appSecret;
+    }
+
+    public void setAppSecret(String appSecret) {
+        this.appSecret = appSecret;
+    }
+
+    @Override
+    public String toString() {
+        return "KuaishouAccessToken{" +
+                "id='" + id + '\'' +
+                ", accessToken='" + accessToken + '\'' +
+                ", refreshToken='" + refreshToken + '\'' +
+                ", appKey='" + appKey + '\'' +
+                ", appSecret='" + appSecret + '\'' +
+                '}';
+    }
+}

+ 59 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemCategory.java

@@ -0,0 +1,59 @@
+package com.ruixuan.isc.entity;
+
+import com.ruixuan.common.core.domain.BaseEntity;
+
+public class KuaishouItemCategory extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long categoryId;
+    private String categoryName;
+    private Long parentId;
+    private Integer categorySort;
+
+    public static long getSerialVersionUID() {
+        return serialVersionUID;
+    }
+
+    public Long getCategoryId() {
+        return categoryId;
+    }
+
+    public void setCategoryId(Long categoryId) {
+        this.categoryId = categoryId;
+    }
+
+    public String getCategoryName() {
+        return categoryName;
+    }
+
+    public void setCategoryName(String categoryName) {
+        this.categoryName = categoryName;
+    }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public Integer getCategorySort() {
+        return categorySort;
+    }
+
+    public void setCategorySort(Integer categorySort) {
+        this.categorySort = categorySort;
+    }
+
+    @Override
+    public String toString() {
+        return "KuaishouItemCategory{" +
+                "categoryId=" + categoryId +
+                ", categoryName='" + categoryName + '\'' +
+                ", parentId=" + parentId +
+                ", categorySort=" + categorySort +
+                '}';
+    }
+}

+ 6 - 6
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemCollectSamples.java

@@ -35,7 +35,7 @@ public class KuaishouItemCollectSamples extends BaseEntity
 
     /** 商品图片链接 */
     @Excel(name = "商品图片链接")
-    private String itemMgUrl;
+    private String itemImgUrl;
 
     /** 商品备注 */
     @Excel(name = "商品备注")
@@ -151,12 +151,12 @@ public class KuaishouItemCollectSamples extends BaseEntity
         this.itemPrice = itemPrice;
     }
 
-    public String getItemMgUrl() {
-        return itemMgUrl;
+    public String getItemImgUrl() {
+        return itemImgUrl;
     }
 
-    public void setItemMgUrl(String itemMgUrl) {
-        this.itemMgUrl = itemMgUrl;
+    public void setItemImgUrl(String itemImgUrl) {
+        this.itemImgUrl = itemImgUrl;
     }
 
     public String getItemDesc() {
@@ -326,7 +326,7 @@ public class KuaishouItemCollectSamples extends BaseEntity
                 ", itemId=" + itemId +
                 ", itemTitle='" + itemTitle + '\'' +
                 ", itemPrice=" + itemPrice +
-                ", itemMgUrl='" + itemMgUrl + '\'' +
+                ", itemImgUrl='" + itemImgUrl + '\'' +
                 ", itemDesc='" + itemDesc + '\'' +
                 ", commissionRate=" + commissionRate +
                 ", regimentalPromotion=" + regimentalPromotion +

+ 18 - 67
ruixuan-live/src/main/java/com/ruixuan/isc/entity/KuaishouItemList.java

@@ -40,7 +40,7 @@ public class KuaishouItemList extends BaseEntity {
      * 商品图片链接
      */
     @Excel(name = "商品图片链接")
-    private String itemMgUrl;
+    private String itemImgUrl;
 
     /**
      * 商品详情图
@@ -52,7 +52,7 @@ public class KuaishouItemList extends BaseEntity {
      * 小店星级
      */
     @Excel(name = "小店星级")
-    private String shoStar;
+    private String shopStar;
 
     /**
      * 品牌名称
@@ -126,29 +126,7 @@ public class KuaishouItemList extends BaseEntity {
     @Excel(name = "店铺质量分")
     private String mallQualityScore;
 
-    /**
-     * 商品规格ID
-     */
-    @Excel(name = "商品规格ID")
-    private Long skuId;
-
-    /**
-     * 商品规格名称
-     */
-    @Excel(name = "商品规格名称")
-    private String specification;
-
-    /**
-     * 商品规格库存
-     */
-    @Excel(name = "商品规格库存")
-    private Long skuStock;
-
-    /**
-     * 商品规格价格(分)
-     */
-    @Excel(name = "商品规格价格", readConverterExp = "分=")
-    private Long skuPrice;
+    private String skuList;
 
     /**
      * 创建人id
@@ -284,12 +262,12 @@ public class KuaishouItemList extends BaseEntity {
         this.zkFinalPrice = zkFinalPrice;
     }
 
-    public String getItemMgUrl() {
-        return itemMgUrl;
+    public String getItemImgUrl() {
+        return itemImgUrl;
     }
 
-    public void setItemMgUrl(String itemMgUrl) {
-        this.itemMgUrl = itemMgUrl;
+    public void setItemImgUrl(String itemImgUrl) {
+        this.itemImgUrl = itemImgUrl;
     }
 
     public String getItemDescUrls() {
@@ -300,12 +278,12 @@ public class KuaishouItemList extends BaseEntity {
         this.itemDescUrls = itemDescUrls;
     }
 
-    public String getShoStar() {
-        return shoStar;
+    public String getShopStar() {
+        return shopStar;
     }
 
-    public void setShoStar(String shoStar) {
-        this.shoStar = shoStar;
+    public void setShopStar(String shopStar) {
+        this.shopStar = shopStar;
     }
 
     public String getMallLogisticsScore() {
@@ -404,36 +382,12 @@ public class KuaishouItemList extends BaseEntity {
         this.mallQualityScore = mallQualityScore;
     }
 
-    public Long getSkuId() {
-        return skuId;
-    }
-
-    public void setSkuId(Long skuId) {
-        this.skuId = skuId;
-    }
-
-    public String getSpecification() {
-        return specification;
-    }
-
-    public void setSpecification(String specification) {
-        this.specification = specification;
-    }
-
-    public Long getSkuStock() {
-        return skuStock;
-    }
-
-    public void setSkuStock(Long skuStock) {
-        this.skuStock = skuStock;
-    }
-
-    public Long getSkuPrice() {
-        return skuPrice;
+    public String getSkuList() {
+        return skuList;
     }
 
-    public void setSkuPrice(Long skuPrice) {
-        this.skuPrice = skuPrice;
+    public void setSkuList(String skuList) {
+        this.skuList = skuList;
     }
 
     public Long getUserId() {
@@ -564,9 +518,9 @@ public class KuaishouItemList extends BaseEntity {
                 ", itemPrice=" + itemPrice +
                 ", itemDesc='" + itemDesc + '\'' +
                 ", zkFinalPrice=" + zkFinalPrice +
-                ", itemMgUrl='" + itemMgUrl + '\'' +
+                ", itemImgUrl='" + itemImgUrl + '\'' +
                 ", itemDescUrls='" + itemDescUrls + '\'' +
-                ", shoStar='" + shoStar + '\'' +
+                ", shopStar='" + shopStar + '\'' +
                 ", mallLogisticsScore='" + mallLogisticsScore + '\'' +
                 ", activityItemStatus=" + activityItemStatus +
                 ", shopScore='" + shopScore + '\'' +
@@ -579,10 +533,7 @@ public class KuaishouItemList extends BaseEntity {
                 ", commissionRate=" + commissionRate +
                 ", mallServiceScore='" + mallServiceScore + '\'' +
                 ", mallQualityScore='" + mallQualityScore + '\'' +
-                ", skuId=" + skuId +
-                ", specification='" + specification + '\'' +
-                ", skuStock=" + skuStock +
-                ", skuPrice=" + skuPrice +
+                ", skuList='" + skuList + '\'' +
                 ", userId=" + userId +
                 ", userName='" + userName + '\'' +
                 ", examineId=" + examineId +

+ 8 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/AccessTokenMapper.java

@@ -1,5 +1,13 @@
 package com.ruixuan.isc.mapper;
 
+import com.ruixuan.isc.entity.KuaishouAccessToken;
+
+import java.util.List;
+
 public interface AccessTokenMapper {
     String getAccessToken();
+
+    List<KuaishouAccessToken> getTokenInfos();
+
+    void update(KuaishouAccessToken updateToken);
 }

+ 5 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/KuaishouItemListMapper.java

@@ -1,6 +1,7 @@
 package com.ruixuan.isc.mapper;
 
 
+import com.ruixuan.isc.entity.KuaishouItemCategory;
 import com.ruixuan.isc.entity.KuaishouItemList;
 import org.apache.ibatis.annotations.Param;
 
@@ -24,5 +25,9 @@ public interface KuaishouItemListMapper {
     int updateKuaishouItemList(KuaishouItemList kuaishouItemList);
 
     int deleteKuaishouItemListByItemIds(Long[] itemIds);
+
+    void batchCategory( @Param("adds") List<KuaishouItemCategory> adds);
+
+    KuaishouItemCategory getCategoryInfo(@Param("categoryId") Long categoryId);
 }
 

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/mapper/SupplyChainMapper.java

@@ -70,4 +70,6 @@ public interface SupplyChainMapper {
     JSONObject userItemTotal(Map<String, Object> requestMap);
 
     List<JSONObject> exportUserItemDetail(Map<String, Object> requestMap);
+
+    String getCookie();
 }

+ 2 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/IKuaishouItemListService.java

@@ -29,5 +29,7 @@ public interface IKuaishouItemListService {
     int updateKuaishouItemList(KuaishouItemList kuaishouItemList);
 
     int deleteKuaishouItemListByItemIds(Long[] itemIds);
+
+    int addCategoryId() throws KsMerchantApiException;
 }
 

+ 33 - 28
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/AccessTokenServiceImpl.java

@@ -7,12 +7,18 @@ import com.kuaishou.merchant.open.api.client.oauth.OauthAccessTokenKsClient;
 import com.kuaishou.merchant.open.api.client.oauth.OauthCredentialKsClient;
 import com.kuaishou.merchant.open.api.response.oauth.KsAccessTokenResponse;
 import com.kuaishou.merchant.open.api.response.oauth.KsCredentialResponse;
+import com.ruixuan.common.utils.Check;
 import com.ruixuan.common.utils.RedisUtil;
+import com.ruixuan.isc.entity.KuaishouAccessToken;
 import com.ruixuan.isc.mapper.AccessTokenMapper;
 import com.ruixuan.isc.service.IAccessTokenService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
+@Slf4j
 @Service
 public class AccessTokenServiceImpl implements IAccessTokenService {
     @Autowired
@@ -26,35 +32,34 @@ public class AccessTokenServiceImpl implements IAccessTokenService {
 
     @Override
     public void refreshAccessToken() {
-        String appKey = "ks665688320292774929";
-        String appSecret = "3qAsvwcUYuHFVpxJ_OTSFg";
-        String grantCode = "86e73c07a93aa4434335c4d3e9a1773d6bcb573ec65b965a7251749c8b856990f845a095";
-        //    String serverRestUrl = "open.distribution.investment.activity.item.detail";
-
-/*        OauthAccessTokenKsClient oauthAccessTokenKsClient
-                = new OauthAccessTokenKsClient(appKey, appSecret, serverRestUrl);*/
-
-        OauthAccessTokenKsClient oauthAccessTokenKsClient
-                = new OauthAccessTokenKsClient(appKey, appSecret);
-
-// 生成AccessToken
-        try {
-            KsAccessTokenResponse response
-                    = oauthAccessTokenKsClient.getAccessToken(grantCode);
-            System.out.println(JSON.toJSONString(response));
-        } catch (KsMerchantApiException e) {
-            e.printStackTrace();
-        }
+        List<KuaishouAccessToken> tokens = accessTokenMapper.getTokenInfos();
+        if (!Check.isNull(tokens)) {
+            for (KuaishouAccessToken token : tokens) {
+                String appKey = token.getAppKey();
+                String appSecret = token.getAppSecret();
+                String refreshToken = token.getRefreshToken();
+                OauthAccessTokenKsClient oauthAccessTokenKsClient = new OauthAccessTokenKsClient(appKey, appSecret);
+                try {
+                    KsAccessTokenResponse response = oauthAccessTokenKsClient.refreshAccessToken(refreshToken);
+                    JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(response));
+                    log.info("刷新token,id:{},返回结果:{}",token.getId(),jsonObject);
+                    if(jsonObject.getInteger("result") == 1){
+                        KuaishouAccessToken updateToken = new KuaishouAccessToken();
+                        updateToken.setId(token.getId());
+                        updateToken.setAccessToken(jsonObject.getString("accessToken"));
+                        updateToken.setRefreshToken(jsonObject.getString("refreshToken"));
+                        accessTokenMapper.update(updateToken);
+                    }
+
+
+                } catch (KsMerchantApiException e) {
+                    e.printStackTrace();
 
-        String refreshToken = "your app refreshToken";
+                }
 
-// 刷新AccessToken
-      /*  try {
-            KsAccessTokenResponse response
-                    = oauthAccessTokenKsClient.refreshAccessToken(refreshToken);
-            System.out.println(JSON.toJSONString(response));
-        } catch (KsMerchantApiException e) {
-            e.printStackTrace();
-        }*/
+            }
+
+
+        }
     }
 }

+ 66 - 0
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/CityMap.java

@@ -0,0 +1,66 @@
+package com.ruixuan.isc.service.impl;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.*;
+
+public class CityMap {
+
+
+    static Map<String,String[]> province=new LinkedHashMap<>();
+    static{
+        //以下代码中的省市信息从网上爬取
+        province.put("北京市",new String[]{"北京市"});
+        province.put("天津市",new String[]{"天津市"});
+        province.put("上海市",new String[]{"上海市"});
+        province.put("重庆市",new String[]{"重庆市"});
+        province.put("河北省",new String[]{"石家庄市","唐山市","秦皇岛市","邯郸市","邢台市","保定市","张家口市","承德市","沧州市","廊坊市","衡水市"});
+        province.put("山西省",new String[]{"太原市","大同市","阳泉市","长治市","晋城市","朔州市","晋中市","运城市","忻州市","临汾市","吕梁市"});
+        province.put("辽宁省",new String[]{"沈阳市","大连市","鞍山市","抚顺市","本溪市","丹东市","锦州市","营口市","阜新市","辽阳市","盘锦市","铁岭市","朝阳市","葫芦岛市"});
+        province.put("吉林省",new String[]{"长春市","吉林市","四平市","辽源市","通化市","白山市","松原市","白城市","延边朝鲜族自治州"});
+        province.put("黑龙江省",new String[]{"哈尔滨市","齐齐哈尔市","鸡西市","鹤岗市","双鸭山市","大庆市","伊春市","佳木斯市","七台河市","牡丹江市","黑河市","绥化市","大兴安岭地区"});
+        province.put("江苏省",new String[]{"南京市","无锡市","徐州市","常州市","苏州市","南通市","连云港市","淮安市","盐城市","扬州市","镇江市","泰州市","宿迁市"});
+        province.put("浙江省",new String[]{"杭州市","宁波市","温州市","嘉兴市","湖州市","绍兴市","金华市","衢州市","舟山市","台州市","丽水市"});
+        province.put("安徽省",new String[]{"合肥市","芜湖市","蚌埠市","淮南市","马鞍山市","淮北市","铜陵市","安庆市","黄山市","滁州市","阜阳市","宿州市","六安市","亳州市","池州市","宣城市"});
+        province.put("福建省",new String[]{"福州市","厦门市","莆田市","三明市","泉州市","漳州市","南平市","龙岩市","宁德市"});
+        province.put("江西省",new String[]{"南昌市","景德镇市","萍乡市","九江市","新余市","鹰潭市","赣州市","吉安市","宜春市","抚州市","上饶市"});
+        province.put("山东省",new String[]{"济南市","青岛市","淄博市","枣庄市","东营市","烟台市","潍坊市","济宁市","泰安市","威海市","日照市","临沂市","德州市","聊城市","滨州市","菏泽市"});
+        province.put("河南省",new String[]{"郑州市","开封市","洛阳市","平顶山市","安阳市","鹤壁市","新乡市","焦作市","濮阳市","许昌市","漯河市","三门峡市","南阳市","商丘市","信阳市","周口市","驻马店市","省直辖县级行政区划"});
+        province.put("湖北省",new String[]{"武汉市","黄石市","十堰市","宜昌市","襄阳市","鄂州市","荆门市","孝感市","荆州市","黄冈市","咸宁市","随州市","恩施土家族苗族自治州","省直辖县级行政区划"});
+        province.put("湖南省",new String[]{"长沙市","株洲市","湘潭市","衡阳市","邵阳市","岳阳市","常德市","张家界市","益阳市","郴州市","永州市","怀化市","娄底市","湘西土家族苗族自治州"});
+        province.put("广东省",new String[]{"广州市","韶关市","深圳市","珠海市","汕头市","佛山市","江门市","湛江市","茂名市","肇庆市","惠州市","梅州市","汕尾市","河源市","阳江市","清远市","东莞市","中山市","潮州市","揭阳市","云浮市"});
+        province.put("海南省",new String[]{"海口市","三亚市","三沙市","儋州市","省直辖县级行政区划"});
+        province.put("四川省",new String[]{"成都市","自贡市","攀枝花市","泸州市","德阳市","绵阳市","广元市","遂宁市","内江市","乐山市","南充市","眉山市","宜宾市","广安市","达州市","雅安市","巴中市","资阳市","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州"});
+        province.put("贵州省",new String[]{"贵阳市","六盘水市","遵义市","安顺市","毕节市","铜仁市","黔西南布依族苗族自治州","黔东南苗族侗族自治州","黔南布依族苗族自治州"});
+        province.put("云南省",new String[]{"昆明市","曲靖市","玉溪市","保山市","昭通市","丽江市","普洱市","临沧市","楚雄彝族自治州","红河哈尼族彝族自治州","文山壮族苗族自治州","西双版纳傣族自治州","大理白族自治州","德宏傣族景颇族自治州","怒江傈僳族自治州","迪庆藏族自治州"});
+        province.put("西藏自治区",new String[]{"拉萨市","日喀则市","昌都市","林芝市","山南市","那曲市","阿里地区"});
+        province.put("陕西省",new String[]{"西安市","铜川市","宝鸡市","咸阳市","渭南市","延安市","汉中市","榆林市","安康市","商洛市"});
+        province.put("甘肃省",new String[]{"兰州市","嘉峪关市","金昌市","白银市","天水市","武威市","张掖市","平凉市","酒泉市","庆阳市","定西市","陇南市","临夏回族自治州","甘南藏族自治州"});
+        province.put("青海省",new String[]{"西宁市","海东市","海北藏族自治州","黄南藏族自治州","海南藏族自治州","果洛藏族自治州","玉树藏族自治州","海西蒙古族藏族自治州"});
+        province.put("内蒙古自治区",new String[]{"呼和浩特市","包头市","乌海市","赤峰市","通辽市","鄂尔多斯市","呼伦贝尔市","巴彦淖尔市","乌兰察布市","兴安盟","锡林郭勒盟","阿拉善盟"});
+        province.put("广西壮族自治区",new String[]{"南宁市","柳州市","桂林市","梧州市","北海市","防城港市","钦州市","贵港市","玉林市","百色市","贺州市","河池市","来宾市","崇左市"});
+        province.put("宁夏回族自治区",new String[]{"银川市","石嘴山市","吴忠市","固原市","中卫市"});
+        province.put("新疆维吾尔自治区",new String[]{"乌鲁木齐市","克拉玛依市","吐鲁番市","哈密市","昌吉回族自治州","博尔塔拉蒙古自治州","巴音郭楞蒙古自治州","阿克苏地区","克孜勒苏柯尔克孜自治州","喀什地区","和田地区","伊犁哈萨克自治州","塔城地区","阿勒泰地区","自治区直辖县级行政区划"});
+
+
+
+    }
+    public static JSONArray getProvince(){
+        Map<String, String[]> map = CityMap.province;// 获取省份信息保存到Map中
+        Set<String> set = map.keySet(); // 获取Map集合中的键,并以Set集合返回
+        Object[] province = set.toArray(); // 转换为数组
+        return JSONArray.parseArray(JSONObject.toJSONString(province));
+    }
+
+
+    public static String getCity(String province){
+        Map<String, String[]> map = CityMap.province; // 获取省份信息保存到Map中
+        String[] cities= map.get(province); // 获取指定键的值
+       // System.err.println(JSONObject.toJSONString(cities));
+        return JSONObject.toJSONString(cities) ;
+    }
+
+
+}
+
+

+ 2 - 2
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemCollectSamplesServiceImpl.java

@@ -137,7 +137,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
                 sampleJson.put("itemId", itemJson.getLong("itemId"));
                 sampleJson.put("itemTitle", itemJson.getLong("itemTitle"));
                 sampleJson.put("itemPrice", itemJson.getLong("itemPrice"));
-                sampleJson.put("itemMgUrl", itemJson.getString("itemMgUrl"));
+                sampleJson.put("itemImgUrl", itemJson.getString("itemImgUrl"));
                 sampleJson.put("commissionRate", itemJson.getLong("commissionRate"));
                 sampleJson.put("regimentalPromotion", itemJson.getLong("regimentalPromotion"));
                 sampleJson.put("itemCreateId", itemJson.getLong("userId"));
@@ -172,7 +172,7 @@ public class KuaishouItemCollectSamplesServiceImpl implements IKuaishouItemColle
             sample.setItemId(sampleJson.getLong("item_id"));
             sample.setItemTitle(sampleJson.getString("item_title"));
             sample.setItemPrice(sampleJson.getLong("item_price"));
-            sample.setItemMgUrl(sampleJson.getString("item_mg_url"));
+            sample.setItemImgUrl(sampleJson.getString("item_img_url"));
             sample.setItemDesc(sampleJson.getString("item_desc"));
             sample.setCommissionRate(sampleJson.getLong("commission_rate"));
             sample.setRegimentalPromotion(sampleJson.getLong("regimental_promotion"));

+ 148 - 37
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemListServiceImpl.java

@@ -2,6 +2,7 @@ package com.ruixuan.isc.service.impl;
 
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -12,13 +13,19 @@ import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
 import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityInvalidItemListRequest;
 import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionInvestmentActivityItemDetailRequest;
+import com.kuaishou.merchant.open.api.request.distribution.OpenDistributionPublicCategoryListRequest;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityInvalidItemListResponse;
 import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionInvestmentActivityItemDetailResponse;
+import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionPublicCategoryListResponse;
 import com.ruixuan.common.utils.Check;
+import com.ruixuan.common.utils.KsHttpUtils;
 import com.ruixuan.isc.constants.KuaiShouConstants;
 import com.ruixuan.isc.entity.KuaishouItemList;
+import com.ruixuan.isc.entity.KuaishouItemCategory;
 import com.ruixuan.isc.mapper.KuaishouItemListMapper;
+import com.ruixuan.isc.mapper.SupplyChainMapper;
 import com.ruixuan.isc.service.IKuaishouItemListService;
+import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -54,25 +61,34 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         item.add(itemId);
         request.setItemId(item);
         OpenDistributionInvestmentActivityItemDetailResponse response = client.execute(request);
-        JSONObject itemJson = JSONObject.parseObject(GsonUtils.toJSON(response));
-        log.info("获取信息返回数据:{}", itemJson);
-        if (Check.isNull(itemJson)) {
+        JSONObject json = JSONObject.parseObject(GsonUtils.toJSON(response));
+        log.info("获取信息返回数据:{}", json);
+        if (Check.isNull(json)) {
             throw new Exception("获取商品信息出错,请重新提交");
         }
-        Integer code = itemJson.getInteger("code");
-        Integer subCode = itemJson.getInteger("sub_code");
+        Integer code = json.getInteger("code");
+        Integer subCode = json.getInteger("sub_code");
         if (code == 1 && subCode == 1) {
-            JSONArray data = itemJson.getJSONArray("data");
+            JSONArray data = json.getJSONArray("data");
             if (Check.isNull(data)) {
                 returnJson.put("code", -1);
                 returnJson.put("message", "数据查询失败");
                 return returnJson;
             }
-            JSONObject itemJSon = data.getJSONObject(0);
+            JSONObject itemJson = data.getJSONObject(0);
+            Long categoryId = itemJson.getLong("categoryId");
+            String categoryInfo = getCategoryInfo(categoryId);
+            if (!Check.isNull(categoryInfo)) {
+                itemJson.put("categoryName", categoryInfo);
+            }
+            itemJson.put("detailUrl", "https://app.kwaixiaodian.com/merchant/shop/detail?id=" + itemId);
+
             returnJson.put("judgeStatus", 1);
-            returnJson.put("itemJSon", itemJSon);
+            returnJson.put("itemJson", itemJson);
             returnJson.put("code", 0);
             returnJson.put("message", "查询成功");
+
+
         } else if (code == 807000 && (subCode == 24101 || subCode == 24214)) { // 商品下线
             returnJson = getInvaliItemDetail(activityId, itemId, accessToken);
         } else {
@@ -82,6 +98,32 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         return returnJson;
     }
 
+    private String getCategoryInfo(Long categoryId) {
+        if (Check.isNull(categoryId)) {
+            return null;
+        }
+        StringBuffer stringBuffer = new StringBuffer();
+
+        KuaishouItemCategory category = kuaishouItemListMapper.getCategoryInfo(categoryId);
+        KuaishouItemCategory secondCategory = new KuaishouItemCategory();
+        KuaishouItemCategory thirdCategory = new KuaishouItemCategory();
+        if (category.getCategorySort() == 1) {
+
+            stringBuffer.append(category.getCategoryName());
+        } else if (category.getCategorySort() == 2) {
+            secondCategory = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
+            stringBuffer.append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
+        } else if (category.getCategorySort() == 3) {
+            secondCategory = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
+            thirdCategory = kuaishouItemListMapper.getCategoryInfo(secondCategory.getParentId());
+            stringBuffer.append(thirdCategory.getCategoryName()).append(">").append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
+        }
+
+        return stringBuffer.toString();
+
+
+    }
+
     @Override
     public KuaishouItemList getItemInfoByItemId(Long itemId) {
         return kuaishouItemListMapper.getItemInfoByItemId(itemId);
@@ -102,42 +144,111 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         return kuaishouItemListMapper.deleteKuaishouItemListByItemIds(itemIds);
     }
 
+    @Override
+    public int addCategoryId() throws KsMerchantApiException {
+        String url = "https://openapi.kwaixiaodian.com";
+        String appKey = "ks665688320292774929";
+        String signSecret = "8e21f5bc03b6d2dc63e6256225dac00b";
+        String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJg5CLuL6ttwj9MiWcCHbVN4sRko6KKjKrjzmWJ3GBpR_s7IKevDH5orkC2xKtmrkGESX3VkZVGTFpjw-hqSOHPtJmMfj0QH-_bKLqdYO0t56zqyJr_pTibE1rR6tFUgaAaGhINVY3cQVhC4YDnv5YNyfZ0IKwiIEtqPp9U48e9lE_g3P9Th_KB-cb9VF1e0xlABypm9xdqKAUwAQ";
+        AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
+        OpenDistributionPublicCategoryListRequest request = new OpenDistributionPublicCategoryListRequest();
+        request.setAccessToken(accessToken);
+        request.setApiMethodVersion(1L);
+        OpenDistributionPublicCategoryListResponse response = client.execute(request);
+        JSONObject jsonObject = JSONObject.parseObject(GsonUtils.toJSON(response));
+        JSONArray data = jsonObject.getJSONArray("data");
+        List<KuaishouItemCategory> adds = new ArrayList<>();
+
+        for (int i = 0; i < data.size(); i++) {
+            JSONObject first = data.getJSONObject(i);
+            KuaishouItemCategory firstCategory = new KuaishouItemCategory();
+            firstCategory.setCategoryId(first.getLong("categoryId"));
+            firstCategory.setCategoryName(first.getString("categoryName"));
+            firstCategory.setCategorySort(1);
+            firstCategory.setParentId(1L);
+            Long firstCategoryId = first.getLong("categoryId");
+            adds.add(firstCategory);
+            JSONArray secondChildCategory = first.getJSONArray("childCategory");
+            if (!Check.isNull(secondChildCategory)) {
+                for (int j = 0; j < secondChildCategory.size(); j++) {
+                    JSONObject second = secondChildCategory.getJSONObject(j);
+                    KuaishouItemCategory secondCategory = new KuaishouItemCategory();
+                    secondCategory.setParentId(firstCategoryId);
+                    secondCategory.setCategoryId(second.getLong("categoryId"));
+                    secondCategory.setCategoryName(second.getString("categoryName"));
+                    secondCategory.setCategorySort(2);
+                    Long secondCategoryId = second.getLong("categoryId");
+                    adds.add(secondCategory);
+                    JSONArray thirdChildCategory = second.getJSONArray("childCategory");
+                    if (!Check.isNull(thirdChildCategory)) {
+                        for (int k = 0; k < thirdChildCategory.size(); k++) {
+                            JSONObject third = thirdChildCategory.getJSONObject(k);
+                            KuaishouItemCategory thirdCategory = new KuaishouItemCategory();
+                            thirdCategory.setParentId(secondCategoryId);
+                            thirdCategory.setCategoryId(third.getLong("categoryId"));
+                            thirdCategory.setCategoryName(third.getString("categoryName"));
+                            thirdCategory.setCategorySort(3);
+                            adds.add(thirdCategory);
+                        }
+                    }
+                }
+
+            }
+
+
+        }
+        kuaishouItemListMapper.batchCategory(adds);
+
+        System.err.println(jsonObject);
+
+
+        return 0;
+    }
+
+    @Autowired
+    private SupplyChainMapper supplyChainMapper;
 
     private JSONObject getInvaliItemDetail(Long activityId, Long itemId, String accessToken) throws Exception {
         JSONObject returnJson = new JSONObject();
-        AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(KuaiShouConstants.KFX_URL, KuaiShouConstants.APP_KEY, KuaiShouConstants.SIGN_SECRET);
-        OpenDistributionInvestmentActivityInvalidItemListRequest request = new OpenDistributionInvestmentActivityInvalidItemListRequest();
-        request.setAccessToken(accessToken);
-        request.setApiMethodVersion(1L);
-        request.setOffset("0");
-        request.setItemId(itemId);
-        request.setActivityId(activityId);
-        request.setLimit(10);
-        request.setCloseType(0);
-        OpenDistributionInvestmentActivityInvalidItemListResponse response = client.execute(request);
-        JSONObject itemJson = JSONObject.parseObject(GsonUtils.toJSON(response));
-        if (Check.isNull(itemJson)) {
+        String cookie = supplyChainMapper.getCookie();
+        Map<String, Object> params = new HashMap<>();
+        params.put("limit", 20);
+        params.put("offset", 0);
+        params.put("activityId", activityId);
+        params.put("itemId", itemId);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Cookie", cookie);
+        String resultStr = KsHttpUtils.KuaiShouttpGetRequest("https://cps.kwaixiaodian.com/distribute/pc/investment/activity/item/list", params, headers);
+        JSONObject result = JSONObject.parseObject(resultStr);
+        if (Check.isNull(result)) {
+            log.error("快分销招商商品数据返回为空");
             returnJson.put("code", -1);
-            returnJson.put("message", "获取商品信息出错,请重新提交");
+            returnJson.put("message", "获取商品信息为空");
             return returnJson;
         }
-        Integer code = itemJson.getInteger("code");
-        Integer subCode = itemJson.getInteger("sub_code");
-
-        if (code == 1 && subCode == 1) {
-            JSONObject data = itemJson.getJSONObject("data");
-            JSONArray array = data.getJSONArray("item");
-            if (!Check.isNull(array)) {
-                returnJson = array.getJSONObject(0);
-                returnJson.put("judgeStatus", 2);
-                returnJson.put("code", 0);
-                returnJson.put("message", "查询成功");
-            }
-
-        } else {
-            returnJson.put("code", 0);
-            returnJson.put("message", "查询失败");
+        Integer code = result.getInteger("result");
+        if (code != 1) {
+            log.info("快分销招商商品数据返回异常:", resultStr);
+            //   sendMessageService.sendMessage("113dee46c7df464da78c07a985e92cd1", "快手供应链cookie失效,请及时更新。媒体返回信息:" + resultStr);
+            returnJson.put("code", -1);
+            returnJson.put("message", "增加快手商品信息抓取失败,请联系技术人员");
+            return returnJson;
         }
+        JSONArray dataArray = result.getJSONArray("data");
+        if (Check.isNull(dataArray)) {
+            log.error("快分销招商商品数据返回为data数据为空");
+            returnJson.put("code", -1);
+            returnJson.put("message", "快分销招商商品数据返回为data数据为空");
+            return returnJson;
+        }
+       JSONObject itemJson = dataArray.getJSONObject(0);
+        itemJson.put("detailUrl", "https://app.kwaixiaodian.com/merchant/shop/detail?id=" + itemId);
+        returnJson.put("judgeStatus", 2);
+        returnJson.put("itemJson", itemJson);
+        returnJson.put("code", 0);
+        returnJson.put("message", "查询成功");
+
         return returnJson;
     }
 

+ 7 - 0
ruixuan-live/src/main/resources/mapper/isc/AccessTokenMapper.xml

@@ -3,9 +3,16 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruixuan.isc.mapper.AccessTokenMapper">
+    <update id="update" parameterType="com.ruixuan.isc.entity.KuaishouAccessToken">
+ update kuaishou_access_token set access_token = #{accessToken},refresh_token = #{refreshToken}
+ where id = #{id}
+    </update>
 
 
     <select id="getAccessToken" resultType="java.lang.String">
         select  access_token from kuaishou_access_token limit 1
     </select>
+    <select id="getTokenInfos" resultType="com.ruixuan.isc.entity.KuaishouAccessToken">
+        select *  from kuaishou_access_token
+    </select>
 </mapper>

+ 9 - 9
ruixuan-live/src/main/resources/mapper/isc/KuaishouItemCollectSamplesMapper.xml

@@ -9,7 +9,7 @@
         <result property="itemId" column="item_id"/>
         <result property="itemTitle" column="item_title"/>
         <result property="itemPrice" column="item_price"/>
-        <result property="itemMgUrl" column="item_mg_url"/>
+        <result property="itemImgUrl" column="item_img_url"/>
         <result property="itemDesc" column="item_desc"/>
         <result property="commissionRate" column="commission_rate"/>
         <result property="regimentalPromotion" column="regimental_promotion"/>
@@ -34,7 +34,7 @@
     </resultMap>
 
     <sql id="selectKuaishouItemCollectSamplesVo">
-        select id, item_id, item_title, item_price, item_mg_url, item_desc, commission_rate, regimental_promotion, sample_count, sample_requirement, item_create_id, item_create_name, collect_sample_id, collect_sample_name, partner_recommend_text, promoter_id, promoter_nick_name,promoter_url, promoter_phone, promoter_address, courier_number, task_file_url, collect_sample_status, collect_sample_desc, create_time, update_time from kuaishou_item_collect_samples
+        select id, item_id, item_title, item_price, item_img_url, item_desc, commission_rate, regimental_promotion, sample_count, sample_requirement, item_create_id, item_create_name, collect_sample_id, collect_sample_name, partner_recommend_text, promoter_id, promoter_nick_name,promoter_url, promoter_phone, promoter_address, courier_number, task_file_url, collect_sample_status, collect_sample_desc, create_time, update_time from kuaishou_item_collect_samples
     </sql>
 
     <select id="selectKuaishouItemCollectSamplesList" parameterType="com.ruixuan.isc.entity.KuaishouItemCollectSamples"
@@ -80,7 +80,7 @@
         item_id as 'itemId',
         item_title as 'itemTitle',
         item_price as 'itemPrice',
-        item_mg_url as 'itemMgUrl',
+        item_img_url as 'itemImgUrl',
         regimental_promotion as 'regimentalPromotion',
         user_id as 'userId',
         user_name as 'userName'
@@ -129,7 +129,7 @@
             <if test="itemId != null">item_id,</if>
             <if test="itemTitle != null">item_title,</if>
             <if test="itemPrice != null">item_price,</if>
-            <if test="itemMgUrl != null">item_mg_url,</if>
+            <if test="itemImgUrl != null">item_img_url,</if>
             <if test="itemDesc != null">item_desc,</if>
             <if test="commissionRate != null">commission_rate,</if>
             <if test="regimentalPromotion != null">regimental_promotion,</if>
@@ -157,7 +157,7 @@
             <if test="itemId != null">#{itemId},</if>
             <if test="itemTitle != null">#{itemTitle},</if>
             <if test="itemPrice != null">#{itemPrice},</if>
-            <if test="itemMgUrl != null">#{itemMgUrl},</if>
+            <if test="itemImgUrl != null">#{itemImgUrl},</if>
             <if test="itemDesc != null">#{itemDesc},</if>
             <if test="commissionRate != null">#{commissionRate},</if>
             <if test="regimentalPromotion != null">#{regimentalPromotion},</if>
@@ -187,7 +187,7 @@
         item_id,
         item_title,
         item_price,
-        item_mg_url,
+        item_img_url,
         item_desc,
         commission_rate,
         regimental_promotion,
@@ -213,7 +213,7 @@
             #{add.itemId},
             #{add.itemTitle},
             #{add.itemPrice},
-            #{add.itemMgUrl},
+            #{add.itemImgUrl},
             #{add.itemDesc},
             #{add.commissionRate},
             #{add.regimentalOromotion},
@@ -230,7 +230,7 @@
             #{add.promoterAddress},
             #{add.courierNumber},
             #{add.taskFileUrl},
-            #{add.collectSampleStatus},
+            #{add.collectSampleStatus },
             #{add.collectSampleDesc}
             )
         </foreach>
@@ -260,7 +260,7 @@
             <if test="itemId != null">item_id = #{itemId},</if>
             <if test="itemTitle != null">item_title = #{itemTitle},</if>
             <if test="itemPrice != null">item_price = #{itemPrice},</if>
-            <if test="itemMgUrl != null">item_mg_url = #{itemMgUrl},</if>
+            <if test="itemImgUrl != null">item_img_url = #{itemImgUrl},</if>
             <if test="itemDesc != null">item_desc = #{itemDesc},</if>
             <if test="commissionRate != null">commission_rate = #{commissionRate},</if>
             <if test="regimentalPromotion != null">regimental_promotion = #{regimentalPromotion},</if>

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 36 - 25
ruixuan-live/src/main/resources/mapper/isc/KuaishouItemListMapper.xml


+ 3 - 0
ruixuan-live/src/main/resources/mapper/isc/SupplyChainMapper.xml

@@ -1034,6 +1034,9 @@
         </if>
         order by t.orderNum desc
     </select>
+    <select id="getCookie" resultType="java.lang.String">
+          select  cookie  from ruixuan.kuaishou_supply_chain_cookie limit 1
+    </select>
 
 
 </mapper>

+ 2 - 1
ruixuan-system/src/main/java/com/ruixuan/system/mapper/SysRoleMapper.java

@@ -3,6 +3,7 @@ package com.ruixuan.system.mapper;
 import java.util.List;
 
 import com.ruixuan.common.core.domain.entity.SysRole;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 角色表 数据层
@@ -113,5 +114,5 @@ public interface SysRoleMapper {
      * @param userId
      * @return
      */
-    String getRoleBYUserId(Long userId);
+    String getRoleBYUserId(@Param("userId") Long userId);
 }