Authored by bblu

联盟增加APP类型

@@ -8,6 +8,7 @@ import java.util.HashMap; @@ -8,6 +8,7 @@ import java.util.HashMap;
8 import java.util.List; 8 import java.util.List;
9 import java.util.Map; 9 import java.util.Map;
10 10
  11 +import com.yoho.service.model.union.AppTypeModel;
11 import com.yoho.service.model.union.UnionTypeModel; 12 import com.yoho.service.model.union.UnionTypeModel;
12 13
13 /** 14 /**
@@ -19,19 +20,24 @@ import com.yoho.service.model.union.UnionTypeModel; @@ -19,19 +20,24 @@ import com.yoho.service.model.union.UnionTypeModel;
19 public class UnionConstant { 20 public class UnionConstant {
20 21
21 /** 22 /**
  23 + * 新增:app类型
  24 + */
  25 + public static Map<Integer, AppTypeModel> appTypeMap = new HashMap<>();
  26 +
  27 + /**
22 * 联盟类型 28 * 联盟类型
23 */ 29 */
24 - public static Map<Integer, UnionTypeModel> unionTypeMap = new HashMap<Integer, UnionTypeModel>(); 30 + public static Map<Integer, UnionTypeModel> unionTypeMap = new HashMap<>();
25 31
26 /** 32 /**
27 * 安卓系统需要实现的联盟 33 * 安卓系统需要实现的联盟
28 */ 34 */
29 - public static List<String> andriodServiceList = new ArrayList<String>(); 35 + public static List<String> andriodServiceList = new ArrayList<>();
30 36
31 /** 37 /**
32 * iOS系统需要实现的联盟 38 * iOS系统需要实现的联盟
33 */ 39 */
34 - public static List<String> iOSServiceList = new ArrayList<String>(); 40 + public static List<String> iOSServiceList = new ArrayList<>();
35 41
36 static { 42 static {
37 //andriod系统 43 //andriod系统
@@ -9,6 +9,7 @@ import java.util.Map; @@ -9,6 +9,7 @@ import java.util.Map;
9 import javax.annotation.PostConstruct; 9 import javax.annotation.PostConstruct;
10 import javax.annotation.Resource; 10 import javax.annotation.Resource;
11 11
  12 +import com.yoho.service.model.union.AppTypeModel;
12 import org.slf4j.Logger; 13 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 14 import org.slf4j.LoggerFactory;
14 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
@@ -28,6 +29,8 @@ public class LoaderData { @@ -28,6 +29,8 @@ public class LoaderData {
28 29
29 @Resource 30 @Resource
30 Map<String, Object> unionTypeMap = null; 31 Map<String, Object> unionTypeMap = null;
  32 + @Resource
  33 + Map<String, Object> appTypeMap = null;
31 34
32 /** 35 /**
33 * 初始化参数 36 * 初始化参数
@@ -35,14 +38,23 @@ public class LoaderData { @@ -35,14 +38,23 @@ public class LoaderData {
35 @PostConstruct 38 @PostConstruct
36 public void init() { 39 public void init() {
37 log.info("begin LoaderData"); 40 log.info("begin LoaderData");
38 - List<Map<String, Object>> list = (List<Map<String, Object>>) unionTypeMap.get("union_types");  
39 - UnionTypeModel unionType = null;  
40 - for (Map<String, Object> map : list) { 41 + List<Map<String, Object>> unionTypeList = (List<Map<String, Object>>) unionTypeMap.get("union_types");
  42 + UnionTypeModel unionType;
  43 + for (Map<String, Object> map : unionTypeList) {
41 unionType = new UnionTypeModel(); 44 unionType = new UnionTypeModel();
42 unionType.setValue((int) map.get("value")); 45 unionType.setValue((int) map.get("value"));
43 unionType.setName((String) map.get("name")); 46 unionType.setName((String) map.get("name"));
44 UnionConstant.unionTypeMap.put(unionType.getValue(), unionType); 47 UnionConstant.unionTypeMap.put(unionType.getValue(), unionType);
45 } 48 }
  49 +
  50 + List<Map<String, Object>> appTypeList = (List<Map<String, Object>>) appTypeMap.get("app_types");
  51 + AppTypeModel appType;
  52 + for (Map<String, Object> map : appTypeList) {
  53 + appType = new AppTypeModel();
  54 + appType.setValue((int) map.get("value"));
  55 + appType.setName((String) map.get("name"));
  56 + UnionConstant.appTypeMap.put(appType.getValue(), appType);
  57 + }
46 log.info("end LoaderData"); 58 log.info("end LoaderData");
47 } 59 }
48 } 60 }
@@ -14,5 +14,13 @@ @@ -14,5 +14,13 @@
14 </property> 14 </property>
15 </bean> 15 </bean>
16 16
  17 + <bean id="appTypeMap" class="org.springframework.beans.factory.config.YamlMapFactoryBean">
  18 + <property name="resources">
  19 + <list>
  20 + <value>classpath:app-type.yml</value>
  21 + </list>
  22 + </property>
  23 + </bean>
  24 +
17 25
18 </beans> 26 </beans>
  1 +app_types:
  2 + - value: 0
  3 + name: Yoho!Buy
  4 +
  5 + - value: 1
  6 + name: YOHO!BLK
  7 +
  8 + - value: 2
  9 + name: Yoho!Now
  10 +
  11 + - value: 3
  12 + name: mars
@@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit; @@ -9,6 +9,7 @@ import java.util.concurrent.TimeUnit;
9 9
10 import javax.annotation.Resource; 10 import javax.annotation.Resource;
11 11
  12 +import com.yoho.service.model.union.AppTypeModel;
12 import org.apache.commons.collections.CollectionUtils; 13 import org.apache.commons.collections.CollectionUtils;
13 import org.apache.commons.lang3.StringUtils; 14 import org.apache.commons.lang3.StringUtils;
14 import org.apache.commons.lang3.tuple.Pair; 15 import org.apache.commons.lang3.tuple.Pair;
@@ -246,6 +247,7 @@ public class UnionServiceImpl implements IUnionService { @@ -246,6 +247,7 @@ public class UnionServiceImpl implements IUnionService {
246 return new UnionResponse(203, "have activite in 90 days"); 247 return new UnionResponse(203, "have activite in 90 days");
247 } 248 }
248 UnionTypeModel u = UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type())); 249 UnionTypeModel u = UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
  250 + AppTypeModel a = UnionConstant.appTypeMap.get(request.getApp_type());
249 //如果是ios系统,还要到大数据表里面判断这个用户是否90天内的活跃用户,如果是的话,这次激活就不成功 251 //如果是ios系统,还要到大数据表里面判断这个用户是否90天内的活跃用户,如果是的话,这次激活就不成功
250 String yesterday = DateUtil.dateAdd(DateUtil.getToday("yyyyMMdd"), "d", -1, "yyyyMMdd"); 252 String yesterday = DateUtil.dateAdd(DateUtil.getToday("yyyyMMdd"), "d", -1, "yyyyMMdd");
251 if (ClientTypeEnum.IOS.getName().equals(request.getClient_type())) { 253 if (ClientTypeEnum.IOS.getName().equals(request.getClient_type())) {
@@ -272,6 +274,7 @@ public class UnionServiceImpl implements IUnionService { @@ -272,6 +274,7 @@ public class UnionServiceImpl implements IUnionService {
272 j.put("ip", request.getClientIp()); 274 j.put("ip", request.getClientIp());
273 j.put("collect_ip", ""); 275 j.put("collect_ip", "");
274 j.put("active_type", "15"); 276 j.put("active_type", "15");
  277 + j.put("app_type", a == null ? "Yoho!Buy" : a.getName());
275 activeDingdang.info(j.toString()); 278 activeDingdang.info(j.toString());
276 } 279 }
277 return new UnionResponse(203, "have activite in 90 days"); 280 return new UnionResponse(203, "have activite in 90 days");