Authored by zhengwen.ge

广点通需求

... ... @@ -90,37 +90,43 @@ public class GDTServiceImpl implements MainUnionService {
MainUnionResponseBO response = null;
String msg = null;
String ret = null;
Pair<Integer, String> pair = HttpUtils.httpGet(url);
// Pair<Integer, String> pair = Pair.of(200, "{\"ret\":0,\"msg\":\"success\"}");
// Pair<Integer, String> pair = Pair.of(400, "{\"ret\":-1,\"msg\":\"请求非法参数\"}");
// Pair<Integer, String> pair = Pair.of(789, "adsfasdfasd");
UnionLogs unionLogs = new UnionLogs();
unionLogs.setAppId(String.valueOf(requestBO.getAppid()));
unionLogs.setUdid(requestBO.getMuid());
unionLogs.setUnionType((byte) requestBO.getUnionType());
unionLogs.setActivateParams(JSON.toJSONString(requestBO));
//如果status是200,证明发送成功
if(pair.getLeft() == HttpStatus.SC_OK){
log.debug("url return message is {}",pair.getRight());
//激活成功
JSONObject json = JSONObject.parseObject(pair.getRight());
ret = json.getString("ret");
msg = json.getString("msg");
//广点通返回成功
if(StringUtils.isNotEmpty(ret)&&"0".equals(ret)){
unionLogs.setIsActivate((byte) 1);
unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
log.debug("add to unionLogs db with param is {}", unionLogs);
response = new ActivateDingdangResponseBO(true, "成功");
response = new ActivateDingdangResponseBO(true, msg);
}
//广点通返回错误
else{
//激活失败
unionLogs.setIsActivate((byte) 0);
unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
JSONObject json = JSONObject.parseObject(pair.getRight());
msg = json.getString("msg");
response = new ActivateDingdangResponseBO(false, msg);
}
}
else{
//激活失败
unionLogs.setIsActivate((byte) 0);
unionLogs.setCreateTime(DateUtil.getCurrentTimeSecond());
unionLogs.setUpdateTime(DateUtil.getCurrentTimeSecond());
response = new ActivateDingdangResponseBO(false, "激活失败");
}
unionLogsDAO.insert(unionLogs);
return response;
}
... ...