fix recharge

master
wangyuan 2019-09-04 17:12:24 +08:00
parent d2a22d0a3a
commit f88b00c04f
1 changed files with 20 additions and 3 deletions

View File

@ -18,8 +18,15 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.support.HttpRequestHandlerServlet;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -27,12 +34,22 @@ import java.util.*;
@RestController @RestController
public class RechargeController { public class RechargeController {
private static Gson gson = new Gson();
@Resource @Resource
private CUserDao cuserDao; private CUserDao cuserDao;
private static final Logger LOGGER = LoggerFactory.getLogger(RechargeController.class); private static final Logger LOGGER = LoggerFactory.getLogger(RechargeController.class);
@RequestMapping(value = "/callback") @RequestMapping(value = "/callback")
public String callback(@RequestBody RechargeRequestBean rechargeRequestBean) throws Exception { 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);
}
RechargeRequestBean rechargeRequestBean = gson.fromJson(parameterMap.keySet().iterator().next(), RechargeRequestBean.class);
RechargeRequestBean.DataBean data = rechargeRequestBean.getData(); RechargeRequestBean.DataBean data = rechargeRequestBean.getData();
if(data == null){ if(data == null){
ResultVo resultVo = new ResultVo(8, "data is null"); ResultVo resultVo = new ResultVo(8, "data is null");
@ -105,7 +122,7 @@ public class RechargeController {
resultVo = new ResultVo(11, "send reward fail !!!!"); resultVo = new ResultVo(11, "send reward fail !!!!");
} }
} }
return JsonUtil.getInstence().getGson().toJson(resultVo); return JsonUtil.getInstence().getGson().toJson(new ResultVo(11, "send reward fail !!!!"));
} }
@ -143,7 +160,7 @@ public class RechargeController {
public static void main(String[] args) throws IllegalAccessException { public static void main(String[] args) throws IllegalAccessException {
Gson gson = new Gson(); Gson gson = new Gson();
String s = "{\"state\":1,\"data\":{\"order_id\":\"20190903150413100505555232904\",\"uid\":\"df63a9b82ebc6d886590fb23caa01f1b\",\"pchannel\":\"sy37\",\"appid\":\"129213\",\"serverID\":\"10153\",\"currency\":\"RMB\",\"ext\":\"MTQwMzgzODM2OC5zeTM3XzFfMV8yMDAwMDU5OV8xMDA4MV%2FmmIbku5HkuYvlt4U%3D\",\"productID\":\"1\",\"orderTime\":1567582220,\"pchannelOrderID\":\"B8894B116191F181226A47A27F643D2B\",\"sign\":\"724b49ed94634297a1d9c4f0c0112d8d\"}}"; String s = "{\"state\":1,\"data\":{\"order_id\":\"20190903150413100505555232904\",\"uid\":\"df63a9b82ebc6d886590fb23caa01f1b\",\"pchannel\":\"sy37\",\"appid\":\"129213\",\"serverID\":\"10153\",\"currency\":\"RMB\",\"ext\":\"MTQwMzgzODM2OC5zeTM3XzFfMV8yMDAwMDU5OV8xMDA4MV%2FmmIbku5HkuYvlt4U%3D\",\"productID\":\"1\",\"orderTime\":1567582220,\"pchannelOrderID\":\"B8894B116191F181226A47A27F643D2B\",\"sign\":\"e9f799a340e166648b86eaf0ea8f825e\"}}";
RechargeRequestBean rechargeRequestBean = gson.fromJson(s, RechargeRequestBean.class); RechargeRequestBean rechargeRequestBean = gson.fromJson(s, RechargeRequestBean.class);
String mySign = getMySign(rechargeRequestBean); String mySign = getMySign(rechargeRequestBean);
System.out.println(mySign); System.out.println(mySign);