diff --git a/src/main/java/com/jmfy/controller/HaoGameRechargeController.java b/src/main/java/com/jmfy/controller/HaoGameRechargeController.java index 2ca69b6..11f6aae 100644 --- a/src/main/java/com/jmfy/controller/HaoGameRechargeController.java +++ b/src/main/java/com/jmfy/controller/HaoGameRechargeController.java @@ -43,57 +43,36 @@ public class HaoGameRechargeController { @RequestMapping(value = "/haoGameCallback") public String haoGameCallback(HttpServletRequest request, @RequestBody String body) throws Exception { - - body = URLDecoder.decode(body,"UTF-8"); -// body = body.replaceAll("\"", "'"); -// body = body.replace("'extra':'", "'extra':\""); -// body = body.replace("','openid'", "\",'openid'"); body = body.replace("=", ""); - LOGGER.info("haoGameCallback body.length={} body={}", body.length(), body); - - -// try { -// BufferedReader reader = request.getReader(); -// StringBuilder sb = new StringBuilder(); -// String str; -// while ((str = reader.readLine()) != null) { -// sb.append(str); -// LOGGER.info("haoGameCallback getOuttradeno={} ",str); -// } -// String body = sb.toString(); -// if (body.isEmpty()) { -// LOGGER.info("haoGameCallback body.isEmpty="); -// } -// JsonUtil.getInstence().getGson().fromJson(buffer) HaoGameParamBean haoGameParamBean = JsonUtil.serializeToObject(body); - LOGGER.info("haoGameCallback getOuttradeno={} getOpenid={} getSign={} ={}", haoGameParamBean.getOuttradeno(), haoGameParamBean.getOpenid(), haoGameParamBean.getSign(), haoGameParamBean.getExtra()); -// } catch (Exception e) { -// e.printStackTrace(); -// } + String outtradeno = haoGameParamBean.getOuttradeno(); + String orderId = haoGameParamBean.getOpenid(); + String status = haoGameParamBean.getStatus(); + String timeend = haoGameParamBean.getTimeend(); + String amount = haoGameParamBean.getAmount(); + String openid = haoGameParamBean.getOpenid(); + String extra = haoGameParamBean.getExtra(); - - SortedMap parameterMap = new TreeMap<>(); - if (parameterMap.isEmpty()) { - LOGGER.info("data is null"); - return "failure"; - } - String outtradeno = parameterMap.get("outtradeno"); - String orderId = parameterMap.get("tradeno"); - String status = parameterMap.get("status"); if (status == null || status.isEmpty() || "fail".equals(status)) { - LOGGER.info("status is null {} ", status); + LOGGER.info("haoGameCallback status is null {} ", status); return "failure"; } - String timeend = parameterMap.get("timeend"); - String amount = parameterMap.get("amount"); - String openid = parameterMap.get("openid"); - String extra = parameterMap.get("extra"); - String sign = parameterMap.get("sign"); if (extra == null || extra.isEmpty()) { - LOGGER.info("extra is null"); + LOGGER.info("haoGameCallback extra is {}", extra); return "failure"; } + SortedMap parameterMap = new TreeMap<>(); + parameterMap.put("outtradeno", outtradeno); + parameterMap.put("tradeno", orderId); + parameterMap.put("status", status); + parameterMap.put("timeend", timeend); + parameterMap.put("amount", amount); + parameterMap.put("openid", openid); + parameterMap.put("extra", extra); + + String sign = haoGameParamBean.getSign(); + StringBuilder sbKey = new StringBuilder(); Set> entries = parameterMap.entrySet(); Iterator> iterator = entries.iterator(); @@ -113,7 +92,7 @@ public class HaoGameRechargeController { return "failure"; } JSONObject data = new JSONObject(extra); - String serverID = data.getString("districtid");// 区服id + String serverID = data.getString("serverId");// 区服id String productID = data.getString("productId"); String ccId = data.getString("ccId"); String platform = data.getString("platform"); @@ -128,6 +107,11 @@ public class HaoGameRechargeController { LOGGER.info("callback==>creditId={},uId={} orderId is exit!!!", cUserInfo.getId(), cUserInfo.getOpenId()); return response; } + String userAddress = cuserDao.findUserAddress(cUserInfo.getId()); + if (userAddress == null || userAddress.isEmpty()) { + LOGGER.info("callback==>userAddress={} openId={} uid={}", userAddress, openid, cUserInfo.getId()); + return "failure"; + } DateFormat dateTimeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String date = dateTimeformat.format(new Date()); cPayOrder = new CPayOrder(); @@ -141,11 +125,6 @@ public class HaoGameRechargeController { cPayOrder.setPlatform(platform); cPayOrder.setUserId(Integer.toString(cUserInfo.getId())); Result result = null; - String userAddress = cuserDao.findUserAddress(cUserInfo.getId()); - if (userAddress == null || userAddress.isEmpty()) { - LOGGER.info("callback==>userAddress={} openId={} uid={}", userAddress, openid, cUserInfo.getId()); - return "failure"; - } String[] split = userAddress.split(":"); String ip = split[0]; String port = split[1];