|
@@ -642,14 +642,14 @@ public class AdPlanConfServiceImpl extends ServiceImpl<AdPlanConfMapper, AdPlanC
|
|
|
|
|
|
|
|
private void prepareCreativeAssets(AdPlanConf conf, TencentAds tencentAds, List<AdPlan> plans) throws Exception {
|
|
private void prepareCreativeAssets(AdPlanConf conf, TencentAds tencentAds, List<AdPlan> plans) throws Exception {
|
|
|
log.info("准备创意资产开始,计划数量: {}", plans.size());
|
|
log.info("准备创意资产开始,计划数量: {}", plans.size());
|
|
|
- String creativeFiles = conf.getCreativeFiles();
|
|
|
|
|
String brandImageFile = conf.getBrandImageFile();
|
|
String brandImageFile = conf.getBrandImageFile();
|
|
|
- List<OssFile> creativeOssFile = JSON.parseArray(creativeFiles, OssFile.class);
|
|
|
|
|
OssFile brandFile = JSON.parseObject(brandImageFile, OssFile.class);
|
|
OssFile brandFile = JSON.parseObject(brandImageFile, OssFile.class);
|
|
|
|
|
|
|
|
// 第一步:收集所有 accountId
|
|
// 第一步:收集所有 accountId
|
|
|
Set<Long> accountIds = plans.stream()
|
|
Set<Long> accountIds = plans.stream()
|
|
|
- .map(AdPlan::getAccountId)
|
|
|
|
|
|
|
+ .flatMap(p -> p.getAdCreatives().stream())
|
|
|
|
|
+ .filter(c -> c.getBrandImageId() == 0)
|
|
|
|
|
+ .map(AdPlanCreative::getAccountId)
|
|
|
.collect(Collectors.toSet());
|
|
.collect(Collectors.toSet());
|
|
|
log.info("收集到 {} 个账户ID", accountIds.size());
|
|
log.info("收集到 {} 个账户ID", accountIds.size());
|
|
|
|
|
|
|
@@ -658,7 +658,6 @@ public class AdPlanConfServiceImpl extends ServiceImpl<AdPlanConfMapper, AdPlanC
|
|
|
if (brandFile != null && brandFile.getFileMd5() != null && brandFile.getFileUrl() != null) {
|
|
if (brandFile != null && brandFile.getFileMd5() != null && brandFile.getFileUrl() != null) {
|
|
|
String brandFileMd5 = brandFile.getFileMd5();
|
|
String brandFileMd5 = brandFile.getFileMd5();
|
|
|
String brandFileUrl = brandFile.getFileUrl();
|
|
String brandFileUrl = brandFile.getFileUrl();
|
|
|
-
|
|
|
|
|
// 批量查询已上传的品牌形象记录
|
|
// 批量查询已上传的品牌形象记录
|
|
|
List<TencentAccountIdBrandImage> existingBrandImages = tencentAccountIdBrandImageService
|
|
List<TencentAccountIdBrandImage> existingBrandImages = tencentAccountIdBrandImageService
|
|
|
.batchGetByAccountIdsAndMd5s(new ArrayList<>(accountIds), List.of(brandFileMd5));
|
|
.batchGetByAccountIdsAndMd5s(new ArrayList<>(accountIds), List.of(brandFileMd5));
|
|
@@ -667,12 +666,10 @@ public class AdPlanConfServiceImpl extends ServiceImpl<AdPlanConfMapper, AdPlanC
|
|
|
.put(image.getFileMd5(), image.getImageId());
|
|
.put(image.getFileMd5(), image.getImageId());
|
|
|
}
|
|
}
|
|
|
log.info("从数据库查询到 {} 条已上传品牌形象记录", existingBrandImages.size());
|
|
log.info("从数据库查询到 {} 条已上传品牌形象记录", existingBrandImages.size());
|
|
|
-
|
|
|
|
|
// 处理未上传的品牌形象
|
|
// 处理未上传的品牌形象
|
|
|
List<Long> needUploadAccountIds = accountIds.stream()
|
|
List<Long> needUploadAccountIds = accountIds.stream()
|
|
|
.filter(accId -> !brandImageIdMap.getOrDefault(accId, Collections.emptyMap()).containsKey(brandFileMd5))
|
|
.filter(accId -> !brandImageIdMap.getOrDefault(accId, Collections.emptyMap()).containsKey(brandFileMd5))
|
|
|
.toList();
|
|
.toList();
|
|
|
-
|
|
|
|
|
if (!needUploadAccountIds.isEmpty()) {
|
|
if (!needUploadAccountIds.isEmpty()) {
|
|
|
log.info("品牌形象需要上传到 {} 个账户", needUploadAccountIds.size());
|
|
log.info("品牌形象需要上传到 {} 个账户", needUploadAccountIds.size());
|
|
|
// 获取品牌名称(从 conf 或创意中获取)
|
|
// 获取品牌名称(从 conf 或创意中获取)
|