Commit 46d6ffd9 authored by 宋新宇's avatar 宋新宇

store归因上报redis

parent 9c1d04eb
...@@ -32,6 +32,9 @@ public class UniversalProcess { ...@@ -32,6 +32,9 @@ public class UniversalProcess {
@Resource @Resource
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
@Resource
private RedisTemplate<String,String> biRedisTemplate;
/******************************************** GENERIC METHOD ***********************************************/ /******************************************** GENERIC METHOD ***********************************************/
...@@ -82,9 +85,16 @@ public class UniversalProcess { ...@@ -82,9 +85,16 @@ public class UniversalProcess {
return String.format("fc_%s_%d_%s_%s", action.getDeviceId(), action.getPlatformId(),action.getMediaName(),action.getCurrentDateStr()); return String.format("fc_%s_%d_%s_%s", action.getDeviceId(), action.getPlatformId(),action.getMediaName(),action.getCurrentDateStr());
} }
public String buildKey(Integer platformId,String deviceId) {
return String.format("market:activeness:30:%d:%s",platformId,deviceId);
}
/******************************************** REDIS **********************************************************/ /******************************************** REDIS **********************************************************/
public boolean existsIsAlive(String key) {
return Boolean.TRUE.equals(biRedisTemplate.hasKey(key));
}
public boolean exists(String key) { public boolean exists(String key) {
return Boolean.TRUE.equals(redisTemplate.hasKey(key)); return Boolean.TRUE.equals(redisTemplate.hasKey(key));
} }
......
...@@ -19,7 +19,11 @@ public class StoreAttributionFlow extends NodeFlow<NovelAction> { ...@@ -19,7 +19,11 @@ public class StoreAttributionFlow extends NodeFlow<NovelAction> {
public void process(NovelAction action) { public void process(NovelAction action) {
//商店归因通知 //商店归因通知
if(Objects.isNull(action.getDeliveryDeviceInfo())){ if(Objects.isNull(action.getDeliveryDeviceInfo())){
up.notifyResult(action, AttributionStatus.STORE_CALLBACK); //商店判断30天活跃,不在活跃天数内,发BI
String aliveDeviceKey = up.buildKey(action.getPlatformId(), action.getDeviceId());
if (!up.existsIsAlive(aliveDeviceKey)) {
up.notifyResult(action, AttributionStatus.STORE_CALLBACK);
}
action.stop(true); //结束后面所有执行流程 action.stop(true); //结束后面所有执行流程
} }
......
package com.lwby.marketing.conf;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* @author songxinyu
* @version BiRedisConfig.java, v 0.1 2024年03月07日 11:32 songxinyu Exp $
*/
@Configuration
public class BiRedisConfig {
@Value("${bi.redis.host}")
private String biHostName;
@Value("${bi.redis.port}")
private int biHostPort;
@Bean("biJedisFactory")
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
config.setHostName(biHostName);
config.setPort(biHostPort);
return new JedisConnectionFactory(config);
}
@Bean("biRedisTemplate")
public RedisTemplate<Object, Object> redisTemplate(@Qualifier("biJedisFactory") RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(stringRedisSerializer);
template.setConnectionFactory(redisConnectionFactory);
return template;
}
}
package com.lwby.marketing.conf; package com.lwby.marketing.conf;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration @Configuration
public class RedisConfig { public class RedisConfig {
@Bean @Value("${spring.redis.host}")
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { private String hostName;
@Value("${spring.redis.port}")
private int hostPort;
@Bean("jedisFactory")
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
config.setHostName(hostName);
config.setPort(hostPort);
return new JedisConnectionFactory(config);
}
@Bean("redisTemplate")
public RedisTemplate<Object, Object> redisTemplate(@Qualifier("jedisFactory") RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>(); RedisTemplate<Object, Object> template = new RedisTemplate<>();
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
template.setKeySerializer(stringRedisSerializer); template.setKeySerializer(stringRedisSerializer);
......
...@@ -33,6 +33,11 @@ spring: ...@@ -33,6 +33,11 @@ spring:
listener: listener:
ack-mode: RECORD ack-mode: RECORD
bi:
redis:
host: r-2zethzp7pjl3rjbelp.redis.rds.aliyuncs.com
port: 6379
story: story:
novel: novel:
active: active:
......
...@@ -33,6 +33,11 @@ spring: ...@@ -33,6 +33,11 @@ spring:
listener: listener:
ack-mode: RECORD ack-mode: RECORD
bi:
redis:
host: 172.17.243.150
port: 6379
story: story:
novel: novel:
active: active:
......
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