yumeng пре 2 година
родитељ
комит
f04d696229

+ 78 - 64
ruixuan-live/src/main/java/com/ruixuan/bytedance/service/impl/BytedanceServiceImpl.java

@@ -178,6 +178,7 @@ public class BytedanceServiceImpl implements IBytedanceService {
 
         AllianceColonelActivityProductResponse response = request.execute(accessToken);
         JSONObject jsonObject = JSONObject.parseObject(response.toString());
+        log.info("返回数据:{}",jsonObject);
         Integer code = jsonObject.getInteger("code");
         String msg = jsonObject.getString("msg");
         if (code == 10000) {
@@ -185,73 +186,86 @@ public class BytedanceServiceImpl implements IBytedanceService {
             returnJson.put("message", "请求成功");
             returnJson.put("judgeStatus", "1");
             JSONObject dataJson = jsonObject.getJSONObject("data");
-            JSONObject data = dataJson.getJSONArray("data").getJSONObject(0);
-            if (!Check.isNull(data)) {
-                JSONObject itemJson = new JSONObject();
-                Long product_id = data.getLong("product_id");//商品ID
-                String title = data.getString("title");//商品名称
-                Long price = data.getLong("price");//商品售价
-                Double cos_ratio = data.getDouble("cos_ratio");//	佣金比例
-                Long cos_fee = data.getLong("cos_fee");//	佣金金额,单位分
-                Long first_cid = data.getLong("first_cid");//	商品一级类目
-                Long second_cid = data.getLong("second_cid");//	商品二级类目
-                Long third_cid = data.getLong("third_cid");//	商品商品三级类目
-                Long sales = data.getLong("sales");//	销量
-                String cover = data.getString("cover");//	商品主图
-                String detail_url = data.getString("detail_url");//	商品团长活动链接
-                Long shop_id = data.getLong("shop_id");//	店铺ID
-                String shop_name = data.getString("shop_name");//	店铺名称
-                Integer status = data.getInteger("status");//	审核状态
-                String reason = data.getString("reason");//	reason
-                Long category_id = data.getLong("category_id");//	行业类目ID
-                String category_name = data.getString("category_name");//	行业类目名称
-                String product_stock = data.getString("product_stock");//	商品库存
-                String shop_score = data.getString("shop_score");//	店铺分
-                Double service_ratio = data.getDouble("service_ratio");//	店铺分
-
-                itemJson.put("itemId", product_id);
-                itemJson.put("itemTitle", title);
-                itemJson.put("itemPrice", price);
-                itemJson.put("itemDesc", title);
-                itemJson.put("zkFinalPrice", price);
-                itemJson.put("itemImgUrl", cover);
-                itemJson.put("shopStar", "-");
-                itemJson.put("mallLogisticsScore", shop_name);
-                if (status == 0) {
-                    itemJson.put("activityItemStatus", 1);
-                } else if (status == 1) {
-                    itemJson.put("activityItemStatus", 2);
-                } else if (status == 2) {
-                    itemJson.put("activityItemStatus", 3);
-                } else {
-                    itemJson.put("activityItemStatus", 5);
-                }
-                itemJson.put("categoryId", category_id);
-                itemJson.put("categoryName", category_name);
-                itemJson.put("itemGalleryUrls", null); // 轮播图
-                itemJson.put("itemDescUrls", null); // 详情图
-                itemJson.put("activityId", activityId);
-                itemJson.put("shopTitle", shop_name);
-                if(!Check.isNull(cos_ratio)){
-                    itemJson.put("commissionRate", cos_ratio * 10);
-                }else {
-                    itemJson.put("commissionRate", 0);
-                }
+          JSONArray  dataArr = dataJson.getJSONArray("data");
+          if(!Check.isNull(dataArr)){
+              JSONObject data = dataArr.getJSONObject(0);
+              if (!Check.isNull(data)) {
+                  JSONObject itemJson = new JSONObject();
+                  Long product_id = data.getLong("product_id");//商品ID
+                  String title = data.getString("title");//商品名称
+                  Long price = data.getLong("price");//商品售价
+                  Double cos_ratio = data.getDouble("cos_ratio");//	佣金比例
+                  Long cos_fee = data.getLong("cos_fee");//	佣金金额,单位分
+                  Long first_cid = data.getLong("first_cid");//	商品一级类目
+                  Long second_cid = data.getLong("second_cid");//	商品二级类目
+                  Long third_cid = data.getLong("third_cid");//	商品商品三级类目
+                  Long sales = data.getLong("sales");//	销量
+                  String cover = data.getString("cover");//	商品主图
+                  String detail_url = data.getString("detail_url");//	商品团长活动链接
+                  Long shop_id = data.getLong("shop_id");//	店铺ID
+                  String shop_name = data.getString("shop_name");//	店铺名称
+                  Integer status = data.getInteger("status");//	审核状态
+                  String reason = data.getString("reason");//	reason
+                  Long category_id = data.getLong("category_id");//	行业类目ID
+                  String category_name = data.getString("category_name");//	行业类目名称
+                  String product_stock = data.getString("product_stock");//	商品库存
+                  String shop_score = data.getString("shop_score");//	店铺分
+                  Double service_ratio = data.getDouble("service_ratio");//	店铺分
+
+                  itemJson.put("itemId", product_id);
+                  itemJson.put("itemTitle", title);
+                  itemJson.put("itemPrice", price);
+                  itemJson.put("itemDesc", title);
+                  itemJson.put("zkFinalPrice", price);
+                  itemJson.put("itemImgUrl", cover);
+                  itemJson.put("shopStar", "-");
+                  itemJson.put("mallLogisticsScore", shop_name);
+                  if (status == 0) {
+                      itemJson.put("activityItemStatus", 1);
+                  } else if (status == 1) {
+                      itemJson.put("activityItemStatus", 2);
+                  } else if (status == 2) {
+                      itemJson.put("activityItemStatus", 3);
+                  } else {
+                      itemJson.put("activityItemStatus", 5);
+                  }
+                  itemJson.put("categoryId", category_id);
+                  itemJson.put("categoryName", category_name);
+                  itemJson.put("itemGalleryUrls", null); // 轮播图
+                  itemJson.put("itemDescUrls", null); // 详情图
+                  itemJson.put("activityId", activityId);
+                  itemJson.put("shopTitle", shop_name);
+                  if(!Check.isNull(cos_ratio)){
+                      itemJson.put("commissionRate", cos_ratio * 10);
+                  }else {
+                      itemJson.put("commissionRate", 0);
+                  }
+
+                  itemJson.put("mallServiceScore", shop_score);
+                  itemJson.put("mallQualityScore", ""); // 店铺质量分
+                  itemJson.put("skuList", ""); // sku信息
+                  itemJson.put("postArea", ""); // 发货地址
+                  itemJson.put("detailUrl", detail_url);
+                  if(!Check.isNull(service_ratio)){
+                      itemJson.put("regimentalPromotionRate", service_ratio *  10);
+                  }else {
+                      itemJson.put("regimentalPromotionRate",0);
+                  }
+
+                  returnJson.put("itemJson", itemJson);
+
+              }else{
+                  returnJson.put("code", -1);
+                  returnJson.put("message", "返回数据为空");
+              }
+          } else{
+              returnJson.put("code", -1);
+              returnJson.put("message", "返回数据为空");
+
+          }
 
-                itemJson.put("mallServiceScore", shop_score);
-                itemJson.put("mallQualityScore", ""); // 店铺质量分
-                itemJson.put("skuList", ""); // sku信息
-                itemJson.put("postArea", ""); // 发货地址
-                itemJson.put("detailUrl", detail_url);
-                if(!Check.isNull(service_ratio)){
-                    itemJson.put("regimentalPromotionRate", service_ratio *  10);
-                }else {
-                    itemJson.put("regimentalPromotionRate",0);
-                }
 
-                returnJson.put("itemJson", itemJson);
 
-            }
 
         } else {
             returnJson.put("code", -1);