Merge branch 'master' into 统一推送接口联调
Showing
12 changed files
with
277 additions
and
30 deletions
1 | +package com.yoho.unions.dal.model; | ||
2 | + | ||
3 | +public class UnionTypeMatch { | ||
4 | + private Long unionType; | ||
5 | + | ||
6 | + private Long unionTypeMatch; | ||
7 | + | ||
8 | + private Integer createTime; | ||
9 | + | ||
10 | + public Long getUnionType() { | ||
11 | + return unionType; | ||
12 | + } | ||
13 | + | ||
14 | + public void setUnionType(Long unionType) { | ||
15 | + this.unionType = unionType; | ||
16 | + } | ||
17 | + | ||
18 | + public Long getUnionTypeMatch() { | ||
19 | + return unionTypeMatch; | ||
20 | + } | ||
21 | + | ||
22 | + public void setUnionTypeMatch(Long unionTypeMatch) { | ||
23 | + this.unionTypeMatch = unionTypeMatch; | ||
24 | + } | ||
25 | + | ||
26 | + public Integer getCreateTime() { | ||
27 | + return createTime; | ||
28 | + } | ||
29 | + | ||
30 | + public void setCreateTime(Integer createTime) { | ||
31 | + this.createTime = createTime; | ||
32 | + } | ||
33 | +} |
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.IUnionTypeMatchDAO" > | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionTypeMatch" > | ||
5 | + <id column="union_type" property="unionType" jdbcType="BIGINT" /> | ||
6 | + <result column="union_type_match" property="unionTypeMatch" jdbcType="BIGINT" /> | ||
7 | + <result column="create_time" property="createTime" jdbcType="INTEGER" /> | ||
8 | + </resultMap> | ||
9 | + <sql id="Base_Column_List" > | ||
10 | + union_type, union_type_match, create_time | ||
11 | + </sql> | ||
12 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > | ||
13 | + select | ||
14 | + <include refid="Base_Column_List" /> | ||
15 | + from union_type_match | ||
16 | + where union_type = #{unionType,jdbcType=BIGINT} | ||
17 | + </select> | ||
18 | + | ||
19 | +</mapper> |
@@ -14,6 +14,8 @@ import javax.annotation.Resource; | @@ -14,6 +14,8 @@ import javax.annotation.Resource; | ||
14 | import javax.servlet.http.HttpServletRequest; | 14 | import javax.servlet.http.HttpServletRequest; |
15 | import javax.servlet.http.HttpServletResponse; | 15 | import javax.servlet.http.HttpServletResponse; |
16 | 16 | ||
17 | +import com.yoho.unions.dal.IUnionTypeMatchDAO; | ||
18 | +import com.yoho.unions.dal.model.UnionTypeMatch; | ||
17 | import org.apache.commons.lang.StringUtils; | 19 | import org.apache.commons.lang.StringUtils; |
18 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
19 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
@@ -48,8 +50,8 @@ public class ClickUnionRest { | @@ -48,8 +50,8 @@ public class ClickUnionRest { | ||
48 | IUnionService unionService; | 50 | IUnionService unionService; |
49 | @Resource | 51 | @Resource |
50 | IMobvistaService mobvistaService; | 52 | IMobvistaService mobvistaService; |
51 | - | ||
52 | - | 53 | + @Resource |
54 | + IUnionTypeMatchDAO unionTypeMatchDAO; | ||
53 | 55 | ||
54 | /** | 56 | /** |
55 | * 添加联盟 | 57 | * 添加联盟 |
@@ -279,8 +281,13 @@ public class ClickUnionRest { | @@ -279,8 +281,13 @@ public class ClickUnionRest { | ||
279 | } | 281 | } |
280 | 282 | ||
281 | log.info("addMonitor request={}", bo); | 283 | log.info("addMonitor request={}", bo); |
282 | - //根据union_type区分不同的厂商 | 284 | + //根据union_type区分不同的厂商 |
283 | String union_type = request.getParameter("union_type"); | 285 | String union_type = request.getParameter("union_type"); |
286 | + //先去union_type_match表里面查看,是否有对应关系 | ||
287 | + UnionTypeMatch unionTypeMatch = unionTypeMatchDAO.selectByPrimaryKey(Long.valueOf(union_type)); | ||
288 | + if(unionTypeMatch!=null && StringUtils.isNotEmpty(String.valueOf(unionTypeMatch.getUnionTypeMatch()))){ | ||
289 | + union_type = String.valueOf(unionTypeMatch.getUnionTypeMatch()); | ||
290 | + } | ||
284 | StringBuffer stringBuffer = new StringBuffer(); | 291 | StringBuffer stringBuffer = new StringBuffer(); |
285 | String bean = stringBuffer.append("UnionServiceImpl").append("_").append(union_type).toString(); | 292 | String bean = stringBuffer.append("UnionServiceImpl").append("_").append(union_type).toString(); |
286 | boolean containsBean = SpringContextUtil.containsBean(bean); | 293 | boolean containsBean = SpringContextUtil.containsBean(bean); |
@@ -53,10 +53,13 @@ public class UnionServiceImpl implements IUnionService { | @@ -53,10 +53,13 @@ public class UnionServiceImpl implements IUnionService { | ||
53 | static Logger activeUnion = LoggerFactory.getLogger("activeUnion"); | 53 | static Logger activeUnion = LoggerFactory.getLogger("activeUnion"); |
54 | 54 | ||
55 | static Logger clickUnion = LoggerFactory.getLogger("clickUnion"); | 55 | static Logger clickUnion = LoggerFactory.getLogger("clickUnion"); |
56 | - | 56 | + |
57 | + static Logger ipMatch = LoggerFactory.getLogger("ipMatch"); | ||
58 | + | ||
57 | private static final String UNION_KEY = "UNION:KEY:"; | 59 | private static final String UNION_KEY = "UNION:KEY:"; |
58 | 60 | ||
59 | static Logger log = LoggerFactory.getLogger(UnionServiceImpl.class); | 61 | static Logger log = LoggerFactory.getLogger(UnionServiceImpl.class); |
62 | + | ||
60 | 63 | ||
61 | @Resource(name="yhRedisTemplate") | 64 | @Resource(name="yhRedisTemplate") |
62 | YHRedisTemplate<String, String> yHRedisTemplate; | 65 | YHRedisTemplate<String, String> yHRedisTemplate; |
@@ -177,14 +180,12 @@ public class UnionServiceImpl implements IUnionService { | @@ -177,14 +180,12 @@ public class UnionServiceImpl implements IUnionService { | ||
177 | 180 | ||
178 | 181 | ||
179 | //把IP作为key,也保存到redis | 182 | //把IP作为key,也保存到redis |
180 | -// key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey(); | ||
181 | -// yhValueOperations.set(key, JSON.toJSONString(request)); | ||
182 | -// yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); | ||
183 | -// log.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request)); | ||
184 | - | ||
185 | - | 183 | + key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey(); |
184 | + yhValueOperations.set(key, JSON.toJSONString(request)); | ||
185 | + yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); | ||
186 | + log.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request)); | ||
186 | 187 | ||
187 | - log.info("clickUnion set redis success with request={}", request); | 188 | +// log.info("clickUnion set redis success with request={}", request); |
188 | 189 | ||
189 | // if (union != null) { | 190 | // if (union != null) { |
190 | // //如果90天以内,已经存在点击记录,则不需要插入或更新数据库 | 191 | // //如果90天以内,已经存在点击记录,则不需要插入或更新数据库 |
@@ -284,35 +285,29 @@ public class UnionServiceImpl implements IUnionService { | @@ -284,35 +285,29 @@ public class UnionServiceImpl implements IUnionService { | ||
284 | } | 285 | } |
285 | 286 | ||
286 | log.info("activateUnion with get redis first with key={}, value={}", key, value); | 287 | log.info("activateUnion with get redis first with key={}, value={}", key, value); |
287 | - clickUnion.info("activateUnion with get redis first with key={}, value={}", key, value); | ||
288 | - if (StringUtils.isNotEmpty(request.getTd())) { | 288 | + activeUnion.info("activateUnion with get redis first with key={}, value={}", key, value); |
289 | + String td = request.getTd(); | ||
290 | + if (StringUtils.isNotEmpty(td)) { | ||
289 | if (StringUtils.isEmpty(value)) { | 291 | if (StringUtils.isEmpty(value)) { |
290 | - key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey(); | 292 | + key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey(); |
291 | value = yhValueOperations.get(key); | 293 | value = yhValueOperations.get(key); |
292 | log.info("activateUnion with get redis first with key={}, value={}", key, value); | 294 | log.info("activateUnion with get redis first with key={}, value={}", key, value); |
293 | } | 295 | } |
294 | if (StringUtils.isEmpty(value)) { | 296 | if (StringUtils.isEmpty(value)) { |
295 | String[] arr = request.getTd().split("_"); | 297 | String[] arr = request.getTd().split("_"); |
296 | if (arr.length > 3) { | 298 | if (arr.length > 3) { |
297 | - request.setTd(arr[2] + "_" + arr[3]); | ||
298 | - key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey(); | 299 | + td=(arr[2] + "_" + arr[3]); |
300 | + key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey(); | ||
299 | value = yhValueOperations.get(key); | 301 | value = yhValueOperations.get(key); |
300 | log.info("activateUnion with get redis second with key={}, value={}", key, value); | 302 | log.info("activateUnion with get redis second with key={}, value={}", key, value); |
301 | - clickUnion.info("activateUnion with get redis second with key={}, value={}", key, value); | 303 | + activeUnion.info("activateUnion with get redis second with key={}, value={}", key, value); |
302 | } | 304 | } |
303 | if(arr.length==3){ | 305 | if(arr.length==3){ |
304 | - request.setTd(arr[1]+"_"+arr[2]); | ||
305 | - key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey(); | ||
306 | - value = yhValueOperations.get(key); | ||
307 | - log.info("activateUnion with get redis third with key={}, value={}", key, value); | ||
308 | - clickUnion.info("activateUnion with get redis third with key={}, value={}", key, value); | ||
309 | - } | ||
310 | - | ||
311 | - if(arr.length==3){ | ||
312 | - request.setTd(arr[1]+"_"+arr[2]); | ||
313 | - key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getTd() + "_" + request.getAppkey(); | 306 | + td = (arr[1]+"_"+arr[2]); |
307 | + key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey(); | ||
314 | value = yhValueOperations.get(key); | 308 | value = yhValueOperations.get(key); |
315 | log.info("activateUnion with get redis third with key={}, value={}", key, value); | 309 | log.info("activateUnion with get redis third with key={}, value={}", key, value); |
310 | + activeUnion.info("activateUnion with get redis third with key={}, value={}", key, value); | ||
316 | } | 311 | } |
317 | } | 312 | } |
318 | } | 313 | } |
@@ -323,10 +318,15 @@ public class UnionServiceImpl implements IUnionService { | @@ -323,10 +318,15 @@ public class UnionServiceImpl implements IUnionService { | ||
323 | }else{ | 318 | }else{ |
324 | key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey(); | 319 | key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey(); |
325 | value = yhValueOperations.get(key); | 320 | value = yhValueOperations.get(key); |
321 | + if(StringUtils.isNotEmpty(value)){ | ||
322 | + ipMatch.info("activateUnion with IP params td is {},imei is {},idfa is {},IP is {},---- clickMsg is {}",request.getTd(),request.getImei(),request.getIdfa(),request.getClientIp(),value); | ||
323 | + return new UnionResponse(204, "user not click"); | ||
324 | + } | ||
325 | + | ||
326 | } | 326 | } |
327 | 327 | ||
328 | log.info("activateUnion with get redis forth with key={}, value={}", key, value); | 328 | log.info("activateUnion with get redis forth with key={}, value={}", key, value); |
329 | - clickUnion.info("activateUnion with get redis forth with key={}, value={}", key, value); | 329 | + activeUnion.info("activateUnion with get redis forth with key={}, value={}", key, value); |
330 | } | 330 | } |
331 | 331 | ||
332 | // 如果redis中不存在存在该用户点击信息,则退出 | 332 | // 如果redis中不存在存在该用户点击信息,则退出 |
@@ -395,6 +395,7 @@ public class UnionServiceImpl implements IUnionService { | @@ -395,6 +395,7 @@ public class UnionServiceImpl implements IUnionService { | ||
395 | //15天内有记录,退出 | 395 | //15天内有记录,退出 |
396 | log.warn("activateUnion error because 15 days has activate in bigdata database info with param is {}", request); | 396 | log.warn("activateUnion error because 15 days has activate in bigdata database info with param is {}", request); |
397 | } else { | 397 | } else { |
398 | + //根据mkt_markering | ||
398 | //15天内没有记录,则记录大数据日志,退出 | 399 | //15天内没有记录,则记录大数据日志,退出 |
399 | JSONObject j = new JSONObject(); | 400 | JSONObject j = new JSONObject(); |
400 | j.put("apptype", request.getClient_type()); | 401 | j.put("apptype", request.getClient_type()); |
@@ -39,5 +39,6 @@ datasources: | @@ -39,5 +39,6 @@ datasources: | ||
39 | - com.yoho.unions.dal.IUnionOrderPushDAO | 39 | - com.yoho.unions.dal.IUnionOrderPushDAO |
40 | - com.yoho.unions.dal.IUnionDepartmentUrlDAO | 40 | - com.yoho.unions.dal.IUnionDepartmentUrlDAO |
41 | - com.yoho.unions.dal.IMktMarketingUrlDAO | 41 | - com.yoho.unions.dal.IMktMarketingUrlDAO |
42 | + - com.yoho.unions.dal.IUnionTypeMatchDAO | ||
42 | 43 | ||
43 | readOnlyInSlave: true | 44 | readOnlyInSlave: true |
@@ -161,7 +161,21 @@ | @@ -161,7 +161,21 @@ | ||
161 | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern> | 161 | <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern> |
162 | </encoder> | 162 | </encoder> |
163 | </appender> | 163 | </appender> |
164 | - | 164 | + |
165 | + <!--IP匹配日志--> | ||
166 | + <appender name="IP_MATCH" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
167 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
168 | + <fileNamePattern>${catalina.home}/logs/%d{yyyy-MM-dd}/IP_MATCH.log</fileNamePattern> | ||
169 | + <!-- 日志最大的保存天数 --> | ||
170 | + <maxHistory>${maxHistory}</maxHistory> | ||
171 | + </rollingPolicy> | ||
172 | + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> | ||
173 | + <maxFileSize>${maxFileSize}</maxFileSize> | ||
174 | + </triggeringPolicy> | ||
175 | + <encoder> | ||
176 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern> | ||
177 | + </encoder> | ||
178 | + </appender> | ||
165 | 179 | ||
166 | <!-- 数据库操作日志 --> | 180 | <!-- 数据库操作日志 --> |
167 | <logger name="java.sql.PreparedStatement" value="DEBUG" /> | 181 | <logger name="java.sql.PreparedStatement" value="DEBUG" /> |
@@ -215,5 +229,9 @@ | @@ -215,5 +229,9 @@ | ||
215 | <logger name="activeUnion" level="INFO" additivity="false"> | 229 | <logger name="activeUnion" level="INFO" additivity="false"> |
216 | <appender-ref ref="ACTIVE_UNION"/> | 230 | <appender-ref ref="ACTIVE_UNION"/> |
217 | </logger> | 231 | </logger> |
232 | + | ||
233 | + <logger name="ipMatch" level="INFO" additivity="false"> | ||
234 | + <appender-ref ref="IP_Match"/> | ||
235 | + </logger> | ||
218 | 236 | ||
219 | </configuration> | 237 | </configuration> |
@@ -40,4 +40,6 @@ datasources: | @@ -40,4 +40,6 @@ datasources: | ||
40 | - com.yoho.unions.dal.IUnionOrderPushDAO | 40 | - com.yoho.unions.dal.IUnionOrderPushDAO |
41 | - com.yoho.unions.dal.IUnionDepartmentUrlDAO | 41 | - com.yoho.unions.dal.IUnionDepartmentUrlDAO |
42 | - com.yoho.unions.dal.IMktMarketingUrlDAO | 42 | - com.yoho.unions.dal.IMktMarketingUrlDAO |
43 | + - com.yoho.unions.dal.IUnionTypeMatchDAO | ||
44 | + | ||
43 | readOnlyInSlave: true | 45 | readOnlyInSlave: true |
@@ -191,6 +191,23 @@ | @@ -191,6 +191,23 @@ | ||
191 | </encoder> | 191 | </encoder> |
192 | </appender> | 192 | </appender> |
193 | 193 | ||
194 | + <appender name="IP_MATCH" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
195 | + <file>${yoho.logs.basedir}/${yoho.unions.env.namespace}/IP_MATCH.log</file> | ||
196 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
197 | + <!-- daily rollover --> | ||
198 | + <fileNamePattern>${yoho.logs.basedir}/${yoho.unions.env.namespace}/archived/IP_MATCH/IP_MATCH.%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
199 | + <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
200 | + <!-- or whenever the file size reaches 100MB --> | ||
201 | + <maxFileSize>${yoho.logs.maxFileSize}</maxFileSize> | ||
202 | + </timeBasedFileNamingAndTriggeringPolicy> | ||
203 | + <!-- keep 30 days' worth of history --> | ||
204 | + <maxHistory>${yoho.logs.maxHistory}</maxHistory> | ||
205 | + </rollingPolicy> | ||
206 | + <encoder> | ||
207 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger:%line - %msg%n</pattern> | ||
208 | + </encoder> | ||
209 | + </appender> | ||
210 | + | ||
194 | <!-- 数据库操作日志 --> | 211 | <!-- 数据库操作日志 --> |
195 | <logger name="java.sql.PreparedStatement" value="${yoho.logs.level}" /> | 212 | <logger name="java.sql.PreparedStatement" value="${yoho.logs.level}" /> |
196 | <logger name="java.sql.Connection" value="${yoho.logs.level}" /> | 213 | <logger name="java.sql.Connection" value="${yoho.logs.level}" /> |
@@ -255,4 +272,8 @@ | @@ -255,4 +272,8 @@ | ||
255 | <logger name="activeUnion" level="INFO" additivity="false"> | 272 | <logger name="activeUnion" level="INFO" additivity="false"> |
256 | <appender-ref ref="ACTIVE_UNION"/> | 273 | <appender-ref ref="ACTIVE_UNION"/> |
257 | </logger> | 274 | </logger> |
275 | + | ||
276 | + <logger name="ipMatch" level="INFO" additivity="false"> | ||
277 | + <appender-ref ref="IP_MATCH"/> | ||
278 | + </logger> | ||
258 | </configuration> | 279 | </configuration> |
@@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
21 | <url-pattern>/downmars.html</url-pattern> | 21 | <url-pattern>/downmars.html</url-pattern> |
22 | <url-pattern>/downshow.html</url-pattern> | 22 | <url-pattern>/downshow.html</url-pattern> |
23 | <url-pattern>/downyohoshow.html</url-pattern> | 23 | <url-pattern>/downyohoshow.html</url-pattern> |
24 | + <url-pattern>/downapp3.html</url-pattern> | ||
24 | </servlet-mapping> | 25 | </servlet-mapping> |
25 | 26 | ||
26 | <servlet-mapping> | 27 | <servlet-mapping> |
@@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
6 | <meta charset="utf-8"> | 6 | <meta charset="utf-8"> |
7 | <title>潮流商品 | YOHO!有货</title> | 7 | <title>潮流商品 | YOHO!有货</title> |
8 | <meta name="description" content=""> | 8 | <meta name="description" content=""> |
9 | - <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> | 9 | + <script src="//lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> |
10 | <script type="text/javascript"> | 10 | <script type="text/javascript"> |
11 | var agent = navigator.userAgent.toLowerCase() ; | 11 | var agent = navigator.userAgent.toLowerCase() ; |
12 | var version, type, appid, td, queryString, downUrl; | 12 | var version, type, appid, td, queryString, downUrl; |
web/src/main/webapp/downapp3.html
0 → 100644
1 | + | ||
2 | + | ||
3 | +<!DOCTYPE html> | ||
4 | +<html> | ||
5 | +<head> | ||
6 | + <meta charset="utf-8"> | ||
7 | + <title>潮流商品 | YOHO!有货</title> | ||
8 | + <meta name="description" content=""> | ||
9 | + <script src="//lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> | ||
10 | + <script type="text/javascript"> | ||
11 | + var agent = navigator.userAgent.toLowerCase() ; | ||
12 | + var version, type, appid, td, queryString, downUrl; | ||
13 | + | ||
14 | + var jumpTypes = [110]; | ||
15 | + | ||
16 | + function isInJump(unionType) { | ||
17 | + for (var i = 0 ;i < jumpTypes.length; i++) { | ||
18 | + if (unionType == jumpTypes[i]) { | ||
19 | + return true; | ||
20 | + } | ||
21 | + } | ||
22 | + return false; | ||
23 | + } | ||
24 | + | ||
25 | + function getQueryString() { | ||
26 | + var vars = [], | ||
27 | + hash, | ||
28 | + i; | ||
29 | + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | ||
30 | + | ||
31 | + for (i = 0; i < hashes.length; i++) { | ||
32 | + hash = hashes[i].split('='); | ||
33 | + vars.push(hash[0]); | ||
34 | + vars[hash[0]] = hash[1]; | ||
35 | + } | ||
36 | + return vars; | ||
37 | + } | ||
38 | + | ||
39 | + queryString = getQueryString(); | ||
40 | + downUrl = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445'; | ||
41 | + //downUrl = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8"; | ||
42 | + var appkey = queryString.appkey; | ||
43 | + | ||
44 | + if (appkey == "yoho") { | ||
45 | + //yohonow | ||
46 | + downUrl = "http://a.app.qq.com/o/simple.jsp?pkgname=cn.yoho.magazine#opened"; | ||
47 | + } else if (appkey == "mars") { | ||
48 | + //mars | ||
49 | + downUrl = "https://itunes.apple.com/cn/app/mars-xin-xian-hao-qu-chu-yu/id1056487123?l=en&mt=8"; | ||
50 | + //downUrl = "http://yoho-apps.qiniudn.com/YohoMars.apk"; | ||
51 | + } | ||
52 | + | ||
53 | + if (agent.indexOf("like mac os x") > 0) { | ||
54 | + var regStr_saf = /os [\d._]*/gi ; | ||
55 | + var verinfo = agent.match(regStr_saf) ; | ||
56 | + | ||
57 | + version = (verinfo+'').replace(/[^0-9|_.]/ig,'').replace(/_/ig, '.'); | ||
58 | + type = 'ios'; | ||
59 | + appid = '490655927'; | ||
60 | + td = window.screen.width + '_' + window.screen.height + '_' + type + '_' + version; | ||
61 | + | ||
62 | + } else if (agent.indexOf('android') > -1 || agent.indexOf('linux') > -1) { | ||
63 | + type = 'android'; | ||
64 | + appid = 'com.yoho'; | ||
65 | + try { | ||
66 | + var indextd = agent.indexOf('_td'); | ||
67 | + var index = agent.indexOf(' build'); | ||
68 | + var preString = ''; | ||
69 | + var deviceType = ''; | ||
70 | + | ||
71 | + //alert(agent); | ||
72 | + if (indextd > -1) { | ||
73 | + preString = agent.substr(0, indextd); | ||
74 | + preString = preString.substr(preString.lastIndexOf(";") + 1); | ||
75 | + preString = preString.replace(/\s+/g,'').replace(/_/ig, ''); | ||
76 | + | ||
77 | + var sansungIndex = preString.indexOf('samsung-'); | ||
78 | + if (sansungIndex > -1) { | ||
79 | + preString = preString.substr(8); | ||
80 | + } | ||
81 | + } else if (index > -1) { | ||
82 | + preString = agent.substr(0, index); | ||
83 | + preString = preString.substr(preString.lastIndexOf(";") + 1); | ||
84 | + preString = preString.replace(/\s+/g,'').replace(/_/ig, ''); | ||
85 | + //alert(preString); | ||
86 | + } | ||
87 | + deviceType = preString; | ||
88 | + version = agent.substr(agent.indexOf('android') + 8, 3); | ||
89 | + td = deviceType + '_' + type + '_' + version; | ||
90 | + } catch(e) { | ||
91 | + | ||
92 | + } | ||
93 | + | ||
94 | + | ||
95 | + | ||
96 | + //downUrl = 'http://cdn.yoho.cn/app-downfiles/yohoBuy_YOHO_2953.apk'; | ||
97 | + } | ||
98 | + | ||
99 | + | ||
100 | + | ||
101 | + $.ajax({ | ||
102 | + method: 'POST', | ||
103 | + url: 'http://union.yoho.cn/union/ClickUnionRest/addUnion', | ||
104 | +// url: 'http://192.168.102.205:8088/union/ClickUnionRest/addUnion', | ||
105 | + data: { | ||
106 | + union_type: queryString.union_type, | ||
107 | + identify_id: queryString.identify_id, | ||
108 | + callbackurl: queryString.callbackurl, | ||
109 | + client_type: type, | ||
110 | + td: queryString.td ? queryString.td : td, | ||
111 | + appid: queryString.appid ? queryString.appid : appid, | ||
112 | + appkey: queryString.appkey, | ||
113 | + idfa : queryString.idfa ? queryString.idfa : queryString.IDFA, | ||
114 | + imei:queryString.imei?queryString.imei:queryString.IMEI | ||
115 | + }, | ||
116 | + complete: function() { | ||
117 | + | ||
118 | + /* if (!downUrl) { | ||
119 | + window.location.href = "http://m.yohobuy.com"; | ||
120 | + } else { | ||
121 | + window.location.href = downUrl; | ||
122 | + } */ | ||
123 | + window.location.href = downUrl; | ||
124 | + | ||
125 | + window.setTimeout(function() { | ||
126 | + window.location.href = "http://m.yohobuy.com"; | ||
127 | + }, 2000); | ||
128 | + } | ||
129 | + }); | ||
130 | + | ||
131 | + | ||
132 | + </script> | ||
133 | +</head> | ||
134 | +<body> | ||
135 | +</body> | ||
136 | +</html> |
-
Please register or login to post a comment