generated from root/miduo_server
网页支付相关逻辑补充
parent
16cd526d2e
commit
d5945166bb
5
pom.xml
5
pom.xml
|
@ -75,6 +75,11 @@
|
|||
<artifactId>gson</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.jmfy.dao.GSUserDao;
|
||||
import com.jmfy.dao.ServerInfoDao;
|
||||
import com.jmfy.dao.UserInfoDao;
|
||||
import com.jmfy.handler.GMHandler;
|
||||
import com.jmfy.model.CUserInfo;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.thrift.idl.Result;
|
||||
import com.jmfy.utils.RPCClient;
|
||||
import com.jmfy.utils.RedisUtil;
|
||||
import com.jmfy.model.GSUserFinal;
|
||||
import com.jmfy.model.ServerInfo;
|
||||
import com.jmfy.model.vo.RoleNameVo;
|
||||
import com.jmfy.model.vo.ServerNameVo;
|
||||
import com.jmfy.utils.JsonUtil;
|
||||
import com.jmfy.utils.MD5Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -16,6 +23,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
|
@ -24,17 +34,101 @@ import javax.servlet.http.HttpServletResponse;
|
|||
@RequestMapping(value = "req")
|
||||
public class HttpRequestController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserInfoController.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HttpRequestController.class);
|
||||
|
||||
private static final String YUENAN_SECRETKEY = "XAhRvf9ycmv6BJGTUJci";
|
||||
|
||||
@Resource
|
||||
private UserInfoDao userInfoDao;
|
||||
|
||||
@Resource
|
||||
private ServerInfoDao serverInfoDao;
|
||||
|
||||
@Resource
|
||||
private GSUserDao gsUserDao;
|
||||
|
||||
@RequestMapping(value = "/getServerList", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String getServerList (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
List<ServerInfo> serverInfo = serverInfoDao.getAllServerInfo();
|
||||
ArrayList<ServerNameVo> data = new ArrayList<>();
|
||||
for (ServerInfo info : serverInfo) {
|
||||
if (info.getStatusInt() < 2){
|
||||
continue;
|
||||
}
|
||||
ServerNameVo vo = new ServerNameVo(info.getServerId(), info.getName());
|
||||
data.add(vo);
|
||||
}
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("message", "success");
|
||||
result.put("error_code",0);
|
||||
result.put("data", gson.toJson(data));
|
||||
return gson.toJson(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryRole", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String queryRole (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JSONObject result = new JSONObject();
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
String openId = parameterMap.get("appota_user_id");
|
||||
String serverId = parameterMap.get("server_id");
|
||||
CUserInfo cUserInfo = userInfoDao.findUserInfoByOpenId(serverId, openId);
|
||||
if (cUserInfo == null){
|
||||
result.put("error_code",1);
|
||||
result.put("message", "openId is not exist");
|
||||
return gson.toJson(result);
|
||||
}
|
||||
GSUserFinal userFinal = gsUserDao.findUserInfoCache(Integer.parseInt(serverId), cUserInfo.getUserId());
|
||||
if (userFinal == null){
|
||||
result.put("error_code",1);
|
||||
result.put("message", "userId is not exist");
|
||||
return gson.toJson(result);
|
||||
}
|
||||
ArrayList<RoleNameVo> data = new ArrayList<>();
|
||||
RoleNameVo vo = new RoleNameVo(userFinal.getUserId(), userFinal.getNickName());
|
||||
data.add(vo);
|
||||
|
||||
result.put("message", "success");
|
||||
result.put("error_code",0);
|
||||
result.put("data", gson.toJson(data));
|
||||
return gson.toJson(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/checkRole", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String checkRole (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
JSONObject result = new JSONObject();
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap(request);
|
||||
String userId = parameterMap.get("role_id");
|
||||
String serverId = parameterMap.get("server_id");
|
||||
GSUserFinal userFinal = gsUserDao.findUserInfoCache(Integer.parseInt(serverId), Integer.parseInt(userId));
|
||||
if (userFinal == null){
|
||||
result.put("error_code",1);
|
||||
result.put("message", "rolecheck_fail");
|
||||
return gson.toJson(result);
|
||||
}
|
||||
result.put("error_code",0);
|
||||
result.put("message", "rolecheck_success");
|
||||
return gson.toJson(result);
|
||||
}
|
||||
|
||||
// public static boolean verifySign(HashMap<String, String> parameterMap){
|
||||
// String sign = parameterMap.get("signature");
|
||||
// if (sign == null){
|
||||
// return false;
|
||||
// }
|
||||
// LOGGER.info("参数str:{}",sign);
|
||||
// String apiKey = parameterMap.get("api_key");
|
||||
// String appotaUserId = parameterMap.get("appota_user_id");
|
||||
// String serverId = parameterMap.get("server_id");
|
||||
// String localSign = MD5Util.encrypByMd5(apiKey + appotaUserId + serverId + YUENAN_SECRETKEY);
|
||||
// LOGGER.info("md5Str:{}",localSign);
|
||||
// return localSign.equals(sign);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取战斗记录
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/getFightRecord", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String getFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
@ -48,10 +142,6 @@ public class HttpRequestController {
|
|||
|
||||
/**
|
||||
* 清理游戏服全部战斗记录
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/clearFightRecord", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String clearFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
@ -62,10 +152,6 @@ public class HttpRequestController {
|
|||
|
||||
/**
|
||||
* 获取玩家全部战斗记录
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/getAllFightRecord", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String getAllFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
@ -76,10 +162,6 @@ public class HttpRequestController {
|
|||
|
||||
/**
|
||||
* 发送gm到游戏服
|
||||
* @param uid
|
||||
* @param cmd
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private String sendGm(String uid, String cmd) throws Exception {
|
||||
CUserInfo cUserInfo = userInfoDao.findUserInfoById(uid);
|
||||
|
|
|
@ -16,13 +16,7 @@ public interface GSUserDao {
|
|||
|
||||
GSHeroMap findHeroMap(int serverId, int userId) throws Exception;
|
||||
|
||||
void updateUserInfo(MarkedVo marked, Update update, int id) throws Exception;
|
||||
|
||||
String getThriftIpPort(MarkedVo marked, int userId);
|
||||
|
||||
|
||||
GSUser findUserInfoByname(int serverId, String roleName) throws Exception;
|
||||
|
||||
|
||||
List<GSUser> findAllUserInfo(int serverId,int questionId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -12,29 +12,17 @@ public interface UserInfoDao {
|
|||
|
||||
List<CUserInfo> findUserInfo(String openId) throws Exception;
|
||||
|
||||
CUser findCuserInfo(int serverId ,int userId) throws Exception;
|
||||
|
||||
|
||||
int getCExpedition(int serverId, int userId) throws Exception;
|
||||
|
||||
CUserInfo findUserInfoByUserId(int uid) throws Exception;
|
||||
|
||||
String getThriftIpPort(int serverId, int uid);
|
||||
|
||||
BlackList findBlack(String openId) throws Exception;
|
||||
|
||||
void addBlackList(BlackList blackList) throws Exception;
|
||||
|
||||
void updateBlack(Update update, BlackList blackList) throws Exception;
|
||||
|
||||
void updateStatus(Update update, CUserInfo cUserInfo) throws Exception;
|
||||
|
||||
CUser findCuserByName(int serverId, String userName) throws Exception;
|
||||
void addWhiteList(WhiteList whiteList) throws Exception;
|
||||
|
||||
WhiteList findWhiteListInfo(String openId) throws Exception;
|
||||
|
||||
List<WhiteList> findAllWhiteList() throws Exception;
|
||||
|
||||
void delWhiteList(String openId) throws Exception;
|
||||
|
||||
CUserInfo findUserInfoById(String roleId) throws Exception ;
|
||||
|
||||
CUserInfo findUserInfoByOpenId(String serverId, String openId) throws Exception;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public class GSUserDaoImpl implements GSUserDao {
|
|||
userFinal.setUserId(gsUser.getId());
|
||||
userFinal.setOpenId(gsUser.getPlayerManager().getOpenId());
|
||||
userFinal.setCreateTime(DateUtil.stampToTime(gsUser.getPlayerManager().getCreateTime()));
|
||||
userFinal.setNickName(gsUser.getPlayerManager().getNickName());
|
||||
|
||||
// 写入缓存
|
||||
userFinalExpiryMap.put(userId,userFinal,DateUtil.ONE_DAY);
|
||||
|
@ -79,23 +80,6 @@ public class GSUserDaoImpl implements GSUserDao {
|
|||
return mongoTemplate.findOne(query, GSHeroMap.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserInfo(MarkedVo marked, Update update, int id) throws Exception {
|
||||
// String dbName = MongoName.getMongoDBName(marked);
|
||||
// MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
// Query query = new Query(Criteria.where("playerManager.rootId").is(id));
|
||||
// mongoTemplate.updateMulti(query, update, GSUser.class);
|
||||
// GSUser cUser = mongoTemplate.findOne(query, GSUser.class);
|
||||
// RedisUtil.getInstence().putObject(marked.getPartition() + colon + RedisUserKey.CUser_Key, Integer.toString(id), cUser, 3600 * 24);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getThriftIpPort(MarkedVo marked, int uid) {
|
||||
return RedisUtil.getInstence().getObject(marked.getPartition() + colon + RedisUserKey.CUser_ServerInfo_Key, Integer.toString(uid),
|
||||
String.class, GlobalsDef.REDIS_OVER_TIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GSUser findUserInfoByname(int serverId, String roleName) throws Exception {
|
||||
String dbName = MongoName.getMongoDBName(serverId);
|
||||
|
|
|
@ -20,10 +20,6 @@ import java.util.List;
|
|||
public class UserInfoDaoImpl implements UserInfoDao {
|
||||
@Resource
|
||||
private Connect connect ;
|
||||
public static final String colon = "标题:每日礼包差额补偿\n" +
|
||||
"尊敬的道友:\n" +
|
||||
" 为了给各位道友带来更好的游戏体验,我们对游戏进行了一次更新,本次更新提升了每日礼包中的奖励内容,对于17号至今已购买过礼包的玩家,我们会对其中的差额进行补偿,具体补偿内容详见附件,烦请查收。祝各位道友修行愉快~\n" +
|
||||
" 如果您在修行中还遇到问题,可追踪我们官方Facebook:并进行留言,自有小妖为您解答。";
|
||||
String dbName =Constant.dbName;
|
||||
|
||||
@Override
|
||||
|
@ -47,30 +43,12 @@ public class UserInfoDaoImpl implements UserInfoDao {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CUser findCuserInfo(int serverId ,int userId) throws Exception {
|
||||
CUser cUser = RedisUtil.getInstence().getObject(serverId + colon + RedisUserKey.CUser_Key,
|
||||
String.valueOf(userId), CUser.class, GlobalsDef.REDIS_OVER_TIME);
|
||||
if (cUser != null) {
|
||||
return cUser;
|
||||
}
|
||||
String dbName = MongoName.getMongoDBName(serverId);
|
||||
public CUserInfo findUserInfoByOpenId(String serverId, String openId) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("_id").is(userId));
|
||||
return mongoTemplate.findOne(query, CUser.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getCExpedition(int serverId, int userId) throws Exception {
|
||||
String dbName = MongoName.getMongoDBName(serverId);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete( dbName);
|
||||
Query query = new Query(Criteria.where("_id").is(userId));
|
||||
CExpedition cExpedition = mongoTemplate.findOne(query, CExpedition.class);
|
||||
if(cExpedition == null){
|
||||
return 0;
|
||||
}
|
||||
return cExpedition.getCurCheck();
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("serverId").is(serverId));
|
||||
query.addCriteria(Criteria.where("openId").is(openId));
|
||||
return mongoTemplate.findOne(query, CUserInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,62 +58,6 @@ public class UserInfoDaoImpl implements UserInfoDao {
|
|||
return mongoTemplate.findOne(query, CUserInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getThriftIpPort(int serverId, int uid) {
|
||||
return RedisUtil.getInstence().getObject(serverId + colon + RedisUserKey.CUser_ServerInfo_Key, Integer.toString(uid),
|
||||
String.class, GlobalsDef.REDIS_OVER_TIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlackList findBlack(String openId) throws Exception {
|
||||
BlackList blackList = RedisUtil.getInstence().getObject(0+colon+RedisUserKey.BlackList_key, openId,
|
||||
BlackList.class, GlobalsDef.REDIS_OVER_TIME);
|
||||
if (blackList != null){
|
||||
return blackList;
|
||||
}
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
Criteria cr = new Criteria();
|
||||
cr.andOperator(Criteria.where("black_openid").is(openId), Criteria.where("serverid").is(0));
|
||||
query.addCriteria(cr);
|
||||
return mongoTemplate.findOne(query, BlackList.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBlackList(BlackList black) throws Exception {
|
||||
RedisUtil.getInstence().putObject(black.getServerid()+colon+RedisUserKey.BlackList_key, black.getBlack_openid(),
|
||||
black, -1);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
mongoTemplate.insert(black);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBlack(Update update, BlackList black) throws Exception {
|
||||
RedisUtil.getInstence().putObject(black.getServerid()+colon+RedisUserKey.BlackList_key,black.getBlack_openid(),
|
||||
black, -1);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("_id").is(black.getId()));
|
||||
mongoTemplate.updateMulti(query, update, BlackList.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(Update update, CUserInfo userinfo) throws Exception {
|
||||
RedisUtil.getInstence().putObject(userinfo .getServerid()+colon+RedisUserKey.UserInfo_key, userinfo.getOpenId(),
|
||||
userinfo, -1);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("_id").is(userinfo.getId()));
|
||||
mongoTemplate.updateMulti(query, update, CUserInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CUser findCuserByName(int serverId, String userName) throws Exception {
|
||||
String dbName = MongoName.getMongoDBName(serverId);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete( dbName);
|
||||
Query query = new Query(Criteria.where("userName").is(userName));
|
||||
return mongoTemplate.findOne(query, CUser.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addWhiteList(WhiteList whiteList) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
|
|
|
@ -10,12 +10,7 @@ public class GSUserFinal {
|
|||
private int userId;
|
||||
private String openId;
|
||||
private String createTime;
|
||||
|
||||
public GSUserFinal(int userId, String openId, String createTime) {
|
||||
this.userId = userId;
|
||||
this.openId = openId;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
private String nickName;
|
||||
|
||||
public GSUserFinal() {
|
||||
}
|
||||
|
@ -43,4 +38,12 @@ public class GSUserFinal {
|
|||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.jmfy.model.vo;
|
||||
|
||||
public class RoleNameVo {
|
||||
private int roleId;
|
||||
private String roleName;
|
||||
|
||||
public RoleNameVo() {
|
||||
}
|
||||
|
||||
public RoleNameVo(int roleId, String roleName) {
|
||||
this.roleId = roleId;
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public int getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(int roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.jmfy.model.vo;
|
||||
|
||||
public class ServerNameVo {
|
||||
private int serverId;
|
||||
private String serverName;
|
||||
|
||||
public ServerNameVo() {
|
||||
}
|
||||
|
||||
public ServerNameVo(int serverId, String serverName) {
|
||||
this.serverId = serverId;
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public int getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
public void setServerId(int serverId) {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.jmfy.utils;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.jmfy.model.config.SRechargeCommodityConfig;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
角 色 ID:</label>
|
||||
角 色 ID:</label>q
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="text" name="roleId" placeholder="角色id或者角色名称" value="" class="input-text"/>
|
||||
<span class="ROLEID"></span>
|
||||
|
|
Loading…
Reference in New Issue