|
@@ -20,75 +20,75 @@ import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 广告组Service业务层处理
|
|
|
|
- *
|
|
|
|
- * @author ruoyi
|
|
|
|
- * @date 2022-07-28
|
|
|
|
- */
|
|
|
|
|
|
+* 广告组Service业务层处理
|
|
|
|
+*
|
|
|
|
+* @author ruoyi
|
|
|
|
+* @date 2022-07-28
|
|
|
|
+*/
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class KuaishouLiveUnitListServiceImpl implements IKuaishouLiveUnitListService {
|
|
public class KuaishouLiveUnitListServiceImpl implements IKuaishouLiveUnitListService {
|
|
- @Autowired
|
|
|
|
- private KuaishouLiveUnitListMapper mapper;
|
|
|
|
|
|
+@Autowired
|
|
|
|
+private KuaishouLiveUnitListMapper mapper;
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询广告组
|
|
|
|
- *
|
|
|
|
- * @param accountId 广告组主键
|
|
|
|
- * @return 广告组
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public KuaishouLiveUnitList selectKuaishouLiveUnitListByAccountId(Long accountId) {
|
|
|
|
- return mapper.selectKuaishouLiveUnitListByAccountId(accountId);
|
|
|
|
- }
|
|
|
|
|
|
+/**
|
|
|
|
+ * 查询广告组
|
|
|
|
+ *
|
|
|
|
+ * @param accountId 广告组主键
|
|
|
|
+ * @return 广告组
|
|
|
|
+ */
|
|
|
|
+@Override
|
|
|
|
+public KuaishouLiveUnitList selectKuaishouLiveUnitListByAccountId(Long accountId) {
|
|
|
|
+ return mapper.selectKuaishouLiveUnitListByAccountId(accountId);
|
|
|
|
+}
|
|
|
|
|
|
- /**
|
|
|
|
- * 查询广告组列表
|
|
|
|
- *
|
|
|
|
- * @param kuaishouLiveUnitList 广告组
|
|
|
|
- * @return 广告组
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public List<KuaishouLiveUnitList> selectKuaishouLiveUnitListList(KuaishouLiveUnitList kuaishouLiveUnitList) {
|
|
|
|
- return mapper.selectKuaishouLiveUnitListList(kuaishouLiveUnitList);
|
|
|
|
- }
|
|
|
|
|
|
+/**
|
|
|
|
+ * 查询广告组列表
|
|
|
|
+ *
|
|
|
|
+ * @param kuaishouLiveUnitList 广告组
|
|
|
|
+ * @return 广告组
|
|
|
|
+ */
|
|
|
|
+@Override
|
|
|
|
+public List<KuaishouLiveUnitList> selectKuaishouLiveUnitListList(KuaishouLiveUnitList kuaishouLiveUnitList) {
|
|
|
|
+ return mapper.selectKuaishouLiveUnitListList(kuaishouLiveUnitList);
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public Result<Object> getKuaishouUnit(Long accountId, String token) {
|
|
|
|
- log.info("调用接口---getKuaishouUnit(获取广告组信息)---账户:{}", accountId);
|
|
|
|
- Result<Object> result = new Result<>();
|
|
|
|
- Map<String, Object> param = new HashMap<String, Object>();
|
|
|
|
- param.put("advertiser_id", accountId);
|
|
|
|
- JSONObject params = new JSONObject();
|
|
|
|
- params.put("start_time", DateUtils.timeToStamp(DateUtils.getDate() + " 00:00:00"));
|
|
|
|
- params.put("end_time", DateUtils.timeToStamp(DateUtils.getDate() + " 23:23:59"));
|
|
|
|
- params.put("search_level", 2);
|
|
|
|
- JSONObject pageInfo = new JSONObject();
|
|
|
|
- pageInfo.put("page", 1);
|
|
|
|
- pageInfo.put("page_size", 2000);
|
|
|
|
- param.put("page_info", pageInfo);
|
|
|
|
- param.put("param", params);
|
|
|
|
- JSONObject apiResult = APIUtil.getApiResult(KuaishouAPIConstant.AD_SEARCH, token, param);
|
|
|
|
- if (apiResult.getInteger("code") == 0) {
|
|
|
|
- apiResult = apiResult.getJSONObject("data");
|
|
|
|
- JSONArray data = apiResult.getJSONArray("data");
|
|
|
|
- List<KuaishouLiveUnitList> list = new ArrayList<>();
|
|
|
|
- for (int i = 0; i < data.size(); i++) {
|
|
|
|
- JSONObject object = data.getJSONObject(i);
|
|
|
|
- KuaishouLiveUnitList accountReport = JSONObject.parseObject(object.toJSONString(), KuaishouLiveUnitList.class);
|
|
|
|
- accountReport.setAccountId(accountId);
|
|
|
|
- accountReport.setReportDate(Long.valueOf(object.getString("report_date").replace("-", "")));
|
|
|
|
- accountReport.setUnitCreateTime(Long.valueOf(DateUtils.timestampToStr(object.getLong("unit_create_time"))));
|
|
|
|
- list.add(accountReport);
|
|
|
|
- }
|
|
|
|
- if (!Check.isNull(list)) {
|
|
|
|
- mapper.replaceBatch(list);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- log.error("获取直播账户报表,账户{},{}", accountId, apiResult.toJSONString());
|
|
|
|
|
|
+@Override
|
|
|
|
+public Result<Object> getKuaishouUnit(Long accountId, String token) {
|
|
|
|
+ log.info("调用接口---getKuaishouUnit(获取广告组信息)---账户:{}", accountId);
|
|
|
|
+ Result<Object> result = new Result<>();
|
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>();
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("start_time", DateUtils.timeToStamp(DateUtils.getDate() + " 00:00:00"));
|
|
|
|
+ params.put("end_time", DateUtils.timeToStamp(DateUtils.getDate() + " 23:23:59"));
|
|
|
|
+ params.put("search_level", 2);
|
|
|
|
+ JSONObject pageInfo = new JSONObject();
|
|
|
|
+ pageInfo.put("page", 1);
|
|
|
|
+ pageInfo.put("page_size", 2000);
|
|
|
|
+ param.put("page_info", pageInfo);
|
|
|
|
+ param.put("param", params);
|
|
|
|
+ JSONObject apiResult = APIUtil.getApiResult(KuaishouAPIConstant.AD_SEARCH, token, param);
|
|
|
|
+ if (apiResult.getInteger("code") == 0) {
|
|
|
|
+ apiResult = apiResult.getJSONObject("data");
|
|
|
|
+ JSONArray data = apiResult.getJSONArray("data");
|
|
|
|
+ List<KuaishouLiveUnitList> list = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
|
+ JSONObject object = data.getJSONObject(i);
|
|
|
|
+ KuaishouLiveUnitList accountReport = JSONObject.parseObject(object.toJSONString(), KuaishouLiveUnitList.class);
|
|
|
|
+ accountReport.setAccountId(accountId);
|
|
|
|
+ accountReport.setReportDate(Long.valueOf(object.getString("report_date").replace("-", "")));
|
|
|
|
+ accountReport.setUnitCreateTime(Long.valueOf(DateUtils.timestampToStr(object.getLong("unit_create_time"))));
|
|
|
|
+ list.add(accountReport);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(list)) {
|
|
|
|
+ mapper.replaceBatch(list);
|
|
}
|
|
}
|
|
- return result.success("success");
|
|
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取直播账户报表,账户{},{}", accountId, apiResult.toJSONString());
|
|
}
|
|
}
|
|
|
|
+ return result.success("success");
|
|
|
|
+}
|
|
|
|
|
|
}
|
|
}
|