Authored by zhengwen.ge

广点通需求

@@ -90,36 +90,42 @@ public class GDTServiceImpl implements MainUnionService { @@ -90,36 +90,42 @@ public class GDTServiceImpl implements MainUnionService {
90 90
91 MainUnionResponseBO response = null; 91 MainUnionResponseBO response = null;
92 String msg = null; 92 String msg = null;
93 - 93 + String ret = null;
94 Pair<Integer, String> pair = HttpUtils.httpGet(url); 94 Pair<Integer, String> pair = HttpUtils.httpGet(url);
95 // Pair<Integer, String> pair = Pair.of(200, "{\"ret\":0,\"msg\":\"success\"}"); 95 // Pair<Integer, String> pair = Pair.of(200, "{\"ret\":0,\"msg\":\"success\"}");
96 -// Pair<Integer, String> pair = Pair.of(400, "{\"ret\":-1,\"msg\":\"请求非法参数\"}");  
97 -// Pair<Integer, String> pair = Pair.of(789, "adsfasdfasd");  
98 UnionLogs unionLogs = new UnionLogs(); 96 UnionLogs unionLogs = new UnionLogs();
99 unionLogs.setAppId(String.valueOf(requestBO.getAppid())); 97 unionLogs.setAppId(String.valueOf(requestBO.getAppid()));
100 unionLogs.setUdid(requestBO.getMuid()); 98 unionLogs.setUdid(requestBO.getMuid());
101 unionLogs.setUnionType((byte) requestBO.getUnionType()); 99 unionLogs.setUnionType((byte) requestBO.getUnionType());
102 unionLogs.setActivateParams(JSON.toJSONString(requestBO)); 100 unionLogs.setActivateParams(JSON.toJSONString(requestBO));
103 - 101 + //如果status是200,证明发送成功
104 if(pair.getLeft() == HttpStatus.SC_OK){ 102 if(pair.getLeft() == HttpStatus.SC_OK){
105 log.debug("url return message is {}",pair.getRight()); 103 log.debug("url return message is {}",pair.getRight());
106 - //激活成功  
107 - unionLogs.setIsActivate((byte) 1);  
108 - unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());  
109 - unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());  
110 -  
111 - log.debug("add to unionLogs db with param is {}", unionLogs);  
112 -  
113 - response = new ActivateDingdangResponseBO(true, "成功"); 104 + JSONObject json = JSONObject.parseObject(pair.getRight());
  105 + ret = json.getString("ret");
  106 + msg = json.getString("msg");
  107 + //广点通返回成功
  108 + if(StringUtils.isNotEmpty(ret)&&"0".equals(ret)){
  109 + unionLogs.setIsActivate((byte) 1);
  110 + unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
  111 + unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
  112 + log.debug("add to unionLogs db with param is {}", unionLogs);
  113 + response = new ActivateDingdangResponseBO(true, msg);
  114 + }
  115 + //广点通返回错误
  116 + else{
  117 + unionLogs.setIsActivate((byte) 0);
  118 + unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
  119 + unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
  120 + response = new ActivateDingdangResponseBO(false, msg);
  121 + }
114 } 122 }
115 else{ 123 else{
116 //激活失败 124 //激活失败
117 unionLogs.setIsActivate((byte) 0); 125 unionLogs.setIsActivate((byte) 0);
118 unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond()); 126 unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
119 unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond()); 127 unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
120 - JSONObject json = JSONObject.parseObject(pair.getRight());  
121 - msg = json.getString("msg");  
122 - response = new ActivateDingdangResponseBO(false, msg); 128 + response = new ActivateDingdangResponseBO(false, "激活失败");
123 } 129 }
124 unionLogsDAO.insert(unionLogs); 130 unionLogsDAO.insert(unionLogs);
125 return response; 131 return response;