Commit 14f05777 authored by 宋新宇's avatar 宋新宇

Merge branch '7-短剧app关键行为优化' into 'release_20240408_01'

Resolve "短剧app关键行为优化"

See merge request !31
parents db10b7aa bd87ac00
package com.lwby.marketing.att;
import com.lwby.marketing.vo.AppChannelVO;
import java.util.Objects;
import java.util.function.Function;
public enum BehavoirType {
MOTIVATEMODELCOUNT("motivateModelCount",(a) -> Objects.nonNull(a.getMotivationCount()) ? a.getMotivationCount().intValue() : null),
ECPMAVGMODELCOUNT("ecpmAvgModelCount", (a) -> Objects.nonNull(a.getEcpmAvgCount()) ? a.getEcpmAvgCount().intValue() : null),
PECPMMODELCOUNT("pecpmModelCount",(a) -> Objects.nonNull(a.getEcpmPerCount()) ? a.getEcpmPerCount().intValue() : null),
ARPUMODELCOUNT("arpuModelCount",(a) -> Objects.nonNull(a.getArpuCount()) ? a.getArpuCount().doubleValue() : null);
private String value;
private Function<AppChannelVO,Number> fun;
BehavoirType(String value, Function<AppChannelVO,Number> fun) {
this.value = value;
this.fun = fun;
}
public String getValue() {
return this.value;
}
public Number getBehavoirType(AppChannelVO appChannel){
return fun.apply(appChannel);
}
}
\ No newline at end of file
package com.lwby.marketing.att.videoapp.handle; package com.lwby.marketing.att.videoapp.handle;
import com.lwby.marketing.att.BehavoirType;
import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess; import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess;
import com.lwby.marketing.flow.NodeSwitchFlow; import com.lwby.marketing.flow.NodeSwitchFlow;
import com.lwby.marketing.util.CacheKeyUtils; import com.lwby.marketing.util.CacheKeyUtils;
...@@ -42,54 +43,27 @@ public class VideoAppBehaviorFlow extends NodeSwitchFlow<NovelAction> { ...@@ -42,54 +43,27 @@ public class VideoAppBehaviorFlow extends NodeSwitchFlow<NovelAction> {
long userId = action.getUserId(); long userId = action.getUserId();
DeliveryDeviceInfo deliveryDeviceInfo = action.getDeliveryDeviceInfo(); DeliveryDeviceInfo deliveryDeviceInfo = action.getDeliveryDeviceInfo();
AppChannelVO appChannel = up.getAppChannelByPlatformAndChannel(platformId,channelId); AppChannelVO appChannel = up.getAppChannelByPlatformAndChannel(platformId,channelId);
Integer ecpmAvgModelCount = null ; if (Objects.isNull(appChannel)) {
Integer pecpmModelCount = null;
Integer motivateModelCount = null ;
Double arpuModelCount = null ;
if (Objects.nonNull(appChannel) && ((Objects.nonNull(appChannel.getEcpmAvgCount()) && Objects.nonNull(appChannel.getMotivationCount()))
|| (Objects.nonNull(appChannel.getEcpmPerCount()) && Objects.nonNull(appChannel.getMotivationCount()))
|| (Objects.nonNull(appChannel.getArpuCount()) && Objects.nonNull(appChannel.getMotivationCount())))) {
if (Objects.nonNull(appChannel.getEcpmAvgCount()) && Objects.nonNull(appChannel.getMotivationCount())) {
ecpmAvgModelCount = appChannel.getEcpmAvgCount().intValue();
motivateModelCount = appChannel.getMotivationCount().intValue();
}
if (Objects.nonNull(appChannel.getEcpmPerCount()) && Objects.nonNull(appChannel.getMotivationCount())) {
pecpmModelCount = appChannel.getEcpmPerCount().intValue();
motivateModelCount = appChannel.getMotivationCount().intValue();
}
if (Objects.nonNull(appChannel.getArpuCount()) && Objects.nonNull(appChannel.getMotivationCount())) {
arpuModelCount = appChannel.getArpuCount();
motivateModelCount = appChannel.getMotivationCount().intValue();
}
VIDEOAPP_SYS_LOG.info("cacheModel in table is set value,djChanel={},deviceId={},userId={},ecpmAvgModelCount={},pecpmModelCount={},motivateModelCount={},arpuModelCount={}",channelId,deviceId,userId,ecpmAvgModelCount,pecpmModelCount,motivateModelCount,arpuModelCount);
} else {
VIDEOAPP_SYS_LOG.info("cacheModel in table is not set value,djChanel={},deviceId={},userId={}",channelId,deviceId,userId); VIDEOAPP_SYS_LOG.info("cacheModel in table is not set value,djChanel={},deviceId={},userId={}",channelId,deviceId,userId);
action.stop(true); action.stop(true);
return; return;
} }
// 取缓存算是否触发关键行为 // 取缓存算是否触发关键行为
//总ecpm次数
Integer tcpmCount = null ;
//曝光次数
Integer expCount = null ;
//平均ecpm次数 //平均ecpm次数
Integer ecpmAvgCount = null ; Integer ecpmAvgCount = 0 ;
//每次ecpm次数 //每次ecpm次数
Integer pecpmCount = null ; Integer pecpmCount = 0 ;
//激励视频次数 //激励视频次数
Integer motivateCount = null ; Integer motivateCount = 0 ;
//激励视频总ecpm次数 //激励视频总ecpm次数
Integer tvcCount = null; Integer tvcCount = 0;
Double arpuCount = null ; Double arpuCount = 0.0 ;
String upcBehaviorKey = CacheKeyUtils.getBehavoirKey(userId); String upcBehaviorKey = CacheKeyUtils.getBehavoirKey(userId);
if (up.exists(upcBehaviorKey)) { if (up.exists(upcBehaviorKey)) {
Map<String, Integer> behaviorMap = up.hgetAllOldMarket(Integer.class, upcBehaviorKey); Map<String, Integer> behaviorMap = up.hgetAllOldMarket(Integer.class, upcBehaviorKey);
for (Map.Entry<String,Integer> entry : behaviorMap.entrySet()) { for (Map.Entry<String,Integer> entry : behaviorMap.entrySet()) {
switch (entry.getKey()) { switch (entry.getKey()) {
case "tc": tcpmCount = entry.getValue()/100;break; case "tc": arpuCount = (double)entry.getValue()/100000;break;
case "ec": expCount = entry.getValue();break;
case "tvc": tvcCount = entry.getValue()/100;break; case "tvc": tvcCount = entry.getValue()/100;break;
case "mvc":motivateCount = entry.getValue();break; case "mvc":motivateCount = entry.getValue();break;
case "vec":pecpmCount = entry.getValue();break; case "vec":pecpmCount = entry.getValue();break;
...@@ -98,129 +72,78 @@ public class VideoAppBehaviorFlow extends NodeSwitchFlow<NovelAction> { ...@@ -98,129 +72,78 @@ public class VideoAppBehaviorFlow extends NodeSwitchFlow<NovelAction> {
} }
} }
if (Objects.nonNull(tvcCount) && Objects.nonNull(motivateCount)) { if ((tvcCount != 0 && motivateCount != 0)) {
if(Objects.nonNull(pecpmCount)) {
VIDEOAPP_SYS_LOG.info("pecpmcount not null,tcpmCount={},expCount={},arpuCount={},tvcCount={},motivateCount={},pecpmCount={},djChanel={},deviceId={},userId={}",tcpmCount,expCount,arpuCount,tvcCount,motivateCount,pecpmCount,channelId,deviceId,userId);
}
Double ecpmAvgCountD = (double)tvcCount / motivateCount; Double ecpmAvgCountD = (double)tvcCount / motivateCount;
ecpmAvgCount = ecpmAvgCountD.intValue(); ecpmAvgCount = ecpmAvgCountD.intValue();
arpuCount = (double)tcpmCount / 1000; VIDEOAPP_SYS_LOG.info("ecpmAvgCount success,ecpmAvgCount={},arpucount={},tvcCount={},motivateCount={},djChanel={},deviceId={},userId={}",ecpmAvgCount,arpuCount,tvcCount,motivateCount,channelId,deviceId,userId);
VIDEOAPP_SYS_LOG.info("arpuecpm success,tcpmCount={},expCount={},arpuCount={},tvcCount={},motivateCount={},djChanel={},deviceId={},userId={}",tcpmCount,expCount,arpuCount,tvcCount,motivateCount,channelId,deviceId,userId);
} else {
if (Objects.nonNull(tcpmCount) && Objects.nonNull(motivateCount)) {
arpuCount = (double)tcpmCount / 1000;
VIDEOAPP_SYS_LOG.info("arpuset success,tcpmCount={},expCount={},arpuCount={},tvcCount={},motivateCount={},djChanel={},deviceId={},userId={}",tcpmCount,expCount,arpuCount,tvcCount,motivateCount,channelId,deviceId,userId);
} else if (Objects.nonNull(pecpmCount) && Objects.nonNull(motivateCount)) {
if (Objects.nonNull(tcpmCount)) {
arpuCount = (double)tcpmCount / 1000;
}
VIDEOAPP_SYS_LOG.info("pempcount and motivate not null,tcpmCount={},expCount={},arpuCount={},tvcCount={},motivateCount={},pecpmCount={},djChanel={},deviceId={},userId={}",tcpmCount,expCount,arpuCount,tvcCount,motivateCount,pecpmCount,channelId,deviceId,userId);
} else { } else {
VIDEOAPP_SYS_LOG.info("tvcandmo not up to the standard,tcpmCount={},expCount={},tvcCount={},motivateCount={},djChanel={},deviceId={},userId={}",tcpmCount,expCount,tvcCount,motivateCount,channelId,deviceId,userId); VIDEOAPP_SYS_LOG.info("behavoir not receive data,tvcCount={},motivateCount={},djChanel={},deviceId={},userId={}",tvcCount,motivateCount,channelId,deviceId,userId);
action.stop(true); action.stop(true);
return; return;
} }
}
if (Objects.nonNull(motivateModelCount) && Objects.nonNull(motivateCount)) { int conditionNum = 0;
if (motivateCount < motivateModelCount) { for (BehavoirType type : BehavoirType.values()) {
VIDEOAPP_SYS_LOG.info("motivate not up to the standard,motivateCount={},motivateModelCount={},djChanel={},deviceId={},userId={}",motivateCount,motivateModelCount,channelId,deviceId,userId); Number behavoirVal = type.getBehavoirType(appChannel);
action.stop(true); if (null != behavoirVal) {
return; conditionNum ++;
} }
deliveryDeviceInfo.setMotivateCount(String.valueOf(motivateCount));
} }
for (BehavoirType type : BehavoirType.values()) {
if (Objects.nonNull(ecpmAvgModelCount) && Objects.nonNull(ecpmAvgCount)) { Number behavoirVal = type.getBehavoirType(appChannel);
if (Objects.isNull(arpuModelCount)) { if (null != behavoirVal && behavoirVal instanceof Integer) {
if ((ecpmAvgCount < ecpmAvgModelCount)) { if (type.getValue().startsWith(BehavoirType.MOTIVATEMODELCOUNT.getValue()) && null != motivateCount) {
VIDEOAPP_SYS_LOG.info("ecpm not up to the standard,ecpmAvgCount={},ecpmAvgModelCount={},djChanel={},deviceId={},userId={}",ecpmAvgCount,ecpmAvgModelCount,channelId,deviceId,userId); if (motivateCount < behavoirVal.intValue()) {
VIDEOAPP_SYS_LOG.info("motivate not up to the standard,motivateCount={},motivateModelCount={},djChanel={},deviceId={},userId={},conditionNum={}",motivateCount,behavoirVal,channelId,deviceId,userId,conditionNum);
action.stop(true); action.stop(true);
return; break;
}
deliveryDeviceInfo.setEcpmAvgCount(String.valueOf(ecpmAvgCount));
} else {
//当arpu也配置时,则
if ((ecpmAvgCount < ecpmAvgModelCount)) {
VIDEOAPP_SYS_LOG.info("ecpm and arpu not up to the standard,ecpmAvgCount={},ecpmAvgModelCount={},djChanel={},deviceId={},userId={}",ecpmAvgCount,ecpmAvgModelCount,channelId,deviceId,userId);
} else {
deliveryDeviceInfo.setEcpmAvgCount(String.valueOf(ecpmAvgCount));
} }
deliveryDeviceInfo.setMotivateCount(String.valueOf(motivateCount));
continue;
} }
if (type.getValue().startsWith(BehavoirType.ECPMAVGMODELCOUNT.getValue()) && null != ecpmAvgCount) {
if (ecpmAvgCount < behavoirVal.intValue()) {
VIDEOAPP_SYS_LOG.info("ecpm not up to the standard,ecpmAvgCount={},ecpmAvgModelCount={},djChanel={},deviceId={},userId={},conditionNum={}",ecpmAvgCount,behavoirVal,channelId,deviceId,userId,conditionNum);
if (Objects.equals(conditionNum,3)) {
continue;
} }
if (Objects.nonNull(pecpmModelCount) && Objects.nonNull(motivateModelCount) && Objects.nonNull(motivateCount)) {
if (Objects.isNull(arpuModelCount)) {
if (Objects.nonNull(pecpmCount)) {
if (pecpmCount < motivateModelCount) {
VIDEOAPP_SYS_LOG.info("pecpmCount not up to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={}",pecpmModelCount,pecpmCount,motivateModelCount,motivateCount,channelId,deviceId,userId);
action.stop(true); action.stop(true);
return; break;
} }
deliveryDeviceInfo.setPecpmCount(String.valueOf(pecpmModelCount)); deliveryDeviceInfo.setEcpmAvgCount(String.valueOf(ecpmAvgCount));
deliveryDeviceInfo.setPerecpmSize(String.valueOf(pecpmCount)); if (Objects.equals(conditionNum,3)) {
VIDEOAPP_SYS_LOG.info("pecpmCount up to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={}",pecpmModelCount,pecpmCount,motivateModelCount,motivateCount,channelId,deviceId,userId); break;
} else {
VIDEOAPP_SYS_LOG.info("pecpmCount is null not to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={}",pecpmModelCount,pecpmCount,motivateModelCount,motivateCount,channelId,deviceId,userId);
action.stop(true);
return;
}
} else {
if (Objects.nonNull(pecpmCount)) {
if (pecpmCount < motivateModelCount) {
VIDEOAPP_SYS_LOG.info("pecpmCount and arpu not up to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={}",pecpmModelCount,pecpmCount,motivateModelCount,motivateCount,channelId,deviceId,userId);
} else {
deliveryDeviceInfo.setPecpmCount(String.valueOf(pecpmModelCount));
deliveryDeviceInfo.setPerecpmSize(String.valueOf(pecpmCount));
VIDEOAPP_SYS_LOG.info("pecpmCount and arpu up to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={}",pecpmModelCount,pecpmCount,motivateModelCount,motivateCount,channelId,deviceId,userId);
}
} else {
VIDEOAPP_SYS_LOG.info("pecpmCount and arpu is null not to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={}",pecpmModelCount,pecpmCount,motivateModelCount,motivateCount,channelId,deviceId,userId);
} }
continue;
} }
if (type.getValue().startsWith(BehavoirType.PECPMMODELCOUNT.getValue()) && null != pecpmCount) {
if (pecpmCount < BehavoirType.MOTIVATEMODELCOUNT.getBehavoirType(appChannel).intValue()) {
VIDEOAPP_SYS_LOG.info("pecpmCount not up to the standard,pecpmModelCount={},pecpmCount={},motivateModelCount={},motivateCount={},djChanel={},deviceId={},userId={},conditionNum={}",behavoirVal,pecpmCount,BehavoirType.MOTIVATEMODELCOUNT.getBehavoirType(appChannel),motivateCount,channelId,deviceId,userId,conditionNum);
if (Objects.equals(conditionNum,3)) {
continue;
} }
if (Objects.nonNull(arpuModelCount) && Objects.nonNull(arpuCount)) {
if (Objects.nonNull(ecpmAvgModelCount)) {
//配置了 平均ecpm 三个条件 arpu+平均ecpm + 激励视频
if (Objects.isNull(deliveryDeviceInfo.getEcpmAvgCount())) {
// 平均ecpm没达标,看arpu达标没
if (arpuCount < arpuModelCount) {
VIDEOAPP_SYS_LOG.info("arpu ecpmAvgModelCount not up to the standard,arpuCount={},arpuModelCount={},ecpmAvgCount={},djChanel={},deviceId={},userId={}",arpuCount,arpuModelCount,deliveryDeviceInfo.getEcpmAvgCount(),channelId,deviceId,userId);
action.stop(true); action.stop(true);
return; break;
} else {
deliveryDeviceInfo.setEcpmAvgCount(String.valueOf(ecpmAvgCount));
}
} }
VIDEOAPP_SYS_LOG.info("arpu ecpmAvgModelCount up to the standard,arpuCount={},arpuModelCount={},ecpmAvgCount={},djChanel={},deviceId={},userId={}",arpuCount,arpuModelCount,deliveryDeviceInfo.getEcpmAvgCount(),channelId,deviceId,userId);
} else if (Objects.nonNull(pecpmModelCount)) { deliveryDeviceInfo.setPecpmCount(String.valueOf(behavoirVal));
//配置了 每次ecpm 三个条件 arpu+每次ecpm + 激励视频
if (Objects.isNull(deliveryDeviceInfo.getPecpmCount())) {
// 平均ecpm没达标,看arpu达标没
if (arpuCount < arpuModelCount) {
VIDEOAPP_SYS_LOG.info("arpu pecpmModelCount not up to the standard,arpuCount={},arpuModelCount={},pecpmCount={},djChanel={},deviceId={},userId={}",arpuCount,arpuModelCount,deliveryDeviceInfo.getPecpmCount(),channelId,deviceId,userId);
action.stop(true);
return;
} else {
deliveryDeviceInfo.setPecpmCount(String.valueOf(pecpmModelCount));
deliveryDeviceInfo.setPerecpmSize(String.valueOf(pecpmCount)); deliveryDeviceInfo.setPerecpmSize(String.valueOf(pecpmCount));
if (Objects.equals(conditionNum,3)) {
break;
} }
continue;
} }
VIDEOAPP_SYS_LOG.info("arpu pecpmModelCount up to the standard,arpuCount={},arpuModelCount={},pecpmCount={},djChanel={},deviceId={},userId={}",arpuCount,arpuModelCount,deliveryDeviceInfo.getPecpmCount(),channelId,deviceId,userId); } else if (null != behavoirVal && behavoirVal instanceof Double) {
} else { if (type.getValue().startsWith(BehavoirType.ARPUMODELCOUNT.getValue()) && null != arpuCount) {
//只配两个条件的走原来逻辑 arpu+激励视频 if (arpuCount < behavoirVal.intValue()) {
if (arpuCount < arpuModelCount) { VIDEOAPP_SYS_LOG.info("arpu ecpmAvgModelCount not up to the standard,arpuCount={},arpuModelCount={},ecpmAvgCount={},djChanel={},deviceId={},userId={},conditionNum={}",arpuCount,behavoirVal,deliveryDeviceInfo.getEcpmAvgCount(),channelId,deviceId,userId,conditionNum);
VIDEOAPP_SYS_LOG.info("arpu not up to the standard,arpuCount={},arpuModelCount={},djChanel={},deviceId={},userId={}",arpuCount,arpuModelCount,channelId,deviceId,userId);
action.stop(true); action.stop(true);
return; break;
} }
deliveryDeviceInfo.setEcpmAvgCount(String.valueOf(ecpmAvgCount));
} }
deliveryDeviceInfo.setArpuCount(String.valueOf(arpuCount));
VIDEOAPP_SYS_LOG.info("arpu up to the standard,arpuCount={},arpuModelCount={},djChanel={},deviceId={},userId={}",arpuCount,arpuModelCount,channelId,deviceId,userId);
} }
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment