|
@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
|
+import cn.com.ctop.common.module.utils.BigDecimalUtil;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
@@ -9,9 +10,13 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.common.module.utils.StatusCode;
|
|
import cn.com.ctop.common.module.utils.StatusCode;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouGroupSpeedExploreLogService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouGroupSpeedExploreLogService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyExplore;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyExploreService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -22,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -39,25 +45,23 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouGroupSpeedExploreLogService groupSpeedExploreLogService;
|
|
private IKuaishouGroupSpeedExploreLogService groupSpeedExploreLogService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaishouReportDailyExploreService dailyExploreService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouGroupService kuaiShouGroupService;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 查询加速探索信息
|
|
|
|
|
|
+ * 查询加速探索状态、预算
|
|
*
|
|
*
|
|
* @param
|
|
* @param
|
|
|
|
+ * @return
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result<Object> unitExploreInfoGet(JSONObject data) {
|
|
|
|
|
|
+ public Result<Object> unitExploreInfoGet(Long accountId, Long unitId) {
|
|
try {
|
|
try {
|
|
- Long accountId = data.getLong("accountId");
|
|
|
|
- if (Check.isNull(accountId)) {
|
|
|
|
- return Result.error("请选择广告主");
|
|
|
|
- }
|
|
|
|
- Long unitId = data.getLong("unitId");
|
|
|
|
- if (Check.isNull(unitId)) {
|
|
|
|
- return Result.error("请选择广告组");
|
|
|
|
- }
|
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_INFO_GET;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_INFO_GET;
|
|
Map<String, String> header = new HashMap<>();
|
|
Map<String, String> header = new HashMap<>();
|
|
@@ -84,27 +88,16 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 广告组的加速探索预算设置
|
|
|
|
|
|
+ * 开启广告组加速探索
|
|
*
|
|
*
|
|
* @param
|
|
* @param
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result<Object> unitExploreBudgetUpdate(JSONObject data) {
|
|
|
|
|
|
+ public Result<Object> unitExploreBudgetUpdate(Long accountId, Long unitId, Long exploreBudget) {
|
|
|
|
+ String msg = null;
|
|
try {
|
|
try {
|
|
- Long accountId = data.getLong("accountId");
|
|
|
|
- if (Check.isNull(accountId)) {
|
|
|
|
- return Result.error("请选择广告主");
|
|
|
|
- }
|
|
|
|
- Long unitId = data.getLong("unitId");
|
|
|
|
- if (Check.isNull(unitId)) {
|
|
|
|
- return Result.error("请选择广告组");
|
|
|
|
- }
|
|
|
|
- Long exploreBudget = data.getLong("exploreBudget");
|
|
|
|
- if (Check.isNull(exploreBudget)) {
|
|
|
|
- return Result.error("请填写加速探索预算");
|
|
|
|
- }
|
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_BUDGET_UPDATE;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_BUDGET_UPDATE;
|
|
Map<String, String> header = new HashMap<>();
|
|
Map<String, String> header = new HashMap<>();
|
|
@@ -119,6 +112,21 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
if (!Check.isNull(resultJson)) {
|
|
if (!Check.isNull(resultJson)) {
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
|
|
+ Result<Object> result1 = this.unitExploreInfoGet(accountId, unitId);
|
|
|
|
+ if (result1.getCode() == 200) {
|
|
|
|
+ JSONObject resultData = (JSONObject) result1.getResult();
|
|
|
|
+ Integer exploreStatus = resultData.getInteger("explore_status");
|
|
|
|
+ Long maxExploreBudget = resultData.getLong("max_explore_budget");
|
|
|
|
+ KuaiShouGroup kuaiShouGroup = new KuaiShouGroup();
|
|
|
|
+
|
|
|
|
+ KuaishouReportDailyExplore kuaishouGroupExplore = new KuaishouReportDailyExplore();
|
|
|
|
+ kuaishouGroupExplore.setAccountId(accountId);
|
|
|
|
+ kuaishouGroupExplore.setUnitId(unitId);
|
|
|
|
+ kuaishouGroupExplore.setStatDate(new Date());
|
|
|
|
+ kuaishouGroupExplore.setMaxExploreBudget(maxExploreBudget);
|
|
|
|
+ kuaishouGroupExplore.setExploreStatus(exploreStatus);
|
|
|
|
+ dailyExploreService.save(kuaishouGroupExplore);
|
|
|
|
+ }
|
|
return Result.ok(resultJson.getJSONObject("data"));
|
|
return Result.ok(resultJson.getJSONObject("data"));
|
|
} else {
|
|
} else {
|
|
log.info("广告组的加速探索预算设置失败,accountId:{},返回信息:{}", accountId, resultJson);
|
|
log.info("广告组的加速探索预算设置失败,accountId:{},返回信息:{}", accountId, resultJson);
|
|
@@ -126,7 +134,7 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("广告组的加速探索预算设置失败", e);
|
|
|
|
|
|
+ log.error("广告组({})启动加速探索失败", unitId, e);
|
|
}
|
|
}
|
|
return Result.error("广告组的加速探索预算设置失败");
|
|
return Result.error("广告组的加速探索预算设置失败");
|
|
}
|
|
}
|
|
@@ -182,16 +190,8 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Result<Object> querySpeedExploreReport(JSONObject data) {
|
|
|
|
|
|
+ public Result<Object> querySpeedExploreReport(Long accountId, Long unitId, Integer exploreStatus, Long maxExploreBudget) {
|
|
try {
|
|
try {
|
|
- Long accountId = data.getLong("accountId");
|
|
|
|
- if (Check.isNull(accountId)) {
|
|
|
|
- return Result.error("请选择广告主");
|
|
|
|
- }
|
|
|
|
- Long unitId = data.getLong("unitId");
|
|
|
|
- if (Check.isNull(unitId)) {
|
|
|
|
- return Result.error("请选择广告组");
|
|
|
|
- }
|
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.QUERY_SPEED_EXPLORE_REPORT;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.QUERY_SPEED_EXPLORE_REPORT;
|
|
Map<String, String> header = new HashMap<>();
|
|
Map<String, String> header = new HashMap<>();
|
|
@@ -206,19 +206,32 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
JSONObject exploreJson = resultJson.getJSONObject("data");
|
|
JSONObject exploreJson = resultJson.getJSONObject("data");
|
|
- KuaishouGroupExplore kuaishouGroupExplore = JSONObject.toJavaObject(exploreJson, KuaishouGroupExplore.class);
|
|
|
|
|
|
+ KuaishouReportDailyExplore kuaishouGroupExplore = JSONObject.toJavaObject(exploreJson, KuaishouReportDailyExplore.class);
|
|
if (Check.isNull(kuaishouGroupExplore)) {
|
|
if (Check.isNull(kuaishouGroupExplore)) {
|
|
return Result.error("查询失败,结果为空");
|
|
return Result.error("查询失败,结果为空");
|
|
}
|
|
}
|
|
- QueryWrapper<KuaishouGroupExplore> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.eq("unit_id", kuaishouGroupExplore.getUnitId());
|
|
|
|
- KuaishouGroupExplore one = this.getOne(queryWrapper);
|
|
|
|
|
|
+ QueryWrapper<KuaishouReportDailyExplore> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("unit_id", unitId);
|
|
|
|
+ queryWrapper.eq("account_id", accountId);
|
|
|
|
+ KuaishouReportDailyExplore one = dailyExploreService.getOne(queryWrapper);
|
|
if (!Check.isNull(one)) {
|
|
if (!Check.isNull(one)) {
|
|
kuaishouGroupExplore.setId(one.getId());
|
|
kuaishouGroupExplore.setId(one.getId());
|
|
}
|
|
}
|
|
|
|
+ KuaiShouGroup kuaiShouGroup = kuaiShouGroupService.selectGroupByUnitId(accountId, unitId);
|
|
|
|
+ if(!Check.isNull(kuaiShouGroup)){
|
|
|
|
+ kuaishouGroupExplore.setUnitName(kuaiShouGroup.getUnitName());
|
|
|
|
+ kuaishouGroupExplore.setCampaignId(kuaiShouGroup.getCampaignId());
|
|
|
|
+ }
|
|
kuaishouGroupExplore.setAccountId(accountId);
|
|
kuaishouGroupExplore.setAccountId(accountId);
|
|
- this.saveOrUpdate(kuaishouGroupExplore);
|
|
|
|
- return Result.ok("添加成功");
|
|
|
|
|
|
+ kuaishouGroupExplore.setExploreStatus(exploreStatus);
|
|
|
|
+ kuaishouGroupExplore.setMaxExploreBudget(maxExploreBudget);
|
|
|
|
+ kuaishouGroupExplore.setStatDate(new Date());
|
|
|
|
+ kuaishouGroupExplore.setExploreBudget(BigDecimalUtil.divideBigDecimal(kuaishouGroupExplore.getExploreBudget(), new BigDecimal(1000)));
|
|
|
|
+ kuaishouGroupExplore.setTotalCharge(BigDecimalUtil.divideBigDecimal(kuaishouGroupExplore.getTotalCharge(), new BigDecimal(1000)));
|
|
|
|
+ boolean b = dailyExploreService.saveOrUpdate(kuaishouGroupExplore);
|
|
|
|
+ if (b) {
|
|
|
|
+ return Result.ok("添加成功");
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
log.info("查询广告组的加速探索报表失败,accountId:{},返回信息:{}", accountId, resultJson);
|
|
log.info("查询广告组的加速探索报表失败,accountId:{},返回信息:{}", accountId, resultJson);
|
|
return Result.error("查询广告组的加速探索报表失败," + resultJson.getString("message"));
|
|
return Result.error("查询广告组的加速探索报表失败," + resultJson.getString("message"));
|
|
@@ -311,4 +324,5 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|