Authored by zhengwen.ge

广点通需求

@@ -90,37 +90,43 @@ public class GDTServiceImpl implements MainUnionService { @@ -90,37 +90,43 @@ 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 - //激活成功 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)){
107 unionLogs.setIsActivate((byte) 1); 109 unionLogs.setIsActivate((byte) 1);
108 unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond()); 110 unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
109 unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond()); 111 unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
110 -  
111 log.debug("add to unionLogs db with param is {}", unionLogs); 112 log.debug("add to unionLogs db with param is {}", unionLogs);
112 -  
113 - response = new ActivateDingdangResponseBO(true, "成功"); 113 + response = new ActivateDingdangResponseBO(true, msg);
114 } 114 }
  115 + //广点通返回错误
115 else{ 116 else{
116 - //激活失败  
117 unionLogs.setIsActivate((byte) 0); 117 unionLogs.setIsActivate((byte) 0);
118 unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond()); 118 unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
119 unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond()); 119 unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
120 - JSONObject json = JSONObject.parseObject(pair.getRight());  
121 - msg = json.getString("msg");  
122 response = new ActivateDingdangResponseBO(false, msg); 120 response = new ActivateDingdangResponseBO(false, msg);
123 } 121 }
  122 + }
  123 + else{
  124 + //激活失败
  125 + unionLogs.setIsActivate((byte) 0);
  126 + unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
  127 + unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
  128 + response = new ActivateDingdangResponseBO(false, "激活失败");
  129 + }
124 unionLogsDAO.insert(unionLogs); 130 unionLogsDAO.insert(unionLogs);
125 return response; 131 return response;
126 } 132 }