Authored by LiQZ

Merge branch 'channel' of http://git.yoho.cn/yoho30/yohobuy-union into channel

Showing 26 changed files with 697 additions and 533 deletions
... ... @@ -59,8 +59,7 @@ public class ChannelGroupRest {
UserInfoBO userInfoBO= (UserInfoBO) session.getAttribute("userSession");
logger.info("ChannelGroupRest.sendMessage:useinfo is {}", userInfoBO);
// int result = channelGroupService.sendMessage(channelGroupRequestBO,userInfoBO.getPid());
int result = channelGroupService.sendMessage(channelGroupRequestBO,14);
int result = channelGroupService.sendMessage(channelGroupRequestBO,userInfoBO.getPid());
if(result==1){
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").build();
}else{
... ...
... ... @@ -24,7 +24,6 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
... ... @@ -182,6 +181,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
List<ChannelSmsDetail> smsDetails = Lists.newArrayList();
//4.用户去重、黑名单后,分批发送短信
List<String> mobiles = null;
int successCount = 0 ;
for (int i = 0; i < mobileList.size(); i += BATCH_MESSAGE_NUMBER) {
if(i + BATCH_MESSAGE_NUMBER>mobileList.size()){
mobiles = mobileList.subList(i, mobileList.size());
... ... @@ -205,6 +205,7 @@ public class ChannelGroupServiceImpl implements ChannelGroupService {
for (String sms : mobiles) {
ChannelSmsDetail channelSmsDetail = new ChannelSmsDetail(sms, groupBatchId, SMS_STATUS_SUCCESS, sendTime);
smsDetails.add(channelSmsDetail);
successCount++;
}
} else {
//4.2短信发送失败,打印日志,记录短信日志表(状态为0)和分组批次表
... ...
... ... @@ -40,7 +40,7 @@ public class UnionConstant {
//iSO系统
iOSServiceList.add("dDServiceImpl");
// iOSServiceList.add("dDServiceImpl");
//iOSServiceList.add("gdtServiceImpl");
}
}
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionConfig;
import org.apache.ibatis.annotations.Param;
public interface IUnionConfigDAO {
UnionConfig selectByPrimaryKey(Integer uid);
UnionConfig selectByUidAndClientType(@Param("uid") int uid, @Param("client_type") String client_type);
}
\ No newline at end of file
... ...
... ... @@ -7,6 +7,16 @@ public class ChannelGroup {
private Integer groupNumber;
public Integer getSuccessCount() {
return successCount;
}
public void setSuccessCount(Integer successCount) {
this.successCount = successCount;
}
private Integer successCount;
private Integer createTime;
private Integer createUser;
... ...
package com.yoho.unions.dal.model;
public class UnionConfig {
private Integer id;
private Integer uid;
private String clientType;
private String encryptKey;
private String signKey;
private String url;
private Integer createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getClientType() {
return clientType;
}
public void setClientType(String clientType) {
this.clientType = clientType == null ? null : clientType.trim();
}
public String getEncryptKey() {
return encryptKey;
}
public void setEncryptKey(String encryptKey) {
this.encryptKey = encryptKey == null ? null : encryptKey.trim();
}
public String getSignKey() {
return signKey;
}
public void setSignKey(String signKey) {
this.signKey = signKey == null ? null : signKey.trim();
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url == null ? null : url.trim();
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
... ...
... ... @@ -5,6 +5,7 @@
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="group_number" property="groupNumber" jdbcType="INTEGER" />
<result column="success_count" property="successCount" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="create_user" property="createUser" jdbcType="INTEGER" />
<result column="create_userName" property="createUserName" jdbcType="VARCHAR" />
... ... @@ -18,7 +19,7 @@
<result column="content" property="content" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, group_number, create_time, create_user, create_userName, update_time
id, name, group_number,success_count, create_time, create_user, create_userName, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
... ... @@ -31,10 +32,10 @@
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.ChannelGroup" keyProperty="id" useGeneratedKeys="true" >
insert into channel_group (id, name, group_number,
insert into channel_group (id, name, group_number,success_count,
create_time, create_user, create_userName,update_time
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{groupNumber,jdbcType=INTEGER},
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{groupNumber,jdbcType=INTEGER},#{successCount,jdbcType=INTEGER}
#{createTime,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, #{createUserName,jdbcType=VARCHAR}, #{updateTime,jdbcType=INTEGER}
)
</insert>
... ... @@ -50,6 +51,9 @@
<if test="groupNumber != null" >
group_number,
</if>
<if test="successCount != null" >
success_count,
</if>
<if test="createTime != null" >
create_time,
</if>
... ... @@ -73,6 +77,9 @@
<if test="groupNumber != null" >
#{groupNumber,jdbcType=INTEGER},
</if>
<if test="successCount != null" >
#{successCount,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
... ... @@ -94,7 +101,10 @@
name = #{name,jdbcType=VARCHAR},
</if>
<if test="groupNumber != null" >
group_number = #{groupNumber,jdbcType=INTEGER},
group_number = #{groupNumber,jdbcType=INTEGER},
</if>
<if test="successCount != null" >
success_count = #{successCount,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
... ... @@ -115,6 +125,7 @@
update channel_group
set name = #{name,jdbcType=VARCHAR},
group_number = #{groupNumber,jdbcType=INTEGER},
success_count = #{success_count,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER},
create_user = #{createUser,jdbcType=INTEGER},
create_userName = #{createUserName,jdbcType=VARCHAR},
... ... @@ -153,7 +164,7 @@
</where>
</select>
<select id="selectListByParam" resultMap="groupResultMap" parameterType="com.yoho.service.model.union.response.ChannelGroupRspBO" >
select cg.id as id, name, group_number, create_time, create_user, create_userName, cgb.id as group_id, send_time,
select cg.id as id, name, group_number, success_count,create_time, create_user, create_userName, cgb.id as group_id, send_time,
send_user, send_userName, content
from channel_group cg
left join channel_group_batch cgb
... ...
<?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.IUnionConfigDAO" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionConfig" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="client_type" property="clientType" jdbcType="VARCHAR" />
<result column="encrypt_key" property="encryptKey" jdbcType="VARCHAR" />
<result column="sign_key" property="signKey" jdbcType="VARCHAR" />
<result column="url" property="url" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, client_type, encrypt_key, sign_key, url, create_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_config
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectByUidAndClientType" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from union_config
where uid = #{uid} and client_type = #{client_type} limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -6,7 +6,6 @@
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.2.1-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ... @@ -51,7 +50,7 @@
</dependencyManagement>
<dependencies>
<!-- CORE核心代码�?-->
<!-- CORE核心代码-->
<dependency>
<groupId>com.yoho.core</groupId>
... ...
package com.yoho.activity.restapi;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.activity.service.DrawService;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.union.request.DrawRequestBO;
import com.yoho.service.model.union.response.DrawInfoResponseBO;
import com.yoho.service.model.user.other.response.DrawResponseBO;
import com.yoho.unions.common.ApiResponse;
@Controller
@RequestMapping("/ActivityRest")
public class ActivityRest {
static Logger log = LoggerFactory.getLogger(ActivityRest.class);
@Resource
DrawService drawService;
/**
* 元宵节抽签活动
* @param req
* @return
* @throws ServiceException
*/
@RequestMapping("/draw")
@ResponseBody public ApiResponse draw(@RequestBody DrawRequestBO req) throws ServiceException {
log.info("enter draw with param is {}", req);
DrawResponseBO resp = drawService.draw(req);
log.info("draw with param is {}. and response is {}", req, resp);
return new ApiResponse.ApiResponseBuilder().data(resp).build();
}
/**
* 根据uid,获取用户抽签情况
* @param req
* @return
* @throws ServiceException
*/
@RequestMapping("/getDrawInfo")
@ResponseBody public ApiResponse getDrawInfo(@RequestBody DrawRequestBO req) throws ServiceException {
log.info("enter getDrawInfo with param is {}", req);
DrawInfoResponseBO resp = drawService.getDrawInfo(req.getUid());
log.info("getDrawInfo with param is {}. and response is {}", req, resp);
return new ApiResponse.ApiResponseBuilder().data(resp).build();
}
}
//package com.yoho.activity.restapi;
//
//import javax.annotation.Resource;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.yoho.activity.service.DrawService;
//import com.yoho.error.exception.ServiceException;
//import com.yoho.service.model.union.request.DrawRequestBO;
//import com.yoho.service.model.union.response.DrawInfoResponseBO;
//import com.yoho.service.model.user.other.response.DrawResponseBO;
//import com.yoho.unions.common.ApiResponse;
//
//@Controller
//@RequestMapping("/ActivityRest")
//public class ActivityRest {
//
// static Logger log = LoggerFactory.getLogger(ActivityRest.class);
//
// @Resource
// DrawService drawService;
//
//
//
// /**
// * 元宵节抽签活动
// * @param req
// * @return
// * @throws ServiceException
// */
// @RequestMapping("/draw")
// @ResponseBody public ApiResponse draw(@RequestBody DrawRequestBO req) throws ServiceException {
// log.info("enter draw with param is {}", req);
// DrawResponseBO resp = drawService.draw(req);
// log.info("draw with param is {}. and response is {}", req, resp);
// return new ApiResponse.ApiResponseBuilder().data(resp).build();
// }
//
// /**
// * 根据uid,获取用户抽签情况
// * @param req
// * @return
// * @throws ServiceException
// */
// @RequestMapping("/getDrawInfo")
// @ResponseBody public ApiResponse getDrawInfo(@RequestBody DrawRequestBO req) throws ServiceException {
// log.info("enter getDrawInfo with param is {}", req);
// DrawInfoResponseBO resp = drawService.getDrawInfo(req.getUid());
// log.info("getDrawInfo with param is {}. and response is {}", req, resp);
// return new ApiResponse.ApiResponseBuilder().data(resp).build();
// }
//}
... ...
... ... @@ -111,13 +111,7 @@ public class ActivateUnionRest {
exe.execute(new RunActivate(bo));
return new ActiveUnionResponseBO(200, "success");
}
@RequestMapping("/test")
@ResponseBody
public UnionResponse test() {
return new UnionResponse();
}
public static class RunActivate implements Runnable {
public RunActivate(ActivateUnionRequestBO bo) {
... ...
... ... @@ -78,6 +78,11 @@ public class ClickUnionRest {
String[] td1 = td.split("0_0_");
request.setTd(td1[1]);
}
//增加监控,把接口报上去,根据client_type来判断
request.setInterfaceType("addUnion_ios");
if(StringUtils.isNotEmpty(request.getClient_type())&&request.getClient_type().equals(ClientTypeEnum.ANDROID.getName())){
request.setInterfaceType("addUnion_android");
}
clickUnion.info("addUnion with param is {}", request);
UnionResponse response = unionService.clickUnion(request);
// log.info("addUnion with result is {}, and request is {}", response, request);
... ... @@ -310,7 +315,7 @@ public class ClickUnionRest {
String version = agent.substring(agent.indexOf(" OS ") + 4, agent.indexOf(" like"));
log.info("addUnion4Special version={}", version);
}
@RequestMapping("/addUnion4Jump")
public void addUnion4Stream(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) {
clickUnion.info("addUnion4Stream ClickUnionRequestBO{}", bo);
... ... @@ -339,119 +344,118 @@ public class ClickUnionRest {
}
if (agent.indexOf("mac os x") >= 0 || agent.indexOf("iphone") >= 0 ||agent.indexOf("ipad")>0) {
setClickUnionRequestBO(agent,bo,url);
// if(agent.contains("os")&&agent.contains("like")){
// String version = agent.substring(agent.indexOf(" os ") + 4, agent.indexOf(" like"));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }
// //youku;5.4;ios;10.2;iphone6,1 ---这种情况比较多
// else if(agent.contains("youku")){
// String version = "";
// if(agent.contains("ios")){
// int first = agent.indexOf("ios;")+4;
// String version1 = agent.substring(first);
// version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";"));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// } //youku;5.4.1;iphone os;8.4.1;iphone6,2
// else if(agent.contains("os")){
// int first = agent.indexOf("os;") + 3;
// String version1 = agent.substring(first);
// version = version1.substring(version1.indexOf(" ") + 1, version1.indexOf(";"));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }
// }
// //momochat/7.5.6 ios/664 (iphone 6; ios 10.2; zh_cn; iphone7,2; s1)
// else if(agent.contains("momochat")){
// String version = "";
// if(agent.contains("ios")){
// int first = agent.indexOf(" ios ")+4;
// String version1 = agent.substring(first);
// version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";"));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// } //momochat/7.5.6 ios/664 (iphone 6s; iphone os 9.2; zh_cn; iphone8,1; s1)
// else if(agent.contains("os")){
// int first = agent.indexOf(" os ")+3;
// String version1 = agent.substring(first);
// version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";"));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }
// }
// else if(agent.contains("ios/")){
// String version= "";
// if(agent.contains("mozilla")){ // mozilla/5.0,ios/10.0.2,client/5.8.1,device/iphone6.2,theme/red
// version = agent.substring(agent.indexOf("ios/")+4,agent.indexOf("client")-1);
// }else if (agent.contains("iphone")) { //huazhu/ios/iphone9,2/10.2.1/6.5.3
// int last = agent.lastIndexOf("/");
// String version1 = agent.substring(0,last);
// version = version1.substring(version1.lastIndexOf("/") + 1, version1.length());
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }else{ //ios/6.6 com.jugg.doctor ipad5,3/8.3/768x1024/2.0 /1---这个应该就是ios_6.6
// version = agent.substring(agent.indexOf("ios/")+4,agent.indexOf(" "));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }
// }
// //365jia news client/cn.ahurls.news/3.5.0_300500.209/ios(7.1|0|iphone)/59c2ed8b88175124c539e0c7a96a18d4eedb3d6c(none|none)/640x1136@2
// else if(agent.contains("/ios")){
// int first = agent.indexOf("/ios(") + 5;
// String version1 = agent.substring(first);
// String version = version1.substring(0,version1.indexOf("|"));
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }
// else if (agent.contains("ios")){
// String version = "";
// if(agent.contains("letvshop")){
// //letvshop;1.6.6;iphone 6plus;ios-iphone;9.2;zh_cn
// int lastIndex = agent.lastIndexOf(";");
// String version1 = agent.substring(0,lastIndex);
// version = agent.substring(version1.lastIndexOf(";")+1,lastIndex);
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }else if(agent.contains("jxsg")) { //jxsg_ios-1.2.5/0.0.2 (iphone7,2; ios 10.2.1)
// int first = agent.lastIndexOf("ios ") + 4;
// String version1 = agent.substring(first);
// int lastIndex = version1.indexOf(")");
// version = version1.substring(version1.indexOf(" ") + 1, lastIndex);
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }else{
// int first = agent.lastIndexOf("ios ") + 4;
// String version1 = agent.substring(first);
// int lastIndex = version1.indexOf(";");
// version = version1.substring(0, lastIndex);
// bo.setTd("ios_" + version.replaceAll("_", "."));
// bo.setClient_type("ios");
// bo.setAppid("490655927");
// url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
// }
// }
if(agent.contains("os")&&agent.contains("like")){
String version = agent.substring(agent.indexOf(" os ") + 4, agent.indexOf(" like"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}
//youku;5.4;ios;10.2;iphone6,1 ---这种情况比较多
else if(agent.contains("youku")){
String version = "";
if(agent.contains("ios")){
int first = agent.indexOf("ios;")+4;
String version1 = agent.substring(first);
version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
} //youku;5.4.1;iphone os;8.4.1;iphone6,2
else if(agent.contains("os")){
int first = agent.indexOf("os;") + 3;
String version1 = agent.substring(first);
version = version1.substring(version1.indexOf(" ") + 1, version1.indexOf(";"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}
}
//momochat/7.5.6 ios/664 (iphone 6; ios 10.2; zh_cn; iphone7,2; s1)
else if(agent.contains("momochat")){
String version = "";
if(agent.contains("ios")){
int first = agent.indexOf(" ios ")+4;
String version1 = agent.substring(first);
version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
} //momochat/7.5.6 ios/664 (iphone 6s; iphone os 9.2; zh_cn; iphone8,1; s1)
else if(agent.contains("os")){
int first = agent.indexOf(" os ")+3;
String version1 = agent.substring(first);
version = version1.substring(version1.indexOf(" ")+1, version1.indexOf(";"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}
}
else if(agent.contains("ios/")){
String version= "";
if(agent.contains("mozilla")){ // mozilla/5.0,ios/10.0.2,client/5.8.1,device/iphone6.2,theme/red
version = agent.substring(agent.indexOf("ios/")+4,agent.indexOf("client")-1);
}else if (agent.contains("iphone")) { //huazhu/ios/iphone9,2/10.2.1/6.5.3
int last = agent.lastIndexOf("/");
String version1 = agent.substring(0,last);
version = version1.substring(version1.lastIndexOf("/") + 1, version1.length());
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}else{ //ios/6.6 com.jugg.doctor ipad5,3/8.3/768x1024/2.0 /1---这个应该就是ios_6.6
version = agent.substring(agent.indexOf("ios/")+4,agent.indexOf(" "));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}
}
//365jia news client/cn.ahurls.news/3.5.0_300500.209/ios(7.1|0|iphone)/59c2ed8b88175124c539e0c7a96a18d4eedb3d6c(none|none)/640x1136@2
else if(agent.contains("/ios")){
int first = agent.indexOf("/ios(") + 5;
String version1 = agent.substring(first);
String version = version1.substring(0,version1.indexOf("|"));
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}
else if (agent.contains("ios")){
String version = "";
if(agent.contains("letvshop")){
//letvshop;1.6.6;iphone 6plus;ios-iphone;9.2;zh_cn
int lastIndex = agent.lastIndexOf(";");
String version1 = agent.substring(0,lastIndex);
version = agent.substring(version1.lastIndexOf(";")+1,lastIndex);
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}else if(agent.contains("jxsg")) { //jxsg_ios-1.2.5/0.0.2 (iphone7,2; ios 10.2.1)
int first = agent.lastIndexOf("ios ") + 4;
String version1 = agent.substring(first);
int lastIndex = version1.indexOf(")");
version = version1.substring(version1.indexOf(" ") + 1, lastIndex);
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}else{
int first = agent.lastIndexOf("ios ") + 4;
String version1 = agent.substring(first);
int lastIndex = version1.indexOf(";");
version = version1.substring(0, lastIndex);
bo.setTd("ios_" + version.replaceAll("_", "."));
bo.setClient_type("ios");
bo.setAppid("490655927");
url = "https://itunes.apple.com/cn/app/yoho!-you-huo/id490655927?mt=8";
}
}
} else {
int index = agent.lastIndexOf("android");
... ... @@ -467,6 +471,12 @@ public class ClickUnionRest {
log.error("addUnion4Stream error with request={}", bo, e);
}
try {
//增加监控,把接口报上去,根据client_type来判断
bo.setInterfaceType("addUnion4Jump_ios");
if(StringUtils.isNotEmpty(bo.getClient_type())&&bo.getClient_type().equals(ClientTypeEnum.ANDROID.getName())){
bo.setInterfaceType("addUnion4Jump_android");
}
StringBuffer stringBuffer = new StringBuffer();
String bean = stringBuffer.append("UnionServiceImpl").append("_").append(bo.getUnion_type()).toString();
boolean containsBean = SpringContextUtil.containsBean(bean);
... ... @@ -530,6 +540,11 @@ public class ClickUnionRest {
log.error("addMonitor error with request={}",e1.getMessage());
}
//增加监控,把接口报上去,根据client_type来判断
bo.setInterfaceType("addMonitor_ios");
if(StringUtils.isNotEmpty(bo.getClient_type())&&bo.getClient_type().equals(ClientTypeEnum.ANDROID.getName())){
bo.setInterfaceType("addMonitor_android");
}
clickUnion.info("addMonitor request={}", bo);
//根据union_type区分不同的厂商
String union_type = request.getParameter("union_type");
... ... @@ -550,7 +565,14 @@ public class ClickUnionRest {
// log.info("addMonitor with result is {}, and request is {}", response, bo);
response.setStatus(200);
JSONObject j = new JSONObject();
j.put("ret", "0");
//智慧推对接口返回有要求,定制一下
if(union_type.equals("100000000000453")){
j.put("ret", 0);
j.put("msg","成功");
}else{
j.put("ret","0");
}
return j;
} catch (Exception e) {
... ...
... ... @@ -74,22 +74,6 @@ public class UnionRest {
return response;
}
@RequestMapping(value = "/test")
@ResponseBody public UnionResponseBO test() {
log.info("enter unionsRest.test");
UnionResponseBO response = new UnionResponseBO();
response.setMsg("success");
response.setIsSuccess(true);
return response;
}
@RequestMapping(value ="/addBigData")
@ResponseBody
public UnionResponseBO addBigData(int beginTime,int endTime) {
log.info("enter addBigData,beginTimeis {},endTime is {}",beginTime,endTime);
UnionResponseBO response = dingdangService.addBigData(beginTime,endTime);
return response;
}
public static void main(String[] args) {
String clientId = "80003419";
... ...
//package com.yoho.unions.server.service.impl;
//
//import com.alibaba.fastjson.JSONObject;
//import com.yoho.unions.common.utils.HttpUtils;
//import com.yoho.unions.common.utils.MathUtils;
//import com.yoho.unions.dal.IUserOrdersDAO;
//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.collections.CollectionUtils;
//import org.apache.commons.lang3.tuple.Pair;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.math.BigDecimal;
//import java.net.URLEncoder;
//import java.util.*;
//
///**
// * 多麦走通用的,不单独走定制的
// * 多麦推送订单数据
// * Created by yoho on 2016/12/15.
// */
//public class DuomaiServiceImpl implements IOrderPushService {
//
// @Autowired
// private IUserOrdersDAO userOrdersDAO;
//
// static Logger logger = LoggerFactory.getLogger(DuomaiServiceImpl.class);
//
// @Override
// public void pushOrder(List<OrderInfo> orderInfoList) {
// List<String> successCodes = new ArrayList<>();
// String duomaiContext = getDuomaiContext(orderInfoList);
// OrderInfo orderInfo = orderInfoList.get(0);
// int clientId = orderInfo.getClientId();
// String duomaiPushUrl = null;
// if (clientId == 3017) {
// duomaiPushUrl = "http://www.duomai.com/api/push/yohobuy.php";
// } else if (clientId == 3019) {
// duomaiPushUrl = "http://www.duomai.com/api/push/myohobuy.php";
// } else {
// duomaiPushUrl = "http://www.duomai.com/api/push/yohobuyroi.php";
// }
// Pair<Integer, String> pair = null;
// Map param = new HashMap<>();
// param.put("content", duomaiContext);
// try {
// logger.info("pushOrder: url is {}, param is {}", duomaiPushUrl, param);
// pair = HttpUtils.httpPost(duomaiPushUrl, param);
// } catch (Exception e) {
// logger.error("duomai order post fail,orderCode is {}", orderInfo.getParentOrderCode());
// }
// JSONObject json = JSONObject.parseObject(pair.getRight());
// if (((String) json.get("code")).equals("200")) {
// logger.info("duomai pushOrder success,orderCode is {}", orderInfo.getParentOrderCode());
// successCodes.add(orderInfo.getParentOrderCode());
// } else {
// logger.warn("duomai pushOrder fail,orderCode is {},message is {}", orderInfo.getParentOrderCode(), (String) json.get("msg"));
// }
// //批量更新推送成功的订单状态为1
// userOrdersDAO.batchUpdatePush(successCodes);
// }
//
// private String getDuomaiContext(List<OrderInfo> orderInfoList) {
// String urlContext = null;
// for (OrderInfo orderInfo : orderInfoList) {
// //联盟id
// int client_id = orderInfo.getClientId();
// String hash = "";
// int channel = 0;
// if (client_id == 3017) {
// hash = "96613bf38393aa3d16451218f22344a8";
// channel = 0;
// } else if (client_id == 3019) {
// hash = "d54be2dbc75753eb863ba6139950656b";
// channel = 1;
// } else if (client_id == 3057) {
// hash = "bbf70bcaf5c52947ad26853f7cc1176d";
// channel = 0;
// }
// //多麦在YOHO上的网站主标识
// String euid = orderInfo.getMbrName();
// String orderCode = orderInfo.getOrderCode();
// int orderTime = orderInfo.getOrderTime();
// BigDecimal orderAmount = orderInfo.getOrderAmount();
// String orderStatus = orderInfo.getOrderStatus();
// List<OrdersGood> goods = orderInfo.getOrdersGoods();
// List<String> goodsIdList = new ArrayList<>();
// List<String> goodsNameList = new ArrayList<>();
// List<BigDecimal> goodsPriceList = new ArrayList<>();
// //商品结算金额 price*num-优惠&折扣
// List<BigDecimal> goodsTotalPriceList = new ArrayList<>();
// // 商品分类编号
// List<Integer> small_sort_idList = new ArrayList<>();
// List<Integer> goodsNumList = new ArrayList<>();
//
// for(OrdersGood ordersGood:goods){
// goodsIdList.add(ordersGood.getProductSkn());
// goodsNameList.add(ordersGood.getProductName());
// goodsPriceList.add(ordersGood.getLastPrice());
// goodsNumList.add(ordersGood.getBuyNumber());
// small_sort_idList.add(ordersGood.getSortId());
// goodsTotalPriceList.add(ordersGood.getLastPrice());
// }
//
// LinkedHashMap<String, Object> linkedHashMap = new LinkedHashMap<>();
// linkedHashMap.put("hash", hash);
// linkedHashMap.put("euid", euid);
// linkedHashMap.put("order_sn", orderCode);
// linkedHashMap.put("order_time", orderTime);
// linkedHashMap.put("orders_price", orderAmount);
// linkedHashMap.put("promotion_code", 0);
// //@TODO需要订单传过来,是否新用户
// linkedHashMap.put("is_new_custom", 0);
// linkedHashMap.put("channel", channel);
// linkedHashMap.put("status", orderStatus);
// linkedHashMap.put("goods_id", CollectionUtils.isEmpty(goodsIdList) ? "" : org.apache.commons.lang.StringUtils.join(goodsIdList, "|"));
// linkedHashMap.put("goods_name", CollectionUtils.isEmpty(goodsNameList) ? "" : org.apache.commons.lang.StringUtils.join(goodsNameList, "|"));
// linkedHashMap.put("goods_price", CollectionUtils.isEmpty(goodsPriceList) ? "" : org.apache.commons.lang.StringUtils.join(goodsPriceList, "|"));
// linkedHashMap.put("goods_ta", CollectionUtils.isEmpty(goodsNumList) ? "" : org.apache.commons.lang.StringUtils.join(goodsNumList, "|"));
// linkedHashMap.put("goods_cate", CollectionUtils.isEmpty(small_sort_idList) ? "" : org.apache.commons.lang.StringUtils.join(small_sort_idList, "|"));
// linkedHashMap.put("goods_cate_name", 0);
// linkedHashMap.put("totalPrice", CollectionUtils.isEmpty(goodsTotalPriceList) ? "" : org.apache.commons.lang.StringUtils.join(goodsTotalPriceList, "|"));
// //佣金计算,月底计算一次,7%计算,数据库比例已经老的
// linkedHashMap.put("rate", 0);
// linkedHashMap.put("commission", "");
// linkedHashMap.put("commission_type", 0);
// double coupon = 12d;
// linkedHashMap.put("coupon", MathUtils.roundPrice(coupon));
// Set<String> keys = linkedHashMap.keySet();
// StringBuilder builder = new StringBuilder();
// for (String key : keys) {
// builder.append(key).append("=").append(linkedHashMap.get(key)).append("&");
// }
// try {
// urlContext = URLEncoder.encode(builder.substring(0, builder.length() - 1), "UTF-8");
// } catch (Exception e) {
// logger.warn("send duomai error", e.getMessage());
// }
// }
// return urlContext;
// }
//
//}
... ... @@ -53,8 +53,10 @@ public class GDT2ServiceImpl extends UnionServiceImpl implements IUnionService {
bo.setClient_type(app_type);
if(app_type.equals(ClientTypeEnum.ANDROID.getName())){
bo.setImei(muid);
bo.setInterfaceType("addMonitor_android");
}else {
bo.setIdfa(muid);
bo.setInterfaceType("addMonitor_ios");
}
bo.setAppid(request.getParameter("appid"));
bo.setClickId(request.getParameter("click_id"));
... ... @@ -79,18 +81,37 @@ public class GDT2ServiceImpl extends UnionServiceImpl implements IUnionService {
String encryptKey = null;
String signKey = null;
String muid4MD5 = "";
//有货在广点通的账号id
String uid = requestBO.getCommonUse();
if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(requestBO.getClient_type())) {
DynamicStringProperty ios_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_encrypt_key", "");
encryptKey = ios_encrypt_key.get();
DynamicStringProperty ios_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_sign_key", "");
signKey = ios_sign_key.get();
//由于有两个广点通账号,根据不同的账号取不同的加密密钥和签名密钥
if(StringUtils.isNotEmpty(uid)&&uid.equals("365136")){
DynamicStringProperty ios_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_encrypt_key", "");
encryptKey = ios_encrypt_key.get();
DynamicStringProperty ios_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_sign_key", "");
signKey = ios_sign_key.get();
}else{
DynamicStringProperty ios2_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios2_encrypt_key", "");
encryptKey = ios2_encrypt_key.get();
DynamicStringProperty ios2_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios2_sign_key", "");
signKey = ios2_sign_key.get();
}
//IDFA 码(需转大写),进行 md5 以后得到的 32位全小写 md5 表现字符串。
muid4MD5 = requestBO.getIdfa().toUpperCase();
} else {
DynamicStringProperty android_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_encrypt_key", "");
encryptKey = android_encrypt_key.get();
DynamicStringProperty android_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_sign_key", "");
signKey = android_sign_key.get();
if(StringUtils.isNotEmpty(uid)&&uid.equals("365136")){
DynamicStringProperty android_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_encrypt_key", "");
encryptKey = android_encrypt_key.get();
DynamicStringProperty android_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_sign_key", "");
signKey = android_sign_key.get();
}else{
DynamicStringProperty android2_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("android2_encrypt_key", "");
encryptKey = android2_encrypt_key.get();
DynamicStringProperty android2_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("android2_sign_key", "");
signKey = android2_sign_key.get();
}
//IMEI 号(需转小写),进行 md5 以后得到的 32位全小写 md5 表现字符串。
muid4MD5 = requestBO.getImei().toLowerCase();
}
... ... @@ -165,8 +186,7 @@ public class GDT2ServiceImpl extends UnionServiceImpl implements IUnionService {
}
// conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE);
String convType = "MOBILEAPP_ACTIVITE";
//有货在广点通的账号id
String uid = requestBO.getCommonUse();
url = sb.append(DynamicPropertyFactory.getInstance().getStringProperty("guangdiantong.url", "").get()).append(requestBO.getAppid()).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver(requestBO.getClient_type())).append("&advertiser_id=").append(uid).toString();
log.info("guangdiantong url is {}", url);
return url;
... ...
... ... @@ -76,10 +76,6 @@ public class RedirectServiceImpl implements IRedirectService {
logger.warn("jump: channelId is null, requst param is {}", commonJumpReqVO);
return;
}
// if (StringUtils.isEmpty(commonJumpReqVO.getChannel_code())) {
// logger.warn("jump: trackCode is null, requst param is {}", commonJumpReqVO);
// return;
// }
String redirectUrl = builderCommonUrl(commonJumpReqVO);
response.setStatus(301);
response.sendRedirect(redirectUrl);
... ... @@ -147,9 +143,13 @@ public class RedirectServiceImpl implements IRedirectService {
private String builderCommonUrl(CommonJumpReqVO commonJumpReqVO){
logger.info("builderCommonUrl request is {}", commonJumpReqVO);
// String param = this.generateReqParam(commonJumpReqVO);
String go_url = commonJumpReqVO.getGo_url();
StringBuffer targetUrl = new StringBuffer(commonJumpReqVO.getGo_url());
//如果go_url没有http:需要代码加上,不然301跳转不过去
StringBuffer bf = new StringBuffer();
if(!go_url.startsWith("http")){
go_url = bf.append("http://").append(go_url).toString();
}
StringBuffer targetUrl = new StringBuffer(go_url);
targetUrl = StringUtils.isEmpty(targetUrl) ? new StringBuffer(WAP_URL) : targetUrl;
// String redirectUrl = null;
if(targetUrl.toString().contains("?")){
... ... @@ -157,30 +157,6 @@ public class RedirectServiceImpl implements IRedirectService {
}else {
targetUrl.append("?union_type=").append(commonJumpReqVO.getUnion_type());
}
// if(go_url.contains("m.yohobuy")){
// redirectUrl = WAP_REDIRECT_URL;
// }else {
// redirectUrl = WEB_REDIRECT_URL;
// }
// if (targetUrl.toString().contains("?")) {
// if(targetUrl.toString().contains("utm_source=")){
// targetUrl.append("&utm_medium=").append(commonJumpReqVO.getUtm_medium()).append("&utm_campaign=").append(commonJumpReqVO.getUtm_campaign());
// }else{
// targetUrl.append("&utm_source=").append(commonJumpReqVO.getUtm_source()).append("&utm_medium=").append(commonJumpReqVO.getUtm_medium()).append("&utm_campaign=").append(commonJumpReqVO.getUtm_campaign());
// }
// } else {
// targetUrl.append("?utm_source=").append(commonJumpReqVO.getUtm_source()).append("&utm_medium=").append(commonJumpReqVO.getUtm_medium()).append("&utm_campaign=").append(commonJumpReqVO.getUtm_campaign());
// }
// try {
// param = URLEncoder.encode(param, "UTF-8");
// targetUrl = new StringBuffer(URLEncoder.encode(targetUrl.toString(), "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// logger.warn("builderUrlForPanshi: urlEncode failed: request param is {}", commonJumpReqVO);
// }
// StringBuilder urlBuilder = new StringBuilder();
// urlBuilder.append(redirectUrl).append("?_QYH_UNION=");
// urlBuilder.append(param).append("&target=");
// urlBuilder.append(targetUrl);
logger.info("builderCommonUrl url is {}", targetUrl.toString());
return targetUrl.toString();
}
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.unions.server.service.impl;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
... ... @@ -23,6 +24,10 @@ public class TouTiaoServiceImpl extends UnionServiceImpl implements IUnionServic
bo = new ClickUnionRequestBO();
String idfa = request.getParameter("idfa");
String imei = request.getParameter("imei");
bo.setInterfaceType("addMonitor_ios");
if(StringUtils.isNotEmpty(imei)) {
bo.setInterfaceType("addMonitor_android");
}
bo.setIdfa(idfa);
bo.setImei(imei);
//将毫秒级的转换为秒级别---头条有时候不传
... ...
... ... @@ -92,6 +92,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
@Resource
IUnionActivityLogsDAO unionActivityLogsDAO;
@Resource
IUnionTypeMatchDAO unionTypeMatchDAO;
@Resource(name="unionServiceImpl")
IUnionService unionService;
... ... @@ -108,14 +111,6 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
try {
clickUnion.info("enter clickUnion with param is {}", request);
//检查输入参数
// if (StringUtils.isEmpty(request.getAppid())) {
// log.warn("clickUnion error because appid is empty with param is {}", request);
// return new UnionResponse(201, "appid is empty");
// }
// if (StringUtils.isEmpty(request.getTd())) {
// log.warn("clickUnion error because td is empty with param is {}", request);
// return new UnionResponse(201, "td is empty");
// }
if (StringUtils.isEmpty(request.getUnion_type())) {
log.warn("clickUnion error because union_type is empty with param is {}", request);
return new UnionResponse(201, "union_type is empty");
... ... @@ -124,7 +119,6 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
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()));
MktMarketingUrl type = redisValueCache.get("yh:union:uniontype:"+request.getUnion_type(),MktMarketingUrl.class);
if(type==null){
type = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(request.getUnion_type()));
... ... @@ -288,14 +282,12 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}
}
// log.info("activateUnion with get redis first with key={}, value={}", key, value);
activeUnion.info("activateUnion with get redis first with key={}, value={}", key, value);
String td = request.getTd();
if (StringUtils.isNotEmpty(td)) {
if (StringUtils.isEmpty(value)) {
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
value = yhValueOperations.get(key);
// log.info("activateUnion with get redis first with key={}, value={}", key, value);
activeUnion.info("activateUnion with get redis first with key={}, value={}",key, value);
}
if (StringUtils.isEmpty(value)) {
... ... @@ -304,14 +296,12 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
td=(arr[2] + "_" + arr[3]);
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
value = yhValueOperations.get(key);
// log.info("activateUnion with get redis second with key={}, value={}", key, value);
activeUnion.info("activateUnion with get redis second with key={}, value={}", key, value);
}
if(arr.length==3){
td = (arr[1]+"_"+arr[2]);
key = UNION_KEY + "_" + request.getClientIp() + "_" + td + "_" + request.getAppkey();
value = yhValueOperations.get(key);
// log.info("activateUnion with get redis third with key={}, value={}", key, value);
activeUnion.info("activateUnion with get redis third with key={}, value={}", key, value);
}
}
... ... @@ -330,7 +320,6 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}
// log.info("activateUnion with get redis forth with key={}, value={}", key, value);
activeUnion.info("activateUnion with get redis forth with key={}, value={}", key, value);
}
... ... @@ -364,12 +353,11 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
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()));
String unionTypekey = "yh:union:uniontype:"+click.getUnion_type();
MktMarketingUrl mktMarketingUrl = redisValueCache.get(unionTypekey,MktMarketingUrl.class);
if(mktMarketingUrl==null){
mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(click.getUnion_type()));
redisValueCache.set(unionTypekey,mktMarketingUrl,1, TimeUnit.HOURS);
redisValueCache.set(unionTypekey, mktMarketingUrl, 1, TimeUnit.HOURS);
}
UnionTypeModel u = new UnionTypeModel();
u.setName(mktMarketingUrl.getName());
... ... @@ -421,8 +409,6 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
return new UnionResponse(203, "have activite in 90 days");
}
}
// 调用成功,更新数据库
UnionLogs logs = new UnionLogs();
... ... @@ -442,8 +428,6 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
unionLogsDAO.insert(logs);
log.info("activateUnion add db success with request is {}, and dbData={}", request, logs);
// 记录日志
JSONObject j = new JSONObject();
j.put("apptype", request.getClient_type());
... ... @@ -459,6 +443,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
j.put("app_key", request.getAppkey());
j.put("active_type", "90");
j.put("tdid", request.getTdid());
j.put("interfaceType",click.getInterfaceType());
//打印90天的大数据日志
activeDingdang.info(j.toString());
... ... @@ -474,7 +459,6 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}else if(StringUtils.isNotEmpty(request.getImei())){
muid = request.getImei();
}
String interfaceType = click.getInterfaceType();
DeviceActiveEvent activeEvent = new DeviceActiveEvent("deviceActive",interfaceType,source,source_id,muid);
... ... @@ -485,15 +469,16 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
log.warn("publish activate event fail! e {}", e);
}
// UnionTypeModel type =
// UnionConstant.unionTypeMap.get(Integer.parseInt(click.getUnion_type()));
String url = null;
//取出具体是哪个union_type
//根据不同的url走不同的回调
try {
String union_type = click.getUnion_type();
StringBuffer buffer = new StringBuffer();
UnionTypeMatch unionTypeMatch = unionTypeMatchDAO.selectByPrimaryKey(Long.valueOf(union_type));
if(unionTypeMatch!=null && org.apache.commons.lang.StringUtils.isNotEmpty(String.valueOf(unionTypeMatch.getUnionTypeMatch()))){
union_type = String.valueOf(unionTypeMatch.getUnionTypeMatch());
}
String bean =buffer.append("UnionServiceImpl").append("_").append(union_type).toString();
if(SpringContextUtil.containsBean(bean)){
IUnionService uniteService = SpringContextUtil.getBean(bean, IUnionService.class);
... ... @@ -505,7 +490,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
log.info("activateUnion in success request is {}", request);
return new UnionResponse();
}
if(!"3".equals(union_type)){
if(!"3".equals(union_type)||!"100000000000453".equals(union_type)){
url = URLDecoder.decode(url, "UTF-8");
}
... ... @@ -514,20 +499,8 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
} else {
url += "?identify_id=" + click.getIdentify_id();
}
// if (ClientTypeEnum.IOS.getName().equals(request.getClient_type())) {
// url += "&idfa=" + click.getIdfa();
// } else {
// url += "&imei=" + click.getImei();
// }
activeUnion.info("activateUnion in call url={}", url);
// 调用接口发送短信请求
// AsyncFuture<String> response = service.get("union.activate", url, null, String.class, null);
// String result = response.get();
//改成httpclient方式调用
Pair<Integer, String> pair = HttpUtils.httpGet(url);
activeUnion.info("activateUnion call union success url={}, and result={}", url, pair);
if (pair.getLeft() != 200) {
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.unions.server.service.impl;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
... ... @@ -26,6 +27,10 @@ public class WeiBoServiceImpl extends UnionServiceImpl implements IUnionService
String clicktime = request.getParameter("clicktime");
Long click = Long.valueOf(clicktime);
clickUnionRequestBO.setIdfa(request.getParameter("idfa_md5"));
clickUnionRequestBO.setInterfaceType("addMonitor_ios");
if(StringUtils.isNotEmpty(request.getParameter("imei_md5"))){
clickUnionRequestBO.setInterfaceType("addMonitor_android");
}
clickUnionRequestBO.setImei(request.getParameter("imei_md5"));
clickUnionRequestBO.setClickTime(click/1000);
clickUnionRequestBO.setCallbackurl(request.getParameter("IMP"));
... ...
package com.yoho.unions.server.service.impl;
import com.netflix.config.DynamicPropertyFactory;
import com.netflix.config.DynamicStringProperty;
import com.yoho.core.common.utils.MD5;
import com.yoho.service.model.union.request.ActivateUnionRequestBO;
import com.yoho.service.model.union.request.ClickUnionRequestBO;
import com.yoho.unions.common.enums.ClientTypeEnum;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.dal.IUnionConfigDAO;
import com.yoho.unions.dal.model.UnionConfig;
import com.yoho.unions.server.service.IUnionService;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* Created by yoho on 2017/2/20.
*/
@Service("UnionServiceImpl_100000000000453")
public class ZhihuituiServiceImpl extends UnionServiceImpl implements IUnionService {
static Logger log = LoggerFactory.getLogger(ZhihuituiServiceImpl.class);
@Resource
IUnionConfigDAO unionConfigDAO;
@Override
public String getCallbackUrl(ClickUnionRequestBO clickBO,ActivateUnionRequestBO activateUnionRequestBO) {
//直接调用原有的广点通获取URL的方法
ActivateUnionRequestBO requestBO = new ActivateUnionRequestBO();
requestBO.setAppid(clickBO.getAppid());
requestBO.setClient_type(clickBO.getClient_type());
requestBO.setIdfa(clickBO.getIdfa());
requestBO.setImei(clickBO.getImei());
requestBO.setCommonUse(clickBO.getCommonUse());
//广点通后台生成的点击id
requestBO.setUdid(clickBO.getClickId());
return urlEode(requestBO);
}
@Override
public ClickUnionRequestBO clickHttpRequestTOBO(HttpServletRequest request,ClickUnionRequestBO bo){
bo = new ClickUnionRequestBO();
String muid = request.getParameter("muid");
String app_type = request.getParameter("app_type");
bo.setClient_type(app_type);
if(app_type.equals(ClientTypeEnum.ANDROID.getName())){
bo.setImei(muid);
bo.setInterfaceType("addMonitor_android");
}else {
bo.setIdfa(muid);
bo.setInterfaceType("addMonitor_ios");
}
bo.setAppid(request.getParameter("appid"));
bo.setClickId(request.getParameter("click_id"));
bo.setUnion_type(request.getParameter("union_type"));
bo.setClickTime(Integer.valueOf(request.getParameter("click_time")));
bo.setTd(request.getParameter("td"));
//广告主在智慧推的账户id
// bo.setJson(JSONObject.parseObject(request.getParameter("advertiser_id")));
bo.setCommonUse(String.valueOf(request.getParameter("advertiser_id")));
return bo;
}
/**
* 对url进行拼接,加密
*
* @param requestBO
* @return
*/
public String urlEode(ActivateUnionRequestBO requestBO) {
log.info("enter GDTServiceImpl.urlEode param{} is ", requestBO);
// 根据不同的应用类型,获取不同的加密密钥和签名密钥
String encryptKey = "b4e4b76af6626299";
String signKey = "04ddd32894b3c683";
String muid4MD5 = "";
String url = "http://jump.t.l.qq.com/conv/app/";
//有货在智慧推的账号id
String uid = "18261";
if(StringUtils.isNotEmpty(requestBO.getCommonUse())){
uid = requestBO.getCommonUse();
}
String clientType = ClientTypeEnum.IOS.getName();
if(StringUtils.isNotEmpty(requestBO.getClient_type())){
clientType = requestBO.getClient_type().toLowerCase();
}
UnionConfig unionConfig = unionConfigDAO.selectByUidAndClientType(Integer.valueOf(uid),clientType);
if(null!=unionConfig){
encryptKey = unionConfig.getEncryptKey();
signKey = unionConfig.getSignKey();
url = unionConfig.getUrl();
}
if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(requestBO.getClient_type())) {
//IDFA 码
muid4MD5 = requestBO.getIdfa();
} else {
//IMEI 号
muid4MD5 = requestBO.getImei();
}
String client_ip = requestBO.getClientIp();
String appId = requestBO.getAppid();
int conv_time = DateUtil.getCurrentTimeSecond();
String page = null;
String query_string = null;
StringBuffer bf = new StringBuffer();
StringBuffer sf = new StringBuffer();
if (StringUtils.isEmpty(client_ip)){
page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString();
query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString();
}else{
page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
}
// 对url进行加密
String encode_page = null;
try {
encode_page = URLEncoder.encode(page, "UTF-8");
log.info("activateZhiHuitui urlEncoder is{} ", encode_page);
} catch (UnsupportedEncodingException e) {
log.error("encode exception.", e);
}
// 将签名密钥和提交方式与加密后的url进行拼接
StringBuffer urlBuffer = new StringBuffer();
String property = urlBuffer.append(signKey).append("&GET&").append(encode_page).toString();
String signature = MD5.md5(property);
StringBuffer base = new StringBuffer();
String base_data = base.append(query_string).append("&sign=").append(signature).toString();
// 简单异或处理
String data = simpleXorByGdt(base_data, encryptKey);
// base64编码
String ret = Base64.encodeBase64String(data.getBytes());
// 64位处理之后,防止里面有换行符
String retRep = ret.replaceAll("\n", "");
// 将64位处理之后的值,按照url加密的方式进行加密
try {
retRep = URLEncoder.encode(retRep, "UTF-8");
log.info("activateUnion retRep is{}", retRep);
} catch (UnsupportedEncodingException e) {
log.error("encode exception.", e);
}
// conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE);
String convType = "MOBILE_APP_ACTIVITE";
StringBuffer sb = new StringBuffer();
url = sb.append(url).append(requestBO.getAppid()).append("/conv?v=").append(retRep).append("&conv_type=").append(convType).append("&app_type=").append(clientTypeConver(requestBO.getClient_type())).append("&advertiser_id=").append(uid).toString();
log.info("zhihuitui url is {}", url);
return url;
}
/**
* 简单异或
*
* @param source
* @param key
* @return
*/
private String simpleXorByGdt(String source, String key) {
String result = "";
int j = 0;
for (int i = 0; i < source.length(); i++) {
int c1 = source.charAt(i);
int c2 = key.charAt(j);
result = result + (char) (c1 ^ c2);
j = j + 1;
j = j % (key.length());
}
return result;
}
private String clientTypeConver(String clientType) {
if (StringUtils.isEmpty(clientType)) {
return null;
}
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType)) {
return clientType.toLowerCase();
} else {
return "ios";
}
}
}
... ...
... ... @@ -56,18 +56,27 @@ draw.writeFile.delay=1
ios_encrypt_key=a9dc833b8a75c21f
#广点通 对接方案1ios加密密钥
ios1_encrypt_key=BAAAAAAAAAAABZJQ
#广点通 对接方案1 账号为1125695加密密钥
ios2_encrypt_key=BAAAAAAAAAAAES0b
#广点通 ios签名密钥
ios_sign_key=bd80e4c0ecd5a150
#广点通对接方案1 iosios签名密钥
ios1_sign_key=1461f1237d22dfc7
#广点通对接方案1 账号为1125695签名密钥
ios2_sign_key=3bf06c662eb092ec
#广点通 android加密密钥
android_encrypt_key=BAAAAAAAAAAAE0FR
#广点通对接方案1 android加密密钥
#广点通对接方案1 android加密密钥,账号是365136
android1_encrypt_key=BAAAAAAAAAAABZJQ
#广点通对接方案1 android加密密钥,账号是1125695
android2_encrypt_key=BAAAAAAAAAAAES0b
#广点通 android签名密钥
android_sign_key=d43ef6ef894e3c56
#广点通 android签名密钥
#广点通 android签名密钥账号是365136
android1_sign_key=1461f1237d22dfc7
#广点通 android签名密钥账号是1125695
android2_sign_key=3bf06c662eb092ec
#广点通 url
guangdiantong.url=http://t.gdt.qq.com/conv/app/
... ...
... ... @@ -19,8 +19,8 @@ datasources:
app:
servers:
- 10.67.2.46:3307
- 10.67.2.46:3306
- 192.168.102.219:3306
- 192.168.102.219:3306
username: yh_test
password: 9nm0icOwt6bMHjMusIfMLw==
daos:
... ...
... ... @@ -55,18 +55,26 @@ activeTime_4=24
ios_encrypt_key=a9dc833b8a75c21f
#广点通对接方案1 ios加密密钥
ios1_encrypt_key=BAAAAAAAAAAABZJQ
#广点通 对接方案1 账号为1125695加密密钥
ios2_encrypt_key=BAAAAAAAAAAAES0b
#广点通 ios签名密钥
ios_sign_key=bd80e4c0ecd5a150
#广点通对接方案1 iosios签名密钥
ios1_sign_key=1461f1237d22dfc7
#广点通对接方案1 账号为1125695签名密钥
ios2_sign_key=3bf06c662eb092ec
#广点通 android加密密钥
android_encrypt_key=BAAAAAAAAAAAE0FR
#广点通对接方案1 android加密密钥
android1_encrypt_key=BAAAAAAAAAAABZJQ
#广点通对接方案1 android加密密钥,账号是1125695
android2_encrypt_key=BAAAAAAAAAAAES0b
#广点通 android签名密钥
android_sign_key=d43ef6ef894e3c56
#广点通 android签名密钥
android1_sign_key=1461f1237d22dfc7
#广点通 android签名密钥账号是1125695
android2_sign_key=3bf06c662eb092ec
#广点通 url
guangdiantong.url=http://t.gdt.qq.com/conv/app/
... ...
... ... @@ -23,6 +23,8 @@
<link rel="dns-prefetch" href="//list.m.yohobuy.com">
<link rel="dns-prefetch" href="//guang.m.yohobuy.com">
<script type="text/javascript">
(function (d, c) {
var e = d.documentElement, a = "orientationchange" in window ? "orientationchange" : "resize", b = function () {
... ... @@ -141,10 +143,16 @@
window.cookie = cookie;
var url = 'yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.home","params":{"gender":"1","channel":"2"}}';
var isWechat = /micromessenger/i.test(navigator.userAgent || '');
if(isWechat){
url = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho&g_f=995445';
location.href = url;
}
var u = navigator.userAgent.toLowerCase();
var isiOS = u.indexOf('os') > -1 || u.indexOf('iphone') > -1 || u.indexOf('mac') > -1 || u.indexOf('ipad') > -1;
var isWechat = /micromessenger/i.test(navigator.userAgent || '');
var androidExp = new RegExp('MQQBrowser');//安卓QQ内置浏览器正则
var isAndroidQQ = androidExp.test(navigator.userAgent); //判断是不是QQ内置浏览器
... ...
... ... @@ -7,7 +7,7 @@
<script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div id="search" region="north" style="padding-bottom: 35px; height: auto;">
<div id="search" region="north" style="padding-bottom: 35px; height:220px;">
<script>
document.write(addHead('市场管理', '分组营销管理'));
</script>
... ... @@ -118,8 +118,6 @@
width: 170,
align: "center",
formatter: function (value, rowData, rowIndex) {
// return "<a href='#' class='easyui-tooltip' title='泛渠道来源:淘宝B店\r\nuid:171717171'>条件筛选</a>";
// return "<span class='dd' >条件筛选</span>";
return '<span id="condition-'+rowIndex+'" >条件筛选</span>';
}
},{
... ... @@ -153,6 +151,19 @@
width: 170,
align: "center"
},{
title: "发送结果分析",
field: "successCount",
width: 170,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(rowData.content == null || rowData.content ==''){
return "";
}else{
var fail =rowData.groupNumber - value;
return "成功数"+value+",失败数"+fail;
}
}
},{
title: "操作",
field: "asdf",
width: 170,
... ...
... ... @@ -8,6 +8,7 @@ import com.yoho.service.model.union.request.ActivateUnionRequestBO;
import com.yoho.unions.common.enums.ClientTypeEnum;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.common.utils.HttpUtils;
import com.yoho.unions.dal.model.UnionConfig;
import com.yoho.unions.server.service.impl.GDT2ServiceImpl;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
... ... @@ -26,109 +27,68 @@ public class Test {
public static void main(String[] args){
// 根据不同的应用类型,获取不同的加密密钥和签名密钥
// 根据不同的应用类型,获取不同的加密密钥和签名密钥
String encryptKey = "BAAAAAAAAAAABZJQ";
String signKey = "1461f1237d22dfc7";
// String muid4MD5 = "0f074dc8e1f0547310e729032ac0730b";
String encryptKey = "test_encrypt_key";
String signKey = "test_sign_key";
String muid4MD5 = "0f074dc8e1f0547310e729032ac0730b";
String url = "http://jump.t.l.qq.com/conv/app/";
//有货在智慧推的账号id
String uid = "18261";
GDT2ServiceImpl gdt2Service = new GDT2ServiceImpl();
ActivateUnionRequestBO requestBO = new ActivateUnionRequestBO();
requestBO.setIdfa("5bdfa8ee7a491f67428b2c341a803514");
requestBO.setUdid("sykvcwayaaaasz2b2x7a");
requestBO.setCommonUse("365136");
requestBO.setAppid("490655927");
requestBO.setClient_type("ios");
// requestBO.setClientIp("171.213.29.236");
// String url = gdt2Service.urlEode(requestBO);
// String url1 = url+"&identify_id=null";
// Pair<Integer, String> pair = HttpUtils.httpGet(url1);
// try{
// url = URLDecoder.decode(url1, "UTF-8");
// }catch (Exception e){
//
String clientType = ClientTypeEnum.IOS.getName();
// if(StringUtils.isNotEmpty(requestBO.getClient_type())){
// clientType = requestBO.getClient_type().toLowerCase();
// }
String idfa = requestBO.getIdfa().toUpperCase();
// Pair<Integer, String> pair1 = HttpUtils.httpGet(url);
String client_ip = "10.11.12.13";
String appId = "112233";
int conv_time =1422263664;
String page = null;
String query_string = null;
StringBuffer bf = new StringBuffer();
StringBuffer sf = new StringBuffer();
String query_string = sf.append("click_id=").append(requestBO.getUdid()).append("&muid=").append(MD5.md5(idfa)).append("&conv_time=").append(1481714596).toString();
String page = "http://t.gdt.qq.com/conv/app/"+490655927+"/conv?"+query_string;
if (StringUtils.isEmpty(client_ip)){
page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString();
query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).toString();
}else{
page = bf.append(url).append(appId).append("/conv?muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
query_string = sf.append("muid=").append(muid4MD5).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
}
// 对url进行加密
String encode_page = null;
String GDTurl = null;
try{
try {
encode_page = URLEncoder.encode(page, "UTF-8");
String property = signKey+"&GET&"+encode_page;
String signature = MD5.md5(property);
String base_data = query_string+"&sign="+URLEncoder.encode(signature,"UTF-8");
String data = simpleXorByGdt(base_data, encryptKey);
// base64编码
String ret = Base64.encodeBase64String(data.getBytes());
String attachment = "conv_type="+"MOBILEAPP_ACTIVITE"+"&app_type="+clientTypeConver(requestBO.getClient_type())+"&advertiser_id="+365136;
GDTurl = "http://t.gdt.qq.com/conv/app/"+requestBO.getAppid()+"/conv?v="+ret+"&"+attachment;
}catch (UnsupportedEncodingException e){
log.info("activateZhiHuitui urlEncoder is{} ", encode_page);
} catch (UnsupportedEncodingException e) {
log.error("encode exception.", e);
}
// System.out.print(pair);
// 将签名密钥和提交方式与加密后的url进行拼接
StringBuffer urlBuffer = new StringBuffer();
// if (ClientTypeEnum.IOS.getName().equalsIgnoreCase(requestBO.getClient_type())) {
// DynamicStringProperty ios_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_encrypt_key", "");
// encryptKey = ios_encrypt_key.get();
// DynamicStringProperty ios_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("ios1_sign_key", "");
// signKey = ios_sign_key.get();
// //IDFA 码(需转大写),进行 md5 以后得到的 32位全小写 md5 表现字符串。
// muid4MD5 = 0f074dc8e1f0547310e729032ac0730b
// } else {
// DynamicStringProperty android_encrypt_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_encrypt_key", "");
// encryptKey = android_encrypt_key.get();
// DynamicStringProperty android_sign_key = DynamicPropertyFactory.getInstance().getStringProperty("android1_sign_key", "");
// signKey = android_sign_key.get();
// //IMEI 号(需转小写),进行 md5 以后得到的 32位全小写 md5 表现字符串。
// muid4MD5 = requestBO.getImei().toLowerCase();
// }
/**
* 对设备id进行MD5加密,获取32位小写加密串
*/
//
String property = urlBuffer.append(signKey).append("&GET&").append(encode_page).toString();
String signature = MD5.md5(property);
StringBuffer base = new StringBuffer();
String base_data = base.append(query_string).append("&sign=").append(signature).toString();
/**
* 对url进行拼接,并进行加密-----http://t.gdt.qq.com/conv/app/
*/
// String url = "";
// String client_ip = "11.22.33";
// int conv_time = DateUtil.getCurrentTimeSecond();
// String clickId = "007210548a030059ccdfd1d4";
// String appId = "490655927";
// StringBuffer bf = new StringBuffer();
// StringBuffer sf = new StringBuffer();
// String query_string = null;
// String url4Encoude = null;
// //有货在广点通的账号id
// String advertiser_id = "365136";
// if (StringUtils.isEmpty(client_ip)) {
// url4Encoude = bf.append(url).append(appId).append("/conv?click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).toString();
// query_string = sf.append("click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).toString();
// } else {
// url4Encoude = bf.append(url).append(appId).append("/conv?click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
// query_string = sf.append("click_id=").append(clickId).append("&muid=").append(muid).append("&conv_time=").append(conv_time).append("&client_ip=").append(client_ip).toString();
// }
// log.info("activateUnion url is{} ", url4Encoude);
// //参数加密
//// sf = sf.append(url).append(requestBO.getAppid()).append("/conv?").append(query_string);
// String page = "http://t.gdt.qq.com/conv/app/"+appId+"/conv?"+query_string;
// String encode_page = null;
// String GDTurl = null;
// try{
// encode_page = URLEncoder.encode(page, "UTF-8");
// String property = signKey+"&GET"+"encode_page";
// String signature = MD5.md5(property);
// String base_data = query_string+"&sign="+URLEncoder.encode(signature,"UTF-8");
// String data = simpleXorByGdt(base_data, encryptKey);
// String attachment = "conv_type="+"MOBILEAPP_ACTIVITE"+"&app_type="+"ANDROID"+"&advertiser_id="+advertiser_id;
// GDTurl = "http://t.gdt.qq.com/conv/app/"+"490655927"+"/conv?v="+data+"&"+attachment;
// Pair<Integer, String> pair = HttpUtils.httpGet(GDTurl);
// }catch (UnsupportedEncodingException e){
// log.error("encode exception.", e);
// }
// System.out.print(GDTurl);
// 简单异或处理
String data = simpleXorByGdt(base_data, encryptKey);
// base64编码
String ret = Base64.encodeBase64String(data.getBytes());
// 64位处理之后,防止里面有换行符
String retRep = ret.replaceAll("\n", "");
// 将64位处理之后的值,按照url加密的方式进行加密
try {
retRep = URLEncoder.encode(retRep, "UTF-8");
log.info("activateUnion retRep is{}", retRep);
} catch (UnsupportedEncodingException e) {
log.error("encode exception.", e);
}
// conv_type,,现在只有移动应用激活类型(MOBILEAPP_ACTIVITE);
String convType = "MOBILE_APP_ACTIVITE";
StringBuffer sb = new StringBuffer();
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();
log.info("zhihuitui url is {}", url);
System.out.print(url);
}
private static String clientTypeConver(String clientType) {
... ... @@ -136,9 +96,9 @@ public class Test {
return null;
}
if (ClientTypeEnum.ANDROID.getName().equalsIgnoreCase(clientType)) {
return clientType.toUpperCase();
return clientType.toLowerCase();
} else {
return "IOS";
return "ios";
}
}
... ...