ios
来源:互联网 发布:黎明杀机游戏数据没了 编辑:程序博客网 时间:2024/05/09 22:39
package com.terrace.action.login;import java.util.Date;import java.util.Enumeration;import java.util.HashMap;import java.util.List;import java.util.Map;import javax.annotation.Resource;import org.apache.struts2.convention.annotation.InterceptorRef;import org.apache.struts2.convention.annotation.InterceptorRefs;import org.apache.struts2.convention.annotation.ParentPackage;import org.springframework.util.StringUtils;import com.opensymphony.oscache.util.StringUtil;import com.terrace.entity.login.Account;import com.terrace.entity.login.AccountBinding;import com.terrace.entity.login.AccountMobile;import com.terrace.entity.login.ActivateCodeGaint;import com.terrace.entity.login.Commonality;import com.terrace.entity.login.Game;import com.terrace.entity.login.GameDocking;import com.terrace.service.AccountBindingService;import com.terrace.service.AccountMobileService;import com.terrace.service.AccountService;import com.terrace.service.ActivateCodeGaintService;import com.terrace.service.CommonalityService;import com.terrace.service.GameDockingService;import com.terrace.service.GameService;import com.terrace.service.SysHttpService;import com.terrace.util.CommonUtil;import com.terrace.util.DesUtil;import com.terrace.util.GameUtil;import com.terrace.util.JsonUtil;import com.terrace.util.SysCommonUtil;import com.terrace.vo.AccountMobileVo;import com.terrace.vo.ActivateCodeGaintVo;import com.terrace.vo.GameVo;@ParentPackage("login")@InterceptorRefs({ @InterceptorRef(value = "ipCountInterceptor"), @InterceptorRef(value = "loginStack") })public class IosAction extends BaseTerraceAction {private static final long serialVersionUID = 1L;private static final String mobileKey = "leiting";private String serial; // 手机IMEI码private String phoneNum; // 手机号码private String phoneModel; // 手机型号// 20150331 更改为游戏标识yyxy,由Integer 更改为Stringprivate String game; // 所属的手机游戏private String sid; // 用户唯一标示码private String username; // 用户名private String userpwd; // 用户密码private String key; // 通行验证private String cookie; // cookie 时效性验证private String regMethod; // 注册方式private String phoneActiveKey;// 手机验证码private String activateCode;// 激活码private String channelNo;// 渠道编号@Resource(name = "accountServiceImpl")private AccountService accountService;@Resource(name = "accountMobileServiceImpl")private AccountMobileService accountMobileService;@Resource(name = "sysHttpServiceImpl")private SysHttpService sysHttpService;@Resource(name = "commonalityServiceImpl")private CommonalityService commonalityService;@Resource(name = "accountBindingServiceImpl")private AccountBindingService accountBindingService;@Resource(name = "gameDockingServiceImpl")private GameDockingService gameDockingService;@Resource(name = "gameServiceImpl")private GameService gameService;@Resource(name = "activateCodeGaintServiceImpl")private ActivateCodeGaintService activateCodeGaintService;// ios需要激活码普通注册public String activateRegister() {// 1、账号是否存在// 2、激活码是否有效// 3、创建雷霆账号// 4、激活手游账号// 5、激活激活码// log日志记录saveLog(getRequest().getRequestURL().toString(), getHttpParams().toString(), 1);Map<String, Object> rMap = new HashMap<String, Object>();try {if (StringUtil.isEmpty(username)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(userpwd)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// if (StringUtil.isEmpty(serial)) {// rMap.put(STATUS_PARAMETER_NAME, "3");// // log日志记录// saveLog(rMap.toString(),"ios激活码注册-"+username,2);// return ajaxJsonp(rMap);// }if (StringUtil.isEmpty(game)) {rMap.put(STATUS_PARAMETER_NAME, "2");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(key)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(activateCode)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// 先验证账号格式是否正确if (!username.matches("^[a-zA-Z0-9_@.]+$") || username.length() > 32) {rMap.put(STATUS_PARAMETER_NAME, "5");rMap.put(MESSAGE_PARAMETER_NAME, "账号名必须由字母、数字、点号、@符号或下划线组成,长度小于32位!");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}String msg = username + "|" + userpwd + "|" + serial + "|" + game;Map<String, String> mapVerify = GameUtil.threeDaysVerify(msg, mobileKey, key);if (!"success".equals(mapVerify.get(STATUS_PARAMETER_NAME))) {rMap.put(STATUS_PARAMETER_NAME, "8");rMap.put(MESSAGE_PARAMETER_NAME, "key验证失败,请返回重试!");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}GameVo gameVo = new GameVo();gameVo.setGameSign(game);gameVo.setUseSort(false);gameVo.setPager(false);List<Game> nowGames = gameService.searchList(gameVo);if (nowGames == null || nowGames.size() == 0) {// 该游戏不存在rMap.put(STATUS_PARAMETER_NAME, "10");rMap.put(MESSAGE_PARAMETER_NAME, "该游戏不存在!");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajax(rMap);}try {// DES 解密 userpwdDesUtil des = new DesUtil(mobileKey);userpwd = des.decrypt(userpwd);} catch (Exception e1) {logger.error("DES解密失败!", e1);rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// 1、账号是否存在Account aObj = accountService.getAccountByUsername(username);if (aObj != null) {rMap.put(STATUS_PARAMETER_NAME, "6");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// 2、激活码是否有效String c = GameUtil.encryptMobileCookie(username, mobileKey);StringBuffer sb = new StringBuffer();sb.append("key=" + activateCode);sb.append("&sid=" + username);sb.append("&cookie=" + c);sb.append("&game=" + game);String result = sysHttpService.sendPost(SysCommonUtil.LEITING_ACTIVATE_CODE_USABLE, sb.toString());Map<String, Object> map = JsonUtil.toObject(result, Map.class);if (!"1".equals(String.valueOf(map.get(STATUS_PARAMETER_NAME)))) {// 激活码不可用rMap.put(STATUS_PARAMETER_NAME, "7");rMap.put(MESSAGE_PARAMETER_NAME, map.get(MESSAGE_PARAMETER_NAME));// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// 3、创建雷霆账号String ip = getRemoteIpStr();Account commonAccount = new Account();commonAccount.setUsername(username.toLowerCase());commonAccount.setUserpwd(userpwd.toString());commonAccount.setUserpwd(GameUtil.encryptAccountPwd(commonAccount.getUsername(), commonAccount.getUserpwd()));commonAccount.setIp(ip);commonAccount.setType(SysCommonUtil.ACCOUNT_TYPE_STANDARD);commonAccount.setPriority(SysCommonUtil.ACCOUNT_PRIORITY_COMMON);commonAccount.setIsFinish(1);commonAccount.setAdult("0");commonAccount.setStatus(SysCommonUtil.SYS_STATUS_ON);commonAccount.setLockTime("0");commonAccount.setRegMethod(SysCommonUtil.REGISTER_COMMON_VALUE);commonAccount.setComefrom(game); // 注册来源// 新增账号accountService.save(commonAccount);accountService.flush();// 4、激活手游账号AccountMobile fastMobile = new AccountMobile();fastMobile.setGame(game);if (com.terrace.util.StringUtil.isNullOrEmpty(serial)) {fastMobile.setSerial(GameUtil.desEncrypt(serial));}fastMobile.setIsFast(2);fastMobile.setUsername(commonAccount.getUsername());fastMobile.setSid(CommonUtil.getEightRandomByUUID());fastMobile.setOs(2); // IOSaccountMobileService.save(fastMobile);accountMobileService.flush();// 5、激活激活码c = GameUtil.encryptMobileCookie(fastMobile.getSid(), mobileKey);sb = new StringBuffer();sb.append("key=" + activateCode);sb.append("&username=" + username);sb.append("&sid=" + fastMobile.getSid());sb.append("&cookie=" + c);sb.append("&game=" + game);result = sysHttpService.sendPost(SysCommonUtil.LEITING_ACTIVATE_GAME, sb.toString());map = JsonUtil.toObject(result, Map.class);if (!"1".equals(String.valueOf(map.get(STATUS_PARAMETER_NAME)))) {// 激活失败rMap.put(STATUS_PARAMETER_NAME, "7");rMap.put(MESSAGE_PARAMETER_NAME, map.get(MESSAGE_PARAMETER_NAME));// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// 成功rMap.put("sid", fastMobile.getSid());rMap.put("bind", "2"); // 未绑定标志rMap.put("activate", "1"); // 激活标志rMap.put("channelNo", SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("game", game);rMap.put(STATUS_PARAMETER_NAME, "1");String cookie = GameUtil.ltLoginSign(fastMobile.getSid(), game, SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("cookie", cookie);// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);} catch (Exception e) {logger.error("普通注册异常!", e);}rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios激活码注册-" + username, 2);return ajaxJsonp(rMap);}// ios需要激活码普通注册// -------------密码明文传输public String activateRegisterShow() {// 1、账号是否存在// 2、激活码是否有效// 3、创建雷霆账号// 4、激活手游账号// 5、激活激活码// log日志记录saveLog(getRequest().getRequestURL().toString(), getHttpParams().toString(), 2);Map<String, Object> rMap = new HashMap<String, Object>();try {if (StringUtil.isEmpty(username)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(userpwd)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// if (StringUtil.isEmpty(serial)) {// rMap.put(STATUS_PARAMETER_NAME, "3");// // log日志记录// saveLog(rMap.toString(),"ios激活码注册(明文)-"+username,2);// return ajaxJsonp(rMap);// }if (StringUtil.isEmpty(game)) {rMap.put(STATUS_PARAMETER_NAME, "2");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(key)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(activateCode)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}String msg = username + "|" + userpwd + "|" + serial + "|" + game;Map<String, String> mapVerify = GameUtil.threeDaysVerify(msg, mobileKey, key);if (!"success".equals(mapVerify.get(STATUS_PARAMETER_NAME))) {rMap.put(STATUS_PARAMETER_NAME, "8");rMap.put(MESSAGE_PARAMETER_NAME, "key验证失败,请返回重试!");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}GameVo gameVo = new GameVo();gameVo.setGameSign(game);gameVo.setUseSort(false);gameVo.setPager(false);List<Game> nowGames = gameService.searchList(gameVo);if (nowGames == null || nowGames.size() == 0) {// 该游戏不存在rMap.put(STATUS_PARAMETER_NAME, "10");rMap.put(MESSAGE_PARAMETER_NAME, "该游戏不存在!");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajax(rMap);}// 先验证账号格式是否正确if (!username.matches("^[a-zA-Z0-9_@.]+$") || username.length() > 32) {rMap.put(STATUS_PARAMETER_NAME, "5");rMap.put(MESSAGE_PARAMETER_NAME, "账号名必须由字母、数字、点号、@符号或下划线组成,长度小于32位!");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 1、账号是否存在Account aObj = accountService.getAccountByUsername(username);if (aObj != null) {rMap.put(STATUS_PARAMETER_NAME, "6");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 2、激活码是否有效String c = GameUtil.encryptMobileCookie(username, mobileKey);StringBuffer sb = new StringBuffer();sb.append("key=" + activateCode);sb.append("&sid=" + username);sb.append("&cookie=" + c);sb.append("&game=" + game);String result = sysHttpService.sendPost(SysCommonUtil.LEITING_ACTIVATE_CODE_USABLE, sb.toString());Map<String, Object> map = JsonUtil.toObject(result, Map.class);if (!"1".equals(String.valueOf(map.get(STATUS_PARAMETER_NAME)))) {// 激活码不可用rMap.put(STATUS_PARAMETER_NAME, "7");rMap.put(MESSAGE_PARAMETER_NAME, map.get(MESSAGE_PARAMETER_NAME));// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 3、创建雷霆账号String ip = getRemoteIpStr();Account commonAccount = new Account();commonAccount.setUsername(username.toLowerCase());commonAccount.setUserpwd(userpwd.toString());commonAccount.setUserpwd(GameUtil.encryptAccountPwd(commonAccount.getUsername(), commonAccount.getUserpwd()));commonAccount.setIp(ip);commonAccount.setType(SysCommonUtil.ACCOUNT_TYPE_STANDARD);commonAccount.setPriority(SysCommonUtil.ACCOUNT_PRIORITY_COMMON);commonAccount.setIsFinish(1);commonAccount.setAdult("0");commonAccount.setStatus(SysCommonUtil.SYS_STATUS_ON);commonAccount.setLockTime("0");commonAccount.setRegMethod(SysCommonUtil.REGISTER_COMMON_VALUE);commonAccount.setComefrom(game); // 注册来源// 新增账号accountService.save(commonAccount);accountService.flush();// 4、激活手游账号AccountMobile fastMobile = new AccountMobile();fastMobile.setGame(game);if (com.terrace.util.StringUtil.isNullOrEmpty(serial)) {fastMobile.setSerial(GameUtil.desEncrypt(serial));}fastMobile.setIsFast(2);fastMobile.setUsername(commonAccount.getUsername());fastMobile.setSid(CommonUtil.getEightRandomByUUID());fastMobile.setOs(2); // IOSaccountMobileService.save(fastMobile);accountMobileService.flush();// 5、激活激活码c = GameUtil.encryptMobileCookie(fastMobile.getSid(), mobileKey);sb = new StringBuffer();sb.append("key=" + activateCode);sb.append("&username=" + username);sb.append("&sid=" + fastMobile.getSid());sb.append("&cookie=" + c);sb.append("&game=" + game);result = sysHttpService.sendPost(SysCommonUtil.LEITING_ACTIVATE_GAME, sb.toString());map = JsonUtil.toObject(result, Map.class);if (!"1".equals(String.valueOf(map.get(STATUS_PARAMETER_NAME)))) {// 激活失败rMap.put(STATUS_PARAMETER_NAME, "7");rMap.put(MESSAGE_PARAMETER_NAME, map.get(MESSAGE_PARAMETER_NAME));// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 成功rMap.put("sid", fastMobile.getSid());rMap.put("bind", "2"); // 未绑定标志rMap.put("activate", "1"); // 激活标志rMap.put("channelNo", SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("game", game);rMap.put(STATUS_PARAMETER_NAME, "1");String cookie = GameUtil.ltLoginSign(fastMobile.getSid(), game, SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("cookie", cookie);// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);} catch (Exception e) {logger.error("普通注册异常!", e);}rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios激活码注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// ios普通注册public String register() {// 1、账号是否存在// 2、创建雷霆账号// 3、激活手游账号// log日志记录saveLog(getRequest().getRequestURL().toString(), getHttpParams().toString(), 2);Map<String, Object> rMap = new HashMap<String, Object>();try {if (StringUtil.isEmpty(username)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(userpwd)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}// if (StringUtil.isEmpty(serial)) {// rMap.put(STATUS_PARAMETER_NAME, "3");// // log日志记录// saveLog(rMap.toString(), "ios普通注册-" + username, 2);// return ajaxJsonp(rMap);// }if (StringUtil.isEmpty(game)) {rMap.put(STATUS_PARAMETER_NAME, "2");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(key)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}// 先验证账号格式是否正确if (!username.matches("^[a-zA-Z0-9_@.]+$") || username.length() > 32) {rMap.put(STATUS_PARAMETER_NAME, "5");rMap.put(MESSAGE_PARAMETER_NAME, "账号名必须由字母、数字、点号、@符号或下划线组成,长度小于32位!");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}String msg = username + "|" + userpwd + "|" + serial + "|" + game;Map<String, String> map = GameUtil.threeDaysVerify(msg, mobileKey, key);if (!"success".equals(map.get(STATUS_PARAMETER_NAME))) {rMap.put(STATUS_PARAMETER_NAME, "8");rMap.put(MESSAGE_PARAMETER_NAME, "key验证失败,请返回重试!");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}GameVo gameVo = new GameVo();gameVo.setGameSign(game);gameVo.setUseSort(false);gameVo.setPager(false);List<Game> nowGames = gameService.searchList(gameVo);if (nowGames == null || nowGames.size() == 0) {// 该游戏不存在rMap.put(STATUS_PARAMETER_NAME, "10");rMap.put(MESSAGE_PARAMETER_NAME, "该游戏不存在!");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajax(rMap);}try {// DES 解密 userpwdDesUtil des = new DesUtil(mobileKey);userpwd = des.decrypt(userpwd);} catch (Exception e1) {logger.error("DES解密失败!", e1);rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}// 1、账号是否存在Account aObj = accountService.getAccountByUsername(username);if (aObj != null) {rMap.put(STATUS_PARAMETER_NAME, "6");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}// 2、创建雷霆账号String ip = getRemoteIpStr();Account commonAccount = new Account();commonAccount.setUsername(username.toLowerCase());commonAccount.setUserpwd(userpwd.toString());commonAccount.setUserpwd(GameUtil.encryptAccountPwd(commonAccount.getUsername(), commonAccount.getUserpwd()));commonAccount.setIp(ip);commonAccount.setType(SysCommonUtil.ACCOUNT_TYPE_STANDARD);commonAccount.setPriority(SysCommonUtil.ACCOUNT_PRIORITY_COMMON);commonAccount.setIsFinish(1);commonAccount.setAdult("0");commonAccount.setStatus(SysCommonUtil.SYS_STATUS_ON);commonAccount.setLockTime("0");commonAccount.setRegMethod(SysCommonUtil.REGISTER_COMMON_VALUE);commonAccount.setComefrom(game); // 注册来源// 新增账号accountService.save(commonAccount);accountService.flush();// 3、激活手游账号AccountMobile fastMobile = new AccountMobile();fastMobile.setGame(game);if (com.terrace.util.StringUtil.isNullOrEmpty(serial)) {fastMobile.setSerial(GameUtil.desEncrypt(serial));}fastMobile.setIsFast(2);fastMobile.setUsername(commonAccount.getUsername());fastMobile.setSid(CommonUtil.getEightRandomByUUID());fastMobile.setOs(2); // IOSaccountMobileService.save(fastMobile);accountMobileService.flush();// 成功rMap.put("sid", fastMobile.getSid());rMap.put("bind", "2"); // 未绑定标志rMap.put("activate", "2"); // 激活标志rMap.put("channelNo", SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("game", game);rMap.put(STATUS_PARAMETER_NAME, "1");String cookie = GameUtil.ltLoginSign(fastMobile.getSid(), game, SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("cookie", cookie);// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);} catch (Exception e) {logger.error("普通注册异常!", e);}rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios普通注册-" + username, 2);return ajaxJsonp(rMap);}// ios普通注册// -------------密码明文传输public String registerShow() {// 1、账号是否存在// 2、创建雷霆账号// 3、激活手游账号// log日志记录saveLog(getRequest().getRequestURL().toString(), getHttpParams().toString(), 2);Map<String, Object> rMap = new HashMap<String, Object>();try {if (StringUtil.isEmpty(username)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(userpwd)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// if (StringUtil.isEmpty(serial)) {// rMap.put(STATUS_PARAMETER_NAME, "3");// // log日志记录// saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);// return ajaxJsonp(rMap);// }if (StringUtil.isEmpty(game)) {rMap.put(STATUS_PARAMETER_NAME, "2");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(key)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}String msg = username + "|" + userpwd + "|" + serial + "|" + game;Map<String, String> map = GameUtil.threeDaysVerify(msg, mobileKey, key);if (!"success".equals(map.get(STATUS_PARAMETER_NAME))) {rMap.put(STATUS_PARAMETER_NAME, "8");rMap.put(MESSAGE_PARAMETER_NAME, "key验证失败,请返回重试!");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}GameVo gameVo = new GameVo();gameVo.setGameSign(game);gameVo.setUseSort(false);gameVo.setPager(false);List<Game> nowGames = gameService.searchList(gameVo);if (nowGames == null || nowGames.size() == 0) {// 该游戏不存在rMap.put(STATUS_PARAMETER_NAME, "10");rMap.put(MESSAGE_PARAMETER_NAME, "该游戏不存在!");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajax(rMap);}// 先验证账号格式是否正确if (!username.matches("^[a-zA-Z0-9_@.]+$") || username.length() > 32) {rMap.put(STATUS_PARAMETER_NAME, "5");rMap.put(MESSAGE_PARAMETER_NAME, "账号名必须由字母、数字、点号、@符号或下划线组成,长度小于32位!");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 1、账号是否存在Account aObj = accountService.getAccountByUsername(username);if (aObj != null) {rMap.put(STATUS_PARAMETER_NAME, "6");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 2、创建雷霆账号String ip = getRemoteIpStr();Account commonAccount = new Account();commonAccount.setUsername(username.toLowerCase());commonAccount.setUserpwd(userpwd.toString());commonAccount.setUserpwd(GameUtil.encryptAccountPwd(commonAccount.getUsername(), commonAccount.getUserpwd()));commonAccount.setIp(ip);commonAccount.setType(SysCommonUtil.ACCOUNT_TYPE_STANDARD);commonAccount.setPriority(SysCommonUtil.ACCOUNT_PRIORITY_COMMON);commonAccount.setIsFinish(1);commonAccount.setAdult("0");commonAccount.setStatus(SysCommonUtil.SYS_STATUS_ON);commonAccount.setLockTime("0");commonAccount.setRegMethod(SysCommonUtil.REGISTER_COMMON_VALUE);commonAccount.setComefrom(game); // 注册来源// 新增账号accountService.save(commonAccount);accountService.flush();// 3、激活手游账号AccountMobile fastMobile = new AccountMobile();fastMobile.setGame(game);if (com.terrace.util.StringUtil.isNullOrEmpty(serial)) {fastMobile.setSerial(GameUtil.desEncrypt(serial));}fastMobile.setIsFast(2);fastMobile.setUsername(commonAccount.getUsername());fastMobile.setSid(CommonUtil.getEightRandomByUUID());fastMobile.setOs(2); // IOSaccountMobileService.save(fastMobile);accountMobileService.flush();// 成功rMap.put("sid", fastMobile.getSid());rMap.put("bind", "2"); // 未绑定标志rMap.put("activate", "2"); // 激活标志rMap.put("channelNo", SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("game", game);rMap.put(STATUS_PARAMETER_NAME, "1");String cookie = GameUtil.ltLoginSign(fastMobile.getSid(), game, SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("cookie", cookie);// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);} catch (Exception e) {logger.error("普通注册异常!", e);}rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios普通注册(明文)-" + username, 2);return ajaxJsonp(rMap);}// 普通登陆public String mobileLogin() {// log日志记录saveLog(getRequest().getRequestURL().toString(), getHttpParams().toString(), 2);Map<String, Object> rMap = new HashMap<String, Object>();try {if (StringUtil.isEmpty(username)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(userpwd)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(game)) {rMap.put(STATUS_PARAMETER_NAME, "2");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(key)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}String msg = username + "|" + userpwd + "|" + game;Map<String, String> mapVerify = GameUtil.threeDaysVerify(msg, mobileKey, key);if (!"success".equals(mapVerify.get(STATUS_PARAMETER_NAME))) {rMap.put(STATUS_PARAMETER_NAME, "8");rMap.put(MESSAGE_PARAMETER_NAME, "key验证失败,请返回重试!");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}GameVo gameVo = new GameVo();gameVo.setGameSign(game);gameVo.setUseSort(false);gameVo.setPager(false);List<Game> nowGames = gameService.searchList(gameVo);if (nowGames == null || nowGames.size() == 0) {// 该游戏不存在rMap.put(STATUS_PARAMETER_NAME, "10");rMap.put(MESSAGE_PARAMETER_NAME, "该游戏不存在!");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajax(rMap);}try {// DES 解密 userpwdDesUtil des = new DesUtil(mobileKey);userpwd = des.decrypt(userpwd);} catch (Exception e1) {logger.error("DES解密失败!", e1);rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}// 验证账号Account aObj = accountService.getAccountByUsername(username);if (aObj != null) {if (!aObj.getUserpwd().equals(GameUtil.encryptAccountPwd(username.toLowerCase(), userpwd))) {rMap.put("status", "4");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}Commonality bindingStatusCommonality = commonalityService.getCommonalityByName(SysCommonUtil.SYS_STATUS_USE);Map<String, String> searchParams = new HashMap<String, String>();searchParams.put("account", aObj.getId());searchParams.put("status", bindingStatusCommonality.getId());List<AccountBinding> accountBindingList = accountBindingService.searchList(searchParams);if (accountBindingList.size() > 0) {rMap.put("bind", "1"); // 绑定标志} else {rMap.put("bind", "2"); // 未绑定标志}} else {rMap.put("status", "5");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}// 判断激活游戏没有AccountMobileVo amVo = new AccountMobileVo();amVo.setUsername(username.toLowerCase());amVo.setGame(game);List<AccountMobile> objList = accountMobileService.searchList(amVo);AccountMobile accountMobile = null;if (objList != null && objList.size() > 0) {accountMobile = objList.get(0);} else {// 激活手游账号accountMobile = new AccountMobile();accountMobile.setGame(game);accountMobile.setUsername(aObj.getUsername());accountMobile.setSid(CommonUtil.getEightRandomByUUID());accountMobile.setOs(2);accountMobileService.save(accountMobile);accountMobileService.flush();}// 判断是否激活激活码String sid = accountMobile.getSid();String c = GameUtil.encryptMobileCookie(sid, mobileKey);int activate = 1;if (sid == null || "".equals(sid) || c == null || "".equals(c) || game == null || "".equals(game)) {activate = 7;rMap.put(MESSAGE_PARAMETER_NAME, "参数缺失!");}Map<String, String> map = GameUtil.threeDaysVerify(sid, mobileKey, c);if (!"success".equals(map.get(STATUS_PARAMETER_NAME))) {activate = 8;rMap.put(MESSAGE_PARAMETER_NAME, "cookie验证失败,请返回重试!");}// 激活码使用表中该账户是否使用过激活码,通过sid来验证ActivateCodeGaintVo vo = new ActivateCodeGaintVo();vo.setSid(sid);vo.setGame(nowGames.get(0).getId());vo.setChannelNo(channelNo);List<ActivateCodeGaint> activateCodeGaints = activateCodeGaintService.searchList(vo);if (activateCodeGaints == null || activateCodeGaints.size() == 0) {// 该用户没有激活激活码activate = 9;rMap.put(MESSAGE_PARAMETER_NAME, "该用户没有激活激活码!");}// 该用户已经激活激活码rMap.put(MESSAGE_PARAMETER_NAME, "该用户已经激活激活码!");if ("1".equals(activate)) {// 已激活rMap.put("activate", "1");} else {// 未激活rMap.put("activate", "2");}// 成功rMap.put(STATUS_PARAMETER_NAME, "1");rMap.put("sid", sid);rMap.put("channelNo", SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("game", game);String cookie = GameUtil.ltLoginSign(sid, game, SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("cookie", cookie);// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);} catch (Exception e) {logger.error("普通登陆异常!", e);}rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios登录-" + username, 2);return ajaxJsonp(rMap);}// 普通登陆// ------密码明文传递public String mobileLoginShow() {// log日志记录saveLog(getRequest().getRequestURL().toString(), getHttpParams().toString(), 2);Map<String, Object> rMap = new HashMap<String, Object>();try {if (StringUtil.isEmpty(username)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(userpwd)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(game)) {rMap.put(STATUS_PARAMETER_NAME, "2");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}if (StringUtil.isEmpty(key)) {rMap.put(STATUS_PARAMETER_NAME, "7");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}String msg = username + "|" + userpwd + "|" + game;Map<String, String> mapVerify = GameUtil.threeDaysVerify(msg, mobileKey, key);if (!"success".equals(mapVerify.get(STATUS_PARAMETER_NAME))) {rMap.put(STATUS_PARAMETER_NAME, "8");rMap.put(MESSAGE_PARAMETER_NAME, "key验证失败,请返回重试!");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}GameVo gameVo = new GameVo();gameVo.setGameSign(game);List<Game> nowGames = gameService.searchList(gameVo);if (nowGames == null || nowGames.size() == 0) {// 该游戏不存在rMap.put(STATUS_PARAMETER_NAME, "10");rMap.put(MESSAGE_PARAMETER_NAME, "该游戏不存在!");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajax(rMap);}// 验证账号Account aObj = accountService.getAccountByUsername(username);if (aObj != null) {if (!aObj.getUserpwd().equals(GameUtil.encryptAccountPwd(username.toLowerCase(), userpwd))) {rMap.put("status", "4");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}Commonality bindingStatusCommonality = commonalityService.getCommonalityByName(SysCommonUtil.SYS_STATUS_USE);Map<String, String> searchParams = new HashMap<String, String>();searchParams.put("account", aObj.getId());searchParams.put("status", bindingStatusCommonality.getId());List<AccountBinding> accountBindingList = accountBindingService.searchList(searchParams);if (accountBindingList.size() > 0) {rMap.put("bind", "1"); // 绑定标志} else {rMap.put("bind", "2"); // 未绑定标志}} else {rMap.put("status", "5");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}// 判断激活游戏没有AccountMobileVo amVo = new AccountMobileVo();amVo.setUsername(username.toLowerCase());amVo.setGame(game);List<AccountMobile> objList = accountMobileService.searchList(amVo);AccountMobile accountMobile = null;if (objList != null && objList.size() > 0) {accountMobile = objList.get(0);} else {// 激活手游账号accountMobile = new AccountMobile();accountMobile.setGame(game);accountMobile.setUsername(aObj.getUsername());accountMobile.setSid(CommonUtil.getEightRandomByUUID());accountMobile.setOs(2);accountMobileService.save(accountMobile);accountMobileService.flush();}// 判断是否激活激活码String sid = accountMobile.getSid();String c = GameUtil.encryptMobileCookie(sid, mobileKey);int activate = 1;if (sid == null || "".equals(sid) || c == null || "".equals(c) || game == null || "".equals(game)) {activate = 7;rMap.put(MESSAGE_PARAMETER_NAME, "参数缺失!");}Map<String, String> map = GameUtil.threeDaysVerify(sid, mobileKey, c);if (!"success".equals(map.get(STATUS_PARAMETER_NAME))) {activate = 8;rMap.put(MESSAGE_PARAMETER_NAME, "cookie验证失败,请返回重试!");}// 激活码使用表中该账户是否使用过激活码,通过sid来验证ActivateCodeGaintVo vo = new ActivateCodeGaintVo();vo.setSid(sid);vo.setGame(nowGames.get(0).getId());vo.setChannelNo(channelNo);List<ActivateCodeGaint> activateCodeGaints = activateCodeGaintService.searchList(vo);if (activateCodeGaints == null || activateCodeGaints.size() == 0) {// 该用户没有激活激活码activate = 9;rMap.put(MESSAGE_PARAMETER_NAME, "该用户没有激活激活码!");}// 该用户已经激活激活码rMap.put(MESSAGE_PARAMETER_NAME, "该用户已经激活激活码!");if ("1".equals(activate)) {// 已激活rMap.put("activate", "1");} else {// 未激活rMap.put("activate", "2");}// 成功rMap.put(STATUS_PARAMETER_NAME, "1");rMap.put("sid", sid);rMap.put("channelNo", SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("game", game);String cookie = GameUtil.ltLoginSign(sid, game, SysCommonUtil.CHANNEL_NO_LEITING);rMap.put("cookie", cookie);// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);} catch (Exception e) {logger.error("普通登陆异常!", e);}rMap.put(STATUS_PARAMETER_NAME, "0");// log日志记录saveLog(rMap.toString(), "ios登录(明文)-" + username, 2);return ajaxJsonp(rMap);}/** * 保存log日志 * * @param info * log日志具体内容 * @param params * 标题 * @param type * 1:平台接收,2:平台发送 */private void saveLog(String info, String params, int type) {try {GameDocking entity = new GameDocking();entity.setCreateDate(new Date());entity.setModifyDate(new Date());if (!StringUtil.isEmpty(info)) {if (info.length() > 500) {info = info.substring(0, 500);}entity.setUrl(info);}if (!StringUtil.isEmpty(params)) {if (params.length() > 2000) {params = params.substring(0, 2000);}entity.setParams(params);}entity.setType(type); // 1:平台接收,2:平台发送gameDockingService.save(entity);} catch (Exception e) {logger.error(e.getMessage());}}// 获取http参数private Map getHttpParams() {Map map = new HashMap();Enumeration paramNames = getRequest().getParameterNames();while (paramNames.hasMoreElements()) {String paramName = (String) paramNames.nextElement();String[] paramValues = getRequest().getParameterValues(paramName);if (paramValues.length == 1) {String paramValue = paramValues[0];if (paramValue.length() != 0) {System.out.println("参数:" + paramName + "=" + paramValue);map.put(paramName, paramValue);}}}return map;}public String getSerial() {return serial;}public void setSerial(String serial) {this.serial = serial;}public String getGame() {return game;}public void setGame(String game) {this.game = game;}public String getSid() {return sid;}public void setSid(String sid) {this.sid = sid;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getUserpwd() {return userpwd;}public void setUserpwd(String userpwd) {this.userpwd = userpwd;}public String getCookie() {return cookie;}public void setCookie(String cookie) {this.cookie = cookie;}public String getKey() {return key;}public void setKey(String key) {this.key = key;}public String getRegMethod() {return regMethod;}public void setRegMethod(String regMethod) {this.regMethod = regMethod;}public String getPhoneActiveKey() {return phoneActiveKey;}public void setPhoneActiveKey(String phoneActiveKey) {this.phoneActiveKey = phoneActiveKey;}public String getPhoneNum() {return phoneNum;}public void setPhoneNum(String phoneNum) {this.phoneNum = phoneNum;}public String getPhoneModel() {return phoneModel;}public void setPhoneModel(String phoneModel) {this.phoneModel = phoneModel;}public String getActivateCode() {return activateCode;}public void setActivateCode(String activateCode) {this.activateCode = activateCode;}public String getChannelNo() {return channelNo;}public void setChannelNo(String channelNo) {this.channelNo = channelNo;}}
0 0
- iOS
- iOS
- IOS
- iOS
- iOS
- IOS
- ios
- iOS
- iOS
- IOS
- iOS
- ios
- ios ~~~~~
- ios
- IOS
- IOS
- IOS
- ios
- 常见内排序算法的java实现
- ffmpeg转码本地文件(一)
- CodeForces 630D:Hexagons!【水】
- socket与http的区别
- SVM-支持向量机算法概述
- ios
- 4.8 使用ViewPager 和Fresco 实现图库
- 保存图片到本地相册
- 实际工作中九宫格的一般使用
- 递归之39阶台阶
- Java集合类: Set、List、Map、Queue使用场景梳理
- 小工具-串口连接数据对比
- 【GDOI 2016模拟3.9】暴走的图灵机
- 【java随记】POI各Jar包的作用