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
d2f6d7d0
Commit
d2f6d7d0
authored
Apr 16, 2024
by
宋新宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
点击
parent
5ba5ece1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
0 deletions
+158
-0
ClickbackService.java
.../java/com/lwby/marketing/controller/ClickbackService.java
+134
-0
ServiceHelper.java
...ain/java/com/lwby/marketing/controller/ServiceHelper.java
+12
-0
CacheKeyUtils.java
src/main/java/com/lwby/marketing/util/CacheKeyUtils.java
+12
-0
No files found.
src/main/java/com/lwby/marketing/controller/ClickbackService.java
View file @
d2f6d7d0
package
com
.
lwby
.
marketing
.
controller
;
import
cn.hutool.crypto.SecureUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.ImmutableMap
;
...
...
@@ -24,11 +25,13 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.annotation.Resource
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.UUID
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@RestController
@Slf4j
...
...
@@ -110,6 +113,37 @@ public class ClickbackService extends ServiceHelper{
return
RESULT_SUCCESS
;
}
@RequestMapping
(
"/jrttFreeVideo"
)
@ResponseBody
public
Object
jrttFreeVideoClick
(
@RequestParam
Map
<
String
,
String
>
params
){
NovelAction
action
=
fullJrttFreeVideo
(
params
);
for
(
DeviceVideoType
type:
DeviceVideoType
.
values
()){
String
deviceIdKey
=
type
.
getDeviceId
(
action
.
getClientInfo
());
if
(
null
!=
deviceIdKey
){
DeliveryDeviceInfo
ddi
=
action
.
getDeliveryDeviceInfo
();
if
(
StringUtils
.
isNotEmpty
(
ddi
.
getDj_channel
()))
{
redisTemplate
.
opsForValue
().
set
(
CacheKeyUtils
.
getChannelByDeviceIdKeyAndPlatformId
(
assembleKey
(
deviceIdKey
,
type
),
ddi
.
getPlatform_id
()),
JSON
.
toJSONString
(
Integer
.
parseInt
(
ddi
.
getDj_channel
())),
bookIdExpireTime
,
TimeUnit
.
SECONDS
);
if
(
StringUtils
.
isNumeric
(
ddi
.
getBook_id
()))
{
redisTemplate
.
opsForValue
().
set
(
CacheKeyUtils
.
getDeliveryVRIdCacheKey
(
assembleKey
(
deviceIdKey
,
type
),
ddi
.
getPlatform_id
()),
JSON
.
toJSONString
(
ddi
.
getVideoResourceId
()),
bookIdExpireTime
,
TimeUnit
.
SECONDS
);
if
(
StringUtils
.
isNumeric
(
ddi
.
getPartId
()))
{
redisTemplate
.
opsForValue
().
set
(
CacheKeyUtils
.
getDeliveryVIIdCacheKey
(
assembleKey
(
deviceIdKey
,
type
),
ddi
.
getPlatform_id
()),
JSON
.
toJSONString
(
ddi
.
getVideoId
()),
bookIdExpireTime
,
TimeUnit
.
SECONDS
);
}
}
}
if
(
type
==
DeviceVideoType
.
IDFA
)
{
redisTemplate
.
opsForValue
().
set
(
CacheKeyUtils
.
getClickKey
(
assembleKey
(
deviceIdKey
,
type
),
ddi
.
getPlatform_id
()),
JSON
.
toJSONString
(
ddi
),
bookIdExpireTime
,
TimeUnit
.
SECONDS
);
}
else
{
redisTemplate
.
opsForValue
().
set
(
CacheKeyUtils
.
getClickKeyByIdfaAndPlatformId
(
assembleKey
(
deviceIdKey
,
type
),
ddi
.
getPlatform_id
()),
JSON
.
toJSONString
(
ddi
),
bookIdExpireTime
,
TimeUnit
.
SECONDS
);
}
}
}
return
RESULT_SUCCESS
;
}
public
NovelAction
fullJrtt
(
Map
<
String
,
String
>
params
)
{
ClientInfo
clientInfo
=
new
ClientInfo
();
...
...
@@ -216,6 +250,74 @@ public class ClickbackService extends ServiceHelper{
return
new
NovelAction
(
clientInfo
,
deliveryDeviceInfo
);
}
public
NovelAction
fullJrttFreeVideo
(
Map
<
String
,
String
>
params
)
{
ClientInfo
clientInfo
=
new
ClientInfo
();
//imeiMd5
clientInfo
.
setImei
(
params
.
get
(
"imei"
));
clientInfo
.
setOaid
(
params
.
get
(
"oaid_md5"
));
String
idfa
=
params
.
get
(
"idfa"
);
if
(!
filter
.
contains
(
idfa
)
&&
StringUtils
.
isNotEmpty
(
idfa
))
{
clientInfo
.
setIdfa
(
SecureUtil
.
md5
(
idfa
));
}
clientInfo
.
setClientIp
(
params
.
get
(
"ip"
));
clientInfo
.
setUa
(
params
.
get
(
"ua"
));
clientInfo
.
setPhoneModel
(
encode
(
params
.
get
(
"model"
)));
DeliveryDeviceInfo
deliveryDeviceInfo
=
new
DeliveryDeviceInfo
();
deliveryDeviceInfo
.
setClick_time
(
System
.
currentTimeMillis
());
deliveryDeviceInfo
.
setAd_group_id
(
params
.
get
(
"campaign_id"
));
deliveryDeviceInfo
.
setAd_creative_id
(
params
.
get
(
"cid"
));
deliveryDeviceInfo
.
setAd_plan_id
(
params
.
get
(
"adid"
));
deliveryDeviceInfo
.
setMedia
(
Media
.
VIDEOAPP_JRTT
.
name
);
deliveryDeviceInfo
.
setPlatform_id
(
params
.
get
(
"platform_id"
));
deliveryDeviceInfo
.
setDj_channel
(
params
.
get
(
"channel"
));
deliveryDeviceInfo
.
setVideoResourceId
(
params
.
get
(
"videoResourceId"
));
deliveryDeviceInfo
.
setCallback_param
(
params
.
get
(
"callback_param"
));
if
(
Objects
.
isNull
(
deliveryDeviceInfo
.
getCallback_param
()))
{
deliveryDeviceInfo
.
setCallback_url
(
params
.
get
(
"callback_url"
));
}
deliveryDeviceInfo
.
setAdvertiser_id
(
params
.
get
(
"advertiser_id"
));
deliveryDeviceInfo
.
setUuid
(
UUID
.
randomUUID
().
toString
());
deliveryDeviceInfo
.
setAd_platform_type
(
params
.
get
(
"ad_platform_type"
));
deliveryDeviceInfo
.
setTarget_audience
(
params
.
get
(
"target_audience"
));
deliveryDeviceInfo
.
setIp
(
params
.
get
(
"ip"
));
deliveryDeviceInfo
.
setVideoId
(
params
.
get
(
"videoId"
));
if
(!
filter
.
contains
(
params
.
get
(
"oaid"
)))
{
deliveryDeviceInfo
.
setOaid
(
params
.
get
(
"oaid"
));
}
if
(
StringUtils
.
isNotEmpty
(
clientInfo
.
getImei
()))
{
deliveryDeviceInfo
.
setImeiMd5
(
clientInfo
.
getImei
());
}
if
(
StringUtils
.
isNotEmpty
(
clientInfo
.
getPhoneModel
()))
{
deliveryDeviceInfo
.
setModel
(
clientInfo
.
getPhoneModel
());
}
//通投智选union_site
deliveryDeviceInfo
.
setUnion_site
(
params
.
get
(
"union_site"
));
deliveryDeviceInfo
.
setPartId
(
params
.
get
(
"part_id"
));
//巨量广告体验版中特有的宏参,代表巨量广告体验版的广告ID
deliveryDeviceInfo
.
setPromotion_id
(
emptyIsNull
(
params
.
get
(
"promotion_id"
)));
//巨量广告体验版中特有的宏参,代表巨量广告体验版的项目ID
deliveryDeviceInfo
.
setProject_id
(
emptyIsNull
(
params
.
get
(
"project_id"
)));
//巨量广告体验版中的广告名称
deliveryDeviceInfo
.
setPromotion_name
(
emptyIsNull
(
params
.
get
(
"promotion_name"
)));
//巨量广告体验版中的项目名称
deliveryDeviceInfo
.
setProject_name
(
emptyIsNull
(
params
.
get
(
"project_name"
)));
//信息流投放广告来源(碎片 1 书籍 2)
deliveryDeviceInfo
.
setSource
(
parseInt
(
params
.
get
(
"source"
)));
deliveryDeviceInfo
.
setMid1
(
emptyIsNull
(
params
.
get
(
"mid1"
)));
deliveryDeviceInfo
.
setMid2
(
emptyIsNull
(
params
.
get
(
"mid2"
)));
deliveryDeviceInfo
.
setMid3
(
emptyIsNull
(
params
.
get
(
"mid3"
)));
deliveryDeviceInfo
.
setMid4
(
emptyIsNull
(
params
.
get
(
"mid4"
)));
deliveryDeviceInfo
.
setMid5
(
emptyIsNull
(
params
.
get
(
"mid5"
)));
deliveryDeviceInfo
.
setMid6
(
emptyIsNull
(
params
.
get
(
"mid6"
)));
storyKafkaTemplate
.
send
(
"growth_ad_click"
,
JSONObject
.
toJSONString
(
params
));
return
new
NovelAction
(
clientInfo
,
deliveryDeviceInfo
);
}
enum
DeviceType
{
IMEI
(
"imei"
,(
c
)
->
isNotEmptyAndSNull
(
c
.
getImei
())?
c
.
getImei
():
null
),
OAID
(
"oaid"
,
(
c
)
->
isNotEmptyAndSNull
(
c
.
getOaid
())?
c
.
getOaid
():
null
),
...
...
@@ -245,4 +347,36 @@ public class ClickbackService extends ServiceHelper{
return
StringUtils
.
isNotEmpty
(
str
)
&&
!
filter
.
contains
(
str
);
}
}
enum
DeviceVideoType
{
OAID
(
"oaid"
,
(
c
)
->
isNotEmptyAndSNull
(
c
.
getOaid
())?
c
.
getOaid
():
null
),
IDFA
(
"idfa"
,(
c
)
->
isNotEmptyAndSNull
(
c
.
getIdfa
())?
c
.
getIdfa
():
null
),
IP_UA
(
"ipua"
,(
c
)
->
(
isNotEmptyAndSNull
(
c
.
getClientIp
())
&&
isNotEmptyAndSNull
(
c
.
getUa
()))
?
((
"0"
.
equals
(
c
.
getOs
())
?
c
.
getClientIp
().
concat
(
StringUtils
.
substringBefore
(
c
.
getUa
(),
" Chrome/"
))
:
(
c
.
getUa
().
startsWith
(
"bi kan duan ju"
)
?
Arrays
.
stream
(
c
.
getSystemVersion
().
split
(
"\\."
)).
collect
(
Collectors
.
joining
(
"_"
)):
c
.
getClientIp
().
concat
(
c
.
getUa
())))):
null
),
IP_MODEL
(
"ipmodel"
,(
c
)
->
isNotEmptyAndSNull
(
c
.
getClientIp
())
&&
isNotEmptyAndSNull
(
c
.
getPhoneModel
())?
c
.
getClientIp
().
concat
(
c
.
getPhoneModel
()):
null
);
private
String
value
;
private
Function
<
ClientInfo
,
String
>
fun
;
DeviceVideoType
(
String
value
,
Function
<
ClientInfo
,
String
>
fun
)
{
this
.
value
=
value
;
this
.
fun
=
fun
;
}
public
String
getValue
()
{
return
this
.
value
;
}
public
String
getDeviceId
(
ClientInfo
clientInfo
){
return
fun
.
apply
(
clientInfo
);
}
private
static
boolean
isNotEmptyAndSNull
(
String
str
)
{
return
StringUtils
.
isNotEmpty
(
str
)
&&
!
"null"
.
equals
(
str
);
}
}
}
src/main/java/com/lwby/marketing/controller/ServiceHelper.java
View file @
d2f6d7d0
...
...
@@ -40,4 +40,16 @@ public class ServiceHelper {
}
return
null
;
}
public
String
assembleKey
(
String
deviceId
,
ClickbackService
.
DeviceVideoType
type
)
{
switch
(
type
)
{
case
OAID:
case
IDFA:
return
deviceId
;
case
IP_UA:
case
IP_MODEL:
return
SecureUtil
.
md5
(
deviceId
);
}
return
null
;
}
}
src/main/java/com/lwby/marketing/util/CacheKeyUtils.java
View file @
d2f6d7d0
...
...
@@ -23,6 +23,10 @@ public class CacheKeyUtils {
private
static
final
String
CHANNEL_PREFIX_KEY
=
"getChannelBy"
;
private
static
final
String
CACHE_VRID_PRE
=
"vr:"
;
private
static
final
String
CACHE_VID_PRE
=
"vi:"
;
public
static
String
getBehavoirKey
(
Long
userId
)
{
return
CACHE_BEHAVIOR_PREFIX
+
userId
+
"_"
+
df
.
format
(
new
Date
())
+
"_fv"
;
...
...
@@ -70,4 +74,12 @@ public class CacheKeyUtils {
}
return
model
;
}
public
static
String
getDeliveryVRIdCacheKey
(
String
deviceKey
,
String
platformId
)
{
return
CACHE_VRID_PRE
+
deviceKey
+
":"
+
platformId
;
}
public
static
String
getDeliveryVIIdCacheKey
(
String
deviceKey
,
String
platformId
)
{
return
CACHE_VID_PRE
+
deviceKey
+
":"
+
platformId
;
}
}
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