Toggle navigation
Toggle navigation
This project
Loading...
Sign in
YOHOBUY
/
yohobuy-union
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
zhengwen.ge
8 years ago
Commit
9f89da2cd0f27c9e55665e0406d163a705a44061
1 parent
ed240947
update
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
18 deletions
common/src/main/resources/union-type.yml
server/src/main/java/com/yoho/unions/server/restapi/ClickUnionRest.java
server/src/main/java/com/yoho/unions/server/service/impl/TouTiaoServiceImpl.java
server/src/main/java/com/yoho/unions/server/service/impl/UnionServiceImpl.java
server/src/main/java/com/yoho/unions/server/service/impl/WeiBoServiceImpl.java
common/src/main/resources/union-type.yml
View file @
9f89da2
...
...
@@ -11,6 +11,9 @@ union_types:
-
value
:
4
name
:
test
-
value
:
5
name
:
weibo
-
value
:
100
name
:
ASZM-fensitong
...
...
server/src/main/java/com/yoho/unions/server/restapi/ClickUnionRest.java
View file @
9f89da2
...
...
@@ -97,7 +97,7 @@ public class ClickUnionRest {
request
=
unionService
.
clickHttpRequestTOBO
(
httpServletRequest
);
}
bo
.
setClientIp
(
RemoteIPInterceptor
.
getRemoteIP
());
request
.
setClientIp
(
RemoteIPInterceptor
.
getRemoteIP
());
// IUnionService service = SpringContextUtil.getBean(bean, IUnionService.class);
UnionResponse
response
=
unionService
.
clickUnion
(
request
);
log
.
info
(
"addUnion with result is {}, and request is {}"
,
response
,
request
);
...
...
@@ -130,14 +130,14 @@ public class ClickUnionRest {
log
.
warn
(
"addUnion4Special agent is not correct with user-agent={}, bo={}"
,
agent
,
bo
);
return
;
}
String
version
=
agent
.
substring
(
agent
.
indexOf
(
" OS "
)
+
4
,
agent
.
indexOf
(
" like"
));
log
.
info
(
"addUnion4Special version={}"
,
version
);
bo
.
setTd
(
"ios_"
+
version
.
replaceAll
(
"_"
,
"."
));
bo
.
setClient_type
(
"ios"
);
bo
.
setAppid
(
"490655927"
);
log
.
info
(
"addUnion4Special request={}"
,
bo
);
unionService
.
clickUnion
(
request
);
unionService
.
clickUnion
(
bo
);
log
.
info
(
"addUnion4Special with result is {}, and request is {}"
,
response
,
bo
);
response
.
setStatus
(
301
);
response
.
sendRedirect
(
"https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"
);
...
...
@@ -158,19 +158,19 @@ public class ClickUnionRest {
String
version
=
agent
.
substring
(
agent
.
indexOf
(
" OS "
)
+
4
,
agent
.
indexOf
(
" like"
));
log
.
info
(
"addUnion4Special version={}"
,
version
);
}
@RequestMapping
(
"/addMonitor"
)
public
void
addMonitor
(
ClickUnionRequestBO
bo
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
log
.
info
(
"addMonitor with param is {}"
,
bo
);
clickUnion
.
info
(
"addMonitor with param is {}"
,
bo
);
try
{
Enumeration
<
String
>
e
=
request
.
getParameterNames
();
while
(
e
.
hasMoreElements
())
{
String
key
=
e
.
nextElement
();
log
.
info
(
"addMonitor with key={}, value={}"
,
key
,
request
.
getParameter
(
key
));
}
bo
.
setClientIp
(
RemoteIPInterceptor
.
getRemoteIP
());
String
agent
=
request
.
getHeader
(
"user-agent"
);
log
.
info
(
"addMonitor user-agent={}"
,
agent
);
...
...
@@ -183,7 +183,7 @@ public class ClickUnionRest {
bo
.
setClient_type
(
"ios"
);
bo
.
setAppid
(
"490655927"
);
log
.
info
(
"addMonitor request={}"
,
bo
);
unionService
.
clickUnion
(
request
);
unionService
.
clickUnion
(
bo
);
log
.
info
(
"addMonitor with result is {}, and request is {}"
,
response
,
bo
);
response
.
setStatus
(
200
);
}
catch
(
Exception
e
)
{
...
...
server/src/main/java/com/yoho/unions/server/service/impl/TouTiaoServiceImpl.java
View file @
9f89da2
...
...
@@ -7,6 +7,7 @@ import com.yoho.service.model.union.request.ClickUnionRequestBO;
import
com.yoho.unions.common.enums.ClientTypeEnum
;
import
com.yoho.unions.server.service.IUnionService
;
import
com.yoho.unions.server.service.IUniteService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -24,11 +25,19 @@ public class TouTiaoServiceImpl implements IUniteService {
ClickUnionRequestBO
bo
=
new
ClickUnionRequestBO
();
String
idfa
=
request
.
getParameter
(
"idfa"
);
String
imei
=
request
.
getParameter
(
"imei"
);
bo
.
setIdfa
(
idfa
.
replaceAll
(
"__"
,
""
));
bo
.
setImei
(
imei
.
replaceAll
(
"__"
,
""
));
if
(
StringUtils
.
isNotEmpty
(
idfa
)){
bo
.
setIdfa
(
idfa
.
replaceAll
(
"__"
,
""
));
}
if
(
StringUtils
.
isNotEmpty
(
imei
)){
bo
.
setImei
(
imei
.
replaceAll
(
"__"
,
""
));
}
//将毫秒级的转换为秒级别
bo
.
setClickTime
(
Integer
.
valueOf
(
request
.
getParameter
(
"timestamp"
))/
1000
);
bo
.
setTd
(
request
.
getParameter
(
"td"
));
bo
.
setUnion_type
(
request
.
getParameter
(
"union_type"
));
bo
.
setAppid
(
request
.
getParameter
(
"appid"
));
String
callBackUrl
=
request
.
getParameter
(
"callback_url"
);
bo
.
setCallbackurl
(
callBackUrl
.
replaceAll
(
"__"
,
""
));
return
bo
;
...
...
server/src/main/java/com/yoho/unions/server/service/impl/UnionServiceImpl.java
View file @
9f89da2
...
...
@@ -73,6 +73,9 @@ public class UnionServiceImpl implements IUnionService {
@Resource
IAppActivateIdfaListDAO
appActivateIdfaListDAO
;
@Resource
(
name
=
"unionServiceImpl"
)
IUnionService
unionService
;
@Override
public
UnionResponse
clickUnion
(
ClickUnionRequestBO
request
)
throws
ServiceException
{
...
...
@@ -336,18 +339,19 @@ public class UnionServiceImpl implements IUnionService {
// UnionTypeModel type =
// UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
String
url
=
click
.
getCallbackurl
()
;
String
url
=
null
;
//取出具体是哪个union_type
//根据不同的url走不同的回调
try
{
if
(
StringUtils
.
isEmpty
(
url
)){
String
union_type
=
click
.
getUnion_type
();
StringBuffer
buffer
=
new
StringBuffer
();
String
bean
=
buffer
.
append
(
"UnionServiceImpl"
).
append
(
"_"
).
append
(
union_type
).
toString
();
String
union_type
=
click
.
getUnion_type
();
StringBuffer
buffer
=
new
StringBuffer
();
String
bean
=
buffer
.
append
(
"UnionServiceImpl"
).
append
(
"_"
).
append
(
union_type
).
toString
();
if
(
SpringContextUtil
.
containsBean
(
bean
)){
IUniteService
uniteService
=
SpringContextUtil
.
getBean
(
bean
,
IUniteService
.
class
);
url
=
uniteService
.
getCallbackUrl
(
click
,
request
);
}
else
{
url
=
unionService
.
getCallbackUrl
(
click
,
request
);
}
if
(
StringUtils
.
isEmpty
(
url
))
{
log
.
info
(
"activateUnion in success request is {}"
,
request
);
return
new
UnionResponse
();
...
...
server/src/main/java/com/yoho/unions/server/service/impl/WeiBoServiceImpl.java
View file @
9f89da2
...
...
@@ -23,10 +23,12 @@ public class WeiBoServiceImpl implements IUniteService {
clickUnionRequestBO
.
setIdfa
(
request
.
getParameter
(
"idfa_md5"
));
clickUnionRequestBO
.
setClientIp
(
request
.
getParameter
(
"ip"
));
//微博是毫秒,将其转换成秒
(
Long
.
valueOf
(
request
.
getParameter
(
"clicktime"
)))/
1000
;
clickUnionRequestBO
.
setClickTime
(
Integer
.
valueOf
(
Long
.
valueOf
(
request
.
getParameter
(
"clicktime"
))));
Long
clicktime
=
Long
.
valueOf
(
request
.
getParameter
(
"clicktime"
));
clickUnionRequestBO
.
setClickTime
((
int
)(
clicktime
/
1000
));
clickUnionRequestBO
.
setCallbackurl
(
request
.
getParameter
(
"IMP"
));
clickUnionRequestBO
.
setTd
(
request
.
getParameter
(
"td"
));
clickUnionRequestBO
.
setAppid
(
request
.
getParameter
(
"appid"
));
clickUnionRequestBO
.
setUnion_type
(
request
.
getParameter
(
"union_type"
));
return
clickUnionRequestBO
;
}
...
...
@@ -38,7 +40,7 @@ public class WeiBoServiceImpl implements IUniteService {
String
weiboUrl
=
"http://appmonitor.biz.weibo.com/sdkserver/active?company="
;
String
adv
=
"yoho"
;
StringBuffer
sb
=
new
StringBuffer
();
String
url
=
sb
.
append
(
weiboUrl
).
append
(
adv
).
append
(
imp
).
toString
();
String
url
=
sb
.
append
(
weiboUrl
).
append
(
adv
).
append
(
"&IMP"
).
append
(
imp
).
toString
();
return
url
;
}
...
...
Please
register
or
login
to post a comment