Commit 16e6136a authored by 宋新宇's avatar 宋新宇

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

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

See merge request !37
parents 52a2ad0e 870c5e6d
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.bystory; package com.lwby.marketing.att;
import com.lwby.marketing.att.AttributionStatus;
/** /**
* @author songxinyu * @author songxinyu
......
...@@ -4,15 +4,19 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,15 +4,19 @@ import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.anno.CacheRefresh; import com.alicp.jetcache.anno.CacheRefresh;
import com.alicp.jetcache.anno.CacheType; import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached; import com.alicp.jetcache.anno.Cached;
import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.UniversalProcess; import com.lwby.marketing.att.UniversalProcess;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.vo.AttributeRule;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.kafka.support.SendResult; import org.springframework.kafka.support.SendResult;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFuture;
...@@ -65,7 +69,7 @@ public class DyStoryUniversalProcess extends UniversalProcess { ...@@ -65,7 +69,7 @@ public class DyStoryUniversalProcess extends UniversalProcess {
} }
public String getFirstCheckerKey(StoryNovelAction action) { public String getFirstCheckerKey(StoryNovelAction action) {
return Objects.equals(action.getType(),CallBackType.active.getType()) return Objects.equals(action.getType(), CallBackType.active.getType())
? String.format("fc_%d_%d_%s_%s", action.getUserId(), action.getPlatformId(),action.getMediaName(),action.getCurrentDateStr()) ? String.format("fc_%d_%d_%s_%s", action.getUserId(), action.getPlatformId(),action.getMediaName(),action.getCurrentDateStr())
: String.format("fc_%d_%d_%s", action.getUserId(), action.getPlatformId(),action.getMediaName()); : String.format("fc_%d_%d_%s", action.getUserId(), action.getPlatformId(),action.getMediaName());
} }
...@@ -73,11 +77,13 @@ public class DyStoryUniversalProcess extends UniversalProcess { ...@@ -73,11 +77,13 @@ public class DyStoryUniversalProcess extends UniversalProcess {
/******************************************** JDBC *************************************************************/ /******************************************** JDBC *************************************************************/
@Cached(name="attribute_rule_store_novel", cacheType = CacheType.LOCAL) @Cached(name="attribute_rule_story_novel", cacheType = CacheType.LOCAL)
@CacheRefresh(refresh = 300) @CacheRefresh(refresh = 300)
public String getAttributeRuleByPlatformIdAndChannelId(int platformId,Long channelId) { public AttributeRule getAttributeRuleByPlatformIdAndChannelId(int platformId, Long channelId) {
try { try {
return lwbyJdbcTemplate.queryForObject(String.format("select shave_make_call from attribute_rule where channel_id=%d and platform_id=%d",channelId,platformId),String.class); RowMapper<AttributeRule> rowMapper = BeanPropertyRowMapper.newInstance(AttributeRule.class);
return lwbyJdbcTemplate.queryForObject(String.format("select shave_make_call,callback_type from attribute_rule where channel_id=%d and platform_id=%d",channelId,platformId),rowMapper);
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
return null; return null;
} }
......
package com.lwby.marketing.att.bystory.handle; package com.lwby.marketing.att.bystory.handle;
import com.alibaba.fastjson.JSONObject; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.bystory.CallBackType;
import com.lwby.marketing.att.bystory.DyStoryUniversalProcess; import com.lwby.marketing.att.bystory.DyStoryUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.notify.Media; import com.lwby.marketing.notify.Media;
...@@ -34,7 +33,7 @@ public class ParameterSetupStoryNovelFlow extends NodeFlow<StoryNovelAction> { ...@@ -34,7 +33,7 @@ public class ParameterSetupStoryNovelFlow extends NodeFlow<StoryNovelAction> {
DeliveryDeviceInfo deliveryDeviceInfo = null; DeliveryDeviceInfo deliveryDeviceInfo = null;
//String s = "{\"creativeId\":\"112331\",\"creativeType\":\"3\",\"adid\":\"12321\"," //String s = "{\"creativeId\":\"112331\",\"creativeType\":\"3\",\"adid\":\"12321\","
// + "\"clickId\":\"12312143232\",\"channel\":\"216011231\",\"bookId\":\"4322111\"," // + "\"clickId\":\"12312143232\",\"channel\":\"21221021\",\"bookId\":\"4322111\","
// + "\"media\":\"jrtt\",\"clickTime\":123123123,\"code\":\"12ede3e231\"}";; // + "\"media\":\"jrtt\",\"clickTime\":123123123,\"code\":\"12ede3e231\"}";;
//StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class); //StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class);
//匹配OpenId //匹配OpenId
...@@ -61,6 +60,7 @@ public class ParameterSetupStoryNovelFlow extends NodeFlow<StoryNovelAction> { ...@@ -61,6 +60,7 @@ public class ParameterSetupStoryNovelFlow extends NodeFlow<StoryNovelAction> {
deliveryDeviceInfo.setDj_channel(storyLogin.getChannel()); deliveryDeviceInfo.setDj_channel(storyLogin.getChannel());
deliveryDeviceInfo.setPromotion_id(storyLogin.getAdid()); deliveryDeviceInfo.setPromotion_id(storyLogin.getAdid());
deliveryDeviceInfo.setBook_id(storyLogin.getBookId()); deliveryDeviceInfo.setBook_id(storyLogin.getBookId());
deliveryDeviceInfo.setMedia(storyLogin.getMedia());
action.setDeliveryDeviceInfo(deliveryDeviceInfo); action.setDeliveryDeviceInfo(deliveryDeviceInfo);
action.setChannelId(NumberUtils.parseLong(storyLogin.getChannel())); action.setChannelId(NumberUtils.parseLong(storyLogin.getChannel()));
action.setPlanId(NumberUtils.parseLong((storyLogin.getAdid()))); action.setPlanId(NumberUtils.parseLong((storyLogin.getAdid())));
......
...@@ -2,9 +2,11 @@ package com.lwby.marketing.att.bystory.handle; ...@@ -2,9 +2,11 @@ package com.lwby.marketing.att.bystory.handle;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.att.bystory.DyStoryUniversalProcess; import com.lwby.marketing.att.bystory.DyStoryUniversalProcess;
import com.lwby.marketing.flow.NodeSwitchFlow; import com.lwby.marketing.flow.NodeSwitchFlow;
import com.lwby.marketing.vo.AttributeRule;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -16,6 +18,7 @@ import javax.annotation.Resource; ...@@ -16,6 +18,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
/** /**
...@@ -40,8 +43,8 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> { ...@@ -40,8 +43,8 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> {
public void process(StoryNovelAction action) { public void process(StoryNovelAction action) {
int platformId = action.getPlatformId(); int platformId = action.getPlatformId();
Long channelId = action.getChannelId(); Long channelId = action.getChannelId();
String shaveMakeCall = up.getAttributeRuleByPlatformIdAndChannelId(platformId,channelId); AttributeRule attributeRule = up.getAttributeRuleByPlatformIdAndChannelId(platformId,channelId);
if (StringUtils.isEmpty(shaveMakeCall)) { if (Objects.isNull(attributeRule) || StringUtils.isEmpty(attributeRule.getShaveMakeCall())) {
//直接回传,走回传流 //直接回传,走回传流
DYSTORY_SYS_LOG.info("PaySpduFlow process0 attribute is null,platformId={},channelId={}",action.getPlatformId(),action.getChannelId()); DYSTORY_SYS_LOG.info("PaySpduFlow process0 attribute is null,platformId={},channelId={}",action.getPlatformId(),action.getChannelId());
return; return;
...@@ -56,7 +59,9 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> { ...@@ -56,7 +59,9 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> {
* "4" : 100 * "4" : 100
* } * }
*/ */
//在这里设置回传类型
action.setCallbackTypeStory(attributeRule.getCallbackType());
String shaveMakeCall = attributeRule.getShaveMakeCall();
Map<String, Integer> map = JSON.parseObject(shaveMakeCall, Map.class); Map<String, Integer> map = JSON.parseObject(shaveMakeCall, Map.class);
Integer sprDedu = 0; Integer sprDedu = 0;
...@@ -75,6 +80,14 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> { ...@@ -75,6 +80,14 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> {
return; return;
} }
if (sprDedu == 0) {
DYSTORY_SYS_LOG.info("PaySpduFlow process0 attribute.sprDeduChannel 0,platformId={},channelId={}",action.getPlatformId(),action.getChannelId());
up.notifyResult(action,Objects.equals(action.getCallbackTypeStory(),3)? CallBackType.behavior.getTopic():CallBackType.pay.getTopic(), AttributionStatus.NORMAL_DEDUCTION_CALLBACK);
up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1");
action.stop(true);
return;
}
//总数 //总数
String channelTotal = up.getTotalCountKey(AttributionType.CHANNEL, action.getPlatformId(), action.getChannelId(),goodId, sprDedu, action.getCurrentDateStr()); String channelTotal = up.getTotalCountKey(AttributionType.CHANNEL, action.getPlatformId(), action.getChannelId(),goodId, sprDedu, action.getCurrentDateStr());
//回传 //回传
...@@ -92,7 +105,7 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> { ...@@ -92,7 +105,7 @@ public class PaySpduFlow extends NodeSwitchFlow<StoryNovelAction> {
"PaySpduFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, sprDedu = {}, goodId = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}", "PaySpduFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, sprDedu = {}, goodId = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}",
platformId, channelId, sprDedu, goodId, channelTotalCount, channelCallbackCount, 1); platformId, channelId, sprDedu, goodId, channelTotalCount, channelCallbackCount, 1);
} else { } else {
up.notifyResult(action,"ocpc_pay", AttributionStatus.NORMAL_DEDUCTION_CALLBACK); up.notifyResult(action,Objects.equals(action.getCallbackTypeStory(),3)? CallBackType.behavior.getTopic():CallBackType.pay.getTopic(), AttributionStatus.NORMAL_DEDUCTION_CALLBACK);
up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1"); up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1");
DYSTORY_SYS_LOG.info( DYSTORY_SYS_LOG.info(
"PaySpduFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, sprDedu = {}, goodId = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}", "PaySpduFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, sprDedu = {}, goodId = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}",
......
package com.lwby.marketing.att.bystory.handle; package com.lwby.marketing.att.bystory.handle;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.bystory.DyStoryUniversalProcess; import com.lwby.marketing.att.bystory.DyStoryUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
......
package com.lwby.marketing.att.bystory.handle; package com.lwby.marketing.att.bystory.handle;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.bystory.DyStoryUniversalProcess; import com.lwby.marketing.att.bystory.DyStoryUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Objects;
/** /**
* @author songxinyu * @author songxinyu
...@@ -24,7 +25,12 @@ public class UploadCallFlow extends NodeFlow<StoryNovelAction> { ...@@ -24,7 +25,12 @@ public class UploadCallFlow extends NodeFlow<StoryNovelAction> {
boolean success = action.getMedia().notify(action); boolean success = action.getMedia().notify(action);
if (success) { if (success) {
up.notifyResult(action, type.getTopic(),type.getStatus()); if (type.getType().equals(CallBackType.active.getType())) {
up.notifyResult(action, type.getTopic(),type.getStatus());
} else {
up.notifyResult(action, Objects.equals(action.getCallbackTypeStory(),3) ? CallBackType.behavior.getTopic() : CallBackType.pay.getTopic(),
Objects.equals(action.getCallbackTypeStory(),3) ? CallBackType.behavior.getStatus() : CallBackType.pay.getStatus());
}
up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1"); up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1");
} }
} }
......
...@@ -66,6 +66,7 @@ public class DyVideoBehavoirConsumer { ...@@ -66,6 +66,7 @@ public class DyVideoBehavoirConsumer {
event.getUserUploadEvent()); event.getUserUploadEvent());
executorByDyVideoBehavoir.execute(action); executorByDyVideoBehavoir.execute(action);
DYVIDEO_SYS_LOG.info("media.behavoir.dyVideo.end,topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event));
} catch (Throwable e) { } catch (Throwable e) {
DYVIDEO_ERROR_LOG.error("dy.video.behavoir.onMessage failed, data={}, costTime={} ms", data.value(), DYVIDEO_ERROR_LOG.error("dy.video.behavoir.onMessage failed, data={}, costTime={} ms", data.value(),
System.currentTimeMillis() - begin, e); System.currentTimeMillis() - begin, e);
......
package com.lwby.marketing.att.dyvideo; package com.lwby.marketing.att.dyvideo;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.anno.CacheRefresh; import com.alicp.jetcache.anno.CacheRefresh;
...@@ -8,15 +7,18 @@ import com.alicp.jetcache.anno.CacheType; ...@@ -8,15 +7,18 @@ import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached; import com.alicp.jetcache.anno.Cached;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.UniversalProcess; import com.lwby.marketing.att.UniversalProcess;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.po.ThirdAccountDy; import com.lwby.marketing.po.ThirdAccountDy;
import com.lwby.marketing.util.CacheKeyUtils;
import com.lwby.marketing.util.HttpUtil;
import com.lwby.marketing.vo.AppChannelVO; import com.lwby.marketing.vo.AppChannelVO;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.BeanPropertyRowMapper;
...@@ -26,9 +28,8 @@ import org.springframework.stereotype.Component; ...@@ -26,9 +28,8 @@ import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFuture;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.text.SimpleDateFormat;
import java.util.Map; import java.util.*;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
...@@ -42,6 +43,14 @@ public class DyVideoUniversalProcess extends UniversalProcess { ...@@ -42,6 +43,14 @@ public class DyVideoUniversalProcess extends UniversalProcess {
@Resource @Resource
private RedisTemplate<String,String> oldMarketRedisTemplate; private RedisTemplate<String,String> oldMarketRedisTemplate;
SimpleDateFormat dfh = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
private static final String url = "https://open.douyin.com/api/traffic/v1/rt_ecpm/query/";
private static final String tokenDyDevUrl = "https://open-sandbox.douyin.com/oauth/client_token/";
private static final String tokenDyProdUrl = "https://open.douyin.com/oauth/client_token/";
/** /**
* 通知处理结果 * 通知处理结果
*/ */
...@@ -64,7 +73,7 @@ public class DyVideoUniversalProcess extends UniversalProcess { ...@@ -64,7 +73,7 @@ public class DyVideoUniversalProcess extends UniversalProcess {
ddi.setDevice_id(String.valueOf(action.getUserId())); ddi.setDevice_id(String.valueOf(action.getUserId()));
ddi.setActive_time(System.currentTimeMillis()); ddi.setActive_time(System.currentTimeMillis());
ddi.setChannel(String.valueOf(action.getChannelId())); ddi.setChannel(String.valueOf(action.getChannelId()));
ddi.setUserId(action.getUserId()); ddi.setOpenId(action.getOpenId());
String jsonString = JSONObject.toJSONString(ddi); String jsonString = JSONObject.toJSONString(ddi);
ListenableFuture<SendResult<String, String>> active_result = novelKafkaTemplate.send(topic, jsonString); ListenableFuture<SendResult<String, String>> active_result = novelKafkaTemplate.send(topic, jsonString);
...@@ -87,10 +96,18 @@ public class DyVideoUniversalProcess extends UniversalProcess { ...@@ -87,10 +96,18 @@ public class DyVideoUniversalProcess extends UniversalProcess {
oldMarketRedisTemplate.opsForValue().set(key,value,expires, TimeUnit.SECONDS); oldMarketRedisTemplate.opsForValue().set(key,value,expires, TimeUnit.SECONDS);
} }
public boolean existsOld(String key) {
return Boolean.TRUE.equals(oldMarketRedisTemplate.hasKey(key));
}
public void delToken(String key) { public void delToken(String key) {
oldMarketRedisTemplate.delete(key); oldMarketRedisTemplate.delete(key);
} }
public void hsetNew(String key, String field, int expire, String value) {
oldMarketRedisTemplate.opsForHash().put(key,field,value);
oldMarketRedisTemplate.expire(key,expire,TimeUnit.SECONDS);
}
public String getTotalCountKey(AttributionType attributionType, int platformId, Long channelOrPlanId ,int sprDedu, String dateStr) { public String getTotalCountKey(AttributionType attributionType, int platformId, Long channelOrPlanId ,int sprDedu, String dateStr) {
...@@ -161,4 +178,86 @@ public class DyVideoUniversalProcess extends UniversalProcess { ...@@ -161,4 +178,86 @@ public class DyVideoUniversalProcess extends UniversalProcess {
return null; return null;
} }
} }
public Map<String,Integer> getResultCountList(Date day, String openid, String accessToken, Integer tvcCount, Integer motivateCount, Integer pecpmCount, Integer pecpmModelCount, Long userId, String tokenDy, List<String> dyMarketPlatformAppIdList,
Environment env) {
int pageNumer = 1;
Map<String,Integer> resultCountMap = new HashMap<>();
String upcBehaviorKey = CacheKeyUtils.getVideoBehavoirKey(userId);
String cursor = null;
for (int i=1 ; i<= pageNumer ; i++) {
Map<String,Object> mp = new HashMap<>();
mp.put("open_id",openid);
mp.put("date_hour",dfh.format(day));
if (cursor != null) {
mp.put("cursor",cursor);
}
String mapAction = JSONObject.toJSONString(mp);
try {
String result = HttpUtil.postDy(url, mapAction,accessToken);
Integer resultCode = (Integer) JSON.parseObject(result).get("err_no");
if (resultCode == 0) {
Map dataMap = (Map) JSON.parseObject(result).get("data");
List<JSONObject> records = (List<JSONObject>)dataMap.get("records");
String next_cursor = (String)dataMap.get("next_cursor");
if (records != null && records.size()>0) {
if (Objects.isNull(tvcCount)) {
tvcCount = 0;
}
if (Objects.isNull(motivateCount)) {
motivateCount = 0;
}
if (Objects.isNull(pecpmCount)) {
pecpmCount = 0;
}
motivateCount += records.size();
for(JSONObject jsonObject : records) {
String cost = jsonObject.getString("cost");
Integer costI = Integer.parseInt(cost);
Double c = (double)(costI / 100);
int ct = c.intValue();
if (pecpmModelCount != null) {
if (ct>=pecpmModelCount) {
pecpmCount ++;
}
}
tvcCount += costI;
}
hsetNew(upcBehaviorKey,"tvc",60 * 60 * 24 * 3,JSON.toJSONString(tvcCount));
hsetNew(upcBehaviorKey,"mvc",60 * 60 * 24 * 3,JSON.toJSONString(motivateCount));
hsetNew(upcBehaviorKey,"vec",60 * 60 * 24 * 3,JSON.toJSONString(pecpmCount));
}
DYVIDEO_SYS_LOG.info("DyvideoBehaviorFlow.douyin code succ,userId={},result={}",userId,JSON.toJSONString(result));
if (records != null && records.size() == 500) {
pageNumer ++;
cursor = next_cursor;
}
} else {
DYVIDEO_SYS_LOG.info("DouyinBehaviorKafkaConsumer.douyin code error,userId={},result={}",userId,JSON.toJSONString(result));
if (resultCode == 28001008) {
//删除授权过期token
delToken(tokenDy);
getDyAccessToken(dyMarketPlatformAppIdList.get(0), dyMarketPlatformAppIdList.get(1), Objects.equals(env.getActiveProfiles()[0],"prod") ? tokenDyProdUrl : tokenDyDevUrl);
DYVIDEO_SYS_LOG.info("DyvideoBehaviorFlow.douyin code auth token expired,userId={},result={}",userId,JSON.toJSONString(result));
}
return null;
}
resultCountMap.put("tvc",tvcCount);
resultCountMap.put("motivate",motivateCount);
resultCountMap.put("pecpm",pecpmCount);
} catch (Throwable e) {
e.printStackTrace();
}
}
return resultCountMap;
}
} }
package com.lwby.marketing.att.dyvideo.handle; package com.lwby.marketing.att.dyvideo.handle;
import com.alibaba.fastjson.JSONObject; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.bystory.CallBackType;
import com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess; import com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.notify.Media; import com.lwby.marketing.notify.Media;
...@@ -35,11 +34,11 @@ public class ParameterSetupDyVideoFlow extends NodeFlow<StoryNovelAction> { ...@@ -35,11 +34,11 @@ public class ParameterSetupDyVideoFlow extends NodeFlow<StoryNovelAction> {
//VO对像 //VO对像
DeliveryDeviceInfo deliveryDeviceInfo = null; DeliveryDeviceInfo deliveryDeviceInfo = null;
String s = "{\"activeTime\":1711439536879,\"adid\":\"7347520002541764646\",\"channel\":\"214122006\",\"clickId\":\"B.1SLXpxqLP8EXNpAqlfUjsQvppp7bkeHT9LpYmfnxMwxH61cZtBGopyXg3glnl8880WYw3XUYfeh21oLLnT9ovSPFtvFp5faNJQbetTFwBfZiesPw0IpoWF2GtLeJW66Bf8vMnUilTWN7sUlexUfVKQiAefYso0MEqhkcUJhpqzz21B\",\"clickTime\":1711394346686,\"code\":\"FN1za8huKsDQ3TyZYhtyzFgjFTDt-ddTEAzYFwrEpYGMyF6NBImpXtzv9ZTZVnoaI6nSyHU4hQ0kjnwNFsXwLV02x0cpIiod-3L9G35DyTOh_K5LQd6Nvs2FQ20\",\"creativeId\":\"1793848259919929\",\"creativeType\":\"15\",\"media\":\"jrtt\",\"videoResourceId\":\"100013\"}"; //String s = "{\"activeTime\":1711439536879,\"adid\":\"7347520002541764646\",\"channel\":\"214122006\",\"clickId\":\"B.1SLXpxqLP8EXNpAqlfUjsQvppp7bkeHT9LpYmfnxMwxH61cZtBGopyXg3glnl8880WYw3XUYfeh21oLLnT9ovSPFtvFp5faNJQbetTFwBfZiesPw0IpoWF2GtLeJW66Bf8vMnUilTWN7sUlexUfVKQiAefYso0MEqhkcUJhpqzz21B\",\"clickTime\":1711394346686,\"code\":\"FN1za8huKsDQ3TyZYhtyzFgjFTDt-ddTEAzYFwrEpYGMyF6NBImpXtzv9ZTZVnoaI6nSyHU4hQ0kjnwNFsXwLV02x0cpIiod-3L9G35DyTOh_K5LQd6Nvs2FQ20\",\"creativeId\":\"1793848259919929\",\"creativeType\":\"15\",\"media\":\"jrtt\",\"videoResourceId\":\"100013\"}";
//StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class); //StoryLogin storyLogin = JSONObject.parseObject(s,StoryLogin.class);
//匹配OpenId //匹配OpenId
VideoUpload videoUpload = JSONObject.parseObject(s,VideoUpload.class); //VideoUpload videoUpload = JSONObject.parseObject(s,VideoUpload.class);
// VideoUpload videoUpload = up.get(VideoUpload.class,assembleKey(openId)); VideoUpload videoUpload = up.get(VideoUpload.class,assembleKey(openId));
action.setVideoUpload(videoUpload); action.setVideoUpload(videoUpload);
//StoryNovelAction对像参数填充 //StoryNovelAction对像参数填充
...@@ -61,6 +60,7 @@ public class ParameterSetupDyVideoFlow extends NodeFlow<StoryNovelAction> { ...@@ -61,6 +60,7 @@ public class ParameterSetupDyVideoFlow extends NodeFlow<StoryNovelAction> {
deliveryDeviceInfo.setUuid(UUID.randomUUID().toString()); deliveryDeviceInfo.setUuid(UUID.randomUUID().toString());
deliveryDeviceInfo.setDj_channel(videoUpload.getChannel()); deliveryDeviceInfo.setDj_channel(videoUpload.getChannel());
deliveryDeviceInfo.setPromotion_id(videoUpload.getAdid()); deliveryDeviceInfo.setPromotion_id(videoUpload.getAdid());
deliveryDeviceInfo.setMedia(videoUpload.getMedia());
deliveryDeviceInfo.setVideoResourceId(videoUpload.getVideoResourceId()); deliveryDeviceInfo.setVideoResourceId(videoUpload.getVideoResourceId());
action.setDeliveryDeviceInfo(deliveryDeviceInfo); action.setDeliveryDeviceInfo(deliveryDeviceInfo);
action.setChannelId(NumberUtils.parseLong(videoUpload.getChannel())); action.setChannelId(NumberUtils.parseLong(videoUpload.getChannel()));
......
package com.lwby.marketing.att.dyvideo.handle; package com.lwby.marketing.att.dyvideo.handle;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess; import com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
......
package com.lwby.marketing.att.dyvideo.handle; package com.lwby.marketing.att.dyvideo.handle;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess; import com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
......
...@@ -38,27 +38,27 @@ public class VideoAppBehavoirConsumer { ...@@ -38,27 +38,27 @@ public class VideoAppBehavoirConsumer {
long begin = System.currentTimeMillis(); long begin = System.currentTimeMillis();
if (VIDEO_SYS_LOG.isInfoEnabled()) { if (VIDEO_SYS_LOG.isInfoEnabled()) {
VIDEO_SYS_LOG.info("media.active.onMessage start ,size = {}", datas.size()); VIDEO_SYS_LOG.info("media.behavoir.onMessage start ,size = {}", datas.size());
} }
for (ConsumerRecord<String, String> data : datas) { for (ConsumerRecord<String, String> data : datas) {
try { try {
if (data == null) { if (data == null) {
VIDEO_SYS_LOG.warn("media.active.story.onMessage listen 消费数据为null"); VIDEO_SYS_LOG.warn("media.behavoir.story.onMessage listen 消费数据为null");
return; return;
} }
VIDEO_SYS_LOG.info("media.active.onMessage start, data={}", data == null ? null : data.value()); VIDEO_SYS_LOG.info("media.behavoir.onMessage start, data={}", data == null ? null : data.value());
StoreUserUploadEventBO event = JSON.parseObject(data.value(), StoreUserUploadEventBO.class); StoreUserUploadEventBO event = JSON.parseObject(data.value(), StoreUserUploadEventBO.class);
VIDEO_SYS_LOG.info("media.active.topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event)); VIDEO_SYS_LOG.info("media.behavoir.topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event));
NovelAction action = new NovelAction(event.getClientInfo(), data.value(),event.getUserUploadEvent()); NovelAction action = new NovelAction(event.getClientInfo(), data.value(),event.getUserUploadEvent());
videoAppFlowExecutor.getExecutorByStory().execute(action); videoAppFlowExecutor.getExecutorByStory().execute(action);
} catch (Throwable e) { } catch (Throwable e) {
VIDEO_ERROR_LOG.info("media.active.onMessage failed, data={}, costTime={} ms", data.value(), VIDEO_ERROR_LOG.info("media.behavoir.onMessage failed, data={}, costTime={} ms", data.value(),
System.currentTimeMillis() - begin, e); System.currentTimeMillis() - begin, e);
} }
} }
......
package com.lwby.marketing.att.videoapp; package com.lwby.marketing.att.videoapp;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.anno.CacheRefresh; import com.alicp.jetcache.anno.CacheRefresh;
...@@ -8,7 +7,7 @@ import com.alicp.jetcache.anno.CacheType; ...@@ -8,7 +7,7 @@ import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached; import com.alicp.jetcache.anno.Cached;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.UniversalProcess; import com.lwby.marketing.att.UniversalProcess;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.vo.*; import com.lwby.marketing.vo.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -77,6 +76,10 @@ public class VideoAppUniversalProcess extends UniversalProcess { ...@@ -77,6 +76,10 @@ public class VideoAppUniversalProcess extends UniversalProcess {
return null; return null;
} }
public boolean existsOld(String key) {
return Boolean.TRUE.equals(oldMarketRedisTemplate.hasKey(key));
}
public <T> Map<String,T> hgetAllOldMarket(Class<T> clazz,String key) { public <T> Map<String,T> hgetAllOldMarket(Class<T> clazz,String key) {
Map<Object, Object> json = oldMarketRedisTemplate.opsForHash().entries(key); Map<Object, Object> json = oldMarketRedisTemplate.opsForHash().entries(key);
...@@ -98,8 +101,8 @@ public class VideoAppUniversalProcess extends UniversalProcess { ...@@ -98,8 +101,8 @@ public class VideoAppUniversalProcess extends UniversalProcess {
public String getFirstCheckerKey(NovelAction action) { public String getFirstCheckerKey(NovelAction action) {
return Objects.equals(action.getType(), CallBackType.active.getType()) return Objects.equals(action.getType(), CallBackType.active.getType())
? String.format("fc_%d_%d_%s_%s", action.getDeviceId(), action.getPlatformId(),action.getMediaName(),action.getCurrentDateStr()) ? String.format("fc_%s_%d_%s_%s", action.getDeviceId(), action.getPlatformId(),action.getMediaName(),action.getCurrentDateStr())
: String.format("fc_%d_%d_%s", action.getDeviceId(), action.getPlatformId(),action.getMediaName()); : String.format("fc_%s_%d_%s", action.getDeviceId(), action.getPlatformId(),action.getMediaName());
} }
public int getExpire(NovelAction action) { public int getExpire(NovelAction action) {
......
package com.lwby.marketing.att.videoapp.handle; package com.lwby.marketing.att.videoapp.handle;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.videoapp.DeviceVideoType; import com.lwby.marketing.att.videoapp.DeviceVideoType;
import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess; import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
......
package com.lwby.marketing.att.videoapp.handle; package com.lwby.marketing.att.videoapp.handle;
import com.lwby.marketing.att.AttributionStatus; import com.lwby.marketing.att.AttributionStatus;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess; import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.NovelAction; import com.lwby.marketing.vo.NovelAction;
......
package com.lwby.marketing.att.videoapp.handle; package com.lwby.marketing.att.videoapp.handle;
import com.lwby.marketing.att.bystory.CallBackType; import com.lwby.marketing.att.CallBackType;
import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess; import com.lwby.marketing.att.videoapp.VideoAppUniversalProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.NovelAction; import com.lwby.marketing.vo.NovelAction;
......
...@@ -34,6 +34,9 @@ public class OldMarketRedisConfig { ...@@ -34,6 +34,9 @@ public class OldMarketRedisConfig {
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
template.setKeySerializer(stringRedisSerializer); template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(stringRedisSerializer); template.setValueSerializer(stringRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(stringRedisSerializer);
template.setConnectionFactory(redisConnectionFactory); template.setConnectionFactory(redisConnectionFactory);
return template; return template;
} }
......
...@@ -10,10 +10,7 @@ import com.lwby.marketing.att.bystory.DyStoryUniversalProcess; ...@@ -10,10 +10,7 @@ import com.lwby.marketing.att.bystory.DyStoryUniversalProcess;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.po.CrossCallback; import com.lwby.marketing.po.CrossCallback;
import com.lwby.marketing.util.DateTimUtils; import com.lwby.marketing.util.DateTimUtils;
import com.lwby.marketing.vo.CrossPlatformAccount; import com.lwby.marketing.vo.*;
import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoryNovelAction;
import com.lwby.marketing.vo.StoreUserUploadEventBO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.BeanPropertyRowMapper;
...@@ -87,8 +84,8 @@ public class AttrController { ...@@ -87,8 +84,8 @@ public class AttrController {
System.out.println(sprDedu); System.out.println(sprDedu);
} }
System.out.println(sprDedu); System.out.println(sprDedu);
String shaveMakeCall = up.getAttributeRuleByPlatformIdAndChannelId(platformId,channelId); AttributeRule attributeRule = up.getAttributeRuleByPlatformIdAndChannelId(platformId,channelId);
if (StringUtils.isEmpty(shaveMakeCall)) { if (Objects.isNull(attributeRule) || StringUtils.isEmpty(attributeRule.getShaveMakeCall())) {
//直接回传,走回传流 //直接回传,走回传流
return; return;
} }
...@@ -102,7 +99,7 @@ public class AttrController { ...@@ -102,7 +99,7 @@ public class AttrController {
* "4" : 100 * "4" : 100
* } * }
*/ */
String shaveMakeCall = attributeRule.getShaveMakeCall();
Map<String, Integer> map = JSON.parseObject(shaveMakeCall, Map.class); Map<String, Integer> map = JSON.parseObject(shaveMakeCall, Map.class);
String goodId = "1"; String goodId = "1";
...@@ -152,8 +149,8 @@ public class AttrController { ...@@ -152,8 +149,8 @@ public class AttrController {
@RequestMapping("/sendPay") @RequestMapping("/sendPay")
public void testSendPay() { public void testSendPay() {
String msg = "{\"clientInfo\":{\"channel\":214120503,\"clientIp\":\"183.219.7.180\",\"pkv\":1,\"platformGroupId\":412," String msg = "{\"clientInfo\":{\"channel\":214120503,\"clientIp\":\"183.219.7.180\",\"pkv\":1,\"platformGroupId\":601,"
+ "\"platformId\":412,\"sessionid\":\"undefined\",\"ua\":\"Mozilla/5.0 (Linux; Android 12; OXF-AN00 Build/HUAWEIOXF-AN00;" + "\"platformId\":601,\"sessionid\":\"undefined\",\"ua\":\"Mozilla/5.0 (Linux; Android 12; OXF-AN00 Build/HUAWEIOXF-AN00;"
+ " wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36 aweme.lite/28.9.0 " + " wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/117.0.0.0 Mobile Safari/537.36 aweme.lite/28.9.0 "
+ "ToutiaoMicroApp/3.14.0 PluginVersion/28909073\",\"version\":\"2.0.0\",\"xClient\":\"version=2.0.0;platformId=412;" + "ToutiaoMicroApp/3.14.0 PluginVersion/28909073\",\"version\":\"2.0.0\",\"xClient\":\"version=2.0.0;platformId=412;"
+ "equipment=android\"},\"createTime\":1709533439693,\"extraData\":{},\"id\":\"93857260-8130-442f-bc92-b549dbf28ef0\"," + "equipment=android\"},\"createTime\":1709533439693,\"extraData\":{},\"id\":\"93857260-8130-442f-bc92-b549dbf28ef0\","
...@@ -249,6 +246,15 @@ public class AttrController { ...@@ -249,6 +246,15 @@ public class AttrController {
@RequestMapping("/sendVideoApp") @RequestMapping("/sendVideoApp")
public void testSendVideoapp() { public void testSendVideoapp() {
com.alibaba.fastjson.JSONObject dyMarketPlatformAppIdJson = JSON.parseObject(
"{\n"
+ " \"400\": \"ttf2f6844b6dc9702901_d4ac08a22f80f73256836fdd9655dbb0b6e6de7c\",\n"
+ " \"412\": \"ttd3dda5604ce230b401_5aac82a8c76db9c54f187dea7b43b58b233459db\"\n"
+ "}");
String platformKey = String.valueOf(412);
//走平台
String dyMarketPlatformAppId = dyMarketPlatformAppIdJson.getString(platformKey);
String msg = "{\"clientInfo\":{\"channel\":682000,\"clientIp\":\"183.226.74.112\"," String msg = "{\"clientInfo\":{\"channel\":682000,\"clientIp\":\"183.226.74.112\","
+ "\"dID\":\"2705A240-1875-4C38-9529-0343B56B6C49\",\"fixVersion\":4,\"idfa\":\"00000000-0000-0000-0000-000000000000\"," + "\"dID\":\"2705A240-1875-4C38-9529-0343B56B6C49\",\"fixVersion\":4,\"idfa\":\"00000000-0000-0000-0000-000000000000\","
+ "\"language\":\"zh\",\"mainVersion\":1,\"oaid\":\"2705A240-1875-4C38-9529-0343B56B6C49\",\"os\":\"1\"," + "\"language\":\"zh\",\"mainVersion\":1,\"oaid\":\"2705A240-1875-4C38-9529-0343B56B6C49\",\"os\":\"1\","
......
...@@ -3,20 +3,28 @@ package com.lwby.marketing.notify.media.jrtt; ...@@ -3,20 +3,28 @@ package com.lwby.marketing.notify.media.jrtt;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.lwby.marketing.att.bystory.DyStoryUniversalProcess;
import com.lwby.marketing.notify.DYNotify; import com.lwby.marketing.notify.DYNotify;
import com.lwby.marketing.notify.media.jrtt.dto.JrttAttributeRequest; import com.lwby.marketing.notify.media.jrtt.dto.JrttAttributeRequest;
import com.lwby.marketing.vo.AttributeRule;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoryNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import java.util.Objects;
@Slf4j @Slf4j
public class StoryJRTTNotify extends DYNotify { public class StoryJRTTNotify extends DYNotify {
public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion"; public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion";
private static final Logger DYSTORY_SYS_LOG = LoggerFactory.getLogger("dystory.sys"); private static final Logger DYSTORY_SYS_LOG = LoggerFactory.getLogger("dystory.sys");
@Resource
DyStoryUniversalProcess up;
@Override @Override
public boolean active(StoryNovelAction na) { public boolean active(StoryNovelAction na) {
return notify(na,"active"); return notify(na,"active");
...@@ -24,12 +32,12 @@ public class StoryJRTTNotify extends DYNotify { ...@@ -24,12 +32,12 @@ public class StoryJRTTNotify extends DYNotify {
@Override @Override
public boolean pay(StoryNovelAction na) { public boolean pay(StoryNovelAction na) {
return notify(na,"active_pay"); return Objects.equals(na.getCallbackTypeStory(),3) ? behavior(na) : notify(na,"active_pay");
} }
@Override @Override
public boolean behavior(StoryNovelAction na) { public boolean behavior(StoryNovelAction na) {
return false; return notify(na,"game_addiction");
} }
public boolean notify(StoryNovelAction na,String eventType) { public boolean notify(StoryNovelAction na,String eventType) {
......
package com.lwby.marketing.notify.media.jrtt; package com.lwby.marketing.notify.media.jrtt;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.lwby.marketing.notify.MobileNotify; import com.lwby.marketing.notify.MobileNotify;
import com.lwby.marketing.notify.media.jrtt.dto.JrttAttributeRequest; import com.lwby.marketing.notify.media.jrtt.dto.JrttAttributeRequest;
import com.lwby.marketing.util.HttpUtil;
import com.lwby.marketing.util.Signature;
import com.lwby.marketing.vo.ClientInfo; import com.lwby.marketing.vo.ClientInfo;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.NovelAction; import com.lwby.marketing.vo.NovelAction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Objects;
@Slf4j @Slf4j
public class VideoAppJRTTNotify extends MobileNotify { public class VideoAppJRTTNotify extends MobileNotify {
public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion"; public static final String ATTRIBUTE_URL = "https://analytics.oceanengine.com/api/v2/conversion";
public static final String uploadAndroidUrl = "https://www.csjplatform.com/growth_dispatcher/api/attribution_callback_self_built/276cbd93-aae4-9b66-68be-b086f7a419d1/android?pg_site_id=5385181&signature=";
public static final String uploadIosUrl = "https://www.csjplatform.com/growth_dispatcher/api/attribution_callback_self_built/155005fb-6940-4134-8729-f7eb9fb993d6/ios?pg_site_id=5443881&signature=";
@Override @Override
public boolean android(NovelAction na) { public boolean android(NovelAction na) {
return na.getType() == 0 ? android(na,"active") :android(na,"game_addiction"); return Objects.equals(na.getType(),0) ? android(na,"active") :android(na,"game_addiction");
} }
@Override @Override
public boolean ios(NovelAction na) { public boolean ios(NovelAction na) {
return na.getType() == 0 ? android(na,"active") :android(na,"game_addiction"); return Objects.equals(na.getType(),0) ? ios(na,"active") :ios(na,"game_addiction");
} }
public boolean android(NovelAction na,String eventType){ public boolean android(NovelAction na,String eventType){
...@@ -48,6 +62,9 @@ public class VideoAppJRTTNotify extends MobileNotify { ...@@ -48,6 +62,9 @@ public class VideoAppJRTTNotify extends MobileNotify {
// Integer resultCode = (Integer) JSON.parseObject(result).get("code"); // Integer resultCode = (Integer) JSON.parseObject(result).get("code");
// return resultCode == 0; // return resultCode == 0;
log.info("VideoAppJRTTNotify android Callback info:{}",userJson); log.info("VideoAppJRTTNotify android Callback info:{}",userJson);
//if (Objects.equals(na.getType(),0)) {
// sendAutoAttribute(ci,ddi,uploadAndroidUrl);
//}
return true; return true;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
...@@ -79,9 +96,96 @@ public class VideoAppJRTTNotify extends MobileNotify { ...@@ -79,9 +96,96 @@ public class VideoAppJRTTNotify extends MobileNotify {
// Integer resultCode = (Integer) JSON.parseObject(result).get("code"); // Integer resultCode = (Integer) JSON.parseObject(result).get("code");
// return resultCode == 0; // return resultCode == 0;
log.info("VideoAppJRTTNotify ios Callback info:{}",userJson); log.info("VideoAppJRTTNotify ios Callback info:{}",userJson);
//if (Objects.equals(na.getType(),0)) {
// sendAutoAttribute(ci,ddi,uploadIosUrl);
//}
return true; return true;
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
} }
private void sendAutoAttribute(ClientInfo clientInfo, DeliveryDeviceInfo deliveryDeviceInfo,String url) {
try {
String clientIp = clientInfo.getClientIp();
String ua = clientInfo.getUa();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("time_ts",System.currentTimeMillis());
map.put("ad_platform","toutiao_v2");
if ("0".equals(clientInfo.getOs())) {
if (StringUtils.isNotEmpty(clientInfo.getImei())) {
map.put("imei",clientInfo.getImei());
map.put("imei_md5",SecureUtil.md5(clientInfo.getImei()));
}
if (StringUtils.isNotEmpty(clientInfo.getOaid())) {
map.put("oaid",clientInfo.getOaid());
map.put("oaid_md5",SecureUtil.md5(clientInfo.getOaid()));
}
if (StringUtils.isNotEmpty(clientInfo.getDID())) {
map.put("android_id",clientInfo.getDID());
map.put("android_id_md5", SecureUtil.md5(clientInfo.getDID()));
}
} else if ("1".equals(clientInfo.getOs())){
if (StringUtils.isNotEmpty(clientInfo.getIdfa()) && !"00000000-0000-0000-0000-000000000000".equals(clientInfo.getIdfa())) {
map.put("idfa",clientInfo.getIdfa());
map.put("idfa_md5",SecureUtil.md5(clientInfo.getIdfa()));
} else {
map.put("idfa",clientInfo.getDID());
map.put("idfa_md5",SecureUtil.md5(clientInfo.getDID()));
}
if (StringUtils.isNotEmpty(clientIp) && StringUtils.isNotEmpty(ua)) {
map.put("ip",clientIp);
map.put("ua",ua);
}
}
map.put("ad_id",deliveryDeviceInfo.getPromotion_id());
map.put("ad_name",deliveryDeviceInfo.getPromotion_name());
map.put("campaign_id",deliveryDeviceInfo.getProject_id());
map.put("campaign_name",deliveryDeviceInfo.getProject_name());
map.put("ad_account_id",deliveryDeviceInfo.getAdvertiser_id());
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid1())) {
map.put("mid1",deliveryDeviceInfo.getMid1());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid2())) {
map.put("mid2",deliveryDeviceInfo.getMid2());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid3())) {
map.put("mid3",deliveryDeviceInfo.getMid3());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid4())) {
map.put("mid4",deliveryDeviceInfo.getMid4());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid5())) {
map.put("mid5",deliveryDeviceInfo.getMid5());
}
if (StringUtils.isNotBlank(deliveryDeviceInfo.getMid6())) {
map.put("mid6",deliveryDeviceInfo.getMid6());
}
String signature = Signature.getSignature(map);
String mapAction = JSONObject.toJSONString(map);
try {
String result = HttpUtil.post(url+signature, mapAction);
JSONObject bresp = (JSONObject) JSON.parseObject(result).get("base_resp");
Integer resultCode = (Integer) bresp.get("status");
if (resultCode == 0) {
log.info("JrttFreeVideoActiveImpl.sendAutoAttribute success, clientInfo = {}, deliveryDeviceInfo = {}",
JSON.toJSONString(clientInfo),JSON.toJSONString(deliveryDeviceInfo));
} else {
log.info("JrttFreeVideoActiveImpl.sendAutoAttribute fail, result={}, clientInfo = {} , deliveryDeviceInfo = {}",
result,JSON.toJSONString(clientInfo),JSON.toJSONString(deliveryDeviceInfo));
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (Throwable e) {
log.info("JrttFreeVideoActiveImpl.sendAutoAttribute error,clientInfo={}",JSON.toJSONString(clientInfo),e);
}
}
} }
...@@ -15,6 +15,22 @@ import java.io.*; ...@@ -15,6 +15,22 @@ import java.io.*;
*/ */
public class HttpUtil { public class HttpUtil {
public static String post (String url, String toJson) throws IOException {
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(url);
RequestEntity se = new StringRequestEntity(toJson ,"application/json" ,"UTF-8");
postMethod.setRequestEntity(se);
postMethod.setRequestHeader("Content-Type","application/json");
//默认的重试策略
postMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
postMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 5000);//设置超时时间
int httpStatus = httpClient.executeMethod(postMethod);
InputStream bodystreams = postMethod.getResponseBodyAsStream();
String body = convertStreamToString(bodystreams);
return body;
}
public static String postDy (String url, String toJson,String token) throws IOException { public static String postDy (String url, String toJson,String token) throws IOException {
HttpClient httpClient = new HttpClient(); HttpClient httpClient = new HttpClient();
......
package com.lwby.marketing.util;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
/**
* @author songxinyu
* @version Signature.java, v 0.1 2023年06月28日 11:28 songxinyu Exp $
*/
public class Signature {
private static final String apiKey = "436a49808b0ed157";
private static final String apiKeyIos = "1749844bed13f705";
public static String getSignature(Map<String, Object> data) {
TreeMap<String, Object> sorted = new TreeMap<>();
sorted.putAll(data);
String dataBeforeMD5 = "";
for(Map.Entry<String, Object> entry : sorted.entrySet()) {
if(!"".equals(entry.getValue())) {
dataBeforeMD5 += entry.getKey() + "=" + entry.getValue() + "&";
}
}
dataBeforeMD5 += "secretKey=" + apiKey;
String signature = DigestUtils.md5Hex(dataBeforeMD5.getBytes());
System.out.println(dataBeforeMD5);
return signature;
}
public static String getSignatureIos(Map<String, Object> data) {
TreeMap<String, Object> sorted = new TreeMap<>();
sorted.putAll(data);
String dataBeforeMD5 = "";
for(Map.Entry<String, Object> entry : sorted.entrySet()) {
if(!"".equals(entry.getValue())) {
dataBeforeMD5 += entry.getKey() + "=" + entry.getValue() + "&";
}
}
dataBeforeMD5 += "secretKey=" + apiKeyIos;
String signature = DigestUtils.md5Hex(dataBeforeMD5.getBytes());
System.out.println(dataBeforeMD5);
return signature;
}
public static void main(String[] args) {
Map<String, Object> data = new HashMap<>();
data.put("paramC", "c");
data.put("paramD", "");
data.put("paramE", "e");
data.put("paramA", "a");
data.put("paramB", "b");
System.out.println(data);
System.out.println(getSignature(data));
}
}
...@@ -57,4 +57,6 @@ public class AttributeRule implements Serializable { ...@@ -57,4 +57,6 @@ public class AttributeRule implements Serializable {
private String link; private String link;
private Integer callbackType;
} }
...@@ -122,4 +122,7 @@ public class DeliveryDeviceInfo { ...@@ -122,4 +122,7 @@ public class DeliveryDeviceInfo {
private String mid4; private String mid4;
private String mid5; private String mid5;
private String mid6; private String mid6;
private String openId;
} }
...@@ -29,6 +29,7 @@ public class StoryNovelAction extends Action { ...@@ -29,6 +29,7 @@ public class StoryNovelAction extends Action {
Media media; Media media;
String currentDateStr; String currentDateStr;
String goodId; String goodId;
Integer callbackTypeStory;
public StoryNovelAction(ClientInfo clientInfo, Long userId, String openId, Integer type){ public StoryNovelAction(ClientInfo clientInfo, Long userId, String openId, Integer type){
......
...@@ -22,7 +22,7 @@ spring: ...@@ -22,7 +22,7 @@ spring:
initialSize: 2 initialSize: 2
minIdle: 2 minIdle: 2
video-inland: video-inland:
jdbc-url: jdbc:mysql://rm-2zeo09186ukqa8zh1.mysql.rds.aliyuncs.com:3306/video-inland?zeroDateTimeBehavior=CONVERT_TO_NULL&characterEncoding=utf8&autoReconnect=true jdbc-url: jdbc:mysql://rm-2zeyw42052h06f905.mysql.rds.aliyuncs.com:3306/video-inland?zeroDateTimeBehavior=CONVERT_TO_NULL&characterEncoding=utf8&serverTimezone=Asia/Shanghai&autoReconnect=true
username: video username: video
password: hdTImXLlzOEbP5bk password: hdTImXLlzOEbP5bk
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
......
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