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
21a2466b7f3c39081078cbad990663c6013ff84d
1 parent
6d2e582e
unionType整改
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
392 additions
and
50 deletions
common/src/main/java/com/yoho/unions/common/constant/UnionConstant.java
common/src/main/java/com/yoho/unions/common/loader/LoaderData.java
common/src/main/java/com/yoho/unions/vo/OrderInfo.java
dal/src/main/java/com/yoho/unions/dal/IUnionTypeDAO.java
dal/src/main/java/com/yoho/unions/dal/model/UnionType.java
dal/src/main/java/com/yoho/unions/dal/model/UserOrders.java
dal/src/main/resources/META-INF/mybatis/UnionTypeMapper.xml
server/src/main/java/com/yoho/unions/server/mqconsumer/OrderPushConsumer.java
server/src/main/java/com/yoho/unions/server/service/impl/DDServiceImpl.java
server/src/main/java/com/yoho/unions/server/service/impl/GDTServiceImpl.java
server/src/main/java/com/yoho/unions/server/service/impl/OrderPushServiceImpl.java
server/src/main/java/com/yoho/unions/server/service/impl/UnionServiceImpl.java
server/src/main/java/com/yoho/unions/server/task/BigDataOrderInfoTask.java
web/src/main/resources/databases.yml
web/src/main/webapp/META-INF/autoconf/databases.yml
web/src/test/java/com/test/TestStart.java
common/src/main/java/com/yoho/unions/common/constant/UnionConstant.java
View file @
21a2466
...
...
@@ -22,7 +22,7 @@ public class UnionConstant {
/**
* 联盟类型
*/
public
static
Map
<
Integer
,
UnionTypeModel
>
unionTypeMap
=
new
HashMap
<>();
//
public static Map<Integer, UnionTypeModel> unionTypeMap = new HashMap<>();
/**
* 安卓系统需要实现的联盟
...
...
common/src/main/java/com/yoho/unions/common/loader/LoaderData.java
View file @
21a2466
...
...
@@ -25,25 +25,25 @@ import com.yoho.unions.common.constant.UnionConstant;
@Component
public
class
LoaderData
{
static
Logger
log
=
LoggerFactory
.
getLogger
(
LoaderData
.
class
);
@Resource
Map
<
String
,
Object
>
unionTypeMap
=
null
;
/**
* 初始化参数
*/
@PostConstruct
public
void
init
()
{
log
.
info
(
"begin LoaderData"
);
List
<
Map
<
String
,
Object
>>
unionTypeList
=
(
List
<
Map
<
String
,
Object
>>)
unionTypeMap
.
get
(
"union_types"
);
UnionTypeModel
unionType
;
for
(
Map
<
String
,
Object
>
map
:
unionTypeList
)
{
unionType
=
new
UnionTypeModel
();
unionType
.
setValue
((
int
)
map
.
get
(
"value"
));
unionType
.
setName
((
String
)
map
.
get
(
"name"
));
UnionConstant
.
unionTypeMap
.
put
(
unionType
.
getValue
(),
unionType
);
}
log
.
info
(
"end LoaderData"
);
}
// static Logger log = LoggerFactory.getLogger(LoaderData.class);
//
// @Resource
// Map<String, Object> unionTypeMap = null;
//
// /**
// * 初始化参数
// */
// @PostConstruct
// public void init() {
// log.info("begin LoaderData");
// List<Map<String, Object>> unionTypeList = (List<Map<String, Object>>) unionTypeMap.get("union_types");
// UnionTypeModel unionType;
// for (Map<String, Object> map : unionTypeList) {
// unionType = new UnionTypeModel();
// unionType.setValue((int) map.get("value"));
// unionType.setName((String) map.get("name"));
// UnionConstant.unionTypeMap.put(unionType.getValue(), unionType);
// }
// log.info("end LoaderData");
// }
}
...
...
common/src/main/java/com/yoho/unions/vo/OrderInfo.java
View file @
21a2466
...
...
@@ -5,6 +5,7 @@ import java.math.BigDecimal;
import
java.util.List
;
/**
* 大数据提供的订单数据
* Created by zhouxiang on 2016/11/4.
*/
public
class
OrderInfo
implements
Serializable
{
...
...
dal/src/main/java/com/yoho/unions/dal/IUnionTypeDAO.java
0 → 100644
View file @
21a2466
package
com
.
yoho
.
unions
.
dal
;
import
com.yoho.unions.dal.model.UnionType
;
public
interface
IUnionTypeDAO
{
int
deleteByPrimaryKey
(
Integer
id
);
int
insert
(
UnionType
record
);
int
insertSelective
(
UnionType
record
);
UnionType
selectByPrimaryKey
(
Integer
id
);
UnionType
selectByUnionType
(
Integer
unionType
);
int
updateByPrimaryKeySelective
(
UnionType
record
);
int
updateByPrimaryKey
(
UnionType
record
);
}
\ No newline at end of file
...
...
dal/src/main/java/com/yoho/unions/dal/model/UnionType.java
0 → 100644
View file @
21a2466
package
com
.
yoho
.
unions
.
dal
.
model
;
public
class
UnionType
{
private
Integer
id
;
private
String
name
;
private
Integer
createId
;
private
Integer
createTime
;
private
Integer
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
==
null
?
null
:
name
.
trim
();
}
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
;
}
}
\ No newline at end of file
...
...
dal/src/main/java/com/yoho/unions/dal/model/UserOrders.java
View file @
21a2466
...
...
@@ -43,12 +43,16 @@ public class UserOrders {
private
String
source
;
//目前没有使用
private
String
trackingCode
;
//目前没有使用
private
Integer
uId
;
//目前没有使用
private
Integer
orderTime
;
//目前没有使用
private
Integer
isPush
;
public
Integer
getId
()
{
...
...
dal/src/main/resources/META-INF/mybatis/UnionTypeMapper.xml
0 → 100644
View file @
21a2466
<?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.UnionType"
>
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"name"
property=
"name"
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
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
from union_type
where id = #{id,jdbcType=INTEGER}
</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
...
...
server/src/main/java/com/yoho/unions/server/mqconsumer/OrderPushConsumer.java
View file @
21a2466
...
...
@@ -74,7 +74,7 @@ public class OrderPushConsumer implements CommonMessageConsumer {
userOrders
.
setOrderTime
(
jsonObject
.
getInteger
(
"createTime"
));
//订单状态
userOrders
.
setOrderStatus
(
jsonObject
.
getInteger
(
"orderStatus"
));
//使用有货币、券
//使用有货币、券
,渠道
//第三方tracking_code
userOrders
.
setTrackingCode
(
unionCookie
.
getString
(
"channel_code"
));
//第三方用户id
...
...
server/src/main/java/com/yoho/unions/server/service/impl/DDServiceImpl.java
View file @
21a2466
...
...
@@ -4,9 +4,14 @@
package
com
.
yoho
.
unions
.
server
.
service
.
impl
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
javax.annotation.Resource
;
import
com.yoho.core.redis.YHValueOperations
;
import
com.yoho.unions.common.redis.RedisValueCache
;
import
com.yoho.unions.dal.IUnionTypeDAO
;
import
com.yoho.unions.dal.model.UnionType
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang3.tuple.Pair
;
...
...
@@ -53,9 +58,15 @@ public class DDServiceImpl implements MainUnionService {
@Resource
IUnionsActiveRecordDAO
unionsActiveRecordDAO
;
@Resource
IUnionTypeDAO
unionTypeDAO
;
@Resource
IAppActivateIdfaListDAO
appActivateIdfaListDAO
;
@Resource
RedisValueCache
redisValueCache
;
private
static
final
String
unions_KEY
=
"yh:unions:dingdang_"
;
...
...
@@ -169,8 +180,15 @@ public class DDServiceImpl implements MainUnionService {
response
.
setMsg
(
"app udid had actived"
);
return
response
;
}
UnionTypeModel
type
=
UnionConstant
.
unionTypeMap
.
get
(
1
);
UnionType
unionType
=
redisValueCache
.
get
(
"yh:union:uniontype:1"
,
UnionType
.
class
);
if
(
unionType
==
null
){
unionType
=
unionTypeDAO
.
selectByUnionType
(
1
);
redisValueCache
.
set
(
"yh:union:uniontype:1"
,
unionType
,
24
,
TimeUnit
.
HOURS
);
}
UnionTypeModel
type
=
new
UnionTypeModel
();
type
.
setName
(
unionType
.
getName
());
type
.
setValue
(
unionType
.
getUnionType
());
// UnionTypeModel type = UnionConstant.unionTypeMap.get(1);
String
yesterday
=
DateUtil
.
dateAdd
(
DateUtil
.
getToday
(
"yyyyMMdd"
),
"d"
,
-
1
,
"yyyyMMdd"
);
if
(
ClientTypeEnum
.
IOS
.
getName
().
equals
(
request
.
getClient_type
()))
{
List
<
AppActivateIdfaList
>
_90DayIdfaList
=
appActivateIdfaListDAO
.
selectByIdfaAndDate
(
new
AppActivateIdfaList
(
Long
.
valueOf
(
yesterday
),
request
.
getIdfa
()));
...
...
server/src/main/java/com/yoho/unions/server/service/impl/GDTServiceImpl.java
View file @
21a2466
...
...
@@ -3,9 +3,13 @@ package com.yoho.unions.server.service.impl;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
javax.annotation.Resource
;
import
com.yoho.unions.common.redis.RedisValueCache
;
import
com.yoho.unions.dal.IUnionTypeDAO
;
import
com.yoho.unions.dal.model.UnionType
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -51,6 +55,12 @@ public class GDTServiceImpl implements MainUnionService {
IUnionLogsDAO
unionLogsDAO
;
@Resource
IUnionTypeDAO
unionTypeDAO
;
@Resource
RedisValueCache
redisValueCache
;
@Resource
IAppActivateIdfaListDAO
appActivateIdfaListDAO
;
@Override
...
...
@@ -125,7 +135,15 @@ public class GDTServiceImpl implements MainUnionService {
// }
// }
UnionTypeModel
u
=
UnionConstant
.
unionTypeMap
.
get
(
3
);
// UnionTypeModel u = UnionConstant.unionTypeMap.get(3);
UnionType
unionType
=
redisValueCache
.
get
(
"yh:union:uniontype:3"
,
UnionType
.
class
);
if
(
unionType
==
null
){
unionType
=
unionTypeDAO
.
selectByUnionType
(
3
);
redisValueCache
.
set
(
"yh:union:uniontype:1"
,
unionType
,
24
,
TimeUnit
.
HOURS
);
}
UnionTypeModel
u
=
new
UnionTypeModel
();
u
.
setName
(
unionType
.
getName
());
u
.
setValue
(
unionType
.
getUnionType
());
String
yesterday
=
DateUtil
.
dateAdd
(
DateUtil
.
getToday
(
"yyyyMMdd"
),
"d"
,
-
1
,
"yyyyMMdd"
);
if
(
ClientTypeEnum
.
IOS
.
getName
().
equals
(
request
.
getClient_type
()))
{
List
<
AppActivateIdfaList
>
_90DayIdfaList
=
appActivateIdfaListDAO
.
selectByIdfaAndDate
(
new
AppActivateIdfaList
(
Long
.
valueOf
(
yesterday
),
request
.
getIdfa
()));
...
...
server/src/main/java/com/yoho/unions/server/service/impl/OrderPushServiceImpl.java
View file @
21a2466
package
com
.
yoho
.
unions
.
server
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.netflix.config.DynamicBooleanProperty
;
import
com.netflix.config.DynamicPropertyFactory
;
import
com.netflix.config.DynamicStringProperty
;
import
com.yoho.unions.common.utils.HttpUtils
;
import
com.yoho.unions.server.service.IOrderPushService
;
import
com.yoho.unions.vo.OrderInfo
;
import
com.yoho.unions.vo.OrdersGood
;
import
net.spy.memcached.compat.log.Logger
;
import
net.spy.memcached.compat.log.LoggerFactory
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by zhouxiang on 2016/11/7.
*/
public
class
OrderPushServiceImpl
{
@Service
public
class
OrderPushServiceImpl
implements
IOrderPushService
{
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrderPushServiceImpl
.
class
);
//推送公共的订单
public
void
pushOrder
(
List
<
OrderInfo
>
orderInfos
){
List
<
String
>
successCodes
=
new
ArrayList
<>();
for
(
OrderInfo
orderInfo
:
orderInfos
){
logger
.
info
(
"commonPushOrder: orderInfo is {}"
,
orderInfo
);
Map
param
=
new
HashMap
<>();
//订单号--对应父订单
param
.
put
(
"orderCode"
,
orderInfo
.
getParentOrderCode
());
//订单时间---时间戳
param
.
put
(
"orderTime"
,
orderInfo
.
getOrderTime
());
//订单支付方式--- //2=银联支付,3=线下支付,0=网上支付 默认网上支付
param
.
put
(
"orderPay"
,
orderInfo
.
getPayment
());
//订单金额
param
.
put
(
"orderAmount"
,
orderInfo
.
getOrderAmount
());
//订单状态,大于700,订单取消,否则订单已付款
param
.
put
(
"orderStatus"
,
orderInfo
.
getOrderStatus
());
//运费
param
.
put
(
"orderShipCost"
,
orderInfo
.
getShippingCost
());
//订单来源平台,(web,wap,app)
param
.
put
(
"orderType"
,
orderInfo
.
getOrderType
());
//商品最终支付金额
BigDecimal
proRealPay
=
new
BigDecimal
(
0
);
//如果有多个则需要将多个商品进行分割
List
<
OrdersGood
>
goods
=
orderInfo
.
getOrdersGoods
();
if
(
goods
.
size
()
==
1
)
{
OrdersGood
good
=
goods
.
get
(
0
);
//商品编号
param
.
put
(
"proNo"
,
good
.
getProductSkn
());
//商品价格
param
.
put
(
"proPrice"
,
good
.
getLastPrice
());
//商品数量
param
.
put
(
"proNum"
,
good
.
getBuyNumber
());
//商品名称
param
.
put
(
"proName"
,
good
.
getProductName
());
//商品分类名称
param
.
put
(
"proCat"
,
good
.
getSortName
());
//商品最终支付金额
proRealPay
=
good
.
getRealPayFee
().
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
else
{
StringBuffer
skns
=
new
StringBuffer
();
StringBuffer
prices
=
new
StringBuffer
();
StringBuffer
nums
=
new
StringBuffer
();
StringBuffer
names
=
new
StringBuffer
();
StringBuffer
cats
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
goods
.
size
();
i
++)
{
skns
.
append
(
goods
.
get
(
i
).
getProductSkn
()
+
"|"
);
prices
.
append
(
goods
.
get
(
i
).
getLastPrice
().
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
()
+
"|"
);
nums
.
append
(
goods
.
get
(
i
).
getBuyNumber
()
+
"|"
);
names
.
append
(
goods
.
get
(
i
).
getProductName
()
+
"|"
);
cats
.
append
(
goods
.
get
(
i
).
getSortName
()
+
"|"
);
proRealPay
=
proRealPay
.
add
(
goods
.
get
(
i
).
getRealPayFee
());
}
param
.
put
(
"proNo"
,
skns
.
substring
(
0
,
skns
.
length
()
-
1
));
param
.
put
(
"proPrice"
,
prices
.
substring
(
0
,
prices
.
length
()
-
1
));
param
.
put
(
"proNum"
,
nums
.
substring
(
0
,
nums
.
length
()
-
1
));
param
.
put
(
"proName"
,
names
.
substring
(
0
,
names
.
length
()
-
1
));
param
.
put
(
"proCat"
,
cats
.
substring
(
0
,
cats
.
length
()
-
1
));
}
param
.
put
(
"proRealPay"
,
proRealPay
.
doubleValue
());
Pair
<
Integer
,
String
>
pair
=
null
;
try
{
//根据不同的厂商,发送不同的URL
int
clientId
=
orderInfo
.
getClientId
();
DynamicStringProperty
url
=
DynamicPropertyFactory
.
getInstance
().
getStringProperty
(
"union-type-url:"
+
clientId
,
""
);
logger
.
info
(
"pushOrder: url is {}, param is {}"
,
url
,
param
);
pair
=
HttpUtils
.
httpPost
(
url
.
get
(),
param
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"common order post fail,orderCode is {}"
,
orderInfo
.
getParentOrderCode
());
}
JSONObject
json
=
JSONObject
.
parseObject
(
pair
.
getRight
());
if
(((
String
)
json
.
get
(
"code"
)).
equals
(
"200"
))
{
logger
.
info
(
"common pushOrder success,orderCode is {}"
,
orderInfo
.
getParentOrderCode
());
successCodes
.
add
(
orderInfo
.
getParentOrderCode
());
}
else
{
logger
.
warn
(
"common pushOrder fail,orderCode is {},message is {}"
,
orderInfo
.
getParentOrderCode
(),
(
String
)
json
.
get
(
"msg"
));
}
}
}
}
...
...
server/src/main/java/com/yoho/unions/server/service/impl/UnionServiceImpl.java
View file @
21a2466
...
...
@@ -9,6 +9,9 @@ import java.util.concurrent.TimeUnit;
import
javax.annotation.Resource
;
import
com.yoho.unions.common.redis.RedisValueCache
;
import
com.yoho.unions.dal.IUnionTypeDAO
;
import
com.yoho.unions.dal.model.UnionType
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.tuple.Pair
;
...
...
@@ -70,6 +73,12 @@ public class UnionServiceImpl implements IUnionService {
@Resource
IAppActivateIdfaListDAO
appActivateIdfaListDAO
;
@Resource
RedisValueCache
redisValueCache
;
@Resource
IUnionTypeDAO
unionTypeDAO
;
@Resource
(
name
=
"unionServiceImpl"
)
IUnionService
unionService
;
...
...
@@ -94,8 +103,13 @@ public class UnionServiceImpl implements IUnionService {
log
.
warn
(
"clickUnion error because union_type is error with param is {}"
,
request
);
return
new
UnionResponse
(
201
,
"union_type is error"
);
}
UnionTypeModel
m
=
UnionConstant
.
unionTypeMap
.
get
(
Integer
.
parseInt
(
request
.
getUnion_type
()));
if
(
m
==
null
)
{
// UnionTypeModel m = UnionConstant.unionTypeMap.get(Integer.parseInt(request.getUnion_type()));
UnionType
type
=
redisValueCache
.
get
(
"yh:union:uniontype:1"
,
UnionType
.
class
);
if
(
type
==
null
){
type
=
unionTypeDAO
.
selectByUnionType
(
1
);
redisValueCache
.
set
(
"yh:union:uniontype:1"
,
type
,
24
,
TimeUnit
.
HOURS
);
}
if
(
type
==
null
)
{
log
.
warn
(
"clickUnion error because union_type is error with param is {}"
,
request
);
return
new
UnionResponse
(
201
,
"union_type is error"
);
}
...
...
@@ -286,7 +300,16 @@ public class UnionServiceImpl implements IUnionService {
log
.
warn
(
"activateUnion error because 90 days has activate info with param is {}"
,
request
);
return
new
UnionResponse
(
203
,
"have activite in 90 days"
);
}
UnionTypeModel
u
=
UnionConstant
.
unionTypeMap
.
get
(
Integer
.
parseInt
(
click
.
getUnion_type
()));
// UnionTypeModel u = UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
String
unionTypekey
=
"yh:union:uniontype:"
+
click
.
getUnion_type
();
UnionType
unionType
=
redisValueCache
.
get
(
unionTypekey
,
UnionType
.
class
);
if
(
unionType
==
null
){
unionType
=
unionTypeDAO
.
selectByUnionType
(
Integer
.
parseInt
(
click
.
getUnion_type
()));
redisValueCache
.
set
(
unionTypekey
,
unionType
,
24
,
TimeUnit
.
HOURS
);
}
UnionTypeModel
u
=
new
UnionTypeModel
();
u
.
setName
(
unionType
.
getName
());
u
.
setValue
(
unionType
.
getUnionType
());
//如果是ios系统,还要到大数据表里面判断这个用户是否90天内的活跃用户,如果是的话,这次激活就不成功
String
yesterday
=
DateUtil
.
dateAdd
(
DateUtil
.
getToday
(
"yyyyMMdd"
),
"d"
,
-
1
,
"yyyyMMdd"
);
if
(
ClientTypeEnum
.
IOS
.
getName
().
equals
(
request
.
getClient_type
()))
{
...
...
server/src/main/java/com/yoho/unions/server/task/BigDataOrderInfoTask.java
View file @
21a2466
...
...
@@ -6,10 +6,12 @@ import com.google.common.collect.Lists;
import
com.google.common.collect.Maps
;
import
com.yoho.core.rest.client.ServiceCaller
;
import
com.yoho.unions.common.redis.RedisValueCache
;
import
com.yoho.unions.common.utils.SpringContextUtil
;
import
com.yoho.unions.dal.IUserOrdersDAO
;
import
com.yoho.unions.dal.model.UserOrders
;
import
com.yoho.unions.server.service.IOrderPushService
;
import
com.yoho.unions.server.service.IUnionOrderService
;
import
com.yoho.unions.server.service.IUnionService
;
import
com.yoho.unions.vo.OrderInfo
;
import
com.yoho.unions.vo.UnionOrderReqVO
;
import
jdk.nashorn.api.scripting.JSObject
;
...
...
@@ -21,6 +23,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -66,7 +69,7 @@ public class BigDataOrderInfoTask {
List
<
UserOrders
>
userOrderList
=
userOrdersDAO
.
getExistOrderCodes
(
orderMap
.
keySet
());
logger
.
info
(
"execute: userOrdersDAO.getExistOrderCodes: param is {}, result is {}"
,
orderMap
.
keySet
(),
userOrderList
==
null
?
0
:
userOrderList
.
size
());
//按source分类
Map
<
Integer
,
List
<
OrderInfo
>>
orderInfoMap
=
Maps
.
newHashMap
();
Map
<
Integer
,
List
<
OrderInfo
>>
orderInfoMap
=
Maps
.
newHashMap
();
for
(
UserOrders
userOrders
:
userOrderList
)
{
OrderInfo
orderInfo
=
orderMap
.
get
(
userOrders
.
getOrderCode
());
logger
.
info
(
"execute: get orderInfo is {}"
,
orderInfo
);
...
...
@@ -85,12 +88,17 @@ public class BigDataOrderInfoTask {
}
orderInfoMap
.
get
(
orderInfo
.
getClientId
()).
add
(
orderInfo
);
}
//按source分类推送
for
(
Integer
clientId
:
orderInfoMap
.
keySet
())
{
IOrderPushService
orderPushService
=
orderPushServiceMap
.
get
(
clientId
);
//clientId如果不在xml配置的里面,则走通用的
try
{
orderPushService
.
pushOrder
(
orderInfoMap
.
get
(
clientId
));
if
(
orderPushService
==
null
){
IOrderPushService
pushService
=
SpringContextUtil
.
getBean
(
"orderPushServiceImpl"
,
IOrderPushService
.
class
);
pushService
.
pushOrder
(
orderInfoMap
.
get
(
clientId
));
}
else
{
orderPushService
.
pushOrder
(
orderInfoMap
.
get
(
clientId
));
}
}
catch
(
Exception
e
){
logger
.
warn
(
"push order fail! clientId {} e {}"
,
clientId
,
e
);
}
...
...
web/src/main/resources/databases.yml
View file @
21a2466
...
...
@@ -32,5 +32,6 @@ datasources:
password
:
9nm0icOwt6bMHjMusIfMLw==
daos
:
-
com.yoho.unions.dal.IUserOrdersDAO
-
com.yoho.unions.dal.IUnionTypeDAO
readOnlyInSlave
:
true
\ No newline at end of file
...
...
web/src/main/webapp/META-INF/autoconf/databases.yml
View file @
21a2466
...
...
@@ -33,4 +33,6 @@ datasources:
password
:
${jdbc.mysql.unions.password}
daos
:
-
com.yoho.unions.dal.IUserOrdersDAO
-
com.yoho.unions.dal.IUnionTypeDAO
readOnlyInSlave
:
true
\ No newline at end of file
...
...
web/src/test/java/com/test/TestStart.java
View file @
21a2466
...
...
@@ -28,20 +28,20 @@ public class TestStart {
@Resource
Map
<
String
,
Object
>
unionTypeMap
;
@Test
public
void
test
()
{
for
(
Entry
<
Integer
,
UnionTypeModel
>
entry
:
UnionConstant
.
unionTypeMap
.
entrySet
())
{
System
.
out
.
print
(
entry
.
getValue
().
getName
());
System
.
out
.
print
(
","
);
System
.
out
.
print
(
entry
.
getValue
().
getValue
());
System
.
out
.
print
(
","
);
System
.
out
.
print
(
"http://union.yoho.cn/union/downapp.html?union_type="
+
entry
.
getKey
());
System
.
out
.
print
(
","
);
System
.
out
.
print
(
"http://union.yoho.cn/union/ClickUnionRest/addMonitor?union_type="
+
entry
.
getKey
());
System
.
out
.
print
(
","
);
System
.
out
.
print
(
"http://union.yoho.cn/union/ClickUnionRest/addUnion4Special?union_type="
+
entry
.
getKey
());
System
.
out
.
println
();
}
System
.
out
.
println
(
"hahahah= "
+
UnionConstant
.
unionTypeMap
.
get
(
1
).
getName
());
}
// @Test
// public void test() {
// for (Entry<Integer, UnionTypeModel> entry : UnionConstant.unionTypeMap.entrySet()) {
// System.out.print(entry.getValue().getName());
// System.out.print(",");
// System.out.print(entry.getValue().getValue());
// System.out.print(",");
// System.out.print("http://union.yoho.cn/union/downapp.html?union_type=" + entry.getKey());
// System.out.print(",");
// System.out.print("http://union.yoho.cn/union/ClickUnionRest/addMonitor?union_type=" + entry.getKey());
// System.out.print(",");
// System.out.print("http://union.yoho.cn/union/ClickUnionRest/addUnion4Special?union_type=" + entry.getKey());
// System.out.println();
// }
// System.out.println("hahahah= " + UnionConstant.unionTypeMap.get(1).getName());
// }
}
...
...
Please
register
or
login
to post a comment