|
@@ -2,10 +2,8 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
-import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
-import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
+import cn.com.ctop.common.module.utils.*;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouGroupSpeedExploreLog;
|
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouGroupExplore;
|
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouGroupExploreMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouGroupExploreService;
|
|
@@ -17,6 +15,7 @@ import org.jeecg.common.api.vo.Result;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -224,5 +223,39 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
|
|
|
return Result.error("查询广告组的加速探索报表失败");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void unitOpenSpeedExplore(Long accountId, Long unitId, BigDecimal groupAccount,Long accountExploreId) {
|
|
|
+ KuaishouGroupSpeedExploreLog groupSpeedExploreLog = new KuaishouGroupSpeedExploreLog();
|
|
|
+ groupSpeedExploreLog.setAccountExploreId(accountExploreId);
|
|
|
+ groupSpeedExploreLog.setAccountId(accountId);
|
|
|
+ try {
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UNIT_EXPLORE_BUDGET_UPDATE;
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Access-Token", token.getAccessToken());
|
|
|
+ header.put("Content-Type", "application/json");
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", accountId);
|
|
|
+ params.put("unit_id", unitId);
|
|
|
+ params.put("explore_budget", groupAccount.longValue());
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, header);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ groupSpeedExploreLog.setStatus(code);
|
|
|
+ groupSpeedExploreLog.setMessage(message);
|
|
|
+ }else{
|
|
|
+ groupSpeedExploreLog.setStatus(StatusCode.KUAISHOU_SPEED_EXPLORE_FAIL.getCode());
|
|
|
+ groupSpeedExploreLog.setMessage(StatusCode.KUAISHOU_SPEED_EXPLORE_FAIL.getDesc());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("广告组的加速探索预算设置失败", e);
|
|
|
+ groupSpeedExploreLog.setStatus(StatusCode.COMMON_SERVER_ERROR.getCode());
|
|
|
+ groupSpeedExploreLog.setMessage(StatusCode.COMMON_SERVER_ERROR.getDesc());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|