|
@@ -76,7 +76,7 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
@Override
|
|
|
public JSONObject getItemDetail(Long regId, Long activityId, Long itemId, KuaishouAccessToken accessToken) throws Exception {
|
|
|
// 调用爬虫信息
|
|
|
- JSONObject invaliItemDetail = getInvaliItemDetail(regId, activityId, itemId);
|
|
|
+ // JSONObject invaliItemDetail = getInvaliItemDetail(regId, activityId, itemId);
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(KuaiShouConstants.KFX_URL, accessToken.getAppKey(), accessToken.getAppSecret());
|
|
|
OpenDistributionInvestmentActivityItemDetailRequest request = new OpenDistributionInvestmentActivityItemDetailRequest();
|
|
@@ -108,21 +108,38 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
itemJson.put("categoryId", categoryInfo.getString("categoryId"));
|
|
|
}
|
|
|
itemJson.put("detailUrl", "https://app.kwaixiaodian.com/merchant/shop/detail?id=" + itemId);
|
|
|
- if (!Check.isNull(invaliItemDetail)) {
|
|
|
- JSONObject invaliJSon = invaliItemDetail.getJSONObject("itemJson");
|
|
|
- if (!Check.isNull(invaliJSon)) {
|
|
|
- itemJson.put("postArea", invaliJSon.getString("postArea"));
|
|
|
- itemJson.put("deliveryRate", invaliJSon.getString("deliveryRate"));
|
|
|
- itemJson.put("regimentalPromotionRate", invaliJSon.getLong("regimentalPromotionRate"));
|
|
|
- itemJson.put("commissionRate", invaliJSon.getLong("commissionRate"));
|
|
|
- }
|
|
|
+
|
|
|
+ // 有效商品列表
|
|
|
+ JSONObject effectiveItemJson = new JSONObject();
|
|
|
+ if (!Check.isNull(effectiveItemJson)) {
|
|
|
+ itemJson.put("regimentalPromotionRate", effectiveItemJson.getLong("investmentPromotionRate"));
|
|
|
+ itemJson.put("commissionRate", effectiveItemJson.getLong("itemCommissionRate"));
|
|
|
}
|
|
|
+
|
|
|
returnJson.put("judgeStatus", 1);
|
|
|
returnJson.put("itemJson", itemJson);
|
|
|
returnJson.put("code", 0);
|
|
|
returnJson.put("message", "查询成功");
|
|
|
} else if (code != 1) { // 商品下线
|
|
|
- return invaliItemDetail;
|
|
|
+ // return invaliItemDetail;
|
|
|
+ JSONObject invalidJson = new JSONObject();
|
|
|
+ JSONObject invalidItemJson = new JSONObject();
|
|
|
+ invalidItemJson.put("itemId", invalidJson.getLong("itemId"));
|
|
|
+ invalidItemJson.put("itemTitle", invalidJson.getLong("itemTitle"));
|
|
|
+ invalidItemJson.put("itemDesc", invalidJson.getLong("itemTitle"));
|
|
|
+ invalidItemJson.put("itemPrice", invalidJson.getLong("itemPrice"));
|
|
|
+ invalidItemJson.put("itemImgUrl", invalidJson.getLong("itemImgUrl"));
|
|
|
+ invalidItemJson.put("itemDescUrls", invalidJson.getLong("itemImgUrl"));
|
|
|
+ invalidItemJson.put("activityId", activityId);
|
|
|
+ invalidItemJson.put("activityItemS tatus", invalidJson.getLong("status"));
|
|
|
+ invalidItemJson.put("commissionRate", invalidJson.getLong("itemCommissionRate"));
|
|
|
+ invalidItemJson.put("detailUrl", "https://app.kwaixiaodian.com/merchant/shop/detail?id=" + itemId);
|
|
|
+ invalidItemJson.put("regimentalPromotionRate", invalidJson.getLong("investmentPromotionRate"));
|
|
|
+ returnJson.put("judgeStatus", 2);
|
|
|
+ returnJson.put("itemJson", invalidItemJson);
|
|
|
+ returnJson.put("code", 0);
|
|
|
+ returnJson.put("message", "查询成功");
|
|
|
+ return returnJson;
|
|
|
} else {
|
|
|
returnJson.put("code", 500);
|
|
|
returnJson.put("message", "数据查询失败");
|
|
@@ -136,13 +153,16 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
String cookie = supplyChainMapper.getCookie(regId);
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("limit", 20);
|
|
|
- params.put("offset", 0);
|
|
|
- params.put("activityId", activityId);
|
|
|
+ params.put("retryLimit", true);
|
|
|
+ params.put("carrierType", 0);
|
|
|
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);
|
|
|
+ String referer = "https://app.kwaixiaodian.com/page/kwaishop-goods-detail-h5-vue/detail?id=&hyId=kwaishop-goods-detail-h5-vue&_refer=null_refer";
|
|
|
+ String str = "?id=" + itemId;
|
|
|
+ String replace = referer.replace("?id=", str);
|
|
|
+ headers.put("Referer", replace);
|
|
|
+ String resultStr = KsHttpUtils.KuaiShouttpGetRequest("https://app.kwaixiaodian.com/rest/app/grocery/product/self/detail", params, headers);
|
|
|
JSONObject result = JSONObject.parseObject(resultStr);
|
|
|
if (Check.isNull(result)) {
|
|
|
log.error("快分销招商商品数据返回为空");
|
|
@@ -157,16 +177,16 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
returnJson.put("message", "增加快手商品信息抓取失败,请联系技术人员");
|
|
|
return returnJson;
|
|
|
}
|
|
|
- JSONArray dataArray = result.getJSONArray("data");
|
|
|
+ /* 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);
|
|
|
+ }*/
|
|
|
+ JSONObject itemJson = new JSONObject();
|
|
|
itemJson.put("detailUrl", "https://app.kwaixiaodian.com/merchant/shop/detail?id=" + itemId);
|
|
|
- String itemCategoryName = itemJson.getString("itemCategoryName");
|
|
|
+ /*String itemCategoryName = itemJson.getString("itemCategoryName");
|
|
|
if (!Check.isNull(itemCategoryName)) {
|
|
|
String[] split = itemCategoryName.split(">");
|
|
|
if (!Check.isNull(split)) {
|
|
@@ -176,7 +196,14 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
itemJson.put("categoryId", categoryId);
|
|
|
}
|
|
|
}
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ JSONObject productDetail = result.getJSONObject("productDetail");
|
|
|
+ if (!Check.isNull(productDetail)) {
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
itemJson.put("commissionRate", itemJson.getLong("itemCommissionRate"));
|
|
|
itemJson.put("regimentalPromotionRate", itemJson.getLong("investmentPromotionRate"));
|
|
|
JSONObject otherInfo = getOtherInfo(itemId, cookie);
|
|
@@ -235,6 +262,13 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
return returnJson;
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String referer = "https://app.kwaixiaodian.com/page/kwaishop-goods-detail-h5-vue/detail?id=&hyId=kwaishop-goods-detail-h5-vue&_refer=null_refer";
|
|
|
+ String str = "?id=" + 122;
|
|
|
+ String replace = referer.replace("?id=", str);
|
|
|
+ System.err.println(replace);
|
|
|
+ }
|
|
|
+
|
|
|
private JSONObject getCategoryInfo(Long categoryId) {
|
|
|
if (Check.isNull(categoryId)) {
|
|
|
return null;
|