|
@@ -45,26 +45,27 @@ public class MixSDK {
|
|
|
private static final CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
private static final CloseableHttpClient httpClient = HttpClients.createDefault();
|
|
|
private final static String _COLLECTION_PAY = "pay";
|
|
private final static String _COLLECTION_PAY = "pay";
|
|
|
private static final Gson GSON = new Gson();
|
|
private static final Gson GSON = new Gson();
|
|
|
- public static boolean verifyUser(String uid, int appId,String channel,String loginCallBackToken,int ts) {
|
|
|
|
|
|
|
+ public static boolean verifyUser(String uid, int appId,String channel,String loginCallBackToken,int ts,String ch) {
|
|
|
try {
|
|
try {
|
|
|
LOGGER.info("MixSDK 验证参数,appid:{} token:{}, uid:{} channel:{} ts:{}",appId,loginCallBackToken,uid,channel,ts);
|
|
LOGGER.info("MixSDK 验证参数,appid:{} token:{}, uid:{} channel:{} ts:{}",appId,loginCallBackToken,uid,channel,ts);
|
|
|
- Properties properties = BaseGlobal.getInstance().properties;
|
|
|
|
|
- String check = appId+channel+loginCallBackToken+ts+uid+properties.getProperty("Mix_sdk_md5");
|
|
|
|
|
|
|
+ //Properties properties = BaseGlobal.getInstance().properties;
|
|
|
|
|
+ String check = appId+ch+loginCallBackToken+ts+uid+"9b635fc1698b8f68dcc31281a67a2a66vfuyP";
|
|
|
LOGGER.info("登录验证加密前的数据:{}", check);
|
|
LOGGER.info("登录验证加密前的数据:{}", check);
|
|
|
String sign1 = md5(check);
|
|
String sign1 = md5(check);
|
|
|
- String sign2 = md5(sign1.substring(6));
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // LOGGER.info("登录验证加密前的数据1:{},s:{}", sign1,substringFromPosition(sign1,7,22));
|
|
|
|
|
+ String sign2 = md5(substringFromPosition(sign1,7,22));
|
|
|
|
|
+ LOGGER.info("登录验证加密前的数据2:{}", sign2);
|
|
|
// 域名+/tools/gamefactor.ashx?action=factor_login
|
|
// 域名+/tools/gamefactor.ashx?action=factor_login
|
|
|
List<NameValuePair> formParams = new ArrayList<>();
|
|
List<NameValuePair> formParams = new ArrayList<>();
|
|
|
formParams.add(new BasicNameValuePair("appId", String.valueOf(appId))); // app_id 参数
|
|
formParams.add(new BasicNameValuePair("appId", String.valueOf(appId))); // app_id 参数
|
|
|
formParams.add(new BasicNameValuePair("uid", uid)); // app_id 参数
|
|
formParams.add(new BasicNameValuePair("uid", uid)); // app_id 参数
|
|
|
- formParams.add(new BasicNameValuePair("channelCode", channel)); // app_id 参数
|
|
|
|
|
|
|
+ formParams.add(new BasicNameValuePair("channelCode", ch)); // app_id 参数
|
|
|
formParams.add(new BasicNameValuePair("loginCallBackToken", loginCallBackToken)); // uid 参数
|
|
formParams.add(new BasicNameValuePair("loginCallBackToken", loginCallBackToken)); // uid 参数
|
|
|
formParams.add(new BasicNameValuePair("ts", String.valueOf(ts)));
|
|
formParams.add(new BasicNameValuePair("ts", String.valueOf(ts)));
|
|
|
formParams.add(new BasicNameValuePair("sign", sign2));
|
|
formParams.add(new BasicNameValuePair("sign", sign2));
|
|
|
//HttpPost httpPost = new HttpPost(VERIFY_API_URL);
|
|
//HttpPost httpPost = new HttpPost(VERIFY_API_URL);
|
|
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(formParams, StandardCharsets.UTF_8);
|
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(formParams, StandardCharsets.UTF_8);
|
|
|
- HttpPost httpPost = new HttpPost(properties.getProperty("Mix_sdk_verify_api_url"));
|
|
|
|
|
|
|
+ HttpPost httpPost = new HttpPost("https://xyx-sdkm.chuanqu.com/MixSdkSimpleApi/loginCallBack");
|
|
|
httpPost.setEntity(formEntity);
|
|
httpPost.setEntity(formEntity);
|
|
|
// uriBuilder.addParameter("channel_code", ""); // 必须传渠道 ID
|
|
// uriBuilder.addParameter("channel_code", ""); // 必须传渠道 ID
|
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
CloseableHttpResponse response = httpClient.execute(httpPost);
|
|
@@ -113,16 +114,37 @@ public class MixSDK {
|
|
|
uriBuilder.addParameter("token", token);
|
|
uriBuilder.addParameter("token", token);
|
|
|
return uriBuilder;
|
|
return uriBuilder;
|
|
|
}
|
|
}
|
|
|
|
|
+ public static String substringFromPosition(String str, int startPosition, int length) {
|
|
|
|
|
+ if (str == null) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- public static boolean verifyCallback(String orderId, String price,int status,String sign, String extend) {
|
|
|
|
|
- if (orderId == null || sign == null) {
|
|
|
|
|
- LOGGER.error("参数不可为空,nt_data={}, sign={}", orderId, sign);
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ // 将人类习惯的位置(从1开始)转换为Java索引(从0开始)
|
|
|
|
|
+ int startIndex = startPosition - 1;
|
|
|
|
|
+
|
|
|
|
|
+ if (startIndex < 0) {
|
|
|
|
|
+ startIndex = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果开始位置超过字符串长度,返回空字符串
|
|
|
|
|
+ if (startIndex >= str.length()) {
|
|
|
|
|
+ return "";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 计算结束位置
|
|
|
|
|
+ int endIndex = startIndex + length;
|
|
|
|
|
+
|
|
|
|
|
+ // 如果结束位置超过字符串长度,只截取到末尾
|
|
|
|
|
+ endIndex = Math.min(endIndex, str.length());
|
|
|
|
|
+
|
|
|
|
|
+ return str.substring(startIndex, endIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static boolean verifyCallback(String uid,String orderId, String cpOrderId,int ts,String appId,String payMoney,String payRealMoney,String sign, String extrasParams) {
|
|
|
Properties properties = BaseGlobal.getInstance().properties;
|
|
Properties properties = BaseGlobal.getInstance().properties;
|
|
|
- String md5Key = properties.getProperty("Mix_sdk_md5key_");
|
|
|
|
|
- String rawString = orderId+price+status+extend+ md5Key;
|
|
|
|
|
- LOGGER.info("rawString = {}", rawString);
|
|
|
|
|
|
|
+ //String md5Key = properties.getProperty("Mix_sdk_md5key_");
|
|
|
|
|
+ String rawString = appId+cpOrderId+orderId+payMoney+payRealMoney+ts+uid+extrasParams+"9b635fc1698b8f68dcc31281a67a2a66vfuyP";
|
|
|
|
|
+ LOGGER.info("mixRawString = {}", rawString);
|
|
|
try {
|
|
try {
|
|
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
|
|
|
|
@@ -177,7 +199,7 @@ public class MixSDK {
|
|
|
// payInfo.put("uid", fields.get("channel_uid"));
|
|
// payInfo.put("uid", fields.get("channel_uid"));
|
|
|
// payInfo.put("openId", uid);
|
|
// payInfo.put("openId", uid);
|
|
|
// dbObject.put("region", serverId);
|
|
// dbObject.put("region", serverId);
|
|
|
- payInfo.put("channel", "wanba");
|
|
|
|
|
|
|
+ payInfo.put("channel", "mix");
|
|
|
// payInfo.put("gameorderId", fields.get("game_order"));
|
|
// payInfo.put("gameorderId", fields.get("game_order"));
|
|
|
// dbObject.put("cporderId", platform);
|
|
// dbObject.put("cporderId", platform);
|
|
|
// payInfo.put("creattime", fields.get("pay_time"));
|
|
// payInfo.put("creattime", fields.get("pay_time"));
|