fix response

master
wangyuan 2019-09-16 10:57:57 +08:00
parent 7ceac5f191
commit 4a5eee2c64
3 changed files with 11 additions and 17 deletions

View File

@ -23,7 +23,6 @@ import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@ -40,8 +39,8 @@ public class RechargeController {
public String callback( HttpServletRequest request) throws Exception {
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
if(parameterMap.isEmpty()) {
ResultVo resultVo = new ResultVo(8, "data is null");
return JsonUtil.getInstence().getGson().toJson(resultVo);
LOGGER.info( "data is null");
return "data is null";
}
String source = parameterMap.keySet().iterator().next();
source = source.replaceAll(" ", "+");
@ -50,8 +49,8 @@ public class RechargeController {
RechargeRequestBean.DataBean data = rechargeRequestBean.getData();
if(data == null){
ResultVo resultVo = new ResultVo(8, "data is null");
return JsonUtil.getInstence().getGson().toJson(resultVo);
LOGGER.info( "data is null");
return "data is null";
}
String orderId =data.getOrder_id();
String userId = data.getUid();
@ -63,21 +62,19 @@ public class RechargeController {
if (!sig.equals(sign)){
LOGGER.info("callback==>roleUid={},sin derify fail,mine sign={} ",userId,sig);
ResultVo resultVo = new ResultVo(9, "sign fail");
return JsonUtil.getInstence().getGson().toJson(resultVo);
return "sign fail";
}
CUserInfo cUserInfo = cuserDao.findUserByOpenIdAndUidInfo(userId,serverID);
if(cUserInfo == null || !userId.equals(cUserInfo.getOpenId()) ){
ResultVo resultVo = new ResultVo(10, "该用户无此角色");
return JsonUtil.getInstence().getGson().toJson(resultVo);
LOGGER.info( "该用户无此角色");
return "该用户无此角色";
}
CPayOrder cPayOrder = cuserDao.getCpayOrderByOrderId(orderId);
ResultVo resultVo;
String response = "SUCCESS";
if (cPayOrder != null) {
LOGGER.info("callback==>creditId={},uId={} orderId is exit!!!",cUserInfo.getId(),cUserInfo.getOpenId());
resultVo = new ResultVo(1, "SUCCESS");
} else {
DateFormat dateTimeformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date = dateTimeformat.format(new Date());
@ -115,12 +112,11 @@ public class RechargeController {
if (result != null && result.getResultCode() == 1) {
LOGGER.info(" callback==>RPC result : ResultCode : " + result.getResultCode() + "; ResultMsg : " + result.getResultMsg());
cuserDao.addCpayOrder(cPayOrder);
resultVo = new ResultVo(1, "SUCCESS");
} else {
resultVo = new ResultVo(11, "fail!!!!");
response = "fail";
}
}
return JsonUtil.getInstence().getGson().toJson(resultVo);
return response;
}

View File

@ -53,7 +53,7 @@ public class JsonUtil {
}
map.put(key, paramValue);
LOGGER.info("parameter : {} " + key);
LOGGER.info("parameter : {} " , key);
}
return map;
}

View File

@ -19,8 +19,6 @@ public class MD5Util {
if (i < 16) buf.append("0");
buf.append(Integer.toHexString(i));
}
System.out.println("32result: " + buf.toString());// 32位的加密
System.out.println("16result: " + buf.toString().substring(8, 24));// 16位的加密
return buf.toString().toLowerCase();