Merge branch '广点通转化上报'
# Conflicts: # web/src/main/resources/databases.yml # web/src/main/webapp/META-INF/autoconf/databases.yml
Showing
15 changed files
with
702 additions
and
74 deletions
1 | package com.yoho.unions.common.redis; | 1 | package com.yoho.unions.common.redis; |
2 | 2 | ||
3 | import com.yoho.core.redis.YHListOperations; | 3 | import com.yoho.core.redis.YHListOperations; |
4 | +import com.yoho.core.redis.YHRedisTemplate; | ||
4 | import com.yoho.unions.common.utils.SerializeUtils; | 5 | import com.yoho.unions.common.utils.SerializeUtils; |
6 | +import com.yoho.unions.helper.CacheKeyHelper; | ||
7 | +import org.apache.commons.collections.CollectionUtils; | ||
5 | import org.apache.commons.lang3.StringUtils; | 8 | import org.apache.commons.lang3.StringUtils; |
6 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
7 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
@@ -9,6 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -9,6 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
10 | 13 | ||
11 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
15 | +import java.util.ArrayList; | ||
16 | +import java.util.Collection; | ||
17 | +import java.util.concurrent.TimeUnit; | ||
12 | 18 | ||
13 | @Component | 19 | @Component |
14 | public class RedisListCache { | 20 | public class RedisListCache { |
@@ -17,6 +23,8 @@ public class RedisListCache { | @@ -17,6 +23,8 @@ public class RedisListCache { | ||
17 | 23 | ||
18 | @Resource(name="yhListOperations") | 24 | @Resource(name="yhListOperations") |
19 | YHListOperations<String, String> yhListOperations; | 25 | YHListOperations<String, String> yhListOperations; |
26 | + @Resource | ||
27 | + YHRedisTemplate<String, String> yHRedisTemplate; | ||
20 | 28 | ||
21 | /** | 29 | /** |
22 | * redis rightPop 操作 | 30 | * redis rightPop 操作 |
@@ -66,4 +74,33 @@ public class RedisListCache { | @@ -66,4 +74,33 @@ public class RedisListCache { | ||
66 | 74 | ||
67 | } | 75 | } |
68 | 76 | ||
77 | + public <T> void rightPushAll(String key,Collection<T> values, long timeout, TimeUnit unit) { | ||
78 | + logger.debug("Enter rightPushAll redis list. key is {}, value is {}, timeout is {}, unit is {}", key, values, timeout, unit); | ||
79 | + // 如果是空列表,直接返回 | ||
80 | + if (CollectionUtils.isEmpty(values)) { | ||
81 | + return; | ||
82 | + } | ||
83 | + | ||
84 | + String cacheKey = key; | ||
85 | + // 如果获取的key为空,则说明缓存开关是关闭的 | ||
86 | + if (StringUtils.isEmpty(cacheKey)) { | ||
87 | + return; | ||
88 | + } | ||
89 | + try { | ||
90 | + Collection<String> strValues = new ArrayList<String>(); | ||
91 | + for (T t : values) { | ||
92 | + String strValue = CacheKeyHelper.value2String(t); | ||
93 | + if (StringUtils.isEmpty(strValue)) { | ||
94 | + continue; | ||
95 | + } | ||
96 | + strValues.add(strValue); | ||
97 | + } | ||
98 | + yhListOperations.rightPushAll(cacheKey, strValues); | ||
99 | + yHRedisTemplate.longExpire(cacheKey, timeout, unit); | ||
100 | + | ||
101 | + } catch (Exception e) { | ||
102 | + logger.warn("rightPushAll redis list operation failed. key is {}", cacheKey, e); | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
69 | } | 106 | } |
1 | +package com.yoho.unions.vo; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import java.math.BigDecimal; | ||
5 | + | ||
6 | +/** | ||
7 | + * 转化数据 | ||
8 | + * Created by yoho on 2017/2/22. | ||
9 | + */ | ||
10 | +public class TransInfo implements Serializable { | ||
11 | + | ||
12 | + //标示是普通交寄还是首单交寄 | ||
13 | + private String type; | ||
14 | + | ||
15 | + private BigDecimal orderAmount; | ||
16 | + | ||
17 | + private String udid; | ||
18 | + | ||
19 | + private String uid; | ||
20 | + | ||
21 | + private String ordercode; | ||
22 | + | ||
23 | + public String getUid() { | ||
24 | + return uid; | ||
25 | + } | ||
26 | + | ||
27 | + public void setUid(String uid) { | ||
28 | + this.uid = uid; | ||
29 | + } | ||
30 | + | ||
31 | + public String getOrdercode() { | ||
32 | + return ordercode; | ||
33 | + } | ||
34 | + | ||
35 | + public void setOrdercode(String ordercode) { | ||
36 | + this.ordercode = ordercode; | ||
37 | + } | ||
38 | + | ||
39 | + public String getType() { | ||
40 | + return type; | ||
41 | + } | ||
42 | + | ||
43 | + public void setType(String type) { | ||
44 | + this.type = type; | ||
45 | + } | ||
46 | + | ||
47 | + public BigDecimal getOrderAmount() { | ||
48 | + return orderAmount; | ||
49 | + } | ||
50 | + | ||
51 | + public void setOrderAmount(BigDecimal orderAmount) { | ||
52 | + this.orderAmount = orderAmount; | ||
53 | + } | ||
54 | + | ||
55 | + public String getUdid() { | ||
56 | + return udid; | ||
57 | + } | ||
58 | + | ||
59 | + public void setUdid(String udid) { | ||
60 | + this.udid = udid; | ||
61 | + } | ||
62 | +} |
1 | +package com.yoho.unions.dal; | ||
2 | + | ||
3 | + | ||
4 | +import com.yoho.unions.dal.model.UnionActivity; | ||
5 | + | ||
6 | +public interface IUnionActivityDAO { | ||
7 | + | ||
8 | + int insert(UnionActivity record); | ||
9 | + | ||
10 | + int insertSelective(UnionActivity record); | ||
11 | + | ||
12 | + UnionActivity selectByPrimaryKey(Long id); | ||
13 | + | ||
14 | + UnionActivity selectByUdid(String udid); | ||
15 | +} |
1 | -//package com.yoho.unions.dal; | ||
2 | -// | ||
3 | -// | ||
4 | -//import com.yoho.unions.dal.model.UnionDepartmentUrl; | ||
5 | -// | ||
6 | -//public interface IUnionDepartmentUrlDAO { | ||
7 | -// int deleteByPrimaryKey(Integer id); | ||
8 | -// | ||
9 | -// int insert(UnionDepartmentUrl record); | ||
10 | -// | ||
11 | -// int insertSelective(UnionDepartmentUrl record); | ||
12 | -// | ||
13 | -// UnionDepartmentUrl selectByPrimaryKey(Integer id); | ||
14 | -// | ||
15 | -// int updateByPrimaryKeySelective(UnionDepartmentUrl record); | ||
16 | -// | ||
17 | -// int updateByPrimaryKey(UnionDepartmentUrl record); | ||
18 | -// | ||
19 | -// UnionDepartmentUrl selectByUnionType(String unionType); | ||
20 | -//} |
1 | -//package com.yoho.unions.dal; | ||
2 | -// | ||
3 | -// | ||
4 | -//import com.yoho.unions.dal.model.UnionType; | ||
5 | -// | ||
6 | -//public interface IUnionTypeDAO { | ||
7 | -// int deleteByPrimaryKey(Integer id); | ||
8 | -// | ||
9 | -// int insert(UnionType record); | ||
10 | -// | ||
11 | -// int insertSelective(UnionType record); | ||
12 | -// | ||
13 | -// UnionType selectByPrimaryKey(Integer id); | ||
14 | -// | ||
15 | -// UnionType selectByUnionType(Integer unionType); | ||
16 | -// | ||
17 | -// int updateByPrimaryKeySelective(UnionType record); | ||
18 | -// | ||
19 | -// int updateByPrimaryKey(UnionType record); | ||
20 | -//} |
1 | +package com.yoho.unions.dal.model; | ||
2 | + | ||
3 | +public class UnionActivity { | ||
4 | + private Long id; | ||
5 | + | ||
6 | + private String udid; | ||
7 | + | ||
8 | + private String muid; | ||
9 | + | ||
10 | + private String unionType; | ||
11 | + | ||
12 | + private String clientType; | ||
13 | + | ||
14 | + private String advertiserId; | ||
15 | + | ||
16 | + private String clickId; | ||
17 | + | ||
18 | + private Integer createTime; | ||
19 | + | ||
20 | + public Long getId() { | ||
21 | + return id; | ||
22 | + } | ||
23 | + | ||
24 | + public void setId(Long id) { | ||
25 | + this.id = id; | ||
26 | + } | ||
27 | + | ||
28 | + public String getUdid() { | ||
29 | + return udid; | ||
30 | + } | ||
31 | + | ||
32 | + public void setUdid(String udid) { | ||
33 | + this.udid = udid == null ? null : udid.trim(); | ||
34 | + } | ||
35 | + | ||
36 | + public String getMuid() { | ||
37 | + return muid; | ||
38 | + } | ||
39 | + | ||
40 | + public void setMuid(String muid) { | ||
41 | + this.muid = muid == null ? null : muid.trim(); | ||
42 | + } | ||
43 | + | ||
44 | + public String getUnionType() { | ||
45 | + return unionType; | ||
46 | + } | ||
47 | + | ||
48 | + public void setUnionType(String unionType) { | ||
49 | + this.unionType = unionType == null ? null : unionType.trim(); | ||
50 | + } | ||
51 | + | ||
52 | + public String getClientType() { | ||
53 | + return clientType; | ||
54 | + } | ||
55 | + | ||
56 | + public void setClientType(String clientType) { | ||
57 | + this.clientType = clientType == null ? null : clientType.trim(); | ||
58 | + } | ||
59 | + | ||
60 | + public String getAdvertiserId() { | ||
61 | + return advertiserId; | ||
62 | + } | ||
63 | + | ||
64 | + public void setAdvertiserId(String advertiserId) { | ||
65 | + this.advertiserId = advertiserId == null ? null : advertiserId.trim(); | ||
66 | + } | ||
67 | + | ||
68 | + public String getClickId() { | ||
69 | + return clickId; | ||
70 | + } | ||
71 | + | ||
72 | + public void setClickId(String clickId) { | ||
73 | + this.clickId = clickId == null ? null : clickId.trim(); | ||
74 | + } | ||
75 | + | ||
76 | + public Integer getCreateTime() { | ||
77 | + return createTime; | ||
78 | + } | ||
79 | + | ||
80 | + public void setCreateTime(Integer createTime) { | ||
81 | + this.createTime = createTime; | ||
82 | + } | ||
83 | +} |
1 | +package com.yoho.unions.dal.model; | ||
2 | + | ||
3 | +import java.math.BigDecimal; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by yoho on 2017/2/22. | ||
7 | + */ | ||
8 | +public class UnionActivityTrans { | ||
9 | + | ||
10 | + //订单金额 | ||
11 | + private BigDecimal order_amount; | ||
12 | + //设备号 | ||
13 | + private String udid; | ||
14 | + | ||
15 | + private String uid; | ||
16 | + | ||
17 | + private String order_code; | ||
18 | + | ||
19 | + public String getUid() { | ||
20 | + return uid; | ||
21 | + } | ||
22 | + | ||
23 | + public void setUid(String uid) { | ||
24 | + this.uid = uid; | ||
25 | + } | ||
26 | + | ||
27 | + public String getUdid() { | ||
28 | + return udid; | ||
29 | + } | ||
30 | + | ||
31 | + public void setUdid(String udid) { | ||
32 | + this.udid = udid; | ||
33 | + } | ||
34 | + | ||
35 | + public BigDecimal getOrder_amount() { | ||
36 | + return order_amount; | ||
37 | + } | ||
38 | + | ||
39 | + public void setOrder_amount(BigDecimal order_amount) { | ||
40 | + this.order_amount = order_amount; | ||
41 | + } | ||
42 | + | ||
43 | + public String getOrder_code() { | ||
44 | + return order_code; | ||
45 | + } | ||
46 | + | ||
47 | + public void setOrder_code(String order_code) { | ||
48 | + this.order_code = order_code; | ||
49 | + } | ||
50 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.unions.dal.IUnionActivityDAO" > | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionActivity" > | ||
5 | + <id column="id" property="id" jdbcType="BIGINT" /> | ||
6 | + <result column="udid" property="udid" jdbcType="VARCHAR" /> | ||
7 | + <result column="muid" property="muid" jdbcType="VARCHAR" /> | ||
8 | + <result column="union_type" property="unionType" jdbcType="VARCHAR" /> | ||
9 | + <result column="client_type" property="clientType" jdbcType="VARCHAR" /> | ||
10 | + <result column="advertiser_id" property="advertiserId" jdbcType="VARCHAR" /> | ||
11 | + <result column="click_id" property="clickId" jdbcType="VARCHAR" /> | ||
12 | + <result column="create_time" property="createTime" jdbcType="INTEGER" /> | ||
13 | + </resultMap> | ||
14 | + <sql id="Base_Column_List" > | ||
15 | + id, udid, muid, union_type, client_type, advertiser_id, click_id, create_time | ||
16 | + </sql> | ||
17 | + | ||
18 | + <select id="selectByUdid" resultMap="BaseResultMap"> | ||
19 | + select <include refid="Base_Column_List" /> | ||
20 | + from union_activity | ||
21 | + where udid = #{udid} limit 1 | ||
22 | + </select> | ||
23 | + <insert id="insert" parameterType="com.yoho.unions.dal.model.UnionActivity" > | ||
24 | + insert into union_activity (id, udid, muid, | ||
25 | + union_type, client_type, advertiser_id, | ||
26 | + click_id, create_time) | ||
27 | + values (#{id,jdbcType=BIGINT}, #{udid,jdbcType=VARCHAR}, #{muid,jdbcType=VARCHAR}, | ||
28 | + #{unionType,jdbcType=VARCHAR}, #{clientType,jdbcType=VARCHAR}, #{advertiserId,jdbcType=VARCHAR}, | ||
29 | + #{clickId,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}) | ||
30 | + </insert> | ||
31 | + <insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionActivity" > | ||
32 | + insert into union_activity | ||
33 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
34 | + <if test="id != null" > | ||
35 | + id, | ||
36 | + </if> | ||
37 | + <if test="udid != null" > | ||
38 | + udid, | ||
39 | + </if> | ||
40 | + <if test="muid != null" > | ||
41 | + muid, | ||
42 | + </if> | ||
43 | + <if test="unionType != null" > | ||
44 | + union_type, | ||
45 | + </if> | ||
46 | + <if test="clientType != null" > | ||
47 | + client_type, | ||
48 | + </if> | ||
49 | + <if test="advertiserId != null" > | ||
50 | + advertiser_id, | ||
51 | + </if> | ||
52 | + <if test="clickId != null" > | ||
53 | + click_id, | ||
54 | + </if> | ||
55 | + <if test="createTime != null" > | ||
56 | + create_time, | ||
57 | + </if> | ||
58 | + </trim> | ||
59 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
60 | + <if test="id != null" > | ||
61 | + #{id,jdbcType=BIGINT}, | ||
62 | + </if> | ||
63 | + <if test="udid != null" > | ||
64 | + #{udid,jdbcType=VARCHAR}, | ||
65 | + </if> | ||
66 | + <if test="muid != null" > | ||
67 | + #{muid,jdbcType=VARCHAR}, | ||
68 | + </if> | ||
69 | + <if test="unionType != null" > | ||
70 | + #{unionType,jdbcType=VARCHAR}, | ||
71 | + </if> | ||
72 | + <if test="clientType != null" > | ||
73 | + #{clientType,jdbcType=VARCHAR}, | ||
74 | + </if> | ||
75 | + <if test="advertiserId != null" > | ||
76 | + #{advertiserId,jdbcType=VARCHAR}, | ||
77 | + </if> | ||
78 | + <if test="clickId != null" > | ||
79 | + #{clickId,jdbcType=VARCHAR}, | ||
80 | + </if> | ||
81 | + <if test="createTime != null" > | ||
82 | + #{createTime,jdbcType=INTEGER}, | ||
83 | + </if> | ||
84 | + </trim> | ||
85 | + </insert> | ||
86 | + | ||
87 | +</mapper> |
1 | package com.yoho.unions.server.service; | 1 | package com.yoho.unions.server.service; |
2 | 2 | ||
3 | import com.yoho.unions.vo.OrderInfo; | 3 | import com.yoho.unions.vo.OrderInfo; |
4 | +import com.yoho.unions.vo.TransInfo; | ||
4 | import com.yoho.unions.vo.UnionOrderReqVO; | 5 | import com.yoho.unions.vo.UnionOrderReqVO; |
5 | 6 | ||
6 | import java.util.List; | 7 | import java.util.List; |
@@ -9,4 +10,6 @@ public interface IUnionOrderService { | @@ -9,4 +10,6 @@ public interface IUnionOrderService { | ||
9 | 10 | ||
10 | public List<OrderInfo> getUnionOrders(UnionOrderReqVO req); | 11 | public List<OrderInfo> getUnionOrders(UnionOrderReqVO req); |
11 | 12 | ||
13 | + public List<TransInfo> getTrandInfo(UnionOrderReqVO req); | ||
14 | + | ||
12 | } | 15 | } |
1 | package com.yoho.unions.server.service.impl; | 1 | package com.yoho.unions.server.service.impl; |
2 | 2 | ||
3 | +import com.yoho.service.model.union.UnionTrans; | ||
3 | import com.yoho.unions.common.redis.RedisHashCache; | 4 | import com.yoho.unions.common.redis.RedisHashCache; |
4 | import com.yoho.unions.common.redis.RedisListCache; | 5 | import com.yoho.unions.common.redis.RedisListCache; |
6 | +import com.yoho.unions.dal.model.UnionActivityTrans; | ||
5 | import com.yoho.unions.dal.model.UnionOrders; | 7 | import com.yoho.unions.dal.model.UnionOrders; |
6 | import com.yoho.unions.dal.model.UnionOrdersGoods; | 8 | import com.yoho.unions.dal.model.UnionOrdersGoods; |
7 | import com.yoho.unions.server.service.IUnionOrderService; | 9 | import com.yoho.unions.server.service.IUnionOrderService; |
8 | import com.yoho.unions.vo.OrderInfo; | 10 | import com.yoho.unions.vo.OrderInfo; |
9 | import com.yoho.unions.vo.OrdersGood; | 11 | import com.yoho.unions.vo.OrdersGood; |
12 | +import com.yoho.unions.vo.TransInfo; | ||
10 | import com.yoho.unions.vo.UnionOrderReqVO; | 13 | import com.yoho.unions.vo.UnionOrderReqVO; |
11 | import org.apache.commons.collections.CollectionUtils; | 14 | import org.apache.commons.collections.CollectionUtils; |
12 | import org.apache.commons.lang3.StringUtils; | 15 | import org.apache.commons.lang3.StringUtils; |
@@ -26,8 +29,14 @@ public class UnionOrderServiceImpl implements IUnionOrderService { | @@ -26,8 +29,14 @@ public class UnionOrderServiceImpl implements IUnionOrderService { | ||
26 | 29 | ||
27 | private static final String UNION_ORDER_KEY = "union:orders"; | 30 | private static final String UNION_ORDER_KEY = "union:orders"; |
28 | 31 | ||
32 | + private static final String UNION_TRAND = "YH:BD:ORDER:UNIONS"; | ||
33 | + | ||
29 | private static final String UNION_ORDER_GOODS_KEY_PRE = "union:order_goods:"; | 34 | private static final String UNION_ORDER_GOODS_KEY_PRE = "union:order_goods:"; |
30 | 35 | ||
36 | + private static final String UNION_TRANS_UNIONTYPE = "YH:BD:UNI:1:ORDER:"; | ||
37 | + | ||
38 | + private static final String UNION_NORMAL_TRANS_UNIONTYPE = "YH:BD:UNI:ALL:ORDER:"; | ||
39 | + | ||
31 | @Autowired | 40 | @Autowired |
32 | private RedisListCache redisListCache; | 41 | private RedisListCache redisListCache; |
33 | 42 | ||
@@ -67,6 +76,52 @@ public class UnionOrderServiceImpl implements IUnionOrderService { | @@ -67,6 +76,52 @@ public class UnionOrderServiceImpl implements IUnionOrderService { | ||
67 | } | 76 | } |
68 | } | 77 | } |
69 | 78 | ||
79 | + @Override | ||
80 | + public List<TransInfo> getTrandInfo(UnionOrderReqVO req) { | ||
81 | + logger.info("Enter getTrandInfo: request param is {}", req); | ||
82 | + try { | ||
83 | + List<TransInfo> resList = new ArrayList<TransInfo>(); | ||
84 | + Long size = redisListCache.size(UNION_TRAND); | ||
85 | + int sizeInt = size == null ? 0 : size.intValue(); | ||
86 | + if (sizeInt > 0) { | ||
87 | + for (int i = 0; i < size; i++) { | ||
88 | + UnionTrans unionTrans = redisListCache.rightPop(UNION_TRAND, UnionTrans.class); | ||
89 | + String union_type = unionTrans.getUnion_type(); | ||
90 | + //首单交寄 | ||
91 | + String firstOrder = UNION_TRANS_UNIONTYPE + union_type; | ||
92 | + //普通交寄 | ||
93 | + String normalOrder = UNION_NORMAL_TRANS_UNIONTYPE + union_type; | ||
94 | + List<UnionActivityTrans> firstOrderList = new ArrayList<>(); | ||
95 | + Long firstOrderSize = redisListCache.size(firstOrder); | ||
96 | + Long normalOrderSize = redisListCache.size(normalOrder); | ||
97 | + if (firstOrderSize > 0) { | ||
98 | + for (int j = 0; j < firstOrderSize; j++) { | ||
99 | + UnionActivityTrans unionActivityTrans = redisListCache.rightPop(firstOrder, UnionActivityTrans.class); | ||
100 | + firstOrderList.add(unionActivityTrans); | ||
101 | + } | ||
102 | + | ||
103 | + } | ||
104 | + logger.info("getFirstOrderList: from bigdata redis: key is {}, result size is {}", firstOrder, firstOrderList == null ? 0 : firstOrderList.size()); | ||
105 | + List<UnionActivityTrans> normalOrderList = new ArrayList<>(); | ||
106 | + if (normalOrderSize > 0) { | ||
107 | + for (int k = 0; k < normalOrderSize; k++) { | ||
108 | + UnionActivityTrans unionActivityTrans = redisListCache.rightPop(normalOrder, UnionActivityTrans.class); | ||
109 | + normalOrderList.add(unionActivityTrans); | ||
110 | + } | ||
111 | + } | ||
112 | + logger.info("getNormalOrderList: from bigdata redis: key is {}, result size is {}", normalOrder, normalOrderList == null ? 0 : normalOrderList.size()); | ||
113 | + resList = this.convertTrans(resList,firstOrderList, normalOrderList); | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + return resList; | ||
118 | + | ||
119 | + } catch (Exception e) { | ||
120 | + logger.warn("getUnionOrders: get orders from bigdata redis failed, error is {}", e); | ||
121 | + return null; | ||
122 | + } | ||
123 | + } | ||
124 | + | ||
70 | private OrderInfo convertToUnionOrderBo(UnionOrders unionOrder){ | 125 | private OrderInfo convertToUnionOrderBo(UnionOrders unionOrder){ |
71 | if(null == unionOrder){ | 126 | if(null == unionOrder){ |
72 | return null; | 127 | return null; |
@@ -114,4 +169,35 @@ public class UnionOrderServiceImpl implements IUnionOrderService { | @@ -114,4 +169,35 @@ public class UnionOrderServiceImpl implements IUnionOrderService { | ||
114 | return resList; | 169 | return resList; |
115 | } | 170 | } |
116 | 171 | ||
172 | + private List<TransInfo> convertTrans(List<TransInfo> resList,List<UnionActivityTrans> firstOrderList,List<UnionActivityTrans> normalOrderList){ | ||
173 | + if(CollectionUtils.isEmpty(firstOrderList)&&CollectionUtils.isEmpty(normalOrderList)){ | ||
174 | + return null; | ||
175 | + } | ||
176 | + | ||
177 | + if(CollectionUtils.isNotEmpty(firstOrderList)){ | ||
178 | + for(UnionActivityTrans unionActivityTrans:firstOrderList){ | ||
179 | + TransInfo transInfo = new TransInfo(); | ||
180 | + //首单设为1 | ||
181 | + transInfo.setType("1"); | ||
182 | + transInfo.setUdid(unionActivityTrans.getUdid()); | ||
183 | + transInfo.setOrderAmount(unionActivityTrans.getOrder_amount()); | ||
184 | + transInfo.setUid(unionActivityTrans.getUid()); | ||
185 | + transInfo.setOrdercode(unionActivityTrans.getOrder_code()); | ||
186 | + resList.add(transInfo); | ||
187 | + } | ||
188 | + } | ||
189 | + if(CollectionUtils.isNotEmpty(normalOrderList)){ | ||
190 | + for(UnionActivityTrans unionActivityTran:normalOrderList){ | ||
191 | + TransInfo transInfo = new TransInfo(); | ||
192 | + //正常单设为2 | ||
193 | + transInfo.setType("2"); | ||
194 | + transInfo.setUdid(unionActivityTran.getUdid()); | ||
195 | + transInfo.setOrderAmount(unionActivityTran.getOrder_amount()); | ||
196 | + transInfo.setUid(unionActivityTran.getUid()); | ||
197 | + transInfo.setOrdercode(unionActivityTran.getOrder_code()); | ||
198 | + resList.add(transInfo); | ||
199 | + } | ||
200 | + } | ||
201 | + return resList; | ||
202 | + } | ||
117 | } | 203 | } |
@@ -19,6 +19,7 @@ import com.yoho.service.model.union.request.ActivateUnionRequestBO; | @@ -19,6 +19,7 @@ import com.yoho.service.model.union.request.ActivateUnionRequestBO; | ||
19 | import com.yoho.service.model.union.request.ClickUnionRequestBO; | 19 | import com.yoho.service.model.union.request.ClickUnionRequestBO; |
20 | import com.yoho.service.model.union.response.UnionResponse; | 20 | import com.yoho.service.model.union.response.UnionResponse; |
21 | import com.yoho.unions.common.enums.ClientTypeEnum; | 21 | import com.yoho.unions.common.enums.ClientTypeEnum; |
22 | +import com.yoho.unions.common.redis.RedisListCache; | ||
22 | import com.yoho.unions.common.redis.RedisValueCache; | 23 | import com.yoho.unions.common.redis.RedisValueCache; |
23 | import com.yoho.unions.common.utils.DateUtil; | 24 | import com.yoho.unions.common.utils.DateUtil; |
24 | import com.yoho.unions.common.utils.HttpUtils; | 25 | import com.yoho.unions.common.utils.HttpUtils; |
@@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory; | @@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory; | ||
34 | import org.springframework.context.ApplicationEventPublisher; | 35 | import org.springframework.context.ApplicationEventPublisher; |
35 | import org.springframework.context.ApplicationEventPublisherAware; | 36 | import org.springframework.context.ApplicationEventPublisherAware; |
36 | import org.springframework.stereotype.Service; | 37 | import org.springframework.stereotype.Service; |
38 | + | ||
37 | import javax.annotation.Resource; | 39 | import javax.annotation.Resource; |
38 | import java.net.URLDecoder; | 40 | import java.net.URLDecoder; |
39 | import java.util.List; | 41 | import java.util.List; |
@@ -70,7 +72,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -70,7 +72,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
70 | 72 | ||
71 | @Resource(name="yhValueOperations") | 73 | @Resource(name="yhValueOperations") |
72 | YHValueOperations<String, String> yhValueOperations; | 74 | YHValueOperations<String, String> yhValueOperations; |
73 | - | 75 | + |
74 | @Resource | 76 | @Resource |
75 | IUnionLogsDAO unionLogsDAO; | 77 | IUnionLogsDAO unionLogsDAO; |
76 | 78 | ||
@@ -84,6 +86,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -84,6 +86,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
84 | RedisValueCache redisValueCache; | 86 | RedisValueCache redisValueCache; |
85 | 87 | ||
86 | @Resource | 88 | @Resource |
89 | + RedisListCache redisListCache; | ||
90 | + | ||
91 | + @Resource | ||
87 | IMktMarketingUrlDAO mktMarketingUrlDAO; | 92 | IMktMarketingUrlDAO mktMarketingUrlDAO; |
88 | 93 | ||
89 | @Resource | 94 | @Resource |
@@ -93,6 +98,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -93,6 +98,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
93 | IUnionActivityLogsDAO unionActivityLogsDAO; | 98 | IUnionActivityLogsDAO unionActivityLogsDAO; |
94 | 99 | ||
95 | @Resource | 100 | @Resource |
101 | + IUnionActivityDAO unionActivityDAO; | ||
102 | + | ||
103 | + @Resource | ||
96 | IUnionTypeMatchDAO unionTypeMatchDAO; | 104 | IUnionTypeMatchDAO unionTypeMatchDAO; |
97 | 105 | ||
98 | @Resource(name="unionServiceImpl") | 106 | @Resource(name="unionServiceImpl") |
@@ -182,25 +190,18 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -182,25 +190,18 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
182 | yhValueOperations.set(key, JSON.toJSONString(request)); | 190 | yhValueOperations.set(key, JSON.toJSONString(request)); |
183 | yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); | 191 | yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); |
184 | clickUnion.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request)); | 192 | clickUnion.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request)); |
185 | - | ||
186 | -// log.info("clickUnion set redis success with request={}", request); | ||
187 | - | ||
188 | -// if (union != null) { | ||
189 | -// //如果90天以内,已经存在点击记录,则不需要插入或更新数据库 | ||
190 | -// log.info("clickUnion have click in 90 days with request={}", request); | ||
191 | -// return new UnionResponse(); | 193 | + |
194 | +// UnionActivityTrans unionActivityTrans = new UnionActivityTrans(); | ||
195 | +// List<UnionActivityTrans> list = new ArrayList<>(); | ||
196 | +// for(int i=0;i<3;i++){ | ||
197 | +// UnionActivityTrans unionActivityTrans = new UnionActivityTrans(); | ||
198 | +// unionActivityTrans.setOrdercode("123"); | ||
199 | +// unionActivityTrans.setUdid("234"); | ||
200 | +// unionActivityTrans.setOrderAmount(new BigDecimal(12)); | ||
201 | +// unionActivityTrans.setUid("12"); | ||
202 | +// list.add(unionActivityTrans); | ||
192 | // } | 203 | // } |
193 | - //保存信息到数据库 | ||
194 | -// UnionLogs logs = new UnionLogs(); | ||
195 | -// logs.setTd(request.getTd()); | ||
196 | -// logs.setAppId(request.getAppid()); | ||
197 | -// logs.setClientType(request.getClient_type()); | ||
198 | -// logs.setUnionType(Byte.valueOf(request.getUnion_type())); | ||
199 | -// logs.setCreateTime(DateUtil.getCurrentTimeSecond()); | ||
200 | -// logs.setUpdateTime(logs.getCreateTime()); | ||
201 | -// logs.setAddParams(JSON.toJSONString(request)); | ||
202 | -// logs.setIsActivate(Byte.valueOf("0")); | ||
203 | -// unionLogsDAO.insert(logs); | 204 | +// redisListCache.rightPushAll("UNION:KEY:123",list,activeTime.get(),TimeUnit.HOURS); |
204 | 205 | ||
205 | return new UnionResponse(); | 206 | return new UnionResponse(); |
206 | } catch (Exception e) { | 207 | } catch (Exception e) { |
@@ -507,12 +508,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -507,12 +508,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
507 | log.warn("callback error with request={}", request); | 508 | log.warn("callback error with request={}", request); |
508 | return new UnionResponse(204, "callback error"); | 509 | return new UnionResponse(204, "callback error"); |
509 | } | 510 | } |
511 | + //如果来源是广点通,则把广点通的一些信息记入表,给之后做转化上报使用 | ||
512 | + if(union_type.equals("3")){ | ||
513 | + saveUnionActivity(click,request); | ||
514 | + } | ||
515 | + | ||
516 | + | ||
510 | } catch (Exception e) { | 517 | } catch (Exception e) { |
511 | log.error("callback error with request={}", request, e); | 518 | log.error("callback error with request={}", request, e); |
512 | //return new UnionResponse(204, "callback error"); | 519 | //return new UnionResponse(204, "callback error"); |
513 | } | 520 | } |
514 | 521 | ||
515 | - | ||
516 | activeUnion.info("activateUnion in success request is {}", request); | 522 | activeUnion.info("activateUnion in success request is {}", request); |
517 | 523 | ||
518 | return new UnionResponse(); | 524 | return new UnionResponse(); |
@@ -565,6 +571,30 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -565,6 +571,30 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
565 | }); | 571 | }); |
566 | } | 572 | } |
567 | 573 | ||
574 | + private void saveUnionActivity(ClickUnionRequestBO click,ActivateUnionRequestBO request){ | ||
575 | + taskExecutor.execute(new Runnable(){ | ||
576 | + @Override | ||
577 | + public void run() | ||
578 | + { | ||
579 | + UnionActivity unionActivity = new UnionActivity(); | ||
580 | + unionActivity.setClientType(request.getClient_type()); | ||
581 | + unionActivity.setUdid(request.getUdid()); | ||
582 | + if(StringUtils.isNotEmpty(click.getIdfa())){ | ||
583 | + unionActivity.setUdid(click.getIdfa()); | ||
584 | + }else { | ||
585 | + unionActivity.setUdid(click.getImei()); | ||
586 | + } | ||
587 | + unionActivity.setUnionType(click.getUnion_type()); | ||
588 | + //广点通的账号id存入的是click的commonUse字段 | ||
589 | + unionActivity.setAdvertiserId(click.getCommonUse()); | ||
590 | + //广点通点击id | ||
591 | + unionActivity.setClickId(click.getClickId()); | ||
592 | + unionActivity.setCreateTime(DateUtil.getCurrentTimeSecond()); | ||
593 | + unionActivityDAO.insertSelective(unionActivity); | ||
594 | + } | ||
595 | + }); | ||
596 | + } | ||
597 | + | ||
568 | @Override | 598 | @Override |
569 | public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { | 599 | public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) { |
570 | this.publisher = applicationEventPublisher; | 600 | this.publisher = applicationEventPublisher; |
1 | +package com.yoho.unions.server.task; | ||
2 | + | ||
3 | +import com.yoho.service.model.union.response.UnionResponse; | ||
4 | +import com.yoho.unions.common.enums.ClientTypeEnum; | ||
5 | +import com.yoho.unions.common.utils.DateUtil; | ||
6 | +import com.yoho.unions.common.utils.HttpUtils; | ||
7 | +import com.yoho.unions.dal.IUnionActivityDAO; | ||
8 | +import com.yoho.unions.dal.IUnionConfigDAO; | ||
9 | +import com.yoho.unions.dal.model.UnionActivity; | ||
10 | +import com.yoho.unions.dal.model.UnionConfig; | ||
11 | +import com.yoho.unions.server.service.IUnionOrderService; | ||
12 | +import com.yoho.core.common.utils.MD5; | ||
13 | +import org.apache.commons.codec.binary.Base64; | ||
14 | +import com.yoho.unions.vo.TransInfo; | ||
15 | +import com.yoho.unions.vo.UnionOrderReqVO; | ||
16 | +import org.apache.commons.collections.CollectionUtils; | ||
17 | +import org.apache.commons.lang.StringUtils; | ||
18 | +import org.apache.commons.lang3.tuple.Pair; | ||
19 | +import org.slf4j.Logger; | ||
20 | +import org.slf4j.LoggerFactory; | ||
21 | +import org.springframework.beans.factory.annotation.Autowired; | ||
22 | +import org.springframework.scheduling.annotation.Scheduled; | ||
23 | +import org.springframework.stereotype.Component; | ||
24 | + | ||
25 | +import javax.annotation.Resource; | ||
26 | +import java.io.UnsupportedEncodingException; | ||
27 | +import java.math.BigDecimal; | ||
28 | +import java.net.URLEncoder; | ||
29 | +import java.util.List; | ||
30 | + | ||
31 | +/** | ||
32 | + * 广点通转化数据上报,定时从大数据抽取数据,然后联盟拼接,上报给广点通 | ||
33 | + * Created by yoho on 2017/2/22. | ||
34 | + */ | ||
35 | +@Component | ||
36 | +public class GdtTransTask { | ||
37 | + | ||
38 | + static Logger log = LoggerFactory.getLogger(GdtTransTask.class); | ||
39 | + | ||
40 | + @Autowired | ||
41 | + private IUnionOrderService unionOrderService; | ||
42 | + | ||
43 | + @Resource | ||
44 | + IUnionActivityDAO unionActivityDAO; | ||
45 | + | ||
46 | + @Resource | ||
47 | + IUnionConfigDAO unionConfigDAO; | ||
48 | + | ||
49 | + @Scheduled(cron = "* 0/5 * * * ?") | ||
50 | + public void run() { | ||
51 | + UnionOrderReqVO reqVO = new UnionOrderReqVO(); | ||
52 | + reqVO.setLimit(20); | ||
53 | + this.execute(reqVO); | ||
54 | + } | ||
55 | + | ||
56 | + public void execute(UnionOrderReqVO reqVO){ | ||
57 | + //从大数据中取出联盟需要的广点通带来转化的设备号,和金额 | ||
58 | + | ||
59 | + List<TransInfo> transInfoList = unionOrderService.getTrandInfo(reqVO); | ||
60 | + if (CollectionUtils.isEmpty(transInfoList)) { | ||
61 | + return; | ||
62 | + } | ||
63 | + //将取出来的数据进行拼接 | ||
64 | + for(TransInfo transInfo:transInfoList){ | ||
65 | + log.info("enter trans udid is {},ordercode is {}",transInfo.getUdid(),transInfo.getOrdercode()); | ||
66 | + String udid = transInfo.getUdid(); | ||
67 | + //利用udid去表中查出是两个广点通账号带来的 | ||
68 | + UnionActivity unionActivity = unionActivityDAO.selectByUdid(udid); | ||
69 | + | ||
70 | + if(unionActivity==null){ | ||
71 | + return; | ||
72 | + } | ||
73 | + //按照广点通要求拼接数据 | ||
74 | + String url = urlEode(unionActivity,transInfo); | ||
75 | + //改成httpclient方式调用 | ||
76 | + Pair<Integer, String> pair = HttpUtils.httpGet(url); | ||
77 | + log.info("GdtTransTask call union success url={}, and result={}", url, pair); | ||
78 | + if (pair.getLeft() != 200) { | ||
79 | + log.warn("callback error with request={}", url); | ||
80 | + } | ||
81 | + | ||
82 | + } | ||
83 | + } | ||
84 | + | ||
85 | + public String urlEode(UnionActivity requestBO,TransInfo transInfo) { | ||
86 | + log.info("enter GdtTransTask.urlEode requestBO is {}, transInfo is {} ", requestBO,transInfo); | ||
87 | + // 根据不同的应用类型,获取不同的加密密钥和签名密钥 | ||
88 | + String encryptKey = "BAAAAAAAAAAABZJQ"; | ||
89 | + String signKey = "1461f1237d22dfc7"; | ||
90 | + String muid4MD5 = requestBO.getMuid(); | ||
91 | + String url = "http://t.gdt.qq.com/conv/app/"; | ||
92 | + //有货在智慧推的账号id | ||
93 | + String uid = "365136"; | ||
94 | + if(StringUtils.isNotEmpty(requestBO.getAdvertiserId())){ | ||
95 | + uid = requestBO.getAdvertiserId(); | ||
96 | + } | ||
97 | + String clientType = ClientTypeEnum.IOS.getName(); | ||
98 | + if(StringUtils.isNotEmpty(requestBO.getClientType())){ | ||
99 | + clientType = requestBO.getClientType().toLowerCase(); | ||
100 | + } | ||
101 | + UnionConfig unionConfig = unionConfigDAO.selectByUidAndClientType(Integer.valueOf(uid),clientType); | ||
102 | + if(null!=unionConfig){ | ||
103 | + encryptKey = unionConfig.getEncryptKey(); | ||
104 | + signKey = unionConfig.getSignKey(); | ||
105 | + url = unionConfig.getUrl(); | ||
106 | + } | ||
107 | + //APPID可以固定根据clientType判断 | ||
108 | + String appId = "490655927"; | ||
109 | + if(clientType.equals(ClientTypeEnum.ANDROID.getName())){ | ||
110 | + appId = "100898104"; | ||
111 | + } | ||
112 | + int conv_time = DateUtil.getCurrentTimeSecond(); | ||
113 | + String page = null; | ||
114 | + String query_string = null; | ||
115 | + String clickId = requestBO.getClickId(); | ||
116 | + StringBuffer bf = new StringBuffer(); | ||
117 | + StringBuffer sf = new StringBuffer(); | ||
118 | + page = bf.append(url).append(appId).append("/conv?click_id=").append(clickId).append("&muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&value=").append(transInfo.getOrderAmount().multiply(new BigDecimal(100))).toString(); | ||
119 | + query_string = sf.append("click_id=").append(clickId).append("&muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&value=").append(transInfo.getOrderAmount().multiply(new BigDecimal(100))).toString(); | ||
120 | + log.info("enter GdtTransTask.urlEode page is {}",page); | ||
121 | + log.info("enter GdtTransTask.urlEode query_string is {}",query_string); | ||
122 | + // 对url进行加密 | ||
123 | + String encode_page = null; | ||
124 | + try { | ||
125 | + encode_page = URLEncoder.encode(page, "UTF-8"); | ||
126 | + log.info("activateZhiHuitui urlEncoder is{} ", encode_page); | ||
127 | + } catch (UnsupportedEncodingException e) { | ||
128 | + log.error("encode exception.", e); | ||
129 | + } | ||
130 | + // 将签名密钥和提交方式与加密后的url进行拼接 | ||
131 | + StringBuffer urlBuffer = new StringBuffer(); | ||
132 | + | ||
133 | + String property = urlBuffer.append(signKey).append("&GET&").append(encode_page).toString(); | ||
134 | + String signature = MD5.md5(property); | ||
135 | + StringBuffer base = new StringBuffer(); | ||
136 | + String base_data = base.append(query_string).append("&sign=").append(signature).toString(); | ||
137 | + | ||
138 | + // 简单异或处理 | ||
139 | + String data = simpleXorByGdt(base_data, encryptKey); | ||
140 | + // base64编码 | ||
141 | + String ret = Base64.encodeBase64String(data.getBytes()); | ||
142 | + // 64位处理之后,防止里面有换行符 | ||
143 | + String retRep = ret.replaceAll("\n", ""); | ||
144 | + // 将64位处理之后的值,按照url加密的方式进行加密 | ||
145 | + try { | ||
146 | + retRep = URLEncoder.encode(retRep, "UTF-8"); | ||
147 | + log.info("activateUnion retRep is{}", retRep); | ||
148 | + } catch (UnsupportedEncodingException e) { | ||
149 | + log.error("encode exception.", e); | ||
150 | + } | ||
151 | + // conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE); | ||
152 | + String convType = "MOBILEAPP_COST"; | ||
153 | + if(transInfo.getType().equals("1")){ | ||
154 | + convType = "MOBILEAPP_ADDTOCART"; | ||
155 | + } | ||
156 | + StringBuffer sb = new StringBuffer(); | ||
157 | + url = sb.append(url).append(appId).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver(clientType)).append("&advertiser_id=").append(uid).toString(); | ||
158 | + log.info("GdtTransTask url is {}", url); | ||
159 | + return url; | ||
160 | + } | ||
161 | + | ||
162 | + /** | ||
163 | + * 简单异或 | ||
164 | + * | ||
165 | + * @param source | ||
166 | + * @param key | ||
167 | + * @return | ||
168 | + */ | ||
169 | + private String simpleXorByGdt(String source, String key) { | ||
170 | + String result = ""; | ||
171 | + int j = 0; | ||
172 | + for (int i = 0; i < source.length(); i++) { | ||
173 | + int c1 = source.charAt(i); | ||
174 | + int c2 = key.charAt(j); | ||
175 | + | ||
176 | + result = result + (char) (c1 ^ c2); | ||
177 | + j = j + 1; | ||
178 | + j = j % (key.length()); | ||
179 | + } | ||
180 | + | ||
181 | + return result; | ||
182 | + } | ||
183 | + | ||
184 | + private String clientTypeConver(String clientType) { | ||
185 | + if (StringUtils.isEmpty(clientType)) { | ||
186 | + return null; | ||
187 | + } | ||
188 | + if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType)) { | ||
189 | + return clientType.toUpperCase(); | ||
190 | + } else { | ||
191 | + return "IOS"; | ||
192 | + } | ||
193 | + | ||
194 | + } | ||
195 | +} |
@@ -42,6 +42,7 @@ datasources: | @@ -42,6 +42,7 @@ datasources: | ||
42 | - com.yoho.unions.dal.IUnionTypeMatchDAO | 42 | - com.yoho.unions.dal.IUnionTypeMatchDAO |
43 | - com.yoho.unions.dal.ITencentMktActivityDAO | 43 | - com.yoho.unions.dal.ITencentMktActivityDAO |
44 | - com.yoho.unions.dal.ITencentMktCouponHistoryDAO | 44 | - com.yoho.unions.dal.ITencentMktCouponHistoryDAO |
45 | + - com.yoho.unions.dal.IUnionActivityDAO | ||
45 | - com.yoho.unions.dal.IUnionConfigDAO | 46 | - com.yoho.unions.dal.IUnionConfigDAO |
46 | 47 | ||
47 | readOnlyInSlave: true | 48 | readOnlyInSlave: true |
@@ -43,6 +43,7 @@ datasources: | @@ -43,6 +43,7 @@ datasources: | ||
43 | - com.yoho.unions.dal.IUnionTypeMatchDAO | 43 | - com.yoho.unions.dal.IUnionTypeMatchDAO |
44 | - com.yoho.unions.dal.ITencentMktActivityDAO | 44 | - com.yoho.unions.dal.ITencentMktActivityDAO |
45 | - com.yoho.unions.dal.ITencentMktCouponHistoryDAO | 45 | - com.yoho.unions.dal.ITencentMktCouponHistoryDAO |
46 | + - com.yoho.unions.dal.IUnionActivityDAO | ||
46 | - com.yoho.unions.dal.IUnionConfigDAO | 47 | - com.yoho.unions.dal.IUnionConfigDAO |
47 | 48 | ||
48 | readOnlyInSlave: true | 49 | readOnlyInSlave: true |
1 | package com.test; | 1 | package com.test; |
2 | 2 | ||
3 | import java.io.UnsupportedEncodingException; | 3 | import java.io.UnsupportedEncodingException; |
4 | +import java.math.BigDecimal; | ||
4 | import java.net.URLDecoder; | 5 | import java.net.URLDecoder; |
5 | import java.net.URLEncoder; | 6 | import java.net.URLEncoder; |
6 | 7 | ||
@@ -30,7 +31,7 @@ public class Test { | @@ -30,7 +31,7 @@ public class Test { | ||
30 | String encryptKey = "test_encrypt_key"; | 31 | String encryptKey = "test_encrypt_key"; |
31 | String signKey = "test_sign_key"; | 32 | String signKey = "test_sign_key"; |
32 | String muid4MD5 = "0f074dc8e1f0547310e729032ac0730b"; | 33 | String muid4MD5 = "0f074dc8e1f0547310e729032ac0730b"; |
33 | - String url = "http://jump.t.l.qq.com/conv/app/"; | 34 | + String url = "http://t.gdt.qq.com/conv/app/"; |
34 | //有货在智慧推的账号id | 35 | //有货在智慧推的账号id |
35 | String uid = "18261"; | 36 | String uid = "18261"; |
36 | 37 | ||
@@ -40,20 +41,33 @@ public class Test { | @@ -40,20 +41,33 @@ public class Test { | ||
40 | // clientType = requestBO.getClient_type().toLowerCase(); | 41 | // clientType = requestBO.getClient_type().toLowerCase(); |
41 | // } | 42 | // } |
42 | 43 | ||
43 | - String client_ip = "10.11.12.13"; | 44 | +// if(org.apache.commons.lang.StringUtils.isNotEmpty(requestBO.getAdvertiserId())){ |
45 | +// uid = requestBO.getAdvertiserId(); | ||
46 | +// } | ||
47 | +// String clientType = ClientTypeEnum.IOS.getName(); | ||
48 | +// if(org.apache.commons.lang.StringUtils.isNotEmpty(requestBO.getClientType())){ | ||
49 | +// clientType = requestBO.getClientType().toLowerCase(); | ||
50 | +// } | ||
51 | +// UnionConfig unionConfig = unionConfigDAO.selectByUidAndClientType(Integer.valueOf(uid),clientType); | ||
52 | +// if(null!=unionConfig){ | ||
53 | +// encryptKey = unionConfig.getEncryptKey(); | ||
54 | +// signKey = unionConfig.getSignKey(); | ||
55 | +// url = unionConfig.getUrl(); | ||
56 | +// } | ||
57 | + //APPID可以固定根据clientType判断 | ||
44 | String appId = "112233"; | 58 | String appId = "112233"; |
45 | - int conv_time =1422263664; | 59 | + if(clientType.equals(ClientTypeEnum.ANDROID.getName())){ |
60 | + appId = "112233"; | ||
61 | + } | ||
62 | + int conv_time = DateUtil.getCurrentTimeSecond(); | ||
46 | String page = null; | 63 | String page = null; |
47 | String query_string = null; | 64 | String query_string = null; |
48 | StringBuffer bf = new StringBuffer(); | 65 | StringBuffer bf = new StringBuffer(); |
49 | StringBuffer sf = new StringBuffer(); | 66 | StringBuffer sf = new StringBuffer(); |
50 | - if (StringUtils.isEmpty(client_ip)){ | ||
51 | - page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString(); | ||
52 | - query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString(); | ||
53 | - }else{ | ||
54 | - page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString(); | ||
55 | - query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString(); | ||
56 | - } | 67 | + |
68 | + page = bf.append(url).append(appId).append("/conv?click_id=").append("007210548a030059ccdfd1d4").append("&muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=10.11.12.13").toString(); | ||
69 | + query_string = sf.append("click_id=").append("007210548a030059ccdfd1d4").append("&muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=10.11.12.13").toString(); | ||
70 | + | ||
57 | // 对url进行加密 | 71 | // 对url进行加密 |
58 | String encode_page = null; | 72 | String encode_page = null; |
59 | try { | 73 | try { |
@@ -84,11 +98,15 @@ public class Test { | @@ -84,11 +98,15 @@ public class Test { | ||
84 | log.error("encode exception.", e); | 98 | log.error("encode exception.", e); |
85 | } | 99 | } |
86 | // conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE); | 100 | // conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE); |
87 | - String convType = "MOBILE_APP_ACTIVITE"; | 101 | + String convType = "MOBILEAPP_COST"; |
102 | +// if(transInfo.getType().equals("1")){ | ||
103 | +// convType = "MOBILEAPP_ADDTOCART"; | ||
104 | +// } | ||
88 | StringBuffer sb = new StringBuffer(); | 105 | StringBuffer sb = new StringBuffer(); |
89 | - url = sb.append(url).append(112233).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver("Android")).append("&advertiser_id=").append(uid).toString(); | ||
90 | - log.info("zhihuitui url is {}", url); | ||
91 | - System.out.print(url); | 106 | + url = sb.append(url).append(appId).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver(clientType)).append("&advertiser_id=").append(uid).toString(); |
107 | + log.info("GdtTransTask url is {}", url); | ||
108 | + String md5 = MD5.md5("862380036648114"); | ||
109 | + System.out.print(md5); | ||
92 | } | 110 | } |
93 | 111 | ||
94 | private static String clientTypeConver(String clientType) { | 112 | private static String clientTypeConver(String clientType) { |
-
Please register or login to post a comment