Commit 53bccf9e authored by 宋新宇's avatar 宋新宇

store归因上报

parent ee6e5323
...@@ -5,10 +5,8 @@ import com.lwby.marketing.flow.FlowExecutor; ...@@ -5,10 +5,8 @@ import com.lwby.marketing.flow.FlowExecutor;
import com.lwby.marketing.flow.Rule; import com.lwby.marketing.flow.Rule;
import com.lwby.marketing.vo.BookStoreEvent; import com.lwby.marketing.vo.BookStoreEvent;
import com.lwby.marketing.vo.NovelAction; import com.lwby.marketing.vo.NovelAction;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
...@@ -20,8 +18,8 @@ public class NovelAttributionMain { ...@@ -20,8 +18,8 @@ public class NovelAttributionMain {
ApplicationContext ctx; ApplicationContext ctx;
public FlowExecutor<NovelAction> executorNovel; public FlowExecutor<NovelAction> executorNovel;
public FlowExecutor<StoreNovelAction> executorStoreNovelActive; public FlowExecutor<StoryNovelAction> executorStoreNovelActive;
public FlowExecutor<StoreNovelAction> executorStoreNovelPay; public FlowExecutor<StoryNovelAction> executorStoreNovelPay;
@PostConstruct @PostConstruct
public void init() { public void init() {
......
package com.lwby.marketing.att.storenovel;
import com.alibaba.fastjson2.JSONObject;
import com.lwby.marketing.flow.FlowExecutor;
import com.lwby.marketing.flow.Rule;
import com.lwby.marketing.vo.BookStoreEvent;
import com.lwby.marketing.vo.NovelAction;
import com.lwby.marketing.vo.StoreNovelAction;
import com.lwby.marketing.vo.StoreUserUploadEventBO;
import org.springframework.context.ApplicationContext;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@Component
public class StoreNovelAttributionMain {
@Resource
ApplicationContext ctx;
public FlowExecutor<StoreNovelAction> executorStoreNovelActive;
@PostConstruct
public void init() {
executorStoreNovelActive = new FlowExecutor<>(ctx, Rule.create().THEN("setupStoreNovel").THEN("storeNovelStore").THEN("checkerNovelStorefirst").THEN("uploadcall"));
}
public void test(){
String msg = "{\"clientInfo\":{\"channel\":214120503,\"clientIp\":\"183.219.7.180\",\"pkv\":1,\"platformGroupId\":412,"
+ "\"platformId\":412,\"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 "
+ "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\","
+ "\"userId\":875325,\"userUploadEvent\":0,\"appId\":\"ttd3dda5604ce230b401\","
+ "\"openId\":\"_000HgDjWl-P5-WS9HTQIssNgTnMBRUqDHDu\"}";
StoreUserUploadEventBO event = JSONObject.parseObject(msg, StoreUserUploadEventBO.class);
StoreNovelAction action = new StoreNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent());
try {
executorStoreNovelActive.execute(action);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
// @KafkaListener(topics = "registerMediaEvent1", groupId = "test")
// public void listen(String message) {
// System.out.println("Received Message: " + message);
//
// BookStoreEvent event = JSONObject.parseObject(message, BookStoreEvent.class);
// NovelAction action = new NovelAction(event.getClientInfo(),message);
//
// try {
// executorNovel.execute(action);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
}
package com.lwby.marketing.att.storenovel; package com.lwby.marketing.att.storynovel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.lwby.marketing.att.NovelAttributionMain; import com.lwby.marketing.att.NovelAttributionMain;
import com.lwby.marketing.vo.BookStoreEvent; import com.lwby.marketing.vo.StoryNovelAction;
import com.lwby.marketing.vo.NovelAction;
import com.lwby.marketing.vo.StoreNovelAction;
import com.lwby.marketing.vo.StoreUserUploadEventBO; import com.lwby.marketing.vo.StoreUserUploadEventBO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
...@@ -20,7 +18,7 @@ import org.springframework.stereotype.Component; ...@@ -20,7 +18,7 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
public class StoreNovelActiveConsumer implements MessageListener<String, String> { public class StoryNovelActiveConsumer implements MessageListener<String, String> {
@Autowired @Autowired
NovelAttributionMain novelAttributionMain; NovelAttributionMain novelAttributionMain;
...@@ -41,7 +39,7 @@ public class StoreNovelActiveConsumer implements MessageListener<String, String> ...@@ -41,7 +39,7 @@ public class StoreNovelActiveConsumer implements MessageListener<String, String>
log.info("media.active.topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event)); log.info("media.active.topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event));
} }
StoreNovelAction action = new StoreNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent()); StoryNovelAction action = new StoryNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent());
novelAttributionMain.executorStoreNovelActive.execute(action); novelAttributionMain.executorStoreNovelActive.execute(action);
} catch (Throwable e) { } catch (Throwable e) {
......
package com.lwby.marketing.att.storenovel; package com.lwby.marketing.att.storynovel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.lwby.marketing.att.NovelAttributionMain; import com.lwby.marketing.att.NovelAttributionMain;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import com.lwby.marketing.vo.StoreUserUploadEventBO; import com.lwby.marketing.vo.StoreUserUploadEventBO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
...@@ -18,12 +18,12 @@ import org.springframework.stereotype.Component; ...@@ -18,12 +18,12 @@ import org.springframework.stereotype.Component;
*/ */
@Slf4j @Slf4j
@Component @Component
public class StoreNovelPayConsumer implements MessageListener<String, String> { public class StoryNovelPayConsumer implements MessageListener<String, String> {
@Autowired @Autowired
NovelAttributionMain novelAttributionMain; NovelAttributionMain novelAttributionMain;
@KafkaListener(topics = {"${store.novel.pay.consumer.topic:testStoreNovelpay}"},groupId = "${store.novel.pay.consumer.group.id:test_store_dy_pay}") @KafkaListener(topics = {"${story.novel.pay.consumer.topic:testStoryNovelpay}"},groupId = "${story.novel.pay.consumer.group.id:test_story_dy_pay}")
@Override @Override
public void onMessage(ConsumerRecord<String, String> data) { public void onMessage(ConsumerRecord<String, String> data) {
...@@ -39,7 +39,7 @@ public class StoreNovelPayConsumer implements MessageListener<String, String> { ...@@ -39,7 +39,7 @@ public class StoreNovelPayConsumer implements MessageListener<String, String> {
log.info("media.active.topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event)); log.info("media.active.topic={}, bookStoreEvent={}", data.topic(), JSON.toJSONString(event));
} }
StoreNovelAction action = new StoreNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent(),event.getProductId()); StoryNovelAction action = new StoryNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent(),event.getProductId());
novelAttributionMain.executorStoreNovelPay.execute(action); novelAttributionMain.executorStoreNovelPay.execute(action);
} catch (Throwable e) { } catch (Throwable e) {
......
package com.lwby.marketing.att.storenovel; package com.lwby.marketing.att.storynovel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -8,10 +8,8 @@ import com.alicp.jetcache.anno.Cached; ...@@ -8,10 +8,8 @@ import com.alicp.jetcache.anno.Cached;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.lwby.marketing.att.novel.AttributionStatus; import com.lwby.marketing.att.novel.AttributionStatus;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.po.AppChannel;
import com.lwby.marketing.vo.AttributeRule;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
...@@ -27,7 +25,7 @@ import java.util.concurrent.TimeUnit; ...@@ -27,7 +25,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j @Slf4j
@Component @Component
public class UniversalStoreProcess { public class UniversalStoryProcess {
@Resource @Resource
JdbcTemplate lwbyJdbcTemplate; JdbcTemplate lwbyJdbcTemplate;
...@@ -43,7 +41,7 @@ public class UniversalStoreProcess { ...@@ -43,7 +41,7 @@ public class UniversalStoreProcess {
/** /**
* 通知处理结果 * 通知处理结果
*/ */
public void notifyResult(StoreNovelAction action, AttributionStatus status) { public void notifyResult(StoryNovelAction action, AttributionStatus status) {
DeliveryDeviceInfo ddi = action.getDeliveryDeviceInfo(); DeliveryDeviceInfo ddi = action.getDeliveryDeviceInfo();
if (Objects.isNull(ddi)) { if (Objects.isNull(ddi)) {
...@@ -79,7 +77,7 @@ public class UniversalStoreProcess { ...@@ -79,7 +77,7 @@ public class UniversalStoreProcess {
return String.format("%s_callback_%d_%d_%s_%d_%s", attributionType, platformId, channelOrPlanId,goodsId, sprDedu, dateStr); return String.format("%s_callback_%d_%d_%s_%d_%s", attributionType, platformId, channelOrPlanId,goodsId, sprDedu, dateStr);
} }
public String getFirstCheckerKey(StoreNovelAction action) { public String getFirstCheckerKey(StoryNovelAction action) {
return Objects.equals(action.getType(),0) return Objects.equals(action.getType(),0)
? 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());
......
package com.lwby.marketing.att.storenovel.handle; package com.lwby.marketing.att.storynovel.handle;
import com.lwby.marketing.att.novel.UniversalProcess; import com.lwby.marketing.att.storynovel.UniversalStoryProcess;
import com.lwby.marketing.att.storenovel.UniversalStoreProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.NovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import com.lwby.marketing.vo.StoreNovelAction;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@Component("checkerNovelStorefirst") @Component("checkerNovelStorefirst")
public class CheckerNovelStoreFirstFlow extends NodeFlow<StoreNovelAction> { public class CheckerNovelStoryFirstFlow extends NodeFlow<StoryNovelAction> {
@Resource @Resource
UniversalStoreProcess up; UniversalStoryProcess up;
@Override @Override
public void process(StoreNovelAction action) { public void process(StoryNovelAction action) {
if(up.exists(up.getFirstCheckerKey(action))){ if(up.exists(up.getFirstCheckerKey(action))){
action.stop(true); action.stop(true);
} }
......
package com.lwby.marketing.att.storenovel.handle; package com.lwby.marketing.att.storynovel.handle;
import cn.hutool.crypto.SecureUtil;
import com.lwby.marketing.att.novel.DeviceType;
import com.lwby.marketing.att.novel.UniversalProcess; import com.lwby.marketing.att.novel.UniversalProcess;
import com.lwby.marketing.att.novel.media.Media; import com.lwby.marketing.att.storynovel.media.StoryMedia;
import com.lwby.marketing.att.storenovel.media.StoreMedia;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.po.StoryLogin; import com.lwby.marketing.po.StoryLogin;
import com.lwby.marketing.util.DateTimUtils; import com.lwby.marketing.util.DateTimUtils;
...@@ -19,12 +16,12 @@ import java.util.UUID; ...@@ -19,12 +16,12 @@ import java.util.UUID;
@Slf4j @Slf4j
@Component("setupStoreNovel") @Component("setupStoreNovel")
public class ParameterSetupStoreNovelFlow extends NodeFlow<StoreNovelAction> { public class ParameterSetupStoryNovelFlow extends NodeFlow<StoryNovelAction> {
@Resource @Resource
UniversalProcess up; UniversalProcess up;
@Override @Override
public void process(StoreNovelAction action) { public void process(StoryNovelAction action) {
ClientInfo clientInfo = action.getClientInfo(); ClientInfo clientInfo = action.getClientInfo();
String openId = action.getOpenId(); String openId = action.getOpenId();
...@@ -57,7 +54,7 @@ public class ParameterSetupStoreNovelFlow extends NodeFlow<StoreNovelAction> { ...@@ -57,7 +54,7 @@ public class ParameterSetupStoreNovelFlow extends NodeFlow<StoreNovelAction> {
action.setChannelId(NumberUtils.parseInteger(storyLogin.getChannel())); action.setChannelId(NumberUtils.parseInteger(storyLogin.getChannel()));
action.setPlanId(NumberUtils.parseInteger((storyLogin.getAdid()))); action.setPlanId(NumberUtils.parseInteger((storyLogin.getAdid())));
action.setMediaName(storyLogin.getMedia()); action.setMediaName(storyLogin.getMedia());
action.setMedia(StoreMedia.getMedia(action.getMediaName())); action.setMedia(StoryMedia.getMedia(action.getMediaName()));
} }
} }
......
package com.lwby.marketing.att.storenovel.handle; package com.lwby.marketing.att.storynovel.handle;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.lwby.marketing.att.novel.AttributionStatus; import com.lwby.marketing.att.novel.AttributionStatus;
import com.lwby.marketing.att.novel.AttributionType; import com.lwby.marketing.att.novel.AttributionType;
import com.lwby.marketing.att.storenovel.UniversalStoreProcess; import com.lwby.marketing.att.storynovel.UniversalStoryProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.AttributeRule; import com.lwby.marketing.vo.StoryNovelAction;
import com.lwby.marketing.vo.StoreNovelAction;
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.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -23,17 +22,17 @@ import java.util.concurrent.ThreadLocalRandom; ...@@ -23,17 +22,17 @@ import java.util.concurrent.ThreadLocalRandom;
*/ */
@Slf4j @Slf4j
@Component("payspdu") @Component("payspdu")
public class PaySpduFlow extends NodeFlow<StoreNovelAction> { public class PaySpduFlow extends NodeFlow<StoryNovelAction> {
@Resource @Resource
UniversalStoreProcess up; UniversalStoryProcess up;
@Override @Override
public void process(StoreNovelAction action) { public void process(StoryNovelAction action) {
process0(action, AttributionType.CHANNEL); process0(action, AttributionType.CHANNEL);
} }
public void process0(StoreNovelAction action,AttributionType type) { public void process0(StoryNovelAction action, AttributionType type) {
int platformId = action.getPlatformId(); int platformId = action.getPlatformId();
int channelId = action.getChannelId(); int channelId = action.getChannelId();
......
package com.lwby.marketing.att.storenovel.handle; package com.lwby.marketing.att.storynovel.handle;
import com.lwby.marketing.att.novel.AttributionStatus; import com.lwby.marketing.att.novel.AttributionStatus;
import com.lwby.marketing.att.novel.DeviceType; import com.lwby.marketing.att.storynovel.UniversalStoryProcess;
import com.lwby.marketing.att.novel.UniversalProcess;
import com.lwby.marketing.att.storenovel.UniversalStoreProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.StoreNovelAction; 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; import java.util.Objects;
@Component("storeNovelStore") @Component("storeNovelStore")
public class StoreNovelStoreAttributionFlow extends NodeFlow<StoreNovelAction> { public class StoreNovelStoryAttributionFlow extends NodeFlow<StoryNovelAction> {
@Resource @Resource
UniversalStoreProcess up; UniversalStoryProcess up;
@Override @Override
public void process(StoreNovelAction action) { public void process(StoryNovelAction action) {
//商店归因通知 //商店归因通知
if(Objects.isNull(action.getDeliveryDeviceInfo())){ if(Objects.isNull(action.getDeliveryDeviceInfo())){
up.notifyResult(action, AttributionStatus.STORE_CALLBACK); up.notifyResult(action, AttributionStatus.STORE_CALLBACK);
......
package com.lwby.marketing.att.storenovel.handle; package com.lwby.marketing.att.storynovel.handle;
import com.lwby.marketing.att.novel.AttributionStatus; import com.lwby.marketing.att.novel.AttributionStatus;
import com.lwby.marketing.att.storenovel.UniversalStoreProcess; import com.lwby.marketing.att.storynovel.UniversalStoryProcess;
import com.lwby.marketing.flow.NodeFlow; import com.lwby.marketing.flow.NodeFlow;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -13,13 +13,13 @@ import javax.annotation.Resource; ...@@ -13,13 +13,13 @@ import javax.annotation.Resource;
* @version ActiveCallFlow.java, v 0.1 2024年03月04日 18:28 songxinyu Exp $ * @version ActiveCallFlow.java, v 0.1 2024年03月04日 18:28 songxinyu Exp $
*/ */
@Component("uploadcall") @Component("uploadcall")
public class UploadCallFlow extends NodeFlow<StoreNovelAction> { public class UploadCallFlow extends NodeFlow<StoryNovelAction> {
@Resource @Resource
UniversalStoreProcess up; UniversalStoryProcess up;
@Override @Override
public void process(StoreNovelAction action) { public void process(StoryNovelAction action) {
action.getMedia().callback(action); action.getMedia().callback(action);
up.notifyResult(action, AttributionStatus.ACTIVE_CALLBACK); up.notifyResult(action, AttributionStatus.ACTIVE_CALLBACK);
up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1"); //每天扣量过一次,不在重复走 up.set(up.getFirstCheckerKey(action),60 * 60 * 24,"1"); //每天扣量过一次,不在重复走
......
package com.lwby.marketing.att.storenovel.media; package com.lwby.marketing.att.storynovel.media;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
/** /**
* @author songxinyu * @author songxinyu
* @version BaseStoreCallback.java, v 0.1 2024年03月04日 17:19 songxinyu Exp $ * @version BaseStoreCallback.java, v 0.1 2024年03月04日 17:19 songxinyu Exp $
*/ */
public abstract class BaseStoreCallback implements IStoreCallback { public abstract class BaseStoryCallback implements IStoryCallback {
@Override @Override
public boolean delivery(StoreNovelAction action) { public boolean delivery(StoryNovelAction action) {
return call(action); return call(action);
} }
public abstract boolean call(StoreNovelAction na); public abstract boolean call(StoryNovelAction na);
} }
package com.lwby.marketing.att.storenovel.media; package com.lwby.marketing.att.storynovel.media;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
/** /**
* @author songxinyu * @author songxinyu
* @version IStoreCallback.java, v 0.1 2024年03月04日 17:16 songxinyu Exp $ * @version IStoreCallback.java, v 0.1 2024年03月04日 17:16 songxinyu Exp $
*/ */
public interface IStoreCallback { public interface IStoryCallback {
boolean delivery(StoreNovelAction action); boolean delivery(StoryNovelAction action);
} }
package com.lwby.marketing.att.storenovel.media; package com.lwby.marketing.att.storynovel.media;
import com.lwby.marketing.att.storenovel.media.jrtt.JRTTActiveCallback; import com.lwby.marketing.att.storynovel.media.jrtt.JRTTActiveCallback;
import com.lwby.marketing.att.storenovel.media.jrtt.JRTTPayCallback; import com.lwby.marketing.att.storynovel.media.jrtt.JRTTPayCallback;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public enum StoreMedia { public enum StoryMedia {
JRTT("jrtt","今日头条",(c)-> c == 0 ? new JRTTActiveCallback() : new JRTTPayCallback()); JRTT("jrtt","今日头条",(c)-> c == 0 ? new JRTTActiveCallback() : new JRTTPayCallback());
final String name; final String name;
final String desc; final String desc;
final Function<Integer, IStoreCallback> fun; final Function<Integer, IStoryCallback> fun;
final static Map<String, StoreMedia> mediaMap = Arrays.stream(StoreMedia.values()) final static Map<String, StoryMedia> mediaMap = Arrays.stream(StoryMedia.values())
.collect(Collectors.toMap(StoreMedia::name, Function.identity())); .collect(Collectors.toMap(StoryMedia::name, Function.identity()));
StoreMedia(String name, String desc, Function<Integer,IStoreCallback> fun){ StoryMedia(String name, String desc, Function<Integer, IStoryCallback> fun){
this.name = name; this.name = name;
this.desc = desc; this.desc = desc;
this.fun = fun; this.fun = fun;
} }
public boolean callback(StoreNovelAction action){ public boolean callback(StoryNovelAction action){
return fun.apply(action.getType()).delivery(action); return fun.apply(action.getType()).delivery(action);
} }
public static StoreMedia getMedia(String mediaName){ public static StoryMedia getMedia(String mediaName){
return mediaMap.get(mediaName); return mediaMap.get(mediaName);
} }
} }
\ No newline at end of file
package com.lwby.marketing.att.storenovel.media.jrtt; package com.lwby.marketing.att.storynovel.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.novel.media.jrtt.dto.JrttAttributeRequest; import com.lwby.marketing.att.novel.media.jrtt.dto.JrttAttributeRequest;
import com.lwby.marketing.att.storenovel.media.BaseStoreCallback; import com.lwby.marketing.att.storynovel.media.BaseStoryCallback;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
/** /**
* @author songxinyu * @author songxinyu
* @version JRTTActiveCallback.java, v 0.1 2024年03月04日 17:24 songxinyu Exp $ * @version JRTTActiveCallback.java, v 0.1 2024年03月04日 17:24 songxinyu Exp $
*/ */
public class JRTTActiveCallback extends BaseStoreCallback { public class JRTTActiveCallback extends BaseStoryCallback {
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";
@Override @Override
public boolean call(StoreNovelAction na) { public boolean call(StoryNovelAction na) {
DeliveryDeviceInfo ddi = na.getDeliveryDeviceInfo(); DeliveryDeviceInfo ddi = na.getDeliveryDeviceInfo();
JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad(); JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad();
......
package com.lwby.marketing.att.storenovel.media.jrtt; package com.lwby.marketing.att.storynovel.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.novel.media.jrtt.dto.JrttAttributeRequest; import com.lwby.marketing.att.novel.media.jrtt.dto.JrttAttributeRequest;
import com.lwby.marketing.att.storenovel.media.BaseStoreCallback; import com.lwby.marketing.att.storynovel.media.BaseStoryCallback;
import com.lwby.marketing.vo.DeliveryDeviceInfo; import com.lwby.marketing.vo.DeliveryDeviceInfo;
import com.lwby.marketing.vo.StoreNovelAction; import com.lwby.marketing.vo.StoryNovelAction;
/** /**
* @author songxinyu * @author songxinyu
* @version JRTTPayCallback.java, v 0.1 2024年03月04日 17:25 songxinyu Exp $ * @version JRTTPayCallback.java, v 0.1 2024年03月04日 17:25 songxinyu Exp $
*/ */
public class JRTTPayCallback extends BaseStoreCallback { public class JRTTPayCallback extends BaseStoryCallback {
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";
@Override @Override
public boolean call(StoreNovelAction na) { public boolean call(StoryNovelAction na) {
DeliveryDeviceInfo ddi = na.getDeliveryDeviceInfo(); DeliveryDeviceInfo ddi = na.getDeliveryDeviceInfo();
JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad(); JrttAttributeRequest.Ad ad = new JrttAttributeRequest.Ad();
......
package com.lwby.marketing.att.storenovel.media.jrtt.dto; package com.lwby.marketing.att.storynovel.media.jrtt.dto;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
......
...@@ -3,9 +3,8 @@ package com.lwby.marketing.controller; ...@@ -3,9 +3,8 @@ package com.lwby.marketing.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.lwby.marketing.att.NovelAttributionMain; import com.lwby.marketing.att.NovelAttributionMain;
import com.lwby.marketing.att.storenovel.UniversalStoreProcess; import com.lwby.marketing.att.storynovel.UniversalStoryProcess;
import com.lwby.marketing.vo.AttributeRule; import com.lwby.marketing.vo.StoryNovelAction;
import com.lwby.marketing.vo.StoreNovelAction;
import com.lwby.marketing.vo.StoreUserUploadEventBO; import com.lwby.marketing.vo.StoreUserUploadEventBO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,7 +37,7 @@ public class AttrController { ...@@ -38,7 +37,7 @@ public class AttrController {
+ "\"openId\":\"_000HgDjWl-P5-WS9HTQIssNgTnMBRUqDHDu\"}"; + "\"openId\":\"_000HgDjWl-P5-WS9HTQIssNgTnMBRUqDHDu\"}";
StoreUserUploadEventBO event = JSONObject.parseObject(msg, StoreUserUploadEventBO.class); StoreUserUploadEventBO event = JSONObject.parseObject(msg, StoreUserUploadEventBO.class);
StoreNovelAction action = new StoreNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent()); StoryNovelAction action = new StoryNovelAction(event.getClientInfo(),event.getUserId(),event.getOpenId(),event.getUserUploadEvent());
try { try {
nm.executorStoreNovelActive.execute(action); nm.executorStoreNovelActive.execute(action);
...@@ -48,7 +47,7 @@ public class AttrController { ...@@ -48,7 +47,7 @@ public class AttrController {
} }
@Resource @Resource
UniversalStoreProcess up; UniversalStoryProcess up;
@RequestMapping("dedu") @RequestMapping("dedu")
public void testDedu() { public void testDedu() {
......
package com.lwby.marketing.vo; package com.lwby.marketing.vo;
import com.lwby.marketing.att.novel.media.Media; import com.lwby.marketing.att.storynovel.media.StoryMedia;
import com.lwby.marketing.att.storenovel.media.StoreMedia;
import com.lwby.marketing.flow.Action; import com.lwby.marketing.flow.Action;
import com.lwby.marketing.po.StoryLogin; import com.lwby.marketing.po.StoryLogin;
import lombok.Data; import lombok.Data;
...@@ -11,7 +10,7 @@ import lombok.Data; ...@@ -11,7 +10,7 @@ import lombok.Data;
* @version StoreNovelAction.java, v 0.1 2024年03月04日 15:44 songxinyu Exp $ * @version StoreNovelAction.java, v 0.1 2024年03月04日 15:44 songxinyu Exp $
*/ */
@Data @Data
public class StoreNovelAction extends Action { public class StoryNovelAction extends Action {
ClientInfo clientInfo; ClientInfo clientInfo;
StoryLogin storyLogin; StoryLogin storyLogin;
...@@ -23,24 +22,24 @@ public class StoreNovelAction extends Action { ...@@ -23,24 +22,24 @@ public class StoreNovelAction extends Action {
int planId; int planId;
String mediaName; String mediaName;
Integer type; Integer type;
StoreMedia media; StoryMedia media;
String currentDateStr; String currentDateStr;
String goodId; String goodId;
public StoreNovelAction(ClientInfo clientInfo,Long userId,String openId,Integer type){ public StoryNovelAction(ClientInfo clientInfo, Long userId, String openId, Integer type){
this(clientInfo,null,userId,openId,type); this(clientInfo,null,userId,openId,type);
} }
public StoreNovelAction(ClientInfo clientInfo,Long userId,String openId,Integer type,String goodId){ public StoryNovelAction(ClientInfo clientInfo, Long userId, String openId, Integer type, String goodId){
this(clientInfo,null,userId,openId,type,goodId); this(clientInfo,null,userId,openId,type,goodId);
} }
public StoreNovelAction(ClientInfo clientInfo, DeliveryDeviceInfo deliveryDeviceInfo,Long userId,String openId,Integer type){ public StoryNovelAction(ClientInfo clientInfo, DeliveryDeviceInfo deliveryDeviceInfo, Long userId, String openId, Integer type){
this(clientInfo,null,userId,openId,type,null); this(clientInfo,null,userId,openId,type,null);
} }
public StoreNovelAction(ClientInfo clientInfo, DeliveryDeviceInfo deliveryDeviceInfo,Long userId,String openId,Integer type,String goodId){ public StoryNovelAction(ClientInfo clientInfo, DeliveryDeviceInfo deliveryDeviceInfo, Long userId, String openId, Integer type, String goodId){
this.clientInfo = clientInfo; this.clientInfo = clientInfo;
this.deliveryDeviceInfo = deliveryDeviceInfo; this.deliveryDeviceInfo = deliveryDeviceInfo;
this.userId = userId; this.userId = 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