Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
marketing
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dingjy
marketing
Commits
21b6036c
Commit
21b6036c
authored
Apr 11, 2024
by
宋新宇
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '8-抖小更改' into 'release_20240411'
抖小更改及监测 See merge request
!44
parents
ccfedbac
5d65517d
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
970 additions
and
145 deletions
+970
-145
UniversalProcess.java
src/main/java/com/lwby/marketing/att/UniversalProcess.java
+3
-1
DyVideoUniversalProcess.java
...m/lwby/marketing/att/dyvideo/DyVideoUniversalProcess.java
+136
-3
CheckerDyVideoFirstFlow.java
...marketing/att/dyvideo/handle/CheckerDyVideoFirstFlow.java
+1
-1
DyvideoBehaviorFlow.java
...wby/marketing/att/dyvideo/handle/DyvideoBehaviorFlow.java
+155
-124
StoreDyVideoAttributionFlow.java
...eting/att/dyvideo/handle/StoreDyVideoAttributionFlow.java
+1
-1
UploadDyVideoCallFlow.java
...y/marketing/att/dyvideo/handle/UploadDyVideoCallFlow.java
+6
-1
DyVideoActiveKafkaConsumerConfig.java
...arketing/conf/kafka/DyVideoActiveKafkaConsumerConfig.java
+4
-4
DyVideoBehavoirKafkaConsumerConfig.java
...keting/conf/kafka/DyVideoBehavoirKafkaConsumerConfig.java
+4
-4
DyVideoController.java
...java/com/lwby/marketing/controller/DyVideoController.java
+87
-0
MediaClickController.java
...a/com/lwby/marketing/controller/MediaClickController.java
+47
-0
MediaClickFactory.java
...in/java/com/lwby/marketing/factory/MediaClickFactory.java
+51
-0
Media.java
src/main/java/com/lwby/marketing/notify/Media.java
+1
-1
DyVideoJRTTNotify.java
...m/lwby/marketing/notify/media/jrtt/DyVideoJRTTNotify.java
+3
-5
DyVideoUpload.java
src/main/java/com/lwby/marketing/po/DyVideoUpload.java
+15
-0
VideoUpload.java
src/main/java/com/lwby/marketing/po/VideoUpload.java
+5
-0
MediaClick.java
src/main/java/com/lwby/marketing/service/MediaClick.java
+16
-0
JrttClickImpl.java
...n/java/com/lwby/marketing/service/impl/JrttClickImpl.java
+321
-0
CacheKeyUtils.java
src/main/java/com/lwby/marketing/util/CacheKeyUtils.java
+50
-0
DateTimUtils.java
src/main/java/com/lwby/marketing/util/DateTimUtils.java
+8
-0
ResultConstant.java
src/main/java/com/lwby/marketing/util/ResultConstant.java
+14
-0
Stats.java
src/main/java/com/lwby/marketing/util/Stats.java
+42
-0
No files found.
src/main/java/com/lwby/marketing/att/UniversalProcess.java
View file @
21b6036c
...
@@ -78,7 +78,9 @@ public class UniversalProcess {
...
@@ -78,7 +78,9 @@ public class UniversalProcess {
public
long
incrby
(
String
key
,
int
increment
)
{
public
long
incrby
(
String
key
,
int
increment
)
{
return
redisTemplate
.
opsForValue
().
increment
(
key
,
increment
);
return
redisTemplate
.
opsForValue
().
increment
(
key
,
increment
);
}
}
public
void
del
(
String
key
)
{
redisTemplate
.
delete
(
key
);
}
/******************************************** INNER CLASS ******************************************************/
/******************************************** INNER CLASS ******************************************************/
...
...
src/main/java/com/lwby/marketing/att/dyvideo/DyVideoUniversalProcess.java
View file @
21b6036c
This diff is collapsed.
Click to expand it.
src/main/java/com/lwby/marketing/att/dyvideo/handle/CheckerDyVideoFirstFlow.java
View file @
21b6036c
...
@@ -14,7 +14,7 @@ public class CheckerDyVideoFirstFlow extends NodeFlow<StoryNovelAction> {
...
@@ -14,7 +14,7 @@ public class CheckerDyVideoFirstFlow extends NodeFlow<StoryNovelAction> {
@Override
@Override
public
void
process
(
StoryNovelAction
action
)
{
public
void
process
(
StoryNovelAction
action
)
{
if
(
up
.
exists
(
up
.
getFirstCheckerKey
(
action
))){
if
(
up
.
exists
(
up
.
getFirstCheckerKey
(
action
))
&&
!
"lotto"
.
equals
(
action
.
getVideoUpload
().
getSource
())
){
action
.
stop
(
true
);
action
.
stop
(
true
);
}
}
}
}
...
...
src/main/java/com/lwby/marketing/att/dyvideo/handle/DyvideoBehaviorFlow.java
View file @
21b6036c
package
com
.
lwby
.
marketing
.
att
.
dyvideo
.
handle
;
package
com
.
lwby
.
marketing
.
att
.
dyvideo
.
handle
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.lwby.marketing.att.AttributionStatus
;
import
com.lwby.marketing.att.AttributionStatus
;
import
com.lwby.marketing.att.BehavoirType
;
import
com.lwby.marketing.att.BehavoirType
;
...
@@ -63,23 +64,11 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
...
@@ -63,23 +64,11 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
public
void
process
(
StoryNovelAction
action
)
{
public
void
process
(
StoryNovelAction
action
)
{
VideoUpload
videoUpload
=
action
.
getVideoUpload
();
VideoUpload
videoUpload
=
action
.
getVideoUpload
();
long
userId
=
action
.
getUserId
();
long
userId
=
action
.
getUserId
();
int
platformId
=
action
.
getPlatformId
();
Long
channelId
=
action
.
getChannelId
();
long
activeTime
=
videoUpload
.
getActiveTime
();
long
activeTime
=
videoUpload
.
getActiveTime
();
long
currentTime
=
System
.
currentTimeMillis
();
long
currentTime
=
System
.
currentTimeMillis
();
DeliveryDeviceInfo
deliveryDeviceInfo
=
action
.
getDeliveryDeviceInfo
();
DeliveryDeviceInfo
deliveryDeviceInfo
=
action
.
getDeliveryDeviceInfo
();
long
hour
=
TimeUnit
.
MILLISECONDS
.
toHours
(
currentTime
-
activeTime
);
if
(
hour
>
6
)
{
DYVIDEO_SYS_LOG
.
info
(
"DyvideoBehaviorFlow expeed six hour ,videoUpload={},userId={}"
,
JSON
.
toJSONString
(
videoUpload
),
userId
);
return
;
}
int
platformId
=
action
.
getPlatformId
();
Long
channelId
=
action
.
getChannelId
();
AppChannelVO
appChannel
=
up
.
getAppChannelByPlatformAndChannel
(
platformId
,
channelId
);
//处理关键行为上报
String
openId
=
action
.
getOpenId
();
JSONObject
dyMarketPlatformAppIdJson
=
JSON
.
parseObject
(
JSONObject
dyMarketPlatformAppIdJson
=
JSON
.
parseObject
(
"{\n"
"{\n"
+
" \"400\": \"ttf2f6844b6dc9702901_d4ac08a22f80f73256836fdd9655dbb0b6e6de7c\",\n"
+
" \"400\": \"ttf2f6844b6dc9702901_d4ac08a22f80f73256836fdd9655dbb0b6e6de7c\",\n"
...
@@ -89,18 +78,61 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
...
@@ -89,18 +78,61 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
//走平台
//走平台
String
dyMarketPlatformAppId
=
dyMarketPlatformAppIdJson
.
getString
(
platformKey
);
String
dyMarketPlatformAppId
=
dyMarketPlatformAppIdJson
.
getString
(
platformKey
);
List
<
String
>
dyMarketPlatformAppIdList
=
new
ArrayList
<>();
List
<
String
>
dyMarketPlatformAppIdList
=
new
ArrayList
<>();
String
tokenDy
=
""
;
ThirdAccountDy
thirdAccountDy
=
null
;
if
(
dyMarketPlatformAppId
!=
null
)
{
if
(
dyMarketPlatformAppId
!=
null
)
{
dyMarketPlatformAppIdList
=
Arrays
.
asList
(
dyMarketPlatformAppId
.
split
(
"_"
));
dyMarketPlatformAppIdList
=
Arrays
.
asList
(
dyMarketPlatformAppId
.
split
(
"_"
));
String
tokenDy
=
"token_dy_"
+
dyMarketPlatformAppIdList
.
get
(
0
);
tokenDy
=
"token_dy_"
+
dyMarketPlatformAppIdList
.
get
(
0
);
ThirdAccountDy
thirdAccountDy
=
null
;
DYVIDEO_SYS_LOG
.
info
(
"thirdAccountDy url={}"
,
DYVIDEO_SYS_LOG
.
info
(
"thirdAccountDy url={}"
,
Objects
.
equals
(
env
.
getActiveProfiles
()[
0
],
"prod"
)
?
tokenDyProdUrl
:
tokenDyDevUrl
);
Objects
.
equals
(
env
.
getActiveProfiles
()[
0
],
"prod"
)
?
tokenDyProdUrl
:
tokenDyDevUrl
);
if
(
up
.
exists
Old
(
tokenDy
))
{
if
(
up
.
exists
(
tokenDy
))
{
thirdAccountDy
=
up
.
get
Old
(
ThirdAccountDy
.
class
,
tokenDy
);
thirdAccountDy
=
up
.
get
(
ThirdAccountDy
.
class
,
tokenDy
);
}
else
{
}
else
{
thirdAccountDy
=
up
.
getDyAccessToken
(
dyMarketPlatformAppIdList
.
get
(
0
),
dyMarketPlatformAppIdList
.
get
(
1
),
thirdAccountDy
=
up
.
getDyAccessToken
(
dyMarketPlatformAppIdList
.
get
(
0
),
dyMarketPlatformAppIdList
.
get
(
1
),
Objects
.
equals
(
env
.
getActiveProfiles
()[
0
],
"prod"
)
?
tokenDyProdUrl
:
tokenDyDevUrl
);
Objects
.
equals
(
env
.
getActiveProfiles
()[
0
],
"prod"
)
?
tokenDyProdUrl
:
tokenDyDevUrl
);
}
}
//这里通过source字段 给乐途上报广告信息
if
(
Objects
.
equals
(
action
.
getVideoUpload
().
getSource
(),
"lotto"
))
{
if
(
thirdAccountDy
!=
null
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
// 获取当前日期时间
LocalTime
two
=
LocalTime
.
of
(
2
,
0
,
0
);
// 获取当天6点的时间
Date
date
=
new
Date
();
JSONArray
jsonArray
=
new
JSONArray
();
if
(
now
.
toLocalTime
().
isBefore
(
two
))
{
//当天2点之前,查两天,先查昨天的ecpm指标
Calendar
calendar
=
Calendar
.
getInstance
();
// 获取日历对象
calendar
.
setTime
(
date
);
// 设置时间
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
// 将时间减去一天
Date
day
=
calendar
.
getTime
();
jsonArray
=
up
.
getUploadAdsInfo
(
jsonArray
,
day
,
action
,
thirdAccountDy
.
getAccessToken
(),
tokenDy
,
dyMarketPlatformAppIdList
,
env
);
}
jsonArray
=
up
.
getUploadAdsInfo
(
jsonArray
,
date
,
action
,
thirdAccountDy
.
getAccessToken
(),
tokenDy
,
dyMarketPlatformAppIdList
,
env
);
if
(
jsonArray
.
size
()>
0
)
{
up
.
uploadCallbackAdsInfo
(
action
,
jsonArray
.
toJSONString
());
}
}
}
return
;
}
long
hour
=
TimeUnit
.
MILLISECONDS
.
toHours
(
currentTime
-
activeTime
);
if
(
hour
>
6
)
{
DYVIDEO_SYS_LOG
.
info
(
"DyvideoBehaviorFlow expeed six hour ,videoUpload={},userId={}"
,
JSON
.
toJSONString
(
videoUpload
),
userId
);
return
;
}
AppChannelVO
appChannel
=
up
.
getAppChannelByPlatformAndChannel
(
platformId
,
channelId
);
//处理关键行为上报
String
openId
=
action
.
getOpenId
();
if
(
thirdAccountDy
!=
null
)
{
if
(
thirdAccountDy
!=
null
)
{
//平均ecpm次数
//平均ecpm次数
Integer
ecpmAvgCount
=
0
;
Integer
ecpmAvgCount
=
0
;
...
@@ -203,7 +235,7 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
...
@@ -203,7 +235,7 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
//等于空 或 100直接回传
//等于空 或 100直接回传
if
(
sprDedu
==
null
||
sprDedu
==
100
)
{
if
(
sprDedu
==
null
||
sprDedu
==
100
)
{
action
.
getMedia
().
notify
(
action
);
action
.
getMedia
().
notify
(
action
);
up
.
notifyResult
(
action
,
type
.
getTopic
()+
"_test"
,
type
.
getStatus
());
up
.
notifyResult
(
action
,
type
.
getTopic
()
,
type
.
getStatus
());
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
return
;
return
;
}
}
...
@@ -222,13 +254,13 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
...
@@ -222,13 +254,13 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
//回传,回传个数 + 1
//回传,回传个数 + 1
up
.
incrby
(
channelCallback
,
1
);
up
.
incrby
(
channelCallback
,
1
);
action
.
getMedia
().
notify
(
action
);
action
.
getMedia
().
notify
(
action
);
up
.
notifyResult
(
action
,
type
.
getTopic
()+
"_test"
,
type
.
getStatus
());
up
.
notifyResult
(
action
,
type
.
getTopic
()
,
type
.
getStatus
());
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
DYVIDEO_SYS_LOG
.
info
(
DYVIDEO_SYS_LOG
.
info
(
"ChannelAttributionFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, planId={}, sprDedu = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}"
,
"ChannelAttributionFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, planId={}, sprDedu = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}"
,
action
.
getPlatformId
(),
action
.
getChannelId
(),
action
.
getPlanId
(),
sprDedu
,
channelTotalCount
,
channelCallbackCount
,
1
);
action
.
getPlatformId
(),
action
.
getChannelId
(),
action
.
getPlanId
(),
sprDedu
,
channelTotalCount
,
channelCallbackCount
,
1
);
}
else
{
}
else
{
up
.
notifyResult
(
action
,
"ocpc_behavior_test"
,
AttributionStatus
.
NORMAL_DEDUCTION_CALLBACK
);
up
.
notifyResult
(
action
,
type
.
getTopic
()
,
AttributionStatus
.
NORMAL_DEDUCTION_CALLBACK
);
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
DYVIDEO_SYS_LOG
.
info
(
DYVIDEO_SYS_LOG
.
info
(
"ChannelAttributionFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, planId={}, sprDedu = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}"
,
"ChannelAttributionFlow.process0.deduction doing dynamic, platformId = {}, channel = {}, planId={}, sprDedu = {}, channelTotalCount = {}, channelCallbackCount = {}, v = {}"
,
...
@@ -236,7 +268,6 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
...
@@ -236,7 +268,6 @@ public class DyvideoBehaviorFlow extends NodeSwitchFlow<StoryNovelAction> {
}
}
}
}
}
}
}
...
...
src/main/java/com/lwby/marketing/att/dyvideo/handle/StoreDyVideoAttributionFlow.java
View file @
21b6036c
...
@@ -20,7 +20,7 @@ public class StoreDyVideoAttributionFlow extends NodeFlow<StoryNovelAction> {
...
@@ -20,7 +20,7 @@ public class StoreDyVideoAttributionFlow extends NodeFlow<StoryNovelAction> {
//商店归因通知
//商店归因通知
if
(
Objects
.
isNull
(
action
.
getDeliveryDeviceInfo
())){
if
(
Objects
.
isNull
(
action
.
getDeliveryDeviceInfo
())){
if
(
action
.
getType
().
equals
(
CallBackType
.
active
.
getType
()))
{
if
(
action
.
getType
().
equals
(
CallBackType
.
active
.
getType
()))
{
up
.
notifyResult
(
action
,
"ocpc_result
_test
"
,
AttributionStatus
.
STORE_CALLBACK
);
up
.
notifyResult
(
action
,
"ocpc_result"
,
AttributionStatus
.
STORE_CALLBACK
);
}
}
action
.
stop
(
true
);
//结束后面所有执行流程
action
.
stop
(
true
);
//结束后面所有执行流程
}
}
...
...
src/main/java/com/lwby/marketing/att/dyvideo/handle/UploadDyVideoCallFlow.java
View file @
21b6036c
...
@@ -7,6 +7,7 @@ import com.lwby.marketing.vo.StoryNovelAction;
...
@@ -7,6 +7,7 @@ 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,8 +25,12 @@ public class UploadDyVideoCallFlow extends NodeFlow<StoryNovelAction> {
...
@@ -24,8 +25,12 @@ public class UploadDyVideoCallFlow extends NodeFlow<StoryNovelAction> {
boolean
success
=
action
.
getMedia
().
notify
(
action
);
boolean
success
=
action
.
getMedia
().
notify
(
action
);
if
(
success
)
{
if
(
success
)
{
//根据source判断是否给指定外包上报
if
(
Objects
.
equals
(
action
.
getVideoUpload
().
getSource
(),
"lotto"
))
{
up
.
uploadCallbackUserInfo
(
action
);
}
action
.
getVideoUpload
().
setActiveTime
(
System
.
currentTimeMillis
());
action
.
getVideoUpload
().
setActiveTime
(
System
.
currentTimeMillis
());
up
.
notifyResult
(
action
,
type
.
getTopic
()
+
"_test"
,
type
.
getStatus
());
up
.
notifyResult
(
action
,
type
.
getTopic
(),
type
.
getStatus
());
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
up
.
set
(
up
.
getFirstCheckerKey
(
action
),
up
.
getExpire
(
action
),
"1"
);
}
}
}
}
...
...
src/main/java/com/lwby/marketing/conf/kafka/DyVideoActiveKafkaConsumerConfig.java
View file @
21b6036c
...
@@ -25,19 +25,19 @@ import java.util.Map;
...
@@ -25,19 +25,19 @@ import java.util.Map;
@EnableKafka
@EnableKafka
public
class
DyVideoActiveKafkaConsumerConfig
{
public
class
DyVideoActiveKafkaConsumerConfig
{
@Value
(
"${spring.kafka
2
.bootstrap-servers}"
)
@Value
(
"${spring.kafka.bootstrap-servers}"
)
private
String
servers
;
private
String
servers
;
@Value
(
"${spring.kafka
2
.consumer.enable-auto-commit}"
)
@Value
(
"${spring.kafka.consumer.enable-auto-commit}"
)
private
boolean
enableAutoCommit
;
private
boolean
enableAutoCommit
;
@Value
(
"${spring.kafka
2
.consumer.auto-offset-reset}"
)
@Value
(
"${spring.kafka.consumer.auto-offset-reset}"
)
private
String
autoOffsetReset
;
private
String
autoOffsetReset
;
@Value
(
"${system.consumer.dyvideo.active.group_id}"
)
@Value
(
"${system.consumer.dyvideo.active.group_id}"
)
private
String
groupId
;
private
String
groupId
;
@Value
(
"${spring.kafka
2
.consumer.max-poll-records}"
)
@Value
(
"${spring.kafka.consumer.max-poll-records}"
)
private
int
maxPollRecordsConfig
;
private
int
maxPollRecordsConfig
;
...
...
src/main/java/com/lwby/marketing/conf/kafka/DyVideoBehavoirKafkaConsumerConfig.java
View file @
21b6036c
...
@@ -24,19 +24,19 @@ import java.util.Map;
...
@@ -24,19 +24,19 @@ import java.util.Map;
@EnableKafka
@EnableKafka
public
class
DyVideoBehavoirKafkaConsumerConfig
{
public
class
DyVideoBehavoirKafkaConsumerConfig
{
@Value
(
"${spring.kafka
2
.bootstrap-servers}"
)
@Value
(
"${spring.kafka.bootstrap-servers}"
)
private
String
servers
;
private
String
servers
;
@Value
(
"${spring.kafka
2
.consumer.enable-auto-commit}"
)
@Value
(
"${spring.kafka.consumer.enable-auto-commit}"
)
private
boolean
enableAutoCommit
;
private
boolean
enableAutoCommit
;
@Value
(
"${spring.kafka
2
.consumer.auto-offset-reset}"
)
@Value
(
"${spring.kafka.consumer.auto-offset-reset}"
)
private
String
autoOffsetReset
;
private
String
autoOffsetReset
;
@Value
(
"${system.consumer.dyvideo.behavoir.group_id}"
)
@Value
(
"${system.consumer.dyvideo.behavoir.group_id}"
)
private
String
groupId
;
private
String
groupId
;
@Value
(
"${spring.kafka
2
.consumer.max-poll-records}"
)
@Value
(
"${spring.kafka.consumer.max-poll-records}"
)
private
int
maxPollRecordsConfig
;
private
int
maxPollRecordsConfig
;
...
...
src/main/java/com/lwby/marketing/controller/DyVideoController.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.lwby.marketing.att.dyvideo.DyVideoUniversalProcess
;
import
com.lwby.marketing.notify.media.jrtt.dto.JrttAttributeRequest
;
import
com.lwby.marketing.po.DyVideoUpload
;
import
com.lwby.marketing.po.VideoUpload
;
import
com.lwby.marketing.util.HttpUtil
;
import
com.lwby.marketing.util.ResultConstant
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author songxinyu
* @version DyVideoController.java, v 0.1 2024年04月10日 11:27 songxinyu Exp $
*/
@RestController
@Slf4j
@RequestMapping
(
value
=
"/market_attr"
)
public
class
DyVideoController
{
public
static
final
String
ATTRIBUTE_URL
=
"https://analytics.oceanengine.com/api/v2/conversion"
;
@Resource
DyVideoUniversalProcess
up
;
@RequestMapping
(
"uploadBehavoir"
)
public
String
uploadBehavoirByDyVideo
(
@RequestParam
(
"openId"
)
String
openId
)
{
Map
map
=
new
HashMap
();
String
result
=
""
;
VideoUpload
videoUpload
=
up
.
get
(
VideoUpload
.
class
,
assembleKey
(
openId
));
Integer
platformId
=
videoUpload
.
getPlatformId
();
String
uploadKey
=
String
.
format
(
"dv_%s_%d_%s"
,
openId
,
platformId
,
videoUpload
.
getMedia
());
if
(
up
.
exists
(
uploadKey
))
{
map
.
put
(
"code"
,
ResultConstant
.
CALL_BACK_UPED_FAIL
);
map
.
put
(
"message"
,
ResultConstant
.
CALL_BACK_UPED_MESSAGE
);
result
=
JSONObject
.
toJSONString
(
map
);
return
result
;
}
JrttAttributeRequest
.
Ad
ad
=
new
JrttAttributeRequest
.
Ad
();
ad
.
setCallback
(
videoUpload
.
getClickId
());
JrttAttributeRequest
.
Context
context
=
new
JrttAttributeRequest
.
Context
();
context
.
setAd
(
ad
);
JrttAttributeRequest
request
=
JrttAttributeRequest
.
builder
().
context
(
context
).
event_type
(
"game_addiction"
).
timestamp
(
System
.
currentTimeMillis
()).
build
();
String
userJson
=
JSONObject
.
toJSONString
(
request
);
try
{
String
ret
=
HttpUtil
.
post
(
ATTRIBUTE_URL
,
userJson
);
Integer
resultCode
=
(
Integer
)
JSON
.
parseObject
(
ret
).
get
(
"code"
);
if
(
resultCode
==
0
)
{
map
.
put
(
"code"
,
ResultConstant
.
CALL_BACK_SUCCESS
);
map
.
put
(
"message"
,
ResultConstant
.
CALL_BACK_SUCCESS_MESSAGE
);
result
=
JSONObject
.
toJSONString
(
map
)
;
//给bi发消息
up
.
notifyResult
(
openId
,
videoUpload
);
up
.
set
(
uploadKey
,
60
*
60
*
24
*
7
,
"1"
);
}
else
{
map
.
put
(
"code"
,
ResultConstant
.
CALL_BACK_FAIL
);
map
.
put
(
"message"
,
ResultConstant
.
CALL_BACK_FAIL_MESSAGE
);
result
=
JSONObject
.
toJSONString
(
map
)
;
}
return
result
;
}
catch
(
Exception
e
)
{
map
.
put
(
"code"
,
ResultConstant
.
CALL_BACK_FAIL
);
map
.
put
(
"message"
,
ResultConstant
.
CALL_BACK_FAIL_MESSAGE
);
result
=
JSONObject
.
toJSONString
(
map
)
;
return
result
;
}
}
public
String
assembleKey
(
String
openId
)
{
return
String
.
format
(
"video:upload:%s"
,
openId
);
}
}
src/main/java/com/lwby/marketing/controller/MediaClickController.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.lwby.marketing.factory.MediaClickFactory
;
import
com.lwby.marketing.notify.Media
;
import
com.lwby.marketing.service.MediaClick
;
import
com.lwby.marketing.util.Stats
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author songxinyu
* @version MediaClickController.java, v 0.1 2024年04月10日 13:48 songxinyu Exp $
*/
@RestController
@Slf4j
@RequestMapping
(
value
=
"/market_growth"
)
public
class
MediaClickController
{
@Resource
MediaClickFactory
mediaClickFactory
;
@RequestMapping
(
"/jrtt"
)
public
Object
jrttClick
(
HttpServletRequest
request
,
HttpServletResponse
res
){
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Enumeration
<
String
>
en
=
request
.
getParameterNames
();
while
(
en
.
hasMoreElements
()){
String
key
=
en
.
nextElement
();
params
.
put
(
key
,
request
.
getParameter
(
key
));
}
log
.
info
(
"JrttClick params:{}"
,
JSON
.
toJSONString
(
params
));
MediaClick
mediaClickFacade
=
mediaClickFactory
.
getMediaClickFacade
(
Media
.
NOVEL_JRTT
);
String
result
=
mediaClickFacade
.
click
(
""
,
params
);
log
.
info
(
"JrttClick , {}"
,
result
);
Stats
.
HTTP_MG_JRTT
.
add
();
return
result
;
}
}
src/main/java/com/lwby/marketing/factory/MediaClickFactory.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
factory
;
import
com.google.common.collect.ArrayListMultimap
;
import
com.lwby.marketing.notify.Media
;
import
com.lwby.marketing.service.MediaClick
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Slf4j
public
class
MediaClickFactory
{
@Autowired
ApplicationContext
applicationContext
;
ArrayListMultimap
<
Media
,
MediaClick
>
multimap
=
ArrayListMultimap
.
create
();
/**
* @return
*/
/**
*
* @return
*/
public
MediaClick
getMediaClickFacade
(
Media
mediaEnum
)
{
List
<
MediaClick
>
mediaClickFacade
=
multimap
.
get
(
mediaEnum
);
return
mediaClickFacade
.
get
(
0
);
}
/**
*
*/
@PostConstruct
public
void
init
()
{
Map
<
String
,
MediaClick
>
type
=
applicationContext
.
getBeansOfType
(
MediaClick
.
class
);
for
(
Map
.
Entry
<
String
,
MediaClick
>
item
:
type
.
entrySet
())
{
multimap
.
put
(
item
.
getValue
().
getMedia
(),
item
.
getValue
());
}
}
}
src/main/java/com/lwby/marketing/notify/Media.java
View file @
21b6036c
...
@@ -21,7 +21,7 @@ public enum Media {
...
@@ -21,7 +21,7 @@ public enum Media {
DY_VIDEO_JRTT
(
"jrtt"
,
Platform
.
DY_VIDEO
,
"今日头条"
,
new
DyVideoJRTTNotify
()),
DY_VIDEO_JRTT
(
"jrtt"
,
Platform
.
DY_VIDEO
,
"今日头条"
,
new
DyVideoJRTTNotify
()),
VIDEOAPP_JRTT
(
"jrtt_freevideo"
,
Platform
.
VIDEO
,
"今日头条"
,
new
VideoAppJRTTNotify
());
VIDEOAPP_JRTT
(
"jrtt_freevideo"
,
Platform
.
VIDEO
,
"今日头条"
,
new
VideoAppJRTTNotify
());
final
String
name
;
public
final
String
name
;
final
Platform
platform
;
final
Platform
platform
;
final
String
desc
;
final
String
desc
;
final
BaseNotiry
baseNotify
;
final
BaseNotiry
baseNotify
;
...
...
src/main/java/com/lwby/marketing/notify/media/jrtt/DyVideoJRTTNotify.java
View file @
21b6036c
...
@@ -46,12 +46,10 @@ public class DyVideoJRTTNotify extends DYNotify {
...
@@ -46,12 +46,10 @@ public class DyVideoJRTTNotify extends DYNotify {
String
userJson
=
JSONObject
.
toJSONString
(
request
);
String
userJson
=
JSONObject
.
toJSONString
(
request
);
try
{
try
{
//TODO;测试不执行
String
result
=
HttpUtil
.
post
(
ATTRIBUTE_URL
,
userJson
);
//String result = HttpUtil.post(ATTRIBUTE_URL, userJson);
Integer
resultCode
=
(
Integer
)
JSON
.
parseObject
(
result
).
get
(
"code"
);
//Integer resultCode = (Integer) JSON.parseObject(result).get("code");
//return resultCode == 0;
DYVIDEO_SYS_LOG
.
info
(
"DyVideoJRTTNotify.video.{}.upload,userId={},channel={},platform={}"
,
eventType
,
na
.
getUserId
(),
na
.
getChannelId
(),
na
.
getPlatformId
());
DYVIDEO_SYS_LOG
.
info
(
"DyVideoJRTTNotify.video.{}.upload,userId={},channel={},platform={}"
,
eventType
,
na
.
getUserId
(),
na
.
getChannelId
(),
na
.
getPlatformId
());
return
true
;
return
resultCode
==
0
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
false
;
return
false
;
}
}
...
...
src/main/java/com/lwby/marketing/po/DyVideoUpload.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
po
;
import
lombok.Data
;
/**
* @author songxinyu
* @version DyVideoUpload.java, v 0.1 2024年04月10日 17:06 songxinyu Exp $
*/
@Data
public
class
DyVideoUpload
{
String
openId
;
Integer
platformId
;
}
src/main/java/com/lwby/marketing/po/VideoUpload.java
View file @
21b6036c
...
@@ -25,4 +25,9 @@ public class VideoUpload {
...
@@ -25,4 +25,9 @@ public class VideoUpload {
private
String
perecpmSize
;
private
String
perecpmSize
;
private
long
activeTime
;
private
long
activeTime
;
private
long
clickTime
;
private
long
clickTime
;
private
Integer
platformId
;
private
Long
userId
;
//来源
private
String
source
;
}
}
src/main/java/com/lwby/marketing/service/MediaClick.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
service
;
import
com.lwby.marketing.notify.Media
;
import
java.util.Map
;
/**
* @author songxinyu
* @version MediaClick.java, v 0.1 2024年04月10日 14:11 songxinyu Exp $
*/
public
interface
MediaClick
{
String
click
(
String
s
,
Map
<
String
,
String
>
params
);
Media
getMedia
();
}
src/main/java/com/lwby/marketing/service/impl/JrttClickImpl.java
0 → 100644
View file @
21b6036c
This diff is collapsed.
Click to expand it.
src/main/java/com/lwby/marketing/util/CacheKeyUtils.java
View file @
21b6036c
package
com
.
lwby
.
marketing
.
util
;
package
com
.
lwby
.
marketing
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -13,6 +17,13 @@ public class CacheKeyUtils {
...
@@ -13,6 +17,13 @@ public class CacheKeyUtils {
static
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"MMdd"
);
//设置日期格式
static
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"MMdd"
);
//设置日期格式
private
static
final
String
CACHE_BOOK_PREFIX
=
"getBookId"
;
private
static
final
String
CACHE_PART_PREFIX
=
"getPartId"
;
private
static
final
String
CHANNEL_PREFIX_KEY
=
"getChannelBy"
;
public
static
String
getBehavoirKey
(
Long
userId
)
{
public
static
String
getBehavoirKey
(
Long
userId
)
{
return
CACHE_BEHAVIOR_PREFIX
+
userId
+
"_"
+
df
.
format
(
new
Date
())
+
"_fv"
;
return
CACHE_BEHAVIOR_PREFIX
+
userId
+
"_"
+
df
.
format
(
new
Date
())
+
"_fv"
;
}
}
...
@@ -20,4 +31,43 @@ public class CacheKeyUtils {
...
@@ -20,4 +31,43 @@ public class CacheKeyUtils {
public
static
String
getVideoBehavoirKey
(
Long
userId
)
{
public
static
String
getVideoBehavoirKey
(
Long
userId
)
{
return
CACHE_BEHAVIOR_PREFIX
+
userId
+
"_fv"
;
return
CACHE_BEHAVIOR_PREFIX
+
userId
+
"_fv"
;
}
}
public
static
String
getClickKeyByIdfaAndPlatformId
(
String
idfa
,
String
platformId
)
{
return
"getClickByIdfaAndPlatformId"
+
"_"
+
idfa
+
"_"
+
platformId
;
}
public
static
String
getClickKey
(
String
idfa
,
String
platformId
)
{
return
"mck"
+
":"
+
idfa
+
":"
+
platformId
;
}
public
static
String
getDeliveryBookIdCacheKey
(
String
deviceKey
,
String
platformId
)
{
return
CACHE_BOOK_PREFIX
+
"_"
+
deviceKey
+
"_"
+
platformId
;
}
public
static
String
getDeliveryPartIdCacheKey
(
String
deviceKey
,
String
platformId
)
{
return
CACHE_PART_PREFIX
+
"_"
+
deviceKey
+
"_"
+
platformId
;
}
public
static
String
getChannelByDeviceIdKeyAndPlatformId
(
String
deviceIdKey
,
String
platformId
)
{
return
CHANNEL_PREFIX_KEY
+
deviceIdKey
+
platformId
;
}
public
static
String
getModelByUa
(
String
ua
)
{
String
uasplit
=
ua
.
split
(
"Build"
)[
0
];
String
model
=
null
;
try
{
if
(
ua
.
startsWith
(
"com."
))
{
String
[]
split
=
uasplit
.
split
(
";"
);
model
=
split
[
4
].
trim
();
}
else
{
if
(
uasplit
.
split
(
";"
).
length
>=
3
&&
StringUtils
.
isNotEmpty
(
uasplit
.
split
(
";"
)[
2
].
trim
()))
{
model
=
uasplit
.
substring
(
uasplit
.
lastIndexOf
(
";"
)
+
2
,
uasplit
.
length
()
-
1
);
model
=
URLEncoder
.
encode
(
model
,
"utf-8"
);
}
}
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
model
;
}
}
}
src/main/java/com/lwby/marketing/util/DateTimUtils.java
View file @
21b6036c
...
@@ -28,6 +28,14 @@ public class DateTimUtils {
...
@@ -28,6 +28,14 @@ public class DateTimUtils {
return
DATE_BOTTOM_FORMAT
.
format
(
new
Date
());
return
DATE_BOTTOM_FORMAT
.
format
(
new
Date
());
}
}
public
static
String
getCurrentTimeString
(){
return
DATE_TIME_FORMAT
.
format
(
new
Date
());
}
public
static
String
getCurrentTimeString
(
Date
date
){
return
DATE_TIME_FORMAT
.
format
(
date
);
}
/**
/**
* 时间是否大于7天
* 时间是否大于7天
*
*
...
...
src/main/java/com/lwby/marketing/util/ResultConstant.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
util
;
public
class
ResultConstant
{
public
final
static
Integer
CALL_BACK_SUCCESS
=
0
;
public
final
static
Integer
CALL_BACK_FAIL
=
1
;
public
final
static
Integer
CALL_BACK_UPED_FAIL
=
2
;
public
final
static
String
CALL_BACK_SUCCESS_MESSAGE
=
"上报成功"
;
public
final
static
String
CALL_BACK_FAIL_MESSAGE
=
"上报失败"
;
public
final
static
String
CALL_BACK_UPED_MESSAGE
=
"已上报一次"
;
}
src/main/java/com/lwby/marketing/util/Stats.java
0 → 100644
View file @
21b6036c
package
com
.
lwby
.
marketing
.
util
;
import
io.micrometer.core.instrument.Counter
;
import
io.micrometer.core.instrument.MeterRegistry
;
public
enum
Stats
{
HTTP_MG_JRTT
(
"HTTP接口jrtt"
,
"http_mg_jrtt"
),
HTTP_MG_WECHAT
(
"HTTP接口jrtt"
,
"http_mg_wechat"
),
HTTP_MG_KUAISHOU
(
"HTTP接口jrtt"
,
"http_mg_kuaishou"
),
HTTP_MG_YOUDAO
(
"HTTP接口jrtt"
,
"http_mg_kuaishou"
),
HTTP_MG_XIAOMI
(
"HTTP接口jrtt"
,
"http_mg_xiaomi"
);
private
String
name
;
private
Counter
counter
;
private
String
indicator
;
Stats
(
String
name
,
String
indicator
)
{
this
.
name
=
name
;
this
.
indicator
=
indicator
;
}
public
void
add
()
{
counter
.
increment
();
}
public
void
add
(
long
count
)
{
counter
.
increment
(
count
);
}
public
String
getName
()
{
return
this
.
name
;
}
public
long
getCount
()
{
return
(
long
)
counter
.
count
();
}
public
void
bind
(
MeterRegistry
registry
)
{
this
.
counter
=
registry
.
counter
(
indicator
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment