|
|
@@ -12,6 +12,7 @@ import com.moka.gdtauto.entity.AccountGroupAccountRelationship;
|
|
|
import com.moka.gdtauto.entity.AdPlanConf;
|
|
|
import com.moka.gdtauto.entity.SysUser;
|
|
|
import com.moka.gdtauto.entity.TencentAssetDrama;
|
|
|
+import com.moka.gdtauto.entity.TencentAssetFiction;
|
|
|
import com.moka.gdtauto.entity.AdPlan;
|
|
|
import com.moka.gdtauto.entity.AdPlanCreative;
|
|
|
import com.moka.gdtauto.entity.OssFile;
|
|
|
@@ -19,6 +20,7 @@ import com.moka.gdtauto.service.SysUserService;
|
|
|
|
|
|
import com.moka.gdtauto.mapper.AccountGroupAccountRelationshipMapper;
|
|
|
import com.moka.gdtauto.mapper.TencentAssetDramaMapper;
|
|
|
+import com.moka.gdtauto.mapper.TencentAssetFictionMapper;
|
|
|
import com.moka.gdtauto.service.AccountGroupService;
|
|
|
import com.moka.gdtauto.service.AdPlanConfService;
|
|
|
import com.moka.gdtauto.service.AdPlanCreativeService;
|
|
|
@@ -66,6 +68,7 @@ public class AdPlanConfController {
|
|
|
private final SysUserService sysUserService;
|
|
|
private final AccountGroupService accountGroupService;
|
|
|
private final TencentAssetDramaMapper tencentAssetDramaMapper;
|
|
|
+ private final TencentAssetFictionMapper tencentAssetFictionMapper;
|
|
|
|
|
|
|
|
|
@GetMapping("/gdtSuspendByConfId")
|
|
|
@@ -170,6 +173,8 @@ public class AdPlanConfController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public record TencentAsset(Integer assetType, Long assetId, String assetName) {}
|
|
|
+
|
|
|
private List<AdPlan> buildPlans(String jobNumber, UpdateAdPlanConfRequest request, AccountGroup accountGroup,
|
|
|
List<AccountGroupAccountRelationship> relationships) {
|
|
|
String dateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
|
|
@@ -177,20 +182,39 @@ public class AdPlanConfController {
|
|
|
List<OssFile> creativeFileArr = request.getCreativeFileArr();
|
|
|
List<AdPlan> plans = new ArrayList<>();
|
|
|
Integer dramaAmount = request.getDramaAmount();
|
|
|
- Long dramaId = request.getDramaId();
|
|
|
+ Integer fictionAmount = request.getFictionAmount();
|
|
|
//获取短剧 relationships.size * dramaAmount
|
|
|
- List<TencentAssetDrama> dramas = List.of();
|
|
|
- if (dramaAmount > 0) {
|
|
|
- // 随机获取短剧 order by RAND() limit dramaAmount
|
|
|
- dramas = tencentAssetDramaMapper.selectList(new LambdaQueryWrapper<TencentAssetDrama>().eq(TencentAssetDrama::getJobNumber, jobNumber).last("order by rand() limit " + dramaAmount * relationships.size()));
|
|
|
+ Integer assetType = request.getAssetType();
|
|
|
+ List<TencentAsset> assets = new ArrayList<>();
|
|
|
+ if (assetType == 1 && dramaAmount > 0) {
|
|
|
+ List<TencentAssetDrama> dramas = tencentAssetDramaMapper.selectList(new LambdaQueryWrapper<TencentAssetDrama>().eq(TencentAssetDrama::getJobNumber, jobNumber).last("order by rand() limit " + dramaAmount * relationships.size()));
|
|
|
if (dramas.size() < dramaAmount * relationships.size()) {
|
|
|
throw new IllegalArgumentException("短剧数量不足,请在短剧资产管理同步");
|
|
|
}
|
|
|
- } else {
|
|
|
- if (dramaId != null) {
|
|
|
- throw new IllegalArgumentException("请设置短剧相关配置");
|
|
|
+ assets = dramas.stream().map(drama -> new TencentAsset(1, drama.getMarketingAssetId(), drama.getMarketingAssetName())).toList();
|
|
|
+ }
|
|
|
+ if (assetType == 2 && fictionAmount > 0) {
|
|
|
+ List<TencentAssetFiction> fictions = tencentAssetFictionMapper.selectList(new LambdaQueryWrapper<TencentAssetFiction>().eq(TencentAssetFiction::getJobNumber, jobNumber).last("order by rand() limit " + dramaAmount * relationships.size()));
|
|
|
+ if (fictions.size() < dramaAmount * relationships.size()) {
|
|
|
+ throw new IllegalArgumentException("小说数量不足,请在小说资产管理同步");
|
|
|
+ }
|
|
|
+ assets = fictions.stream().map(fiction -> new TencentAsset(2, fiction.getMarketingAssetId(), fiction.getMarketingAssetName())).toList();
|
|
|
+ }
|
|
|
+ if (assetType == 3) {
|
|
|
+ if (dramaAmount > 0) {
|
|
|
+ List<TencentAssetDrama> dramas = tencentAssetDramaMapper.selectList(new LambdaQueryWrapper<TencentAssetDrama>().eq(TencentAssetDrama::getJobNumber, jobNumber).last("order by rand() limit " + dramaAmount * relationships.size()));
|
|
|
+ if (dramas.size() < dramaAmount * relationships.size()) {
|
|
|
+ throw new IllegalArgumentException("短剧数量不足,请在短剧资产管理同步");
|
|
|
+ }
|
|
|
+ assets.addAll(dramas.stream().map(drama -> new TencentAsset(1, drama.getMarketingAssetId(), drama.getMarketingAssetName())).toList());
|
|
|
+ }
|
|
|
+ if (fictionAmount > 0) {
|
|
|
+ List<TencentAssetFiction> fictions = tencentAssetFictionMapper.selectList(new LambdaQueryWrapper<TencentAssetFiction>().eq(TencentAssetFiction::getJobNumber, jobNumber).last("order by rand() limit " + fictionAmount * relationships.size()));
|
|
|
+ if (fictions.size() < fictionAmount * relationships.size()) {
|
|
|
+ throw new IllegalArgumentException("小说数量不足,请在小说资产管理同步");
|
|
|
+ }
|
|
|
+ assets.addAll(fictions.stream().map(fiction -> new TencentAsset(2, fiction.getMarketingAssetId(), fiction.getMarketingAssetName())).toList());
|
|
|
}
|
|
|
- dramas = tencentAssetDramaMapper.selectList(new LambdaQueryWrapper<TencentAssetDrama>().eq(TencentAssetDrama::getMarketingAssetId, dramaId).orderByDesc(TencentAssetDrama::getId).last("limit 1"));
|
|
|
}
|
|
|
|
|
|
String targets = request.getTargets();
|
|
|
@@ -200,9 +224,10 @@ public class AdPlanConfController {
|
|
|
int dramaIndex = 0;
|
|
|
for (AccountGroupAccountRelationship relationship : relationships) {
|
|
|
Long accountId = relationship.getAccountId();
|
|
|
- for (int k = 0; k < dramaAmount; k++) {
|
|
|
- Long assetId = dramas.get(dramaIndex).getMarketingAssetId();
|
|
|
- String dramaName = dramas.get(dramaIndex).getMarketingAssetName();
|
|
|
+ for (int k = 0; k < assets.size(); k++) {
|
|
|
+ Long assetId = assets.get(k).assetId();
|
|
|
+ String assetName = assets.get(k).assetName();
|
|
|
+ Integer asset_type = assets.get(k).assetType();
|
|
|
dramaIndex++;
|
|
|
for (String target : targetArray) {
|
|
|
for (String site : siteArray) {
|
|
|
@@ -218,8 +243,14 @@ public class AdPlanConfController {
|
|
|
adPlan.setTarget(target);
|
|
|
adPlan.setSite(site);
|
|
|
adPlan.setConversionId(request.getConversionId());
|
|
|
- adPlan.setDramaId(assetId);
|
|
|
- adPlan.setDramaName(dramaName);
|
|
|
+ adPlan.setAssetType(asset_type);
|
|
|
+ if (asset_type == 1) {
|
|
|
+ adPlan.setDramaId(assetId);
|
|
|
+ adPlan.setDramaName(assetName);
|
|
|
+ } else if (asset_type == 2) {
|
|
|
+ adPlan.setFictionId(assetId);
|
|
|
+ adPlan.setFictionName(assetName);
|
|
|
+ }
|
|
|
adPlan.setBidAmount(request.getBidAmount());
|
|
|
//adType=2-ROI
|
|
|
if (request.getAdType().equals(2)) {
|