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
ec467a12
Commit
ec467a12
authored
Apr 09, 2024
by
宋新宇
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '7-短剧app关键行为优化' into 'release_20240408_01'
dy短剧关键行为优化 See merge request
!36
parents
b39afb27
870c5e6d
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
143 additions
and
176 deletions
+143
-176
DyVideoBehavoirConsumer.java
...m/lwby/marketing/att/dyvideo/DyVideoBehavoirConsumer.java
+1
-0
DyVideoUniversalProcess.java
...m/lwby/marketing/att/dyvideo/DyVideoUniversalProcess.java
+94
-3
DyvideoBehaviorFlow.java
...wby/marketing/att/dyvideo/handle/DyvideoBehaviorFlow.java
+48
-173
No files found.
src/main/java/com/lwby/marketing/att/dyvideo/DyVideoBehavoirConsumer.java
View file @
ec467a12
...
...
@@ -66,6 +66,7 @@ public class DyVideoBehavoirConsumer {
event
.
getUserUploadEvent
());
executorByDyVideoBehavoir
.
execute
(
action
);
DYVIDEO_SYS_LOG
.
info
(
"media.behavoir.dyVideo.end,topic={}, bookStoreEvent={}"
,
data
.
topic
(),
JSON
.
toJSONString
(
event
));
}
catch
(
Throwable
e
)
{
DYVIDEO_ERROR_LOG
.
error
(
"dy.video.behavoir.onMessage failed, data={}, costTime={} ms"
,
data
.
value
(),
System
.
currentTimeMillis
()
-
begin
,
e
);
...
...
src/main/java/com/lwby/marketing/att/dyvideo/DyVideoUniversalProcess.java
View file @
ec467a12
...
...
@@ -10,6 +10,7 @@ import com.lwby.marketing.att.UniversalProcess;
import
com.lwby.marketing.att.CallBackType
;
import
com.lwby.marketing.att.novel.AttributionType
;
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.DeliveryDeviceInfo
;
...
...
@@ -17,6 +18,7 @@ import com.lwby.marketing.vo.StoryNovelAction;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.core.env.Environment
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.jdbc.core.BeanPropertyRowMapper
;
...
...
@@ -26,9 +28,8 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.concurrent.ListenableFuture
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
@Slf4j
...
...
@@ -42,6 +43,14 @@ public class DyVideoUniversalProcess extends UniversalProcess {
@Resource
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/"
;
/**
* 通知处理结果
*/
...
...
@@ -169,4 +178,86 @@ public class DyVideoUniversalProcess extends UniversalProcess {
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
;
}
}
src/main/java/com/lwby/marketing/att/dyvideo/handle/DyvideoBehaviorFlow.java
View file @
ec467a12
This diff is collapsed.
Click to expand it.
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