generated from root/miduo_server
8u 我要当大圣渠道
parent
c989254af6
commit
24de8de9af
|
@ -0,0 +1,69 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.jmfy.paramBean.PaySdkEnum;
|
||||
import com.jmfy.util.JsonUtil;
|
||||
import com.jmfy.util.MD5Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 我要当大圣 8u sdk
|
||||
*/
|
||||
@RestController
|
||||
public class EigthURechargeController {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EigthURechargeController.class);
|
||||
private static final String APPKEY = "mzb3bdSsXQKSXRXJTcfwa";
|
||||
|
||||
@RequestMapping(value = "/eightuCallback")
|
||||
public String eightuCallback(HttpServletRequest request) throws Exception {
|
||||
return process(request, APPKEY);
|
||||
}
|
||||
|
||||
public static String process(HttpServletRequest request, String appkey) throws Exception{
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap2(request);
|
||||
if (parameterMap.isEmpty()) {
|
||||
LOGGER.info("8u data is null");
|
||||
return "fail";
|
||||
}
|
||||
if(!checkSign(parameterMap,appkey)){
|
||||
LOGGER.info("8u callback ==> ,sin verify fail");
|
||||
return "fail";
|
||||
}
|
||||
return insertOrder(parameterMap);
|
||||
}
|
||||
|
||||
public static String insertOrder(Map<String,String> map) {
|
||||
String callbackInfo = map.get("ext");
|
||||
String[] callback = callbackInfo.split("_");
|
||||
String orderNo = map.get("orderid");
|
||||
String amount = map.get("money");
|
||||
//quick的是元 要处理一下
|
||||
String amountForward = String.valueOf((int)(Double.parseDouble(amount) * 100));
|
||||
String result = PayLogic.initOrder(callbackInfo, orderNo, amountForward, new Date(System.currentTimeMillis()), callback[0], PaySdkEnum.QUICK);
|
||||
if ("SUCCESS".equals(result) || "ORDER_IS_EXIST".equals(result)) {
|
||||
return "SUCCESS";
|
||||
}else {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkSign(HashMap<String, String> parameterMap,String appKey){
|
||||
String buffer = "uid=" + parameterMap.get("uid") + "&" +
|
||||
"appid=" + parameterMap.get("appid") + "&" +
|
||||
"money=" + parameterMap.get("money") + "&" +
|
||||
"orderid=" + parameterMap.get("orderid") + "&" +
|
||||
"ext=" + parameterMap.get("ext") + "&" +
|
||||
"time=" + parameterMap.get("time") + "&" +
|
||||
"appkey=" + appKey;
|
||||
String md5 = MD5Util.encrypByMd5(buffer);
|
||||
String sign = parameterMap.get("sign");
|
||||
return md5.equals(sign);
|
||||
}
|
||||
}
|
|
@ -1,177 +1,16 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.jmfy.paramBean.PaySdkEnum;
|
||||
import com.jmfy.util.JsonUtil;
|
||||
import com.jmfy.util.MD5Util;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@Deprecated
|
||||
@RestController
|
||||
public class QuickRechargeController2 {
|
||||
@Resource
|
||||
private PayLogic payLogic;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(QuickRechargeController2.class);
|
||||
private static final String callbackkey = "69382864976094208404596003308975";
|
||||
private static final String md5key = "q6k5xzvtkcwhgbiudluckacqzwutqgpg";
|
||||
|
||||
@RequestMapping(value = "/QUICKCallback2")
|
||||
public String QuickGnCallback(HttpServletRequest request) throws Exception {
|
||||
return process(request,callbackkey);
|
||||
}
|
||||
|
||||
private String process(HttpServletRequest request,String appsecret) throws Exception{
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap2(request);
|
||||
if (parameterMap.isEmpty()) {
|
||||
LOGGER.info("data is null");
|
||||
return "FAILED";
|
||||
}
|
||||
String ntdata0 = parameterMap.get("nt_data");
|
||||
|
||||
String ntdata = decode(ntdata0,callbackkey);
|
||||
Map<String,String> map = getData(ntdata);
|
||||
LOGGER.info("MapInfo: is_test:{},channel:{},channel_uid:{},game_order:{},order_no:{},pay_time:{}," +
|
||||
"amount:{},atatus:{}",map.get("is_test"),map.get("channel"),map.get("channel_uid"),
|
||||
map.get("game_order"),map.get("order_no"),map.get("pay_time"));
|
||||
if (map.size() == 0) {
|
||||
LOGGER.info("data is null");
|
||||
return "FAILED";
|
||||
}
|
||||
|
||||
|
||||
String response = "SUCCESS";
|
||||
try {
|
||||
String consumerid = map.get("channel_uid");
|
||||
String sign = parameterMap.get("sign");
|
||||
String md5Sign = parameterMap.get("md5Sign");
|
||||
if(!sign(ntdata0,sign,md5Sign)){
|
||||
LOGGER.info("callback==>roleUid={},sin derify fail ", consumerid);
|
||||
return "FAILED";
|
||||
}
|
||||
if(map.get("status").equals("1")){
|
||||
LOGGER.info("callback==>status:FAILED ");
|
||||
return "FAILED";
|
||||
}
|
||||
response = insertOrder(map);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.info("callback==>err " + e.toString());
|
||||
response = "FAILED";
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private String insertOrder(Map<String,String> map) {
|
||||
String callbackInfo = map.get("extras_params");
|
||||
String[] callback = callbackInfo.split("_");
|
||||
String orderNo = map.get("order_no");
|
||||
String amount = map.get("amount");
|
||||
//quick的是元 要处理一下
|
||||
String amountForward = String.valueOf((int)Double.parseDouble(amount) * 100);
|
||||
String s = payLogic.initOrder(callbackInfo, orderNo, amountForward, new Date(System.currentTimeMillis()), callback[0], PaySdkEnum.QUICK);
|
||||
if ("ORDER_IS_EXIST".equals(s)) {
|
||||
return "SUCCESS";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean sign(String ntdata0,String sign0,String md5Sign){
|
||||
String paramStr = ntdata0+sign0+md5key;
|
||||
String sign = MD5Util.encrypByMd5(paramStr);
|
||||
// LOGGER.info("加密前字符串:{}",paramStr);
|
||||
LOGGER.info("加密后得:{}",sign);
|
||||
if(sign.equals(md5Sign)){
|
||||
return true;
|
||||
}else{
|
||||
LOGGER.info("sign:{} md5Sign:{}",sign,md5Sign);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String encode(String src,String key) {
|
||||
byte[] data = src.getBytes();
|
||||
byte[] keys = key.getBytes();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int n = (0xff & data[i]) + (0xff & keys[i % keys.length]);
|
||||
sb.append("@" + n);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String decode(String src,String key) {
|
||||
if(src == null || src.length() == 0){
|
||||
return src;
|
||||
}
|
||||
Pattern pattern = Pattern.compile("@([^@]*)");
|
||||
Matcher m = pattern.matcher(src);
|
||||
List<Integer> list = new ArrayList();
|
||||
while (m.find()) {
|
||||
try {
|
||||
String group = m.group(1);
|
||||
if(group.equals(""))
|
||||
continue;
|
||||
list.add(Integer.valueOf(group));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return src;
|
||||
}
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
byte[] data = new byte[list.size()];
|
||||
byte[] keys = key.getBytes();
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = (byte) (list.get(i) - (0xff & keys[i % keys.length]));
|
||||
}
|
||||
return new String(data);
|
||||
} else {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Map<String,String> getData(String xml){
|
||||
//1.创建Reader对象
|
||||
SAXReader reader = new SAXReader();
|
||||
StringReader sr = new StringReader(xml);
|
||||
InputSource is = new InputSource(sr);
|
||||
Map<String,String> map = new HashMap<>();
|
||||
//2.加载xml
|
||||
try {
|
||||
Document document = reader.read(is);
|
||||
//3.获取根节点
|
||||
Element rootElement = document.getRootElement();
|
||||
Iterator iterator = rootElement.elementIterator();
|
||||
while (iterator.hasNext()){
|
||||
Element stu = (Element) iterator.next();
|
||||
LOGGER.info("======遍历子节点======");
|
||||
Iterator iterator1 = stu.elementIterator();
|
||||
while (iterator1.hasNext()){
|
||||
Element stuChild = (Element) iterator1.next();
|
||||
map.put(stuChild.getName(),stuChild.getStringValue());
|
||||
LOGGER.info("节点名:"+stuChild.getName()+"---节点值:"+stuChild.getStringValue());
|
||||
}
|
||||
}
|
||||
}catch (DocumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
return QuickRechargeController.process(request,callbackkey,md5key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.regex.Pattern;
|
|||
* 疯体使用quick sdk
|
||||
*/
|
||||
@RestController
|
||||
@Deprecated
|
||||
public class QuickRechargeController3 {
|
||||
private static final String callbackkey = "53780900079388195716762718742907";
|
||||
private static final String md5key = "giahggkise4k7hef3qir4adbrmcejdrz";
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 我要当大圣 sdk
|
||||
*/
|
||||
@RestController
|
||||
public class WYDDSRechargeController {
|
||||
private static final String callbackkey = "mzb3bdSsXQKSXRXJTcfwa";
|
||||
private static final String md5key = "mzb3bdSsXQKSXRXJTcfwa";
|
||||
|
||||
@RequestMapping(value = "/wyydsCallback")
|
||||
public String wyydsCallback(HttpServletRequest request) throws Exception {
|
||||
return QuickRechargeController.process(request,callbackkey,md5key);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue