|
@@ -1,6 +1,7 @@
|
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
@@ -10,21 +11,21 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouAccountBudgetMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouAccountBudgetService;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 账户日预算
|
|
|
+ *
|
|
|
* @author jeecg-boot
|
|
|
- * @date 2020-04-26
|
|
|
* @version V1.0
|
|
|
+ * @date 2020-04-26
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -37,12 +38,13 @@ public class KuaishouAccountBudgetServiceImpl extends ServiceImpl<KuaishouAccoun
|
|
|
|
|
|
/**
|
|
|
* 获取账户日预算结果
|
|
|
+ *
|
|
|
* @param advertiserId
|
|
|
* @param accessToken
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public void getAccountBudget(Long advertiserId, String accessToken) {
|
|
|
+ public void insertAccountBudget(Long advertiserId, String accessToken) {
|
|
|
try {
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_BUDGET;
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
@@ -82,4 +84,28 @@ public class KuaishouAccountBudgetServiceImpl extends ServiceImpl<KuaishouAccoun
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject getAccountBudget(CtopOauthToken oauthToken) {
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_BUDGET;
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Access-Token", oauthToken.getAccessToken());
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("advertiser_id", oauthToken.getAccountId());
|
|
|
+ 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) {
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
+ return dataJson;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("获取账户日预算失败,返回信息:{}", resultJson);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|