|
@@ -1,7 +1,9 @@
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
|
+import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
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;
|
|
@@ -147,6 +149,10 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
String description = requestJson.getString("description");
|
|
String description = requestJson.getString("description");
|
|
String site_id = requestJson.getString("siteId");
|
|
String site_id = requestJson.getString("siteId");
|
|
String schema_uri = requestJson.getString("schemaUri");
|
|
String schema_uri = requestJson.getString("schemaUri");
|
|
|
|
+ String product_id = requestJson.getString("productId");
|
|
|
|
+ String outer_id = requestJson.getString("outerId");
|
|
|
|
+ Integer detail_unit_type = requestJson.getInteger("detailUnitType");
|
|
|
|
+ Long library_id = requestJson.getLong("libraryId");
|
|
Integer startNumber = 0;
|
|
Integer startNumber = 0;
|
|
if (unitName.contains("{{序号}}")) {
|
|
if (unitName.contains("{{序号}}")) {
|
|
if (!Check.isNull(requestJson.getInteger("startNumber"))) {
|
|
if (!Check.isNull(requestJson.getInteger("startNumber"))) {
|
|
@@ -280,6 +286,18 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
if (!Check.isNull(site_id)) {
|
|
if (!Check.isNull(site_id)) {
|
|
template.setSiteId(site_id);
|
|
template.setSiteId(site_id);
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(product_id)) {
|
|
|
|
+ template.setProductId(product_id);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(outer_id)) {
|
|
|
|
+ template.setOuterId(outer_id);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(detail_unit_type)) {
|
|
|
|
+ template.setDetailUnitType(detail_unit_type);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(library_id)) {
|
|
|
|
+ template.setLibraryId(library_id);
|
|
|
|
+ }
|
|
template.setImageCount(imageCount);
|
|
template.setImageCount(imageCount);
|
|
template.setTaskStatus(0);
|
|
template.setTaskStatus(0);
|
|
template.setCreativeReviewDetail("创意待创建");
|
|
template.setCreativeReviewDetail("创意待创建");
|
|
@@ -432,6 +450,25 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
createUnitJson.put("unit_type", template.getUnitType()); //创意制作方式
|
|
createUnitJson.put("unit_type", template.getUnitType()); //创意制作方式
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Long libraryId = template.getLibraryId();
|
|
|
|
+ if (!Check.isNull(libraryId)) {
|
|
|
|
+ JSONObject dpa_unit_param = new JSONObject();
|
|
|
|
+ dpa_unit_param.put("library_id", libraryId);
|
|
|
|
+ String productId = template.getProductId();
|
|
|
|
+ if (!Check.isNull(productId)) {
|
|
|
|
+ dpa_unit_param.put("product_id", productId);
|
|
|
|
+ }
|
|
|
|
+ String outerId = template.getOuterId();
|
|
|
|
+ if (!Check.isNull(outerId)) {
|
|
|
|
+ dpa_unit_param.put("outer_id", outerId);
|
|
|
|
+ }
|
|
|
|
+ Integer detailUnitType = template.getDetailUnitType();
|
|
|
|
+ if (!Check.isNull(detailUnitType)) {
|
|
|
|
+ dpa_unit_param.put("detail_unit_type", detailUnitType);
|
|
|
|
+ }
|
|
|
|
+ dpa_unit_param.put("dpa_unit_sub_type", 2);
|
|
|
|
+ createUnitJson.put("dpa_unit_param", dpa_unit_param);
|
|
|
|
+ }
|
|
Map<String, Object> groupMap = iKuaishouInterfaceService.adUnitCreate(token.getAccessToken(), accountId, createUnitJson, 1);
|
|
Map<String, Object> groupMap = iKuaishouInterfaceService.adUnitCreate(token.getAccessToken(), accountId, createUnitJson, 1);
|
|
updateTemplate = new KuaiShouGroupTemplate();
|
|
updateTemplate = new KuaiShouGroupTemplate();
|
|
updateTemplate.setId(template.getId());
|
|
updateTemplate.setId(template.getId());
|
|
@@ -597,6 +634,64 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 获取商品信息
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @param accessToken
|
|
|
|
+ * @param libraryId
|
|
|
|
+ * @param page
|
|
|
|
+ * @param pageSize
|
|
|
|
+ * @param libraryName
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject productList(Long accountId, String accessToken, Long libraryId, Integer page, Integer pageSize, String libraryName) {
|
|
|
|
+ String url = "https://ad.e.kuaishou.com/rest/openapi/gw/dsp/v1/dpa/product/list";
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ param.put("library_id", libraryId);
|
|
|
|
+ if (!Check.isNull(libraryName)) {
|
|
|
|
+ param.put("id_or_name", libraryName);
|
|
|
|
+ }
|
|
|
|
+ param.put("page_size", pageSize);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
|
+ JSONObject data = resultJson.getJSONObject("data");
|
|
|
|
+ if (!Check.isNull(data)) {
|
|
|
|
+ data.put("page_size", pageSize);
|
|
|
|
+ data.put("page", page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ System.err.println(resultJson);
|
|
|
|
+ return resultJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject getLibraryConfig(Long accountId) {
|
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
|
+ UserAllocation userAllocation = userAllocationService.getByAccountId(accountId);
|
|
|
|
+ Long projectId = userAllocation.getProjectId();
|
|
|
|
+ JSONObject configJson = groupTemplateMapper.getConfig(projectId);
|
|
|
|
+ if (Check.isNull(configJson)) {
|
|
|
|
+ returnJson.put("isLibrary", false);
|
|
|
|
+ } else {
|
|
|
|
+ Long libraryId = configJson.getLong("libraryId");
|
|
|
|
+ returnJson.put("isLibrary", true);
|
|
|
|
+ returnJson.put("libraryId", libraryId);
|
|
|
|
+ }
|
|
|
|
+ return returnJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 获取当天api创建创意数
|
|
* 获取当天api创建创意数
|
|
*
|
|
*
|
|
* @param accountId
|
|
* @param accountId
|