yumeng 2 years ago
parent
commit
fee879a2f6

+ 21 - 1
ruixuan-live/src/main/java/com/ruixuan/isc/service/impl/KuaishouItemListServiceImpl.java

@@ -108,6 +108,7 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         }
         KuaishouItemCategory secondCategory = new KuaishouItemCategory();
         KuaishouItemCategory thirdCategory = new KuaishouItemCategory();
+        KuaishouItemCategory fourthCategory = new KuaishouItemCategory();
         if (category.getCategorySort() == 1) {
             stringBuffer.append(category.getCategoryName());
         } else if (category.getCategorySort() == 2) {
@@ -118,6 +119,12 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
             thirdCategory = kuaishouItemListMapper.getCategoryInfo(secondCategory.getParentId());
             stringBuffer.append(thirdCategory.getCategoryName()).append(">").append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
         }
+        else if (category.getCategorySort() == 4) {
+            secondCategory = kuaishouItemListMapper.getCategoryInfo(category.getParentId());
+            thirdCategory = kuaishouItemListMapper.getCategoryInfo(secondCategory.getParentId());
+            fourthCategory = kuaishouItemListMapper.getCategoryInfo(thirdCategory.getParentId());
+            stringBuffer.append(fourthCategory.getCategoryName()).append(">").append(thirdCategory.getCategoryName()).append(">").append(secondCategory.getCategoryName()).append(">").append(category.getCategoryName());
+        }
 
         return stringBuffer.toString();
 
@@ -149,7 +156,7 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
         String url = "https://openapi.kwaixiaodian.com";
         String appKey = "ks665688320292774929";
         String signSecret = "8e21f5bc03b6d2dc63e6256225dac00b";
-        String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJg5CLuL6ttwj9MiWcCHbVN4sRko6KKjKrjzmWJ3GBpR_s7IKevDH5orkC2xKtmrkGESX3VkZVGTFpjw-hqSOHPtJmMfj0QH-_bKLqdYO0t56zqyJr_pTibE1rR6tFUgaAaGhINVY3cQVhC4YDnv5YNyfZ0IKwiIEtqPp9U48e9lE_g3P9Th_KB-cb9VF1e0xlABypm9xdqKAUwAQ";
+        String accessToken = "ChFvYXV0aC5hY2Nlc3NUb2tlbhJgT28Jn3uMkkU0sSjL_30Jd2X6QCz4B2bs9IsMrIJe1S3J4PhjkaBYIU13FGpBlmy73rx7X-cyNUuuOxKeOloFQeQFZ2Ka8jm_HwDYtqoaoVVm-Y06ILVaPrfs6SjVB84QGhL_b_zNSCZFGYoK2F52yMh0D74iILO5AYTiyqLP-3W1aZ-dql11qIkyhjgvYLXyoNplPgoNKAUwAQ";
         AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(url, appKey, signSecret);
         OpenDistributionPublicCategoryListRequest request = new OpenDistributionPublicCategoryListRequest();
         request.setAccessToken(accessToken);
@@ -188,7 +195,20 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
                             thirdCategory.setCategoryId(third.getLong("categoryId"));
                             thirdCategory.setCategoryName(third.getString("categoryName"));
                             thirdCategory.setCategorySort(3);
+                            Long thirdCategoryId = third.getLong("categoryId");
                             adds.add(thirdCategory);
+                            JSONArray fourthChildCategory = third.getJSONArray("childCategory");
+                            if(!Check.isNull(fourthChildCategory)){
+                                for (int l = 0; l < fourthChildCategory.size(); l++) {
+                                    JSONObject fourth = fourthChildCategory.getJSONObject(l);
+                                    KuaishouItemCategory fourthCategory = new KuaishouItemCategory();
+                                    fourthCategory.setParentId(thirdCategoryId);
+                                    fourthCategory.setCategoryId(fourth.getLong("categoryId"));
+                                    fourthCategory.setCategoryName(fourth.getString("categoryName"));
+                                    fourthCategory.setCategorySort(4);
+                                    adds.add(fourthCategory);
+                                }
+                            }
                         }
                     }
                 }