增加太初行专服6渠道

master
DESKTOP-C3M45P4\dengdan 2024-11-07 23:12:47 +08:00
parent a072c73ebb
commit 5376197618
2 changed files with 149 additions and 1 deletions

View File

@ -79,6 +79,7 @@ public class GetUserController extends HttpServlet {
serviceMap.put("TCX027", new Tcx027VerifyService("TCX027"));
serviceMap.put("TCX02702", new Tcx02702VerifyService("TCX02702"));
serviceMap.put("TCX02703", new Tcx02703VerifyService("TCX02703"));
serviceMap.put("TCX02706", new Tcx02706VerifyService("TCX02706"));
//太初行quick直播渠道
serviceMap.put("TCXQUZB", new QuickTcxZbVerifyService("TCXQUZB"));
//太初行quick直播2渠道
@ -116,7 +117,8 @@ public class GetUserController extends HttpServlet {
DBObject res = new BasicDBObject();
String channel = request.getParameter("channel");
if(channel!= null){
if("TCX027".equals(channel) || "TCX02702".equals(channel) || "TCX02703".equals(channel)) {
if("TCX027".equals(channel) || "TCX02702".equals(channel) || "TCX02703".equals(channel)
||"TCX02706".equals(channel)) {
this.do027Get(request, response);
return;
}

View File

@ -0,0 +1,146 @@
package com.ljsd.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ljsd.pojo.VerifyParams;
import com.ljsd.util.AppConstans;
import com.ljsd.util.HttpUtils;
import com.ljsd.util.MD5Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Tcx02706VerifyService extends Tcx027VerifyService {
private static final Logger LOGGER = LoggerFactory.getLogger(Tcx02703VerifyService.class);
public static int isTestLan=0;
public final static String serverKey = "4944b72022f486189cc6e5afecc7775a";
public final static String appId = "7ea1f76894b5305cc3e476c8543e0e41";
public Tcx02706VerifyService(String sign) {
super(sign);
}
@Override
boolean doVerify(VerifyParams params) {
String url = "http://sdk.user.i.027gm.com/game/verify/login";
LOGGER.info("027登录验证-->{}",params.getOpenId());
Map<String,String> parms = new HashMap<>();
String token = params.getToken();
String appId = params.getAppId();
parms.put("token",token);
parms.put("appId",appId);
String sign = MD5Util.encrypByMd5(appId + serverKey + token);
parms.put("sign",sign);
boolean result = false;
try {
String r = HttpUtils.doPost(url, parms);
LOGGER.info("027登录结果:{}",r);
JSONObject jsonObject = JSON.parseObject(r);
int status = jsonObject.getIntValue("status");
if(status == 1 ){
result = true;
}else{
if(status == 1001){
LOGGER.info("sign error status : ",status);
}
result = false;
}
}catch (IOException e){
LOGGER.info("027验证失败,{}",e.getMessage());
return false;
}
return result;
}
@Override
public String verifyGetOpenId(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId,String token){
try {
//如果是自己人不需要验证了
if(AppConstans.appsecret.equals(admin)) {
return null;
}
if (isTestLan == 1) { //test
boolean result = loginVerfifyByTestLan(openId, token);
if (!result) {
response.sendError(400, "verify fail");
LOGGER.error("test verify fail");
return null;
}
return openId;
}
if (!"3".equals(platform) ) {//正式 切不是pc
String sub_channel = request.getParameter("sub_channel");
boolean result = false;
if (sub_channel != null && !sub_channel.equals("")) {
if (sub_channel.equals("1000")) {
//测试服构建参数
VerifyParams params = new VerifyParams();
VerifyParams testParam = getTestParam(params,request, openId, token);
result = verifyTest(testParam);
if(result){
return openId;
}
}else {
//正式服appId
LOGGER.error("------------- 027 verify openId :" + openId);
VerifyParams params = new VerifyParams();
VerifyParams formatParam = getFormatParam(params,request, openId, token);
formatParam.setAppId(appId);
return doVerifyGetOpenId(formatParam);
}
}
if (!result) {
response.sendError(400, "verify fail");
LOGGER.error("verify fail");
return null;
}
}
}catch (Exception e){
e.printStackTrace();
}
return null;
}
String doVerifyGetOpenId(VerifyParams params) {
String url = "http://sdk.user.i.027gm.com/game/verify/login";
LOGGER.info("027登录验证-->{}",params.getOpenId());
Map<String,String> parms = new HashMap<>();
String token = params.getToken();
String appId = params.getAppId();
parms.put("token",token);
parms.put("appId",appId);
String sign = MD5Util.encrypByMd5(appId + serverKey + token);
parms.put("sign",sign);
try {
String r = HttpUtils.doPost(url, parms);
LOGGER.info("027登录结果:{}",r);
JSONObject jsonObject = JSON.parseObject(r);
int status = jsonObject.getIntValue("status");
if(status == 1 ){
String userId = jsonObject.getString("userId");
if (userId == null || userId.isEmpty()) {
return null;
}
//验证成功返回openId
LOGGER.info("027 openId : ",userId);
return userId;
}
else{
if(status == 1001){
LOGGER.info("sign error status : ",status);
}
}
}catch (IOException e){
LOGGER.info("027验证失败,{}",e.getMessage());
return null;
}
return null;
}
}