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
ZhongW
8 years ago
Commit
4616b3c7a3be7182c9790ea3d4f6efedd3900cb7
1 parent
7e89d02e
推送控制
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
315 additions
and
6 deletions
common/src/main/java/com/yoho/unions/common/enums/UnionTypeStatusEnum.java
dal/src/main/java/com/yoho/unions/dal/IUnionTypeManageDAO.java
dal/src/main/java/com/yoho/unions/dal/model/UnionType.java
dal/src/main/java/com/yoho/unions/dal/model/UnionTypeManage.java
dal/src/main/resources/META-INF/mybatis/UnionTypeManageMapper.xml
dal/src/main/resources/META-INF/mybatis/UnionTypeMapper.xml
server/src/main/java/com/yoho/unions/server/service/impl/RedirectServiceImpl.java
server/src/main/java/com/yoho/unions/server/task/BigDataOrderInfoTask.java
common/src/main/java/com/yoho/unions/common/enums/UnionTypeStatusEnum.java
0 → 100644
View file @
4616b3c
package
com
.
yoho
.
unions
.
common
.
enums
;
/**
* Created by yoho on 2016/12/12.
*/
public
enum
UnionTypeStatusEnum
{
OPEN
(
"0"
),
CLOSE
(
"1"
);
private
String
status
;
public
String
getStatus
()
{
return
status
;
}
private
UnionTypeStatusEnum
(
String
status
)
{
this
.
status
=
status
;
}
}
...
...
dal/src/main/java/com/yoho/unions/dal/IUnionTypeManageDAO.java
0 → 100644
View file @
4616b3c
package
com
.
yoho
.
unions
.
dal
;
import
com.yoho.unions.dal.model.UnionTypeManage
;
import
java.util.List
;
/**
* Created by yoho on 2016/12/12.
*/
public
interface
IUnionTypeManageDAO
{
List
<
UnionTypeManage
>
selectAll
();
}
...
...
dal/src/main/java/com/yoho/unions/dal/model/UnionType.java
View file @
4616b3c
...
...
@@ -5,12 +5,34 @@ public class UnionType {
private
String
name
;
private
String
goUrl
;
private
Integer
createId
;
private
Integer
createTime
;
private
Integer
unionType
;
@Override
public
String
toString
()
{
return
"UnionType{"
+
"id="
+
id
+
", name='"
+
name
+
'\''
+
", goUrl="
+
goUrl
+
", createId="
+
createId
+
", createTime="
+
createTime
+
", unionType="
+
unionType
+
'}'
;
}
public
String
getGoUrl
()
{
return
goUrl
;
}
public
void
setGoUrl
(
String
goUrl
)
{
this
.
goUrl
=
goUrl
;
}
public
Integer
getId
()
{
return
id
;
}
...
...
dal/src/main/java/com/yoho/unions/dal/model/UnionTypeManage.java
0 → 100644
View file @
4616b3c
package
com
.
yoho
.
unions
.
dal
.
model
;
/**
* Created by yoho on 2016/12/12.
*/
public
class
UnionTypeManage
{
private
Integer
id
;
private
String
name
;
private
String
unionClass
;
private
String
status
;
private
Integer
createId
;
private
Integer
createTime
;
private
Integer
unionType
;
@Override
public
String
toString
()
{
return
"UnionTypeManage{"
+
"id="
+
id
+
", name='"
+
name
+
'\''
+
", unionClass='"
+
unionClass
+
'\''
+
", status='"
+
status
+
'\''
+
", createId="
+
createId
+
", createTime="
+
createTime
+
", unionType="
+
unionType
+
'}'
;
}
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getUnionClass
()
{
return
unionClass
;
}
public
void
setUnionClass
(
String
unionClass
)
{
this
.
unionClass
=
unionClass
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
Integer
getCreateId
()
{
return
createId
;
}
public
void
setCreateId
(
Integer
createId
)
{
this
.
createId
=
createId
;
}
public
Integer
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Integer
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Integer
getUnionType
()
{
return
unionType
;
}
public
void
setUnionType
(
Integer
unionType
)
{
this
.
unionType
=
unionType
;
}
}
...
...
dal/src/main/resources/META-INF/mybatis/UnionTypeManageMapper.xml
0 → 100644
View file @
4616b3c
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.yoho.unions.dal.IUnionTypeDAO"
>
<resultMap
id=
"BaseResultMap"
type=
"com.yoho.unions.dal.model.UnionTypeManage"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"union_type"
property=
"unionType"
jdbcType=
"INTEGER"
/>
<result
column=
"name"
property=
"name"
jdbcType=
"VARCHAR"
/>
<result
column=
"union_class"
property=
"unionClass"
jdbcType=
"VARCHAR"
/>
<result
column=
"create_id"
property=
"createId"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"INTEGER"
/>
<result
column=
"status"
property=
"status"
jdbcType=
"VARCHAR"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, union_type,name,union_class, create_id, create_time, status
</sql>
<select
id=
"selectAll"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from union_type
</select>
<!--<select id="selectByUnionType" resultMap="BaseResultMap" parameterType="java.lang.Integer">
SELECT <include refid="Base_Column_List" />
from union_type
where union_type = #{unionType,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_type
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionType" >
insert into union_type (id, name, create_id,
create_time, union_type)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{createId,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{unionType,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionType" >
insert into union_type
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="createId != null" >
create_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="unionType != null" >
union_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="createId != null" >
#{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="unionType != null" >
#{unionType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionType" >
update union_type
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="createId != null" >
create_id = #{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="unionType != null" >
union_type = #{unionType,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionType" >
update union_type
set name = #{name,jdbcType=VARCHAR},
create_id = #{createId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER},
union_type = #{unionType,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>-->
</mapper>
\ No newline at end of file
...
...
dal/src/main/resources/META-INF/mybatis/UnionTypeMapper.xml
View file @
4616b3c
...
...
@@ -4,12 +4,13 @@
<resultMap
id=
"BaseResultMap"
type=
"com.yoho.unions.dal.model.UnionType"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"name"
property=
"name"
jdbcType=
"VARCHAR"
/>
<result
column=
"go_url"
property=
"goUrl"
jdbcType=
"VARCHAR"
/>
<result
column=
"create_id"
property=
"createId"
jdbcType=
"INTEGER"
/>
<result
column=
"create_time"
property=
"createTime"
jdbcType=
"INTEGER"
/>
<result
column=
"union_type"
property=
"unionType"
jdbcType=
"INTEGER"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, name, create_id, create_time, union_type
id, name,
go_url,
create_id, create_time, union_type
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
...
...
@@ -27,9 +28,9 @@
where id = #{id,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.yoho.unions.dal.model.UnionType"
>
insert into union_type (id, name,
create_id,
insert into union_type (id, name,
go_url, create_id,
create_time, union_type)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
#{createId,jdbcType=INTEGER},
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
#{goUrl,jdbcType=VARCHAR}, #{createId,jdbcType=INTEGER},
#{createTime,jdbcType=INTEGER}, #{unionType,jdbcType=INTEGER})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.yoho.unions.dal.model.UnionType"
>
...
...
@@ -38,9 +39,12 @@
<if
test=
"id != null"
>
id,
</if>
<if
test=
"name != null"
>
<if
test=
"name != null
and name != ''
"
>
name,
</if>
<if
test=
"goUrl != null and goUrl != '' "
>
go_url,
</if>
<if
test=
"createId != null"
>
create_id,
</if>
...
...
@@ -55,9 +59,12 @@
<if
test=
"id != null"
>
#{id,jdbcType=INTEGER},
</if>
<if
test=
"name != null"
>
<if
test=
"name != null
and name != ''
"
>
#{name,jdbcType=VARCHAR},
</if>
<if
test=
"goUrl != null and goUrl != '' "
>
#{goUrl,jdbcType=VARCHAR},
</if>
<if
test=
"createId != null"
>
#{createId,jdbcType=INTEGER},
</if>
...
...
@@ -72,9 +79,12 @@
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.yoho.unions.dal.model.UnionType"
>
update union_type
<set
>
<if
test=
"name != null"
>
<if
test=
"name != null
and name !=''
"
>
name = #{name,jdbcType=VARCHAR},
</if>
<if
test=
"name != null and goUrl !='' "
>
name = #{goUrl,jdbcType=VARCHAR},
</if>
<if
test=
"createId != null"
>
create_id = #{createId,jdbcType=INTEGER},
</if>
...
...
@@ -90,6 +100,7 @@
<update
id=
"updateByPrimaryKey"
parameterType=
"com.yoho.unions.dal.model.UnionType"
>
update union_type
set name = #{name,jdbcType=VARCHAR},
go_url = #{goUrl,jdbcType=VARCHAR},
create_id = #{createId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER},
union_type = #{unionType,jdbcType=INTEGER}
...
...
server/src/main/java/com/yoho/unions/server/service/impl/RedirectServiceImpl.java
View file @
4616b3c
...
...
@@ -2,11 +2,14 @@ package com.yoho.unions.server.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.yoho.unions.common.enums.SourceEnum
;
import
com.yoho.unions.dal.IUnionTypeDAO
;
import
com.yoho.unions.dal.model.UnionType
;
import
com.yoho.unions.server.service.IRedirectService
;
import
com.yoho.unions.vo.UnionReqVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -33,6 +36,9 @@ public class RedirectServiceImpl implements IRedirectService {
private
static
final
String
WEB_REDIRECT_URL
=
"http://www.yohobuy.com/3party/ads"
;
@Autowired
private
IUnionTypeDAO
unionTypeDAO
;
@Override
public
void
jump
(
UnionReqVO
uionReqVO
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
logger
.
info
(
"Enter jump: request param is {} "
,
uionReqVO
);
...
...
@@ -55,6 +61,8 @@ public class RedirectServiceImpl implements IRedirectService {
redirectUrl
=
this
.
builderUrlForPanshi
(
uionReqVO
);
}
else
if
(
"51fanli"
.
equals
(
channelId
))
{
redirectUrl
=
this
.
builderUrlForFanli
(
uionReqVO
);
}
else
{
redirectUrl
=
builderCommonUrl
(
uionReqVO
);
}
response
.
setStatus
(
301
);
response
.
sendRedirect
(
redirectUrl
);
...
...
@@ -117,6 +125,27 @@ public class RedirectServiceImpl implements IRedirectService {
return
urlBuilder
.
toString
();
}
private
String
builderCommonUrl
(
UnionReqVO
uionReqVO
){
String
channelId
=
uionReqVO
.
getChannel_id
();
UnionType
unionType
=
unionTypeDAO
.
selectByUnionType
(
Integer
.
parseInt
(
channelId
.
trim
()));
if
(
null
==
unionType
||
StringUtils
.
isBlank
(
unionType
.
getGoUrl
())
||
StringUtils
.
isBlank
(
unionType
.
getName
()))
return
""
;
StringBuilder
targetUrl
=
new
StringBuilder
(
"http://union.yohobuy.com/go?client_id="
);
targetUrl
.
append
(
channelId
.
trim
());
targetUrl
.
append
(
"&channel_code="
);
targetUrl
.
append
(
unionType
.
getName
());
targetUrl
.
append
(
"&append=&go_url="
);
targetUrl
.
append
(
unionType
.
getGoUrl
());
if
(
targetUrl
.
toString
().
contains
(
"?"
))
{
targetUrl
.
append
(
"&utm_source="
).
append
(
uionReqVO
.
getUtm_source
()).
append
(
"&utm_medium="
).
append
(
uionReqVO
.
getUtm_medium
()).
append
(
"&utm_campaign="
).
append
(
uionReqVO
.
getUtm_campaign
());
}
else
{
targetUrl
.
append
(
"?utm_source="
).
append
(
uionReqVO
.
getUtm_source
()).
append
(
"&utm_medium="
).
append
(
uionReqVO
.
getUtm_medium
()).
append
(
"&utm_campaign="
).
append
(
uionReqVO
.
getUtm_campaign
());
}
return
targetUrl
.
toString
();
}
/**
* 解析url
*
...
...
server/src/main/java/com/yoho/unions/server/task/BigDataOrderInfoTask.java
View file @
4616b3c
...
...
@@ -5,9 +5,12 @@ import com.google.common.base.Function;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.yoho.core.rest.client.ServiceCaller
;
import
com.yoho.unions.common.enums.UnionTypeStatusEnum
;
import
com.yoho.unions.common.redis.RedisValueCache
;
import
com.yoho.unions.common.utils.SpringContextUtil
;
import
com.yoho.unions.dal.IUnionTypeManageDAO
;
import
com.yoho.unions.dal.IUserOrdersDAO
;
import
com.yoho.unions.dal.model.UnionTypeManage
;
import
com.yoho.unions.dal.model.UserOrders
;
import
com.yoho.unions.server.service.IOrderPushService
;
import
com.yoho.unions.server.service.IUnionOrderService
;
...
...
@@ -45,6 +48,9 @@ public class BigDataOrderInfoTask {
@Autowired
IUserOrdersDAO
userOrdersDAO
;
@Autowired
IUnionTypeManageDAO
unionTypeManageDAO
;
@Scheduled
(
cron
=
"* 0/3 * * * ?"
)
public
void
run
()
{
UnionOrderReqVO
reqVO
=
new
UnionOrderReqVO
();
...
...
@@ -88,8 +94,13 @@ public class BigDataOrderInfoTask {
}
orderInfoMap
.
get
(
orderInfo
.
getClientId
()).
add
(
orderInfo
);
}
//应该推送的clientId
List
<
UnionTypeManage
>
unionTypeManageList
=
unionTypeManageDAO
.
selectAll
();
//按source分类推送
for
(
Integer
clientId
:
orderInfoMap
.
keySet
())
{
if
(!
checkIsPush
(
clientId
,
unionTypeManageList
))
continue
;
IOrderPushService
orderPushService
=
orderPushServiceMap
.
get
(
clientId
);
//clientId如果不在xml配置的里面,则走通用的
try
{
...
...
@@ -105,4 +116,15 @@ public class BigDataOrderInfoTask {
}
}
//是否需要推送
private
boolean
checkIsPush
(
Integer
clientId
,
List
<
UnionTypeManage
>
unionTypeManageList
){
for
(
UnionTypeManage
unionTypeManage
:
unionTypeManageList
){
if
(
clientId
.
intValue
()
==
unionTypeManage
.
getUnionType
()){
if
(
UnionTypeStatusEnum
.
OPEN
.
getStatus
().
equals
(
unionTypeManage
.
getStatus
())){}
return
true
;
}
}
return
false
;
}
}
...
...
Please
register
or
login
to post a comment