|
@@ -4,6 +4,7 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.utils.*;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
|
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
@@ -66,7 +67,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
@Autowired
|
|
|
private KuaiShouScheduleMapper shouScheduleMapper;
|
|
|
@Autowired
|
|
|
- private KuaiShouCreativeMapper creativeMapper;
|
|
|
+ private IKuaiShouCreativeService creativeService;
|
|
|
@Autowired
|
|
|
private KuaiShouConversionInfosMapper conversionInfosMapper;
|
|
|
@Autowired
|
|
@@ -1190,8 +1191,62 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("advertiser_id", advertiserId);
|
|
|
+ param.put("page_size", 200);
|
|
|
+ param.put("page", page);
|
|
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
+ log.error("获取广告创意返回结果为空,advertiserId:{}", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", advertiserId, message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
+ log.error("获取广告创意返回结果数据为空,advertiserId:{}", advertiserId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
+ JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
|
+ if (!Check.isNull(detailJson)) {
|
|
|
+ KuaiShouCreative creative = new KuaiShouCreative();
|
|
|
+ creative.setId(detailJson.getLong("creative_id"));
|
|
|
+ creative.setAccountId(advertiserId);
|
|
|
+ creative.setStatus(detailJson.getInteger("status"));
|
|
|
+ creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
|
+ creative.setUnitId(detailJson.getLong("unit_id"));
|
|
|
+ creative.setCreativeId(detailJson.getLong("creative_id"));
|
|
|
+ creative.setCreativeName(detailJson.getString("creative_name"));
|
|
|
+ creative.setPhotoId(detailJson.getString("photo_id"));
|
|
|
+ creative.setReviewDetail(detailJson.getString("review_detail"));
|
|
|
+ creative.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
+ creative.setCoverHeight(detailJson.getString("cover_height"));
|
|
|
+ creative.setCoverWidth(detailJson.getString("cover_width"));
|
|
|
+ creative.setClickTrackUrl(detailJson.getString("click_track_url"));
|
|
|
+ JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
|
|
|
+ if (!Check.isNull(displayInfoJson)) {
|
|
|
+ creative.setDescription(displayInfoJson.getString("description"));
|
|
|
+ creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
|
|
|
+ }
|
|
|
+ creativeService.saveOrUpdate(creative);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ getCreativeList(accessToken, advertiserId, page + 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1202,11 +1257,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void getCreativeList(String accessToken, Long advertiserId, Integer page) {
|
|
|
- if (page == 1) { // 第一次请求删除历史数据
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("account_id", advertiserId);
|
|
|
- creativeMapper.deleteByMap(map);
|
|
|
- }
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
|
headers.put("Content-Type", " application/json");
|
|
@@ -1229,24 +1279,25 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
|
if (!Check.isNull(detailJson)) {
|
|
|
KuaiShouCreative creative = new KuaiShouCreative();
|
|
|
+ creative.setId(detailJson.getLong("creative_id"));
|
|
|
creative.setAccountId(advertiserId);
|
|
|
creative.setStatus(detailJson.getInteger("status"));
|
|
|
- creative.setCampaignId(dataJson.getLong("campaign_id"));
|
|
|
- creative.setUnitId(dataJson.getLong("unit_id"));
|
|
|
- creative.setCreativeId(dataJson.getLong("creative_id"));
|
|
|
- creative.setCreativeName(dataJson.getString("creative_name"));
|
|
|
- creative.setPhotoId(dataJson.getString("photo_id"));
|
|
|
- creative.setReviewDetail(dataJson.getString("review_detail"));
|
|
|
- creative.setCoverUrl(dataJson.getString("cover_url"));
|
|
|
- creative.setCoverHeight(dataJson.getString("cover_height"));
|
|
|
- creative.setCoverWidth(dataJson.getString("cover_width"));
|
|
|
- creative.setClickTrackUrl(dataJson.getString("click_track_url"));
|
|
|
+ creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
|
+ creative.setUnitId(detailJson.getLong("unit_id"));
|
|
|
+ creative.setCreativeId(detailJson.getLong("creative_id"));
|
|
|
+ creative.setCreativeName(detailJson.getString("creative_name"));
|
|
|
+ creative.setPhotoId(detailJson.getString("photo_id"));
|
|
|
+ creative.setReviewDetail(detailJson.getString("review_detail"));
|
|
|
+ creative.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
+ creative.setCoverHeight(detailJson.getString("cover_height"));
|
|
|
+ creative.setCoverWidth(detailJson.getString("cover_width"));
|
|
|
+ creative.setClickTrackUrl(detailJson.getString("click_track_url"));
|
|
|
JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
|
|
|
if (!Check.isNull(displayInfoJson)) {
|
|
|
creative.setDescription(displayInfoJson.getString("description"));
|
|
|
creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
|
|
|
}
|
|
|
- creativeMapper.insert(creative);
|
|
|
+ creativeService.saveOrUpdate(creative);
|
|
|
}
|
|
|
|
|
|
}
|