quick支付回调

master
grimm 2024-02-20 11:44:53 +08:00
parent 2ebf36b542
commit 7b97a59ae5
1 changed files with 14 additions and 24 deletions

View File

@ -19,16 +19,13 @@ import java.io.StringReader;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Deprecated
@RestController
public class QuickRechargeController {
@Resource
private PayLogic payLogic;
private static final Logger LOGGER = LoggerFactory.getLogger(QuickRechargeController.class);
private static final String callbackkey = "95443521616386247430552526885495";
private static final String md5key = "zr2i1hqfp54iijlvk8yjhopxrdq23nb3";
private static final String callbackkey = "08453209790281648730731939577328";
private static final String md5key = "9hksxqqils09chbupzx7le6edfpnyfb8";
@RequestMapping(value = "/QUICKCallback")
@RequestMapping(value = "/QuickCallback")
public String QuickGnCallback(HttpServletRequest request) throws Exception {
return process(request,callbackkey);
}
@ -41,18 +38,15 @@ public class QuickRechargeController {
}
String ntdata0 = parameterMap.get("nt_data");
String ntdata = decode(ntdata0,callbackkey);
String ntdata = decode(ntdata0,appsecret);
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("MapInfo: is_test:{},channel:{},channel_uid:{},game_order:{},order_no:{},pay_time:{}",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.isEmpty()) {
LOGGER.info("data is null");
return "FAILED";
}
String response = "SUCCESS";
String response;
try {
String consumerid = map.get("channel_uid");
String sign = parameterMap.get("sign");
@ -66,10 +60,8 @@ public class QuickRechargeController {
return "FAILED";
}
response = insertOrder(map);
} catch (Exception e) {
e.printStackTrace();
LOGGER.info("callback==>err " + e.toString());
LOGGER.info("callback==>err " + e);
response = "FAILED";
}
@ -83,7 +75,7 @@ public class QuickRechargeController {
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);
String s = PayLogic.initOrder(callbackInfo, orderNo, amountForward, new Date(System.currentTimeMillis()), callback[0], PaySdkEnum.QUICK);
if ("ORDER_IS_EXIST".equals(s)) {
return "SUCCESS";
}
@ -109,30 +101,29 @@ public class QuickRechargeController {
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);
sb.append("@").append(n);
}
return sb.toString();
}
public String decode(String src,String key) {
if(src == null || src.length() == 0){
if(src == null || src.isEmpty()){
return src;
}
Pattern pattern = Pattern.compile("@([^@]*)");
Matcher m = pattern.matcher(src);
List<Integer> list = new ArrayList();
List<Integer> list = new ArrayList<>();
while (m.find()) {
try {
String group = m.group(1);
if(group.equals(""))
if(group.isEmpty())
continue;
list.add(Integer.valueOf(group));
} catch (Exception e) {
e.printStackTrace();
return src;
}
}
if (list.size() > 0) {
if (!list.isEmpty()) {
byte[] data = new byte[list.size()];
byte[] keys = key.getBytes();
for (int i = 0; i < data.length; i++) {
@ -145,7 +136,6 @@ public class QuickRechargeController {
}
public static Map<String,String> getData(String xml){
//1.创建Reader对象
SAXReader reader = new SAXReader();