|
@@ -6,14 +6,17 @@ import cn.com.ctop.job.bytedance.data.mapper.BytedanceProductUpdateMapper;
|
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedanceProductUpdateService;
|
|
import cn.com.ctop.job.bytedance.data.service.IBytedanceProductUpdateService;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
import cn.com.ctop.job.bytedance.data.utils.Check;
|
|
|
import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
|
|
|
|
|
+import cn.com.ctop.job.bytedance.utils.BytedanceProductDocProperties;
|
|
|
import cn.com.ctop.job.bytedance.utils.FeishuRobotUtil;
|
|
import cn.com.ctop.job.bytedance.utils.FeishuRobotUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.web.util.UriComponentsBuilder;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -26,6 +29,9 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
BytedanceProductUpdateMapper bytedanceProductUpdateMapper;
|
|
BytedanceProductUpdateMapper bytedanceProductUpdateMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private RedisTemplate redis2Template_db5;
|
|
private RedisTemplate redis2Template_db5;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ BytedanceProductDocProperties productDocProperties;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public static final String DOUYIN_MOVIE_SOURCE_APP="ttd652a0ef496310bd01";
|
|
public static final String DOUYIN_MOVIE_SOURCE_APP="ttd652a0ef496310bd01";
|
|
|
|
|
|
|
@@ -40,7 +46,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
public static final String HOOK_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/92e2445e-76df-44fb-8f61-f55ac94f49bd";
|
|
public static final String HOOK_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/92e2445e-76df-44fb-8f61-f55ac94f49bd";
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void run() throws Exception {
|
|
|
|
|
|
|
+ public void runMp() throws Exception {
|
|
|
Set<String> errors = new HashSet<>();
|
|
Set<String> errors = new HashSet<>();
|
|
|
log.info("付费商品库更新中...");
|
|
log.info("付费商品库更新中...");
|
|
|
List<AigcProductPlatform> iapPlatformList = bytedanceProductUpdateMapper.getIAPPlatformList(); //商品库列表
|
|
List<AigcProductPlatform> iapPlatformList = bytedanceProductUpdateMapper.getIAPPlatformList(); //商品库列表
|
|
@@ -51,7 +57,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
obj -> obj,
|
|
obj -> obj,
|
|
|
(existing, replacement) -> replacement
|
|
(existing, replacement) -> replacement
|
|
|
));
|
|
));
|
|
|
- runProductTask(iapPlatformList, iapVideoList, iapProductTypeMap, errors, BusinessType.IAP);
|
|
|
|
|
|
|
+ runMpProductTask(iapPlatformList, iapVideoList, iapProductTypeMap, errors, BusinessType.IAP);
|
|
|
log.info("付费商品库更新完成");
|
|
log.info("付费商品库更新完成");
|
|
|
|
|
|
|
|
|
|
|
|
@@ -65,7 +71,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
obj -> obj,
|
|
obj -> obj,
|
|
|
(existing, replacement) -> replacement
|
|
(existing, replacement) -> replacement
|
|
|
));
|
|
));
|
|
|
- runProductTask(iaaPlatformList, iaaVideoList, iaaProductTypeMap, errors, BusinessType.IAA);
|
|
|
|
|
|
|
+ runMpProductTask(iaaPlatformList, iaaVideoList, iaaProductTypeMap, errors, BusinessType.IAA);
|
|
|
log.info("免费商品库更新完成");
|
|
log.info("免费商品库更新完成");
|
|
|
|
|
|
|
|
|
|
|
|
@@ -78,10 +84,43 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void runProductTask(List<AigcProductPlatform> platformList, List<AigcProductAlbum> albums, Map<String, JSONObject> productTypeMap, Set<String> errors, BusinessType businessType) throws IOException {
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void runDysDistribute() throws IOException {
|
|
|
|
|
+ Set<String> errors = new HashSet<>();
|
|
|
|
|
+ List<AigcProductPlatform> iaaPlatformList = bytedanceProductUpdateMapper.getDysIaaPlatformList(); //商品库列表
|
|
|
|
|
+ Map<String, String> sourceCopywriteOwner = new HashMap<>();
|
|
|
|
|
+ for (BytedanceProductDocProperties.DysDistributorLinkTable table : productDocProperties.getDysMovies()){
|
|
|
|
|
+ sourceCopywriteOwner.put(table.getMovieSource(), table.getCopyrightOwner());
|
|
|
|
|
+ }
|
|
|
|
|
+ iaaPlatformList.forEach(p -> {
|
|
|
|
|
+ p.setCopywriteOwner(sourceCopywriteOwner.get(String.valueOf(p.getSource())));
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ List<AigcProductAlbum> iaaVideos = bytedanceProductUpdateMapper.getDysDistributorVideo("IAA");
|
|
|
|
|
+ iaaVideos.forEach(v -> {
|
|
|
|
|
+ v.setPlayletId(getQueryParam(v.getAlbumLink(), "playlet_id"));
|
|
|
|
|
+ if (StringUtils.isEmpty(v.getImg())){
|
|
|
|
|
+ v.setImg("https://oss.artlinkworld.cn/imgsource/20251110-144804.png");//兜底
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ runDysProductTask(iaaPlatformList, iaaVideos, new HashMap<>(), errors, BusinessType.IAA);
|
|
|
|
|
+ System.out.println("端原生分销商品库更新完成");
|
|
|
|
|
+
|
|
|
|
|
+ errors.removeIf(s -> s.contains("剧目不可用"));
|
|
|
|
|
+ if (!Check.isNull(errors)){
|
|
|
|
|
+ List<String> info = new ArrayList<>();
|
|
|
|
|
+ info.add("端原生分销商品上传报错通知");
|
|
|
|
|
+ info.addAll(errors);
|
|
|
|
|
+ FeishuRobotUtil.sendTextToWebhook(StringUtils.join(info, "\n"), HOOK_URL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void runMpProductTask(List<AigcProductPlatform> platformList, List<AigcProductAlbum> albums, Map<String, JSONObject> productTypeMap, Set<String> errors, BusinessType businessType) throws IOException {
|
|
|
for (AigcProductPlatform platform : platformList){
|
|
for (AigcProductPlatform platform : platformList){
|
|
|
// 拉取已上传剧目,对比,得到未上传剧目列表
|
|
// 拉取已上传剧目,对比,得到未上传剧目列表
|
|
|
- List<String> hasUpload = hasUploadProductList(platform);
|
|
|
|
|
|
|
+ List<AigcProductAlbum> hasUploadProductList = hasUploadProductList(platform);
|
|
|
|
|
+ List<String> hasUpload = hasUploadProductList.stream().map(AigcProductAlbum::getProductId).collect(Collectors.toList());
|
|
|
System.out.println("已上传剧目数: "+hasUpload.size() + ", 商品库ID: "+platform.getPlatformId()+", 来源:"+platform.getSource());
|
|
System.out.println("已上传剧目数: "+hasUpload.size() + ", 商品库ID: "+platform.getPlatformId()+", 来源:"+platform.getSource());
|
|
|
List<AigcProductAlbum> toUpload = albums.stream()
|
|
List<AigcProductAlbum> toUpload = albums.stream()
|
|
|
.filter(o -> Objects.equals(o.getSource(), platform.getSource()))
|
|
.filter(o -> Objects.equals(o.getSource(), platform.getSource()))
|
|
@@ -121,16 +160,49 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void runDysProductTask(List<AigcProductPlatform> platformList, List<AigcProductAlbum> albums, Map<String, JSONObject> productTypeMap, Set<String> errors, BusinessType businessType) throws IOException {
|
|
|
|
|
+ for (AigcProductPlatform platform : platformList){
|
|
|
|
|
+ // 拉取已上传剧目,对比,得到未上传剧目列表
|
|
|
|
|
+ List<AigcProductAlbum> hasUploadAlbums = hasUploadProductList(platform);
|
|
|
|
|
+ List<String> hasUploadPlayletIds = hasUploadAlbums.stream().map(AigcProductAlbum::getPlayletId).collect(Collectors.toList());
|
|
|
|
|
+// System.out.println("已上传剧目数: "+hasUpload.size() + ", 商品库ID: "+platform.getPlatformId()+", 来源:"+platform.getSource());
|
|
|
|
|
+ List<AigcProductAlbum> toUpload = albums.stream()
|
|
|
|
|
+ .filter(o -> !hasUploadPlayletIds.contains(o.getPlayletId()))
|
|
|
|
|
+ .filter(o -> Objects.equals(o.getPlatformType(), String.valueOf(platform.getPlatformType())))
|
|
|
|
|
+ .filter(o -> Objects.equals(o.getSource(), platform.getSource()))
|
|
|
|
|
+ // 根据link里的参数过滤已上传的
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ System.out.println("待上传剧目数: "+toUpload.size() + ", 商品库ID: "+platform.getPlatformId()+", 来源:"+platform.getSource());
|
|
|
|
|
+
|
|
|
|
|
+// if (1==1){
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+ if (toUpload.isEmpty()){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //未上传剧目:对比平台类型;确定商品分类;获取推广链接
|
|
|
|
|
+ for (AigcProductAlbum album : toUpload){
|
|
|
|
|
+ JSONObject defaultTheme = JSONObject.parseObject("{\"first_type_id\":\"2038\",\"first_type_name\":\"单剧目-短剧\",\"second_type_id\":\"203807\",\"second_type_name\":\"其他剧情\",\"third_type_name\":\"其他\",\"third_type_id\":\"20380701\"}");
|
|
|
|
|
+ uploadProduct(platform, album, null, errors, defaultTheme, businessType);
|
|
|
|
|
+ try {
|
|
|
|
|
+ Thread.sleep(80);
|
|
|
|
|
+ }catch (InterruptedException ignored){}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 当前商品库中,已经上传的商品列表
|
|
* 当前商品库中,已经上传的商品列表
|
|
|
* @param platform
|
|
* @param platform
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private List<String> hasUploadProductList(AigcProductPlatform platform){
|
|
|
|
|
- return hasUploadProductPageList(platform, 1, 100);
|
|
|
|
|
|
|
+ private List<AigcProductAlbum> hasUploadProductList(AigcProductPlatform platform){
|
|
|
|
|
+ return hasUploadProductPageList(platform, 1, 100, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private List<String> hasUploadProductPageList(AigcProductPlatform platform, int page, int pageSize){
|
|
|
|
|
|
|
+ private List<AigcProductAlbum> hasUploadProductPageList(AigcProductPlatform platform, int page, int pageSize, Integer auditStatus){
|
|
|
String url = "https://api.oceanengine.com/open_api/2/dpa/detail/get/";
|
|
String url = "https://api.oceanengine.com/open_api/2/dpa/detail/get/";
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", platform.getAccessToken());
|
|
headers.put("Access-Token", platform.getAccessToken());
|
|
@@ -139,6 +211,13 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
params.put("product_platform_id", Long.valueOf(platform.getPlatformId()));
|
|
params.put("product_platform_id", Long.valueOf(platform.getPlatformId()));
|
|
|
params.put("page", String.valueOf(page));
|
|
params.put("page", String.valueOf(page));
|
|
|
params.put("page_size", String.valueOf(pageSize));
|
|
params.put("page_size", String.valueOf(pageSize));
|
|
|
|
|
+ JSONObject filtering = new JSONObject();
|
|
|
|
|
+ if (auditStatus != null){
|
|
|
|
|
+ filtering.put("audit_status", auditStatus);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!filtering.isEmpty()){
|
|
|
|
|
+ params.put("filtering", filtering);
|
|
|
|
|
+ }
|
|
|
String res = HttpUtils.httpGet(url, params, headers);
|
|
String res = HttpUtils.httpGet(url, params, headers);
|
|
|
if (res == null || res.isEmpty()) {
|
|
if (res == null || res.isEmpty()) {
|
|
|
System.out.println("获取已上传商品列表失败, 广告账号ID:" + platform.getAdvertiserId() + ", 商品库ID:" + platform.getPlatformId());
|
|
System.out.println("获取已上传商品列表失败, 广告账号ID:" + platform.getAdvertiserId() + ", 商品库ID:" + platform.getPlatformId());
|
|
@@ -154,16 +233,24 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
if (list == null || list.isEmpty()){
|
|
if (list == null || list.isEmpty()){
|
|
|
return new ArrayList<>();
|
|
return new ArrayList<>();
|
|
|
}
|
|
}
|
|
|
- List<String> resList = new ArrayList<>(list.size());
|
|
|
|
|
|
|
+ List<AigcProductAlbum> resList = new ArrayList<>(list.size());
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
JSONObject obj = list.getJSONObject(i);
|
|
JSONObject obj = list.getJSONObject(i);
|
|
|
- resList.add(String.valueOf(obj.getLongValue("product_id")));
|
|
|
|
|
|
|
+ AigcProductAlbum album = new AigcProductAlbum();
|
|
|
|
|
+ album.setProductId(String.valueOf(obj.getLongValue("product_id")));
|
|
|
|
|
+ album.setName(obj.getString("name"));
|
|
|
|
|
+ JSONObject profession = obj.getJSONObject("profession");
|
|
|
|
|
+ if (profession!=null && profession.containsKey("album_link")){
|
|
|
|
|
+ album.setAlbumLink(profession.getString("album_link"));
|
|
|
|
|
+ album.setPlayletId(getQueryParam(album.getAlbumLink(), "playlet_id"));
|
|
|
|
|
+ }
|
|
|
|
|
+ resList.add(album);
|
|
|
}
|
|
}
|
|
|
JSONObject page_info = jsonObject.getJSONObject("data").getJSONObject("page_info");
|
|
JSONObject page_info = jsonObject.getJSONObject("data").getJSONObject("page_info");
|
|
|
int total_page = page_info.getIntValue("total_page");
|
|
int total_page = page_info.getIntValue("total_page");
|
|
|
if (total_page > page){
|
|
if (total_page > page){
|
|
|
//递归获取下一页
|
|
//递归获取下一页
|
|
|
- List<String> nextPage = hasUploadProductPageList(platform, page + 1, pageSize);
|
|
|
|
|
|
|
+ List<AigcProductAlbum> nextPage = hasUploadProductPageList(platform, page + 1, pageSize, auditStatus);
|
|
|
resList.addAll(nextPage);
|
|
resList.addAll(nextPage);
|
|
|
}
|
|
}
|
|
|
return resList;
|
|
return resList;
|
|
@@ -299,14 +386,21 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
private void uploadProduct(AigcProductPlatform platform, AigcProductAlbum album,
|
|
private void uploadProduct(AigcProductPlatform platform, AigcProductAlbum album,
|
|
|
String schemaLink, Set<String> errorBlanket, JSONObject productType,
|
|
String schemaLink, Set<String> errorBlanket, JSONObject productType,
|
|
|
BusinessType businessType){
|
|
BusinessType businessType){
|
|
|
- String url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
|
|
|
|
|
|
|
+ String url;
|
|
|
|
|
+ if (StringUtils.isEmpty(album.getAlbumId())){
|
|
|
|
|
+ url = "https://ad.oceanengine.com/open_api/2/dpa/product/create/";
|
|
|
|
|
+ }else {
|
|
|
|
|
+ url = "https://ad.oceanengine.com/open_api/2/dpa/product/update/";
|
|
|
|
|
+ }
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Access-Token", platform.getAccessToken());
|
|
headers.put("Access-Token", platform.getAccessToken());
|
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
|
|
|
|
|
|
JSONObject request = new JSONObject();
|
|
JSONObject request = new JSONObject();
|
|
|
String album_id = album.getAlbumId();
|
|
String album_id = album.getAlbumId();
|
|
|
- request.put("product_id", Long.valueOf(album_id));
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(album_id)){
|
|
|
|
|
+ request.put("product_id", Long.valueOf(album_id));
|
|
|
|
|
+ }
|
|
|
JSONObject product_info = new JSONObject();
|
|
JSONObject product_info = new JSONObject();
|
|
|
product_info.put("name", album.getName());
|
|
product_info.put("name", album.getName());
|
|
|
product_info.put("image_url", album.getImg());
|
|
product_info.put("image_url", album.getImg());
|
|
@@ -363,8 +457,10 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
}
|
|
|
if (platform.getIsBytedance() == 1){
|
|
if (platform.getIsBytedance() == 1){
|
|
|
profession.put("micro_app_link", schemaLink);
|
|
profession.put("micro_app_link", schemaLink);
|
|
|
- }else {
|
|
|
|
|
|
|
+ }else if (platform.getIsWechat() == 1){
|
|
|
profession.put("album_id", album_id);
|
|
profession.put("album_id", album_id);
|
|
|
|
|
+ }else if (platform.getIsDys() == 1){
|
|
|
|
|
+ profession.put("album_link", album.getAlbumLink());
|
|
|
}
|
|
}
|
|
|
profession.put("ad_carrier", JSON.toJSONString(ad_carrier));
|
|
profession.put("ad_carrier", JSON.toJSONString(ad_carrier));
|
|
|
product_info.put("profession", profession);
|
|
product_info.put("profession", profession);
|
|
@@ -376,6 +472,7 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
// System.out.println("请求参数:" + request.toJSONString());
|
|
// System.out.println("请求参数:" + request.toJSONString());
|
|
|
String res = HttpUtils.httpPostRequest(url, request, headers);
|
|
String res = HttpUtils.httpPostRequest(url, request, headers);
|
|
|
JSONObject btRes = JSONObject.parseObject(res);
|
|
JSONObject btRes = JSONObject.parseObject(res);
|
|
|
|
|
+// System.out.println(btRes.toJSONString());
|
|
|
int code = btRes.getIntValue("code");
|
|
int code = btRes.getIntValue("code");
|
|
|
if (code != 0){
|
|
if (code != 0){
|
|
|
String payName = businessType==BusinessType.IAP?"付费":"免费";
|
|
String payName = businessType==BusinessType.IAP?"付费":"免费";
|
|
@@ -647,6 +744,202 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ public static final String FEISHU_EXCEL_TOKEN = "HGZYw1YKRiidYgkpzRocokyPnUd";
|
|
|
|
|
+ public static final String FEISHU_EXCEL_SHEETID = "add053";
|
|
|
|
|
+ public static final String FEISHU_EXCEL_OLD_SHEETID = "krjaDd";
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void pullFanqiePlaylet() {
|
|
|
|
|
+ String userToken = "u-eQOevKV793.WrHbW0yAQVl517s14h0UhjG20g1OGyx6u";
|
|
|
|
|
+ int startRow = 2;
|
|
|
|
|
+ int batchSize = 100;
|
|
|
|
|
+ int endRow = startRow + batchSize - 1;
|
|
|
|
|
+
|
|
|
|
|
+ while(!pullFanqieNewPlayletSheet(null, userToken, startRow, endRow)){
|
|
|
|
|
+ startRow = endRow + 1;
|
|
|
|
|
+ endRow = startRow + batchSize - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ while(!pullFanqieOldPlayletSheet(null, userToken, startRow, endRow)){
|
|
|
|
|
+ startRow = endRow + 1;
|
|
|
|
|
+ endRow = startRow + batchSize - 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void clearAuditFailProduct() {
|
|
|
|
|
+ List<AigcProductPlatform> iaaPlatformList = bytedanceProductUpdateMapper.getDysIaaPlatformList(); //商品库列表
|
|
|
|
|
+ for (AigcProductPlatform platform : iaaPlatformList){
|
|
|
|
|
+ List<AigcProductAlbum> albums = hasUploadProductPageList(platform, 1, 100, 2); //审核失败的商品列表
|
|
|
|
|
+// albums = albums.stream().filter(al -> StringUtils.isEmpty(al.getName())).collect(Collectors.toList());
|
|
|
|
|
+// System.out.println(albums);
|
|
|
|
|
+// if (1==1){
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+ if (Check.isNull(albums)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //删除审核失败的商品
|
|
|
|
|
+ for (AigcProductAlbum album : albums){
|
|
|
|
|
+ String url = "https://ad.oceanengine.com/open_api/2/dpa/product/delete/";
|
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
|
+ headers.put("Access-Token", platform.getAccessToken());
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
|
+ params.put("advertiser_id", Long.valueOf(platform.getAdvertiserId()));
|
|
|
|
|
+ params.put("platform_id", Long.valueOf(platform.getPlatformId()));
|
|
|
|
|
+ params.put("product_id", Long.valueOf(album.getProductId()));
|
|
|
|
|
+ String res = HttpUtils.httpPostRequest(url, params, headers);
|
|
|
|
|
+ if (res == null || res.isEmpty()){
|
|
|
|
|
+ System.out.println("删除审核失败商品失败, 广告账号ID:" + platform.getAdvertiserId() + ", 商品库ID:" + platform.getPlatformId() + ", 商品ID:" + album.getProductId());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
|
+ int code = jsonObject.getIntValue("code");
|
|
|
|
|
+ if (code != 0) {
|
|
|
|
|
+ System.out.println("删除审核失败商品失败,code: " + code + ", msg: " + jsonObject.getString("message") + ", 广告账号ID:" + platform.getAdvertiserId() + ", 商品库ID:" + platform.getPlatformId() + ", 商品ID:" + album.getProductId());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ System.out.println("删除审核失败商品成功,广告账号ID:" + platform.getAdvertiserId() + ", 商品库ID:" + platform.getPlatformId() + ", 商品ID:" + album.getProductId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param tenantToken 当前页签token
|
|
|
|
|
+ * @param userToken 用户token
|
|
|
|
|
+ * @param startRow 起始行
|
|
|
|
|
+ * @param endRow 结束行
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean pullFanqieNewPlayletSheet(String tenantToken, String userToken,
|
|
|
|
|
+ int startRow,
|
|
|
|
|
+ int endRow){
|
|
|
|
|
+ String url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/{spreadsheetToken}/values_batch_get?ranges={ranges}";
|
|
|
|
|
+ url = url.replace("{spreadsheetToken}", FEISHU_EXCEL_TOKEN);
|
|
|
|
|
+ String ranges = FEISHU_EXCEL_SHEETID + "!A" + startRow + ":D" + endRow;
|
|
|
|
|
+ url = url.replace("{ranges}", ranges);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
|
+ headers.put("Authorization", "Bearer " + userToken);
|
|
|
|
|
+
|
|
|
|
|
+ String res = HttpUtils.httpGet(url, null, headers);
|
|
|
|
|
+ JSONObject resultObj = JSON.parseObject(res);
|
|
|
|
|
+ int code = resultObj.getIntValue("code");
|
|
|
|
|
+ boolean endFlag = false;
|
|
|
|
|
+ if (code != 0){
|
|
|
|
|
+ System.out.println("获取飞书表格数据失败,code: " + code + ", msg: " + resultObj.getString("msg"));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JSONObject data = resultObj.getJSONObject("data");
|
|
|
|
|
+ JSONObject valueRanges = data.getJSONArray("valueRanges").getJSONObject(0);
|
|
|
|
|
+ JSONArray values = valueRanges.getJSONArray("values");
|
|
|
|
|
+
|
|
|
|
|
+ List<JSONObject> insertList = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < values.size(); i++) {
|
|
|
|
|
+ JSONArray row = values.getJSONArray(i);
|
|
|
|
|
+ String r1 = row.getString(0);
|
|
|
|
|
+ String r2 = row.getString(1);
|
|
|
|
|
+ String r3 = row.getString(2);
|
|
|
|
|
+ String r4 = row.getString(3);
|
|
|
|
|
+ if (r1 == null && r2 == null && r3 == null && r4 == null){
|
|
|
|
|
+ endFlag = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
|
+ obj.put("movieName", r1);
|
|
|
|
|
+ obj.put("promoteLink", r4);
|
|
|
|
|
+
|
|
|
|
|
+ String[] urlParts = r4.split("\\?");
|
|
|
|
|
+ if (urlParts.length > 1){
|
|
|
|
|
+ String[] queryParams = urlParts[1].split("&");
|
|
|
|
|
+ for (String param : queryParams){
|
|
|
|
|
+ String[] keyValue = param.split("=");
|
|
|
|
|
+ if (keyValue.length == 2 && "playlet_id".equals(keyValue[0])) {
|
|
|
|
|
+ obj.put("playletId", keyValue[1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (keyValue.length == 2 && "playlet_purchase_panel_id".equals(keyValue[0])) {
|
|
|
|
|
+ String purchasePanelId = keyValue[1];
|
|
|
|
|
+ obj.put("playletPurchasePanelId", purchasePanelId);
|
|
|
|
|
+ if ("0".equals(purchasePanelId)){
|
|
|
|
|
+ obj.put("isPay", "0");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ obj.put("isPay", "1");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ insertList.add(obj);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!insertList.isEmpty()){
|
|
|
|
|
+ bytedanceProductUpdateMapper.batchInsertFanqiePlayletInfo(insertList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return endFlag;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param tenantToken 当前页签token
|
|
|
|
|
+ * @param userToken 用户token
|
|
|
|
|
+ * @param startRow 起始行
|
|
|
|
|
+ * @param endRow 结束行
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private boolean pullFanqieOldPlayletSheet(String tenantToken, String userToken,
|
|
|
|
|
+ int startRow,
|
|
|
|
|
+ int endRow){
|
|
|
|
|
+ String url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/{spreadsheetToken}/values_batch_get?ranges={ranges}";
|
|
|
|
|
+ url = url.replace("{spreadsheetToken}", FEISHU_EXCEL_TOKEN);
|
|
|
|
|
+ String ranges = FEISHU_EXCEL_OLD_SHEETID + "!A" + startRow + ":C" + endRow;
|
|
|
|
|
+ url = url.replace("{ranges}", ranges);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
|
+ headers.put("Authorization", "Bearer " + userToken);
|
|
|
|
|
+
|
|
|
|
|
+ String res = HttpUtils.httpGet(url, null, headers);
|
|
|
|
|
+ JSONObject resultObj = JSON.parseObject(res);
|
|
|
|
|
+ int code = resultObj.getIntValue("code");
|
|
|
|
|
+ boolean endFlag = false;
|
|
|
|
|
+ if (code != 0){
|
|
|
|
|
+ System.out.println("获取飞书表格数据失败,code: " + code + ", msg: " + resultObj.getString("msg"));
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ JSONObject data = resultObj.getJSONObject("data");
|
|
|
|
|
+ JSONObject valueRanges = data.getJSONArray("valueRanges").getJSONObject(0);
|
|
|
|
|
+ JSONArray values = valueRanges.getJSONArray("values");
|
|
|
|
|
+
|
|
|
|
|
+ List<JSONObject> insertList = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < values.size(); i++) {
|
|
|
|
|
+ JSONArray row = values.getJSONArray(i);
|
|
|
|
|
+ String r1 = row.getString(0);
|
|
|
|
|
+ String r2 = row.getString(1);
|
|
|
|
|
+ String r3 = row.getString(2);
|
|
|
|
|
+ if (r1 == null && r2 == null && r3 == null){
|
|
|
|
|
+ endFlag = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
|
+ obj.put("movieName", r1.replace("\\r", "").replace("\\n", ""));
|
|
|
|
|
+ String link = r3.replace("\\r", "").replace("\\n", "");
|
|
|
|
|
+ obj.put("promoteLink", link);
|
|
|
|
|
+ String playletId = getQueryParam(link, "playlet_id");
|
|
|
|
|
+ String purchasePanelId = getQueryParam(link, "playlet_purchase_panel_id");
|
|
|
|
|
+ obj.put("playletId", playletId);
|
|
|
|
|
+ obj.put("playletPurchasePanelId", purchasePanelId);
|
|
|
|
|
+ if ("0".equals(purchasePanelId)){
|
|
|
|
|
+ obj.put("isPay", "0");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ obj.put("isPay", "1");
|
|
|
|
|
+ }
|
|
|
|
|
+ insertList.add(obj);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!insertList.isEmpty()){
|
|
|
|
|
+ bytedanceProductUpdateMapper.batchInsertFanqiePlayletInfo(insertList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return endFlag;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 上传短剧
|
|
* 上传短剧
|
|
|
* @param videoId from ly_videos
|
|
* @param videoId from ly_videos
|
|
@@ -710,6 +1003,13 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static String getQueryParam(String url, String paramName){
|
|
|
|
|
+ return UriComponentsBuilder.fromUriString(url)
|
|
|
|
|
+ .build()
|
|
|
|
|
+ .getQueryParams()
|
|
|
|
|
+ .getFirst(paramName);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private String getAppAccessToken(Long app_id, String app_secret){
|
|
private String getAppAccessToken(Long app_id, String app_secret){
|
|
|
String url = "https://open.oceanengine.com/open_api/oauth2/app_access_token/";
|
|
String url = "https://open.oceanengine.com/open_api/oauth2/app_access_token/";
|