generated from root/miduo_server
master
parent
041636e563
commit
73fad773b3
|
@ -3,6 +3,7 @@ package com.jmfy.controller;
|
|||
import com.jmfy.dto.CPayOrder;
|
||||
import com.jmfy.dto.CUserDao;
|
||||
import com.jmfy.dto.CUserInfo;
|
||||
import com.jmfy.paramBean.HaoGameParamBean;
|
||||
import com.jmfy.thrift.idl.RPCRequestIFace;
|
||||
import com.jmfy.thrift.idl.Result;
|
||||
import com.jmfy.thrift.pool.ClientAdapterPo;
|
||||
|
@ -12,12 +13,12 @@ import com.jmfy.util.MD5Util;
|
|||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
@ -35,85 +36,30 @@ public class HaoGameRechargeController {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HaoGameRechargeController.class);
|
||||
|
||||
class HaoGameParam {
|
||||
private String outtradeno;
|
||||
private String tradeno;
|
||||
private String status;
|
||||
private String timeend;
|
||||
private String amount;
|
||||
private String openid;
|
||||
private String extra;
|
||||
private String sign;
|
||||
|
||||
public String getOuttradeno() {
|
||||
return outtradeno;
|
||||
}
|
||||
|
||||
public void setOuttradeno(String outtradeno) {
|
||||
this.outtradeno = outtradeno;
|
||||
}
|
||||
|
||||
public String getTradeno() {
|
||||
return tradeno;
|
||||
}
|
||||
|
||||
public void setTradeno(String tradeno) {
|
||||
this.tradeno = tradeno;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTimeend() {
|
||||
return timeend;
|
||||
}
|
||||
|
||||
public void setTimeend(String timeend) {
|
||||
this.timeend = timeend;
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(String amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/haoGameCallback")
|
||||
public String haoGameCallback(HttpServletRequest request) throws Exception {
|
||||
LOGGER.info("haoGameCallback 收到好游戏支付回调");
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMapYX(request);
|
||||
|
||||
try {
|
||||
BufferedReader reader = request.getReader();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String str;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
sb.append(str);
|
||||
}
|
||||
String body = sb.toString();
|
||||
|
||||
LOGGER.info("haoGameCallback getOuttradeno={} ",body);
|
||||
HaoGameParamBean haoGameParamBean = JsonUtil.serializeToObject(body);
|
||||
LOGGER.info("haoGameCallback getOuttradeno={} getOpenid={} getSign={}",haoGameParamBean.getOuttradeno(), haoGameParamBean.getOpenid(), haoGameParamBean.getSign());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SortedMap<String, String> parameterMap = new TreeMap<>();
|
||||
if (parameterMap.isEmpty()) {
|
||||
LOGGER.info("data is null");
|
||||
return "failure";
|
||||
|
@ -134,20 +80,11 @@ public class HaoGameRechargeController {
|
|||
LOGGER.info("extra is null");
|
||||
return "failure";
|
||||
}
|
||||
SortedMap<String, Object> parameters = new TreeMap<>();
|
||||
parameters.put("outtradeno", outtradeno);
|
||||
parameters.put("tradeno", orderId);
|
||||
parameters.put("status", status);
|
||||
parameters.put("timeend", timeend);
|
||||
parameters.put("amount", amount);
|
||||
parameters.put("openid", openid);
|
||||
parameters.put("extra", extra);
|
||||
|
||||
StringBuilder sbKey = new StringBuilder();
|
||||
Set<Map.Entry<String, Object>> entries = parameters.entrySet();
|
||||
Iterator<Map.Entry<String, Object>> iterator = entries.iterator();
|
||||
Set<Map.Entry<String, String>> entries = parameterMap.entrySet();
|
||||
Iterator<Map.Entry<String, String>> iterator = entries.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Object> next = iterator.next();
|
||||
Map.Entry<String, String> next = iterator.next();
|
||||
String key = next.getKey();
|
||||
Object value = next.getValue();
|
||||
if (value == null || "".equals(value)) {
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
package com.jmfy.paramBean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class HaoGameParamBean implements Serializable {
|
||||
|
||||
private String outtradeno;
|
||||
private String tradeno;
|
||||
private String status;
|
||||
private String timeend;
|
||||
private String amount;
|
||||
private String openid;
|
||||
private String extra;
|
||||
private String sign;
|
||||
|
||||
public String getOuttradeno() {
|
||||
return outtradeno;
|
||||
}
|
||||
|
||||
public void setOuttradeno(String outtradeno) {
|
||||
this.outtradeno = outtradeno;
|
||||
}
|
||||
|
||||
public String getTradeno() {
|
||||
return tradeno;
|
||||
}
|
||||
|
||||
public void setTradeno(String tradeno) {
|
||||
this.tradeno = tradeno;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTimeend() {
|
||||
return timeend;
|
||||
}
|
||||
|
||||
public void setTimeend(String timeend) {
|
||||
this.timeend = timeend;
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(String amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
}
|
||||
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +1,14 @@
|
|||
package com.jmfy.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jmfy.controller.RechargeController;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import org.json.JSONObject;
|
||||
import com.jmfy.paramBean.HaoGameParamBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
@ -69,11 +66,30 @@ public class JsonUtil {
|
|||
return map;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getParameterMapYX(HttpServletRequest request) {
|
||||
HashMap<String, String> map = new HashMap();
|
||||
|
||||
public static HaoGameParamBean serializeToObject(String str) throws IOException, ClassNotFoundException {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(str.getBytes("ISO-8859-1"));
|
||||
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
|
||||
HaoGameParamBean object = (HaoGameParamBean) objectInputStream.readObject();
|
||||
objectInputStream.close();
|
||||
byteArrayInputStream.close();
|
||||
return object;
|
||||
}
|
||||
|
||||
public SortedMap<String, String> getParameterMapYX(HttpServletRequest request) {
|
||||
SortedMap<String, String> map = new TreeMap<>();
|
||||
try {
|
||||
byte[] requestPostBytes = getRequestPostBytes(request);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Enumeration paramNames = request.getParameterNames();
|
||||
while (paramNames.hasMoreElements()) {
|
||||
String string = (String) paramNames.nextElement();
|
||||
|
||||
|
||||
|
||||
|
||||
LOGGER.info("getParameterMapYX param {}", string);
|
||||
string = string.replace("{", "");
|
||||
string = string.replace("}", "");
|
||||
|
|
Loading…
Reference in New Issue