|
@@ -3232,4 +3232,91 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
return returnArr;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取应用列表(新)
|
|
|
+ *
|
|
|
+ * @param advertiserId
|
|
|
+ * @param accessToken
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void getAppList2(Long advertiserId, String accessToken) {
|
|
|
+ Integer pageSize = 20;
|
|
|
+ Integer page = 1;
|
|
|
+ getAppList2ByPage(advertiserId, accessToken, page, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getAppList2ByPage(Long advertiserId, String accessToken, Integer page, Integer pageSize) {
|
|
|
+ try {
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_LIST_v2;
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("advertiser_id", advertiserId);
|
|
|
+ json.put("page", page);
|
|
|
+ json.put("page_size", pageSize);
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ if(page == 1){ //分页保存数据,如果页数为1,删除之前的数据重新入库
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
+ deleteMap.put("account_id", advertiserId);
|
|
|
+ appListMapper.deleteByMap(deleteMap);
|
|
|
+ }
|
|
|
+ JSONObject data = resultJson.getJSONObject("data");
|
|
|
+ if (!Check.isNull(data)) {
|
|
|
+ Integer totalCount = data.getInteger("total_count");
|
|
|
+ JSONArray dataArr = data.getJSONArray("details");
|
|
|
+ for (int i = 0; i < dataArr.size(); i++) {
|
|
|
+ JSONObject dataJson = JSONObject.parseObject(dataArr.get(i).toString());
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
+ KuaiShouAppList appList = new KuaiShouAppList();
|
|
|
+ appList.setAccountId(advertiserId);
|
|
|
+ appList.setPlatform(dataJson.getInteger("platform"));
|
|
|
+ appList.setUrl(dataJson.getString("url"));
|
|
|
+ appList.setAppId(dataJson.getLong("app_id"));
|
|
|
+ appList.setAppVersion(dataJson.getString("app_version"));
|
|
|
+ appList.setAppName(dataJson.getString("app_name"));
|
|
|
+ appList.setAppIconUrl(dataJson.getString("app_icon_url"));
|
|
|
+ appList.setImageToken(dataJson.getString("image_token"));
|
|
|
+ appList.setPackageName(dataJson.getString("package_name"));
|
|
|
+ appList.setReturnTime(DateUtils.timeStamp2Date(dataJson.getTimestamp("update_time")));
|
|
|
+ appListMapper.insert(appList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer totalPage = (totalCount-1)/pageSize + 1;
|
|
|
+ if(page < totalPage ){
|
|
|
+ getAppList2ByPage(advertiserId,accessToken,page+1,pageSize);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("获取应用列表失败,返回信息:{}", resultJson);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("获取地域列表返回结果为空");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|