增加登录接口,修改存储过程
parent
e1b9392271
commit
eeba27679b
|
|
@ -640,7 +640,9 @@ public class GameController implements IController {
|
||||||
owner.destroy(true);
|
owner.destroy(true);
|
||||||
|
|
||||||
GroupPublisherService.delRoomEvt(groupId, roomid);
|
GroupPublisherService.delRoomEvt(groupId, roomid);
|
||||||
Redis.use("group1_db0").getJedis().del("room:"+roomid);
|
Jedis jedis0 =Redis.use("group1_db0").getJedis();
|
||||||
|
jedis0.del("room:"+roomid);
|
||||||
|
jedis0.close();
|
||||||
} else if (owner.room.playerMapBySeat.containsKey(owner.seat)) {
|
} else if (owner.room.playerMapBySeat.containsKey(owner.seat)) {
|
||||||
ITObject data = new TObject();
|
ITObject data = new TObject();
|
||||||
data.putInt("aid", owner.playerid);
|
data.putInt("aid", owner.playerid);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import com.taurus.core.plugin.database.DataBase;
|
||||||
import com.taurus.core.plugin.redis.Redis;
|
import com.taurus.core.plugin.redis.Redis;
|
||||||
import com.taurus.core.routes.ActionKey;
|
import com.taurus.core.routes.ActionKey;
|
||||||
import com.taurus.core.util.StringUtil;
|
import com.taurus.core.util.StringUtil;
|
||||||
|
import com.taurus.core.util.Utils;
|
||||||
import com.taurus.web.Controller;
|
import com.taurus.web.Controller;
|
||||||
import com.taurus.web.WebException;
|
import com.taurus.web.WebException;
|
||||||
|
|
||||||
|
|
@ -487,39 +488,39 @@ public class GroupController extends Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 创建圈子玩法
|
// * 修改圈子玩法
|
||||||
*
|
// *
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
@ActionKey(value = Protocol.UPDATE_PLAY, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
|
// @ActionKey(value = Protocol.UPDATE_PLAY, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
|
||||||
| WebInterceptor.V_GROUP_MGR | WebInterceptor.V_GROUP_PLAY)
|
// | WebInterceptor.V_GROUP_MGR | WebInterceptor.V_GROUP_PLAY)
|
||||||
public final void updatePlay() throws Exception {
|
// public final void updatePlay() throws Exception {
|
||||||
ITObject reqData = this.getParams();
|
// ITObject reqData = this.getParams();
|
||||||
|
//
|
||||||
int groupId = reqData.getInt("id");
|
// int groupId = reqData.getInt("id");
|
||||||
int groupType = reqData.getInt("gtype");
|
// int groupType = reqData.getInt("gtype");
|
||||||
int hpOnOff = reqData.getInt("hpOnOff");
|
// int hpOnOff = reqData.getInt("hpOnOff");
|
||||||
if (hpOnOff == 0 && groupType == 2) {
|
// if (hpOnOff == 0 && groupType == 2) {
|
||||||
throw new WebException(ErrorCode.GROUP_TYPE2_MUST_HP);
|
// throw new WebException(ErrorCode.GROUP_TYPE2_MUST_HP);
|
||||||
}
|
// }
|
||||||
int pid = reqData.getInt("pid");
|
// int pid = reqData.getInt("pid");
|
||||||
int gameId = reqData.getInt("gameId");
|
// int gameId = reqData.getInt("gameId");
|
||||||
ITObject config = reqData.getTObject("config");
|
// ITObject config = reqData.getTObject("config");
|
||||||
String name = reqData.getString("name");
|
// String name = reqData.getString("name");
|
||||||
ITObject hpData = reqData.getTObject("hpData");
|
// ITObject hpData = reqData.getTObject("hpData");
|
||||||
int deskId = reqData.containsKey("deskId") ? reqData.getInt("deskId") : 0;
|
// int deskId = reqData.containsKey("deskId") ? reqData.getInt("deskId") : 0;
|
||||||
|
//
|
||||||
GroupService.updatePlay(groupId, pid, gameId, name, deskId, config, hpData, hpOnOff);
|
// GroupService.updatePlay(groupId, pid, gameId, name, deskId, config, hpData, hpOnOff);
|
||||||
int maxPlayers = config.getInt("maxPlayers");
|
// int maxPlayers = config.getInt("maxPlayers");
|
||||||
int maxRound = config.getInt("maxRound");
|
// int maxRound = config.getInt("maxRound");
|
||||||
|
//
|
||||||
ITObject params = TObject.newInstance();
|
// ITObject params = TObject.newInstance();
|
||||||
params.putInt("maxPlayers", maxPlayers);
|
// params.putInt("maxPlayers", maxPlayers);
|
||||||
params.putInt("maxRound", maxRound);
|
// params.putInt("maxRound", maxRound);
|
||||||
|
//
|
||||||
this.sendResponse(0, params);
|
// this.sendResponse(0, params);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除圈子玩法
|
* 删除圈子玩法
|
||||||
|
|
@ -1565,21 +1566,21 @@ public class GroupController extends Controller {
|
||||||
sendResponse(0, resData);
|
sendResponse(0, resData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 重置用户密码
|
* 重置用户密码
|
||||||
// */
|
*/
|
||||||
// @ActionKey(value = Protocol.GROUP_RESET_PASSWORD, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP)
|
@ActionKey(value = Protocol.GROUP_RESET_PASSWORD, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP | WebInterceptor.V_GROUP_MGR_OR_PARTNER)
|
||||||
// public final void resetPassword() throws Exception {
|
public final void resetPassword() throws Exception {
|
||||||
// ITObject reqData = this.getParams();
|
ITObject reqData = this.getParams();
|
||||||
// String session = this.getSession();
|
String session = this.getSession();
|
||||||
// int tagId = reqData.getInt("tagId");
|
int tagId = reqData.getInt("tagId");
|
||||||
// String password = reqData.getString("password");
|
String password = reqData.getString("password");
|
||||||
//
|
|
||||||
//// AccountBean acc = AccountCache.getAccount(session);
|
// AccountBean acc = AccountCache.getAccount(session);
|
||||||
// String sql = "UPDATE account SET password='" + Utils.getMD5Hash(password) + "' where id=" + tagId;
|
String sql = "UPDATE account SET password='" + Utils.getMD5Hash(password) + "' where id=" + tagId;
|
||||||
// DataBase.use().executeUpdate(sql);
|
DataBase.use().executeUpdate(sql);
|
||||||
// this.sendResponse(0, null);
|
this.sendResponse(0, null);
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置设备锁定状态
|
* 重置设备锁定状态
|
||||||
|
|
|
||||||
|
|
@ -1961,8 +1961,8 @@ public class GroupLogService {
|
||||||
// resData.putInt("pump", hp_cost);
|
// resData.putInt("pump", hp_cost);
|
||||||
|
|
||||||
String rewardsql = String.format(
|
String rewardsql = String.format(
|
||||||
" SELECT -sum(win_score+round_reward) reward FROM `team_round_stat_day` WHERE stat_day >= %s AND stat_day < %s and uid!=%s",
|
" SELECT -sum(win_score+round_reward) reward FROM `team_round_stat_day` WHERE stat_day >= %s AND stat_day < %s and uid!=%s and parent_uid=%s",
|
||||||
beginTime, endTime,gb.owner);
|
beginTime, endTime,gb.owner,gb.owner);
|
||||||
// log.info("rewardsql:" + rewardsql);
|
// log.info("rewardsql:" + rewardsql);
|
||||||
|
|
||||||
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,9 @@ public class GroupService {
|
||||||
try {
|
try {
|
||||||
ITArray list = TArray.newInstance();
|
ITArray list = TArray.newInstance();
|
||||||
String key = GroupCache.genGroupsKey(uid);
|
String key = GroupCache.genGroupsKey(uid);
|
||||||
|
log.info("key:"+key);
|
||||||
|
log.info("uid:"+uid);
|
||||||
|
|
||||||
Set<String> groups = jedis11.zrevrange(key, 0, -1);
|
Set<String> groups = jedis11.zrevrange(key, 0, -1);
|
||||||
for (String tem : groups) {
|
for (String tem : groups) {
|
||||||
ITObject obj = getGroupData(uid, Integer.parseInt(tem), jedis11, jedis10);
|
ITObject obj = getGroupData(uid, Integer.parseInt(tem), jedis11, jedis10);
|
||||||
|
|
@ -667,14 +670,26 @@ public class GroupService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int mgn_uid = mgn_lev == 3 ? uid : 0;
|
int mgn_uid = mgn_lev == 3 ? uid : 0;
|
||||||
String sql = String.format("{call sp_add_member(%s,%s,%s)}", groupId, mgn_uid, tagId);
|
long time = System.currentTimeMillis() / 1000;
|
||||||
log.info("addMember addsql:" + sql);
|
// String sql = String.format("{call sp_add_member(%s,%s,%s)}", groupId, mgn_uid, tagId);
|
||||||
Utility.evtdb(groupId, 2, sql);
|
// Utility.evtdb(groupId, 2, sql);
|
||||||
log.info("addMember add:" + groupId + "--" + mgn_uid + "--" + tagId);
|
|
||||||
|
// INSERT INTO group_member(uid,groupId,join_time,parentId) VALUES(_tagId,_groupId,_time,_pid);
|
||||||
|
String selectSql = String.format("select uid from group_member where uid=%s", tagId);
|
||||||
|
ITArray tmplist = DataBase.use().executeQueryByTArray(selectSql);
|
||||||
|
if (tmplist.size() > 0) {
|
||||||
|
return ErrorCode.GROUP_MEMBER_EXIST;
|
||||||
|
}else {
|
||||||
|
String insertSql = String.format(
|
||||||
|
"INSERT INTO group_member(uid,groupId,join_time,parentId) VALUES(%s,%s,%s,%s)", tagId, groupId,
|
||||||
|
time, mgn_uid);
|
||||||
|
Utility.evtdb(groupId, 1, insertSql);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// sp_add_member(groupId, mgn_uid, tagId);
|
// sp_add_member(groupId, mgn_uid, tagId);
|
||||||
|
|
||||||
long time = System.currentTimeMillis() / 1000;
|
|
||||||
log.info("addMember time:" + time);
|
|
||||||
Map<String, String> redis_map = memberToRedis(groupId + "", tagId, 3, 0, mgn_uid, time);
|
Map<String, String> redis_map = memberToRedis(groupId + "", tagId, 3, 0, mgn_uid, time);
|
||||||
|
|
||||||
redis_map.put("queueid", mng_bean.queueid + "");
|
redis_map.put("queueid", mng_bean.queueid + "");
|
||||||
|
|
@ -1113,6 +1128,169 @@ public class GroupService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 设置体力值
|
||||||
|
// *
|
||||||
|
// * @param groupId
|
||||||
|
// * @param uid
|
||||||
|
// * @param tagId
|
||||||
|
// * @param hp
|
||||||
|
// * @return
|
||||||
|
// * @throws Exception
|
||||||
|
// */
|
||||||
|
// public static final ITObject updateMemberHp(int groupId, int uid, int tagId, int hp, boolean self, int otherId)
|
||||||
|
// throws Exception {
|
||||||
|
//
|
||||||
|
// String tag_key = GroupMemberCache.genKey(groupId, tagId);
|
||||||
|
// Jedis jedis10 = Redis.use("group1_db10").getJedis();
|
||||||
|
// RedisLock lock = new RedisLock(tag_key, jedis10);
|
||||||
|
// try {
|
||||||
|
// lock.lock();
|
||||||
|
// GroupMemberBean tag_bean = GroupCache.getMember(groupId, tagId);
|
||||||
|
// if (tag_bean == null) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_MEMBER);
|
||||||
|
// }
|
||||||
|
// GroupMemberBean mng_bean = GroupCache.getMember(groupId, uid);
|
||||||
|
// if (mng_bean == null) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_MEMBER);
|
||||||
|
// }
|
||||||
|
// // 正在游戏不允许下分操作
|
||||||
|
// if (hp < 0) {
|
||||||
|
// if (GroupRoomService.checkRoom(groupId, uid)) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_DONOT_SUB_HP);
|
||||||
|
// }
|
||||||
|
// if (GroupRoomService.checkRoom(groupId, tagId)) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_DONOT_SUB_HP);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (hp > 0) {
|
||||||
|
// int pre_hp = Integer.parseInt(jedis10.hget(tag_key, "hp"));
|
||||||
|
//
|
||||||
|
// if ((long) pre_hp + (long) hp > Integer.MAX_VALUE) {
|
||||||
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int mgn_partner = mng_bean.partnerLev;
|
||||||
|
// int mgn_lev = mng_bean.lev;
|
||||||
|
// if (tag_bean.lev == 1) {
|
||||||
|
// if (uid != tagId) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_PERMISSION);
|
||||||
|
// }
|
||||||
|
// } else if (tag_bean.lev == 2) {
|
||||||
|
// if (mgn_lev != 1) {
|
||||||
|
// if (uid != tagId) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_PERMISSION);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (mgn_lev == 3 && mgn_partner == 0) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_PARTNER);
|
||||||
|
// }
|
||||||
|
// if (mgn_lev == 2) {
|
||||||
|
// if ((mng_bean.permission & PERMISSION_HP_OPT) == 0) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_PERMISSION);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (self == false && mgn_lev != 1 && uid == tagId) {
|
||||||
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (mgn_lev == 3) {
|
||||||
|
// if (!self) {
|
||||||
|
// List<Integer> par_list = Utility.getMemberParents(jedis10, groupId, tagId, false);
|
||||||
|
// if (par_list == null || !par_list.contains(uid)) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_PERMISSION);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// List<Integer> par_list = Utility.getMemberParents(jedis10, groupId, tagId, true);
|
||||||
|
// if (par_list == null || !par_list.contains(uid)) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_NOT_PERMISSION);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// String lua = MainServer.lua_map.get("mgr");
|
||||||
|
// Object obj = jedis10.evalsha(lua, Arrays.asList(mng_bean.redis_key, tag_key),
|
||||||
|
// Arrays.asList(hp + "", mgn_lev + ""));
|
||||||
|
// if (obj == null) {
|
||||||
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
|
// }
|
||||||
|
// if (obj instanceof Long) {
|
||||||
|
// Long code = (Long) obj;
|
||||||
|
// if (code == 3) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_TAG_MGR_HP);
|
||||||
|
// } else if (code == 4) {
|
||||||
|
// throw new WebException(ErrorCode.GROUP_TAG_NO_HP);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||||
|
// ITObject resData = TObject.newInstance();
|
||||||
|
// int mhp = arr.get(0).intValue();
|
||||||
|
// int thp = arr.get(1).intValue();
|
||||||
|
// resData.putInt("mhp", (int) mhp);
|
||||||
|
// resData.putInt("hp", (int) thp);
|
||||||
|
//
|
||||||
|
//// String sql = String.format("{call sp_update_hp_mgr2(%s,%s,%s,%s,%s,%s,%s,%s)}", groupId, uid, hp, mhp,
|
||||||
|
//// thp, tagId, mgn_lev, otherId);
|
||||||
|
//// Utility.evtdb(groupId, 2, sql);
|
||||||
|
//
|
||||||
|
// String sql = String.format("{call sp_update_hp_mgr2(%s,%s,%s,%s,%s,%s,%s,%s)}", groupId, uid, hp, mhp,
|
||||||
|
// thp, tagId, mgn_lev, otherId);
|
||||||
|
// Utility.evtdb(groupId, 2, sql);
|
||||||
|
//
|
||||||
|
// if (!self)
|
||||||
|
// log.info("updateMemberHp uid:" + uid + " tagId:" + tagId + " hp:" + hp / 1000);
|
||||||
|
//
|
||||||
|
// // ------------------------邮件 -------------------
|
||||||
|
// ITObject mail_data = TObject.newInstance();
|
||||||
|
// mail_data.putInt("mgr_id", uid);
|
||||||
|
// AccountBean acc = AccountCache.getAccount(uid);
|
||||||
|
// mail_data.putString("nick", acc.nick);
|
||||||
|
// mail_data.putString("headurl", acc.portrait);
|
||||||
|
// mail_data.putInt("hp", hp);
|
||||||
|
// mail_data.putInt("type", 1);
|
||||||
|
// int time = (int) (System.currentTimeMillis() / 1000);
|
||||||
|
// mail_data.putInt("time", time);
|
||||||
|
// String mail_key = GroupCache.genMailKey(groupId, tagId);
|
||||||
|
// jedis10.zadd(mail_key, time, mail_data.toJson());
|
||||||
|
// String mail_tip_key = GroupCache.genMailTipKey(groupId);
|
||||||
|
// jedis10.zadd(mail_tip_key, 1, tagId + "");
|
||||||
|
// GroupPublisherService.updateMailTipEvt(groupId, tagId);
|
||||||
|
// // -----------------------------------------------
|
||||||
|
//
|
||||||
|
// String c_tem = hp > 0 ? "upper" : "sub";
|
||||||
|
// if (mgn_lev < 3) {
|
||||||
|
// String hp_mgr_key = String.format("g%s:hp_mgr:%s", groupId, c_tem);
|
||||||
|
// String hp_mgr_id_key = String.format("g%s:hp_mgr:%s:u%s", groupId, c_tem, uid);
|
||||||
|
// Jedis jedis9 = Redis.use(redisdb).getJedis();
|
||||||
|
// try {
|
||||||
|
// hp = Math.abs(hp);
|
||||||
|
// CountUtil.countLogByDay(hp_mgr_key, hp, jedis9);
|
||||||
|
// CountUtil.countLogByDay(hp_mgr_id_key, hp, jedis9);
|
||||||
|
// } finally {
|
||||||
|
// jedis9.close();
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// String hp_par_id_key = String.format("g%s:hp_par:%s:u%s", groupId, c_tem, uid);
|
||||||
|
// Jedis jedis9 = Redis.use(redisdb).getJedis();
|
||||||
|
// try {
|
||||||
|
// hp = Math.abs(hp);
|
||||||
|
// CountUtil.countLogByDay(hp_par_id_key, hp, jedis9);
|
||||||
|
// } finally {
|
||||||
|
// jedis9.close();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return resData;
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// } finally {
|
||||||
|
// lock.unlock();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
/**
|
/**
|
||||||
* 设置体力值
|
* 设置体力值
|
||||||
*
|
*
|
||||||
|
|
@ -1218,12 +1396,92 @@ public class GroupService {
|
||||||
resData.putInt("mhp", (int) mhp);
|
resData.putInt("mhp", (int) mhp);
|
||||||
resData.putInt("hp", (int) thp);
|
resData.putInt("hp", (int) thp);
|
||||||
|
|
||||||
String sql = String.format("{call sp_update_hp_mgr2(%s,%s,%s,%s,%s,%s,%s,%s)}", groupId, uid, hp, mhp,
|
// String sql = String.format("{call sp_update_hp_mgr2(%s,%s,%s,%s,%s,%s,%s,%s)}", groupId, uid, hp, mhp,
|
||||||
thp, tagId, mgn_lev, otherId);
|
// thp, tagId, mgn_lev, otherId);
|
||||||
Utility.evtdb(groupId, 2, sql);
|
// Utility.evtdb(groupId, 2, sql);
|
||||||
|
|
||||||
|
String sql = "";
|
||||||
|
|
||||||
if (!self)
|
if (!self)
|
||||||
log.info("updateMemberHp uid:" + uid + " tagId:" + tagId + " hp:" + hp / 1000);
|
log.info("updateMemberHp uid:" + uid + " tagId:" + tagId + " hp:" + hp / 100);
|
||||||
|
// 手动录入sql,不走存储过程
|
||||||
|
int reason = 8;
|
||||||
|
if (mgn_lev > 1) {
|
||||||
|
if (mgn_lev == 2) {
|
||||||
|
reason = hp < 0 ? ConsumeCode.HP_MGR_SUB : ConsumeCode.HP_MGR_UPPER;
|
||||||
|
} else {
|
||||||
|
reason = hp < 0 ? ConsumeCode.HP_PARTNER_SUB : ConsumeCode.HP_PARTNER_UPPER;
|
||||||
|
}
|
||||||
|
//扣除操作者hp
|
||||||
|
sql = String.format(
|
||||||
|
"UPDATE group_member SET hp=hp+%s WHERE groupId = %s and uid=%s ",
|
||||||
|
-hp,groupId, uid);
|
||||||
|
// log.info("sql1:" + sql);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
//增加记录
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,mgr_id,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, uid,tagId, reason, -hp, mhp, 0, System.currentTimeMillis()/1000);
|
||||||
|
// log.info("操作者sql:" + sql);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
|
||||||
|
|
||||||
|
//扣除目标人物hp
|
||||||
|
sql = String.format(
|
||||||
|
"UPDATE group_member SET hp=hp+%s WHERE groupId = %s and uid=%s ",
|
||||||
|
hp,groupId, tagId);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
//增加记录
|
||||||
|
reason = hp < 0 ? ConsumeCode.HP_MGR_SUB : ConsumeCode.HP_MGR_UPPER;
|
||||||
|
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,mgr_id,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, tagId,uid, reason, hp, thp, 0, System.currentTimeMillis()/1000);
|
||||||
|
// log.info("目标人物sql:" + sql);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
} else {
|
||||||
|
reason = hp < 0 ? ConsumeCode.HP_MGR_SUB : ConsumeCode.HP_MGR_UPPER;
|
||||||
|
|
||||||
|
//扣除目标人物hp
|
||||||
|
sql = String.format(
|
||||||
|
"UPDATE group_member SET hp=hp+%s WHERE groupId = %s and uid=%s",
|
||||||
|
hp,groupId, tagId);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
if (uid == tagId && otherId > 0) {
|
||||||
|
//扣除操作者hp
|
||||||
|
sql = String.format(
|
||||||
|
"UPDATE group_member SET hp=hp+%s WHERE groupId = %s and uid=%s",
|
||||||
|
-hp,groupId, uid);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
//增加记录
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,mgr_id,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, uid,otherId, reason, hp, thp, 0, System.currentTimeMillis()/1000);
|
||||||
|
// log.info("自身记录:" + sql);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
}else {
|
||||||
|
if(uid != tagId) {
|
||||||
|
//扣除操作者hp
|
||||||
|
sql = String.format(
|
||||||
|
"UPDATE group_member SET hp=hp+%s WHERE groupId = %s and uid=%s",
|
||||||
|
-hp,groupId, uid);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
|
||||||
|
}
|
||||||
|
//增加记录
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,mgr_id,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, tagId,uid, reason, hp, thp, 0, System.currentTimeMillis()/1000);
|
||||||
|
// log.info("mengzhu自身记录:" + sql);
|
||||||
|
DataBase.use().executeUpdate(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------邮件 -------------------
|
// ------------------------邮件 -------------------
|
||||||
ITObject mail_data = TObject.newInstance();
|
ITObject mail_data = TObject.newInstance();
|
||||||
|
|
@ -1325,8 +1583,9 @@ public class GroupService {
|
||||||
|
|
||||||
if (gb.owner == tagId) {
|
if (gb.owner == tagId) {
|
||||||
String rewardsql = String.format(
|
String rewardsql = String.format(
|
||||||
" SELECT -sum(win_score+round_reward) reward FROM `team_round_stat_day` WHERE stat_day >= %s AND stat_day < %s and uid!=%s group by stat_day order by stat_day desc",
|
" SELECT -sum(win_score+round_reward) reward FROM `team_round_stat_day` WHERE stat_day >= %s AND stat_day < %s and uid!=%s and parent_uid=%s group by stat_day order by stat_day desc",
|
||||||
DateUtils.getBeginDay() - 3600 * 48, DateUtils.getEndDay(), gb.owner);
|
DateUtils.getBeginDay() - 3600 * 48, DateUtils.getEndDay(), gb.owner, gb.owner);
|
||||||
|
|
||||||
// log.info("rewardsql:" + rewardsql);
|
// log.info("rewardsql:" + rewardsql);
|
||||||
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
||||||
if (rewardArray.size() != 0) {
|
if (rewardArray.size() != 0) {
|
||||||
|
|
@ -1343,9 +1602,9 @@ public class GroupService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String rewardsql = String.format(
|
String rewardsql = String.format(
|
||||||
"SELECT sum(round_reward) reward FROM `team_round_stat_day` WHERE stat_day >= %s AND stat_day < %s and uid=%s group by stat_day order by stat_day desc",
|
"SELECT SUM(h.hp) reward FROM group_hp_log h WHERE h.time >= %s AND h.time < %s AND h.reason = 12 and gid=%s and uid=%s GROUP BY FROM_UNIXTIME(h.time, '%%Y-%%m-%%d') order by h.time desc",
|
||||||
DateUtils.getBeginDay() - 3600 * 48, DateUtils.getEndDay(), tagId);
|
DateUtils.getBeginDay() - 3600 * 48, DateUtils.getEndDay(), groupId, tagId);
|
||||||
// log.info("rewardsql:" + rewardsql);
|
log.info("rewardsql:" + rewardsql);
|
||||||
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
||||||
if (rewardArray.size() != 0) {
|
if (rewardArray.size() != 0) {
|
||||||
ITObject rewardData = rewardArray.getTObject(0);
|
ITObject rewardData = rewardArray.getTObject(0);
|
||||||
|
|
@ -1368,7 +1627,7 @@ public class GroupService {
|
||||||
|
|
||||||
resData.putLong("day_rewad_1", day_rewad_1);
|
resData.putLong("day_rewad_1", day_rewad_1);
|
||||||
resData.putLong("day_rewad_2", day_rewad_2);
|
resData.putLong("day_rewad_2", day_rewad_2);
|
||||||
log.info("resData:"+resData);
|
log.info("resData:" + resData);
|
||||||
return resData;
|
return resData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1496,11 +1755,19 @@ public class GroupService {
|
||||||
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||||
int _r_hp = arr.get(0).intValue();
|
int _r_hp = arr.get(0).intValue();
|
||||||
int mhp = arr.get(1).intValue();
|
int mhp = arr.get(1).intValue();
|
||||||
String sql = String.format("{call sp_take_reward_hp(%s,%s,%s,%s)}", groupId, tagId, (int) hp, mhp);
|
// String sql = String.format("{call sp_take_reward_hp(%s,%s,%s,%s)}", groupId, tagId, (int) hp, mhp);
|
||||||
Utility.evtdb(groupId, 2, sql);
|
// Utility.evtdb(groupId, 2, sql);
|
||||||
sql = String.format("update group_member set reward_hp = %s where uid = %s AND groupId = %s", _r_hp,
|
String sql = String.format("update group_member set reward_hp = reward_hp-%s,hp=hp+%s where uid = %s AND groupId = %s", hp,hp,
|
||||||
tagId, groupId);
|
tagId, groupId);
|
||||||
Utility.evtdb(groupId, 1, sql);
|
Utility.evtdb(groupId, 1, sql);
|
||||||
|
log.info("提取sql:" + sql);
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, tagId, ConsumeCode.HP_TAKE_REWARD, hp , _r_hp, 0,
|
||||||
|
System.currentTimeMillis()/1000);
|
||||||
|
Utility.evtdb(groupId, 1, sql);
|
||||||
|
|
||||||
ITObject resData = TObject.newInstance();
|
ITObject resData = TObject.newInstance();
|
||||||
resData.putInt("hp", mhp);
|
resData.putInt("hp", mhp);
|
||||||
resData.putLong("r_hp", _r_hp);
|
resData.putLong("r_hp", _r_hp);
|
||||||
|
|
@ -1731,11 +1998,18 @@ public class GroupService {
|
||||||
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||||
long mhp = arr.get(0).longValue();
|
long mhp = arr.get(0).longValue();
|
||||||
long b_hp = arr.get(1).longValue();
|
long b_hp = arr.get(1).longValue();
|
||||||
String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, -(int) hp, mhp);
|
// String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, -(int) hp, mhp);
|
||||||
Utility.evtdb(groupId, 2, sql);
|
// Utility.evtdb(groupId, 2, sql);
|
||||||
sql = String.format("update group_member set bank_hp = %s,hp=hp+%s where uid = %s AND groupId = %s",
|
|
||||||
b_hp, hp, tagId, groupId);
|
String sql = String.format("update group_member set bank_hp = bank_hp-%s,hp=hp+%s where uid = %s AND groupId = %s",
|
||||||
|
hp, hp, tagId, groupId);
|
||||||
|
Utility.evtdb(groupId, 1, sql);
|
||||||
log.info("取出sql:" + sql);
|
log.info("取出sql:" + sql);
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, uid, ConsumeCode.HP_TAKE_BANK, -hp , b_hp, 0,
|
||||||
|
System.currentTimeMillis()/1000);
|
||||||
Utility.evtdb(groupId, 1, sql);
|
Utility.evtdb(groupId, 1, sql);
|
||||||
ITObject resData = TObject.newInstance();
|
ITObject resData = TObject.newInstance();
|
||||||
resData.putLong("hp", mhp);
|
resData.putLong("hp", mhp);
|
||||||
|
|
@ -1809,12 +2083,20 @@ public class GroupService {
|
||||||
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||||
long mhp = arr.get(0).longValue();
|
long mhp = arr.get(0).longValue();
|
||||||
long b_hp = arr.get(1).longValue();
|
long b_hp = arr.get(1).longValue();
|
||||||
String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, hp, mhp);
|
// String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, hp, mhp);
|
||||||
Utility.evtdb(groupId, 2, sql);
|
// Utility.evtdb(groupId, 2, sql);
|
||||||
|
|
||||||
sql = String.format("update group_member set bank_hp = %s,hp=hp-%s where uid = %s AND groupId = %s",
|
String sql = String.format("update group_member set bank_hp =bank_hp+ %s,hp=hp-%s where uid = %s AND groupId = %s",
|
||||||
b_hp, hp, tagId, groupId);
|
hp, hp, tagId, groupId);
|
||||||
Utility.evtdb(groupId, 1, sql);
|
Utility.evtdb(groupId, 1, sql);
|
||||||
|
|
||||||
|
sql = String.format(
|
||||||
|
"INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,roomid,time) "
|
||||||
|
+ "VALUES(%s,%s,%s,%s,%s,%s,'',%s)",
|
||||||
|
groupId, uid, ConsumeCode.HP_SAVE_BANK, hp , b_hp, 0,
|
||||||
|
System.currentTimeMillis()/1000);
|
||||||
|
Utility.evtdb(groupId, 1, sql);
|
||||||
|
|
||||||
|
|
||||||
ITObject resData = TObject.newInstance();
|
ITObject resData = TObject.newInstance();
|
||||||
resData.putLong("hp", mhp);
|
resData.putLong("hp", mhp);
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ package com.mjlogin;
|
||||||
|
|
||||||
public class Protocol {
|
public class Protocol {
|
||||||
// ======AccountService
|
// ======AccountService
|
||||||
public static final String REGIST_LOGIN = "regist_login";
|
// public static final String REGIST_LOGIN = "regist_login";
|
||||||
|
|
||||||
public static final String REGIST_LOGIN_2 = "regist_login_2";
|
// public static final String REGIST_LOGIN_2 = "regist_login_2";
|
||||||
|
|
||||||
|
|
||||||
public static final String REGIST_LOGIN_3 = "regist_login_3";
|
public static final String REGIST_LOGIN_3 = "regist_login_3";
|
||||||
|
|
|
||||||
|
|
@ -563,301 +563,301 @@ public class AccountService extends Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 登录
|
// * 登录
|
||||||
*
|
// *
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
@ActionKey(value = Protocol.REGIST_LOGIN)
|
// @ActionKey(value = Protocol.REGIST_LOGIN)
|
||||||
public final void login() throws Exception {
|
// public final void login() throws Exception {
|
||||||
ITObject reqData = this.getParams();
|
// ITObject reqData = this.getParams();
|
||||||
String acc = reqData.getUtfString("acc");
|
// String acc = reqData.getUtfString("acc");
|
||||||
logger.info("acc:" + acc + " regist login");
|
// logger.info("acc:" + acc + " regist login");
|
||||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
// Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||||
RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
// RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
||||||
String deviceCode = reqData.getUtfString("deviceCode");
|
// String deviceCode = reqData.getUtfString("deviceCode");
|
||||||
logger.info("deviceCode:" + deviceCode);
|
// logger.info("deviceCode:" + deviceCode);
|
||||||
logger.info("reqData:" + reqData);
|
// logger.info("reqData:" + reqData);
|
||||||
|
//
|
||||||
boolean havePassword = false;
|
// boolean havePassword = false;
|
||||||
if (acc.length() < 10) {
|
// if (acc.length() < 10) {
|
||||||
throw new WebException(ErrorCode._FAILED);
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
// String sql = "SELECT id FROM account WHERE acc ='" + acc + "'";
|
//// String sql = "SELECT id FROM account WHERE acc ='" + acc + "'";
|
||||||
// ITArray resultArray = DataBase.use().executeQueryByTArray(sql);
|
//// ITArray resultArray = DataBase.use().executeQueryByTArray(sql);
|
||||||
String sql = "SELECT id FROM account WHERE acc =?";
|
// String sql = "SELECT id FROM account WHERE acc =?";
|
||||||
String[] params2 = new String[1];
|
// String[] params2 = new String[1];
|
||||||
params2[0] = acc + "";
|
// params2[0] = acc + "";
|
||||||
|
//
|
||||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params2);
|
// ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params2);
|
||||||
|
//
|
||||||
String strNick = reqData.getUtfString("nick");
|
// String strNick = reqData.getUtfString("nick");
|
||||||
strNick = StringUtil.filterEmoji(strNick);
|
// strNick = StringUtil.filterEmoji(strNick);
|
||||||
reqData.putUtfString("nick", strNick);
|
// reqData.putUtfString("nick", strNick);
|
||||||
|
//
|
||||||
// String nickCountsql = String.format(
|
//// String nickCountsql = String.format(
|
||||||
// "SELECT id FROM account a,group_member gm WHERE a.id=gm.uid and a.nick ='%s' and a.device_code='%s'",
|
//// "SELECT id FROM account a,group_member gm WHERE a.id=gm.uid and a.nick ='%s' and a.device_code='%s'",
|
||||||
// strNick, deviceCode);
|
//// strNick, deviceCode);
|
||||||
// String nickCountsql = "SELECT id FROM account a,group_member gm WHERE a.id=gm.uid and a.nick ='" + strNick
|
//// String nickCountsql = "SELECT id FROM account a,group_member gm WHERE a.id=gm.uid and a.nick ='" + strNick
|
||||||
// + "'";
|
//// + "'";
|
||||||
|
//
|
||||||
// List<Map<String, String>> nickDeviceCount = DataBase.use().executeQuery(nickCountsql);
|
//// List<Map<String, String>> nickDeviceCount = DataBase.use().executeQuery(nickCountsql);
|
||||||
|
//
|
||||||
int accountid = 0;
|
// int accountid = 0;
|
||||||
if (resultArray.size() == 0) {
|
// if (resultArray.size() == 0) {
|
||||||
accountid = register(reqData);
|
// accountid = register(reqData);
|
||||||
reqData.putUtfString("isBangding", "0");
|
// reqData.putUtfString("isBangding", "0");
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
ITObject obj = resultArray.getTObject(0);
|
// ITObject obj = resultArray.getTObject(0);
|
||||||
accountid = obj.getInt("id");
|
// accountid = obj.getInt("id");
|
||||||
String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
// String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
||||||
+ accountid;
|
// + accountid;
|
||||||
DataBase.use().executeUpdate(updateDeviceCodeSql);
|
// DataBase.use().executeUpdate(updateDeviceCodeSql);
|
||||||
reqData.putUtfString("isBangding", obj.getInt("is_bangding") + "");
|
// reqData.putUtfString("isBangding", obj.getInt("is_bangding") + "");
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (acc.equals(accountid + "")) {
|
// if (acc.equals(accountid + "")) {
|
||||||
logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
// logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
||||||
throw new WebException(ErrorCode._FAILED);
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
AccountBean acc_bean = AccountCache.getAccount(accountid);
|
// AccountBean acc_bean = AccountCache.getAccount(accountid);
|
||||||
if (acc_bean == null) {
|
// if (acc_bean == null) {
|
||||||
sql = String.format("SELECT * FROM account WHERE id =?");
|
// sql = String.format("SELECT * FROM account WHERE id =?");
|
||||||
String[] params = new String[1];
|
// String[] params = new String[1];
|
||||||
params[0] = accountid + "";
|
// params[0] = accountid + "";
|
||||||
|
//
|
||||||
ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
// ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
||||||
if (resultArray2.size() == 0) {
|
// if (resultArray2.size() == 0) {
|
||||||
throw new WebException(ErrorCode._FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
ITObject userData = resultArray2.getTObject(0);
|
|
||||||
UpdateUserData(userData, accountid);
|
|
||||||
|
|
||||||
acc_bean = AccountCache.getAccount(accountid);
|
|
||||||
}
|
|
||||||
String session = acc_bean.redis_key;
|
|
||||||
this.setSession(session);
|
|
||||||
|
|
||||||
if (resultArray.size() > 0) {
|
|
||||||
this.setSession(session);
|
|
||||||
String old_nick = acc_bean.nick;
|
|
||||||
String old_portrait = acc_bean.portrait;
|
|
||||||
String new_nick = reqData.getUtfString("nick");
|
|
||||||
String new_portrait = reqData.getUtfString("portrait");
|
|
||||||
if (!old_nick.equals(new_nick) || !old_portrait.equals(new_portrait)) {
|
|
||||||
ITObject userData = TObject.newInstance();
|
|
||||||
userData.putUtfString("nick", reqData.getUtfString("nick"));
|
|
||||||
userData.putUtfString("portrait", reqData.getUtfString("portrait"));
|
|
||||||
userData.putInt("sex", reqData.getInt("sex"));
|
|
||||||
updateSession(reqData, accountid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// password不存在则叫用户重置密码
|
|
||||||
String passwordsql = String.format("SELECT password FROM account WHERE id =?");
|
|
||||||
String[] params = new String[1];
|
|
||||||
params[0] = acc_bean.id + "";
|
|
||||||
|
|
||||||
ITArray passwordArray = DataBase.use().executeQueryByTArrayLogin(passwordsql, params);
|
|
||||||
if (passwordArray.size() > 0) {
|
|
||||||
ITObject userData = passwordArray.getTObject(0);
|
|
||||||
String password = userData.getString("password");
|
|
||||||
if (password == null || password.length() == 0) {
|
|
||||||
havePassword = false;
|
|
||||||
} else {
|
|
||||||
havePassword = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String idPwdBan = Redis.use("group1_db0").get(acc_bean.id + "_login_ban");
|
|
||||||
if (StringUtil.isNotEmpty(idPwdBan)) {
|
|
||||||
logger.error("id:" + acc_bean.id + " ban login");
|
|
||||||
throw new WebException(ErrorCode.BAN_LOGIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
ITObject resData = fillLoginData(session, accountid);
|
|
||||||
String token = Utils.getMD5Hash(acc + "_" + accountid + "_" + System.currentTimeMillis()
|
|
||||||
+ "e4!Fesu]]{QyUuEA" + Math.random() * 1000000);
|
|
||||||
|
|
||||||
Redis.use("group1_db0").sadd(session + "_token", token);
|
|
||||||
|
|
||||||
Redis.use("group1_db0").hset(token, "user", session);
|
|
||||||
Redis.use("group1_db0").hset(token, "create_time", "" + System.currentTimeMillis() / 1000);
|
|
||||||
Redis.use("group1_db0").expire(token, 172800);
|
|
||||||
|
|
||||||
Set<String> allToken = Redis.use("group1_db0").smembers(session + "_token");
|
|
||||||
for (String temp : allToken) {
|
|
||||||
if (!Redis.use("group1_db0").exists(temp)) {
|
|
||||||
Redis.use("group1_db0").srem(session + "_token", temp);
|
|
||||||
logger.info("delte timeout token:" + temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long tokenNum = Redis.use("group1_db0").scard(session + "_token");
|
|
||||||
if (tokenNum >= 10) {
|
|
||||||
logger.warn("id:" + accountid + " repeat login, token count:" + tokenNum);
|
|
||||||
}
|
|
||||||
resData.putString("token", token);
|
|
||||||
resData.putBoolean("havePassword", true);
|
|
||||||
resData.putBoolean("havegroup", true);
|
|
||||||
|
|
||||||
// // 判断是否已经进入圈子
|
|
||||||
// String haveGroupsql = String.format("SELECT uid,partnerLev FROM group_member gm WHERE gm.uid ='%d'",
|
|
||||||
// accountid);
|
|
||||||
// List<Map<String, String>> haveGroupsqlCount = DataBase.use().executeQuery(haveGroupsql);
|
|
||||||
// if (haveGroupsqlCount.size() > 0) {
|
|
||||||
// // 这里只能判断第一条数据,如果多个大联盟需要区分哪个联盟的代理
|
|
||||||
// int partnerLev = haveGroupsqlCount.get(0).get("partnerLev") == null ? 0
|
|
||||||
// : Integer.parseInt(haveGroupsqlCount.get(0).get("partnerLev"));
|
|
||||||
// if (partnerLev > 0) {
|
|
||||||
// throw new WebException(ErrorCode._FAILED);
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
// }
|
// }
|
||||||
// resData.putBoolean("havegroup", true);
|
//
|
||||||
// } else {
|
// ITObject userData = resultArray2.getTObject(0);
|
||||||
// resData.putBoolean("havegroup", false);
|
// UpdateUserData(userData, accountid);
|
||||||
|
//
|
||||||
|
// acc_bean = AccountCache.getAccount(accountid);
|
||||||
// }
|
// }
|
||||||
// logger.info("havePassword:" + resData.getBoolean("havePassword"));
|
// String session = acc_bean.redis_key;
|
||||||
// logger.info("havegroup:" + resData.getBoolean("havegroup"));
|
// this.setSession(session);
|
||||||
|
//
|
||||||
|
// if (resultArray.size() > 0) {
|
||||||
|
// this.setSession(session);
|
||||||
|
// String old_nick = acc_bean.nick;
|
||||||
|
// String old_portrait = acc_bean.portrait;
|
||||||
|
// String new_nick = reqData.getUtfString("nick");
|
||||||
|
// String new_portrait = reqData.getUtfString("portrait");
|
||||||
|
// if (!old_nick.equals(new_nick) || !old_portrait.equals(new_portrait)) {
|
||||||
|
// ITObject userData = TObject.newInstance();
|
||||||
|
// userData.putUtfString("nick", reqData.getUtfString("nick"));
|
||||||
|
// userData.putUtfString("portrait", reqData.getUtfString("portrait"));
|
||||||
|
// userData.putInt("sex", reqData.getInt("sex"));
|
||||||
|
// updateSession(reqData, accountid);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // password不存在则叫用户重置密码
|
||||||
|
// String passwordsql = String.format("SELECT password FROM account WHERE id =?");
|
||||||
|
// String[] params = new String[1];
|
||||||
|
// params[0] = acc_bean.id + "";
|
||||||
|
//
|
||||||
|
// ITArray passwordArray = DataBase.use().executeQueryByTArrayLogin(passwordsql, params);
|
||||||
|
// if (passwordArray.size() > 0) {
|
||||||
|
// ITObject userData = passwordArray.getTObject(0);
|
||||||
|
// String password = userData.getString("password");
|
||||||
|
// if (password == null || password.length() == 0) {
|
||||||
|
// havePassword = false;
|
||||||
|
// } else {
|
||||||
|
// havePassword = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// String idPwdBan = Redis.use("group1_db0").get(acc_bean.id + "_login_ban");
|
||||||
|
// if (StringUtil.isNotEmpty(idPwdBan)) {
|
||||||
|
// logger.error("id:" + acc_bean.id + " ban login");
|
||||||
|
// throw new WebException(ErrorCode.BAN_LOGIN);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ITObject resData = fillLoginData(session, accountid);
|
||||||
|
// String token = Utils.getMD5Hash(acc + "_" + accountid + "_" + System.currentTimeMillis()
|
||||||
|
// + "e4!Fesu]]{QyUuEA" + Math.random() * 1000000);
|
||||||
|
//
|
||||||
|
// Redis.use("group1_db0").sadd(session + "_token", token);
|
||||||
|
//
|
||||||
|
// Redis.use("group1_db0").hset(token, "user", session);
|
||||||
|
// Redis.use("group1_db0").hset(token, "create_time", "" + System.currentTimeMillis() / 1000);
|
||||||
|
// Redis.use("group1_db0").expire(token, 172800);
|
||||||
|
//
|
||||||
|
// Set<String> allToken = Redis.use("group1_db0").smembers(session + "_token");
|
||||||
|
// for (String temp : allToken) {
|
||||||
|
// if (!Redis.use("group1_db0").exists(temp)) {
|
||||||
|
// Redis.use("group1_db0").srem(session + "_token", temp);
|
||||||
|
// logger.info("delte timeout token:" + temp);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// long tokenNum = Redis.use("group1_db0").scard(session + "_token");
|
||||||
|
// if (tokenNum >= 10) {
|
||||||
|
// logger.warn("id:" + accountid + " repeat login, token count:" + tokenNum);
|
||||||
|
// }
|
||||||
|
// resData.putString("token", token);
|
||||||
|
// resData.putBoolean("havePassword", true);
|
||||||
|
// resData.putBoolean("havegroup", true);
|
||||||
|
//
|
||||||
|
//// // 判断是否已经进入圈子
|
||||||
|
//// String haveGroupsql = String.format("SELECT uid,partnerLev FROM group_member gm WHERE gm.uid ='%d'",
|
||||||
|
//// accountid);
|
||||||
|
//// List<Map<String, String>> haveGroupsqlCount = DataBase.use().executeQuery(haveGroupsql);
|
||||||
|
//// if (haveGroupsqlCount.size() > 0) {
|
||||||
|
//// // 这里只能判断第一条数据,如果多个大联盟需要区分哪个联盟的代理
|
||||||
|
//// int partnerLev = haveGroupsqlCount.get(0).get("partnerLev") == null ? 0
|
||||||
|
//// : Integer.parseInt(haveGroupsqlCount.get(0).get("partnerLev"));
|
||||||
|
//// if (partnerLev > 0) {
|
||||||
|
//// throw new WebException(ErrorCode._FAILED);
|
||||||
|
//// }
|
||||||
|
//// resData.putBoolean("havegroup", true);
|
||||||
|
//// } else {
|
||||||
|
//// resData.putBoolean("havegroup", false);
|
||||||
|
//// }
|
||||||
|
//// logger.info("havePassword:" + resData.getBoolean("havePassword"));
|
||||||
|
//// logger.info("havegroup:" + resData.getBoolean("havegroup"));
|
||||||
|
//
|
||||||
|
// this.sendResponse(ErrorCode._SUCC, resData);
|
||||||
|
// } finally {
|
||||||
|
// lock.unlock();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
this.sendResponse(ErrorCode._SUCC, resData);
|
// /**
|
||||||
} finally {
|
// * 加密登录2
|
||||||
lock.unlock();
|
// *
|
||||||
}
|
// * @throws Exception
|
||||||
}
|
// */
|
||||||
|
// @ActionKey(value = Protocol.REGIST_LOGIN_2)
|
||||||
/**
|
// public final void login2() throws Exception {
|
||||||
* 加密登录2
|
// ITObject reqData = this.getParams();
|
||||||
*
|
//
|
||||||
* @throws Exception
|
// String decryptedText = RSAUtils.decrypt(reqData.getString("data"));
|
||||||
*/
|
// JsonObject object = new Gson().fromJson(decryptedText, JsonObject.class);
|
||||||
@ActionKey(value = Protocol.REGIST_LOGIN_2)
|
// String deviceCode = object.get("deviceCode").toString().replaceAll("\"", "");
|
||||||
public final void login2() throws Exception {
|
// String acc = object.get("acc").toString().replaceAll("\"", "");
|
||||||
ITObject reqData = this.getParams();
|
// reqData.putUtfString("acc", acc);
|
||||||
|
// Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||||
String decryptedText = RSAUtils.decrypt(reqData.getString("data"));
|
// RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
||||||
JsonObject object = new Gson().fromJson(decryptedText, JsonObject.class);
|
// logger.info("解密后:" + object);
|
||||||
String deviceCode = object.get("deviceCode").toString().replaceAll("\"", "");
|
//// owbRv6qRVVrnzmDpk0vh3fV1iH1Q
|
||||||
String acc = object.get("acc").toString().replaceAll("\"", "");
|
// boolean havePassword = false;
|
||||||
reqData.putUtfString("acc", acc);
|
// int isBangding = 0;
|
||||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
//
|
||||||
RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
// try {
|
||||||
logger.info("解密后:" + object);
|
// String sql = "SELECT * FROM account WHERE acc =?";
|
||||||
// owbRv6qRVVrnzmDpk0vh3fV1iH1Q
|
// String[] params = new String[1];
|
||||||
boolean havePassword = false;
|
// params[0] = reqData.getUtfString("acc") + "";
|
||||||
int isBangding = 0;
|
// ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
||||||
|
//
|
||||||
try {
|
// String strNick = object.get("nick").toString().replaceAll("\"", "");
|
||||||
String sql = "SELECT * FROM account WHERE acc =?";
|
// strNick = StringUtil.filterEmoji(strNick);
|
||||||
String[] params = new String[1];
|
// reqData.putUtfString("nick", strNick);
|
||||||
params[0] = reqData.getUtfString("acc") + "";
|
// int accountid = 0;
|
||||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
// if (resultArray.size() == 0) {
|
||||||
|
// reqData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
||||||
String strNick = object.get("nick").toString().replaceAll("\"", "");
|
// accountid = register(reqData);
|
||||||
strNick = StringUtil.filterEmoji(strNick);
|
// } else {
|
||||||
reqData.putUtfString("nick", strNick);
|
// ITObject obj = resultArray.getTObject(0);
|
||||||
int accountid = 0;
|
// accountid = obj.getInt("id");
|
||||||
if (resultArray.size() == 0) {
|
// String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
||||||
reqData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
// + accountid;
|
||||||
accountid = register(reqData);
|
// DataBase.use().executeUpdate(updateDeviceCodeSql);
|
||||||
} else {
|
// isBangding = obj.getInt("is_bangding");
|
||||||
ITObject obj = resultArray.getTObject(0);
|
//
|
||||||
accountid = obj.getInt("id");
|
// }
|
||||||
String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
//
|
||||||
+ accountid;
|
// if (acc.equals(accountid + "")) {
|
||||||
DataBase.use().executeUpdate(updateDeviceCodeSql);
|
// logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
||||||
isBangding = obj.getInt("is_bangding");
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
// AccountBean acc_bean = AccountCache.getAccount(accountid);
|
||||||
if (acc.equals(accountid + "")) {
|
// if (acc_bean == null) {
|
||||||
logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
// sql = String.format("SELECT * FROM account WHERE id =?");
|
||||||
throw new WebException(ErrorCode._FAILED);
|
// String[] params1 = new String[1];
|
||||||
}
|
// params1[0] = accountid + "";
|
||||||
|
//
|
||||||
AccountBean acc_bean = AccountCache.getAccount(accountid);
|
// ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||||
if (acc_bean == null) {
|
// if (resultArray2.size() == 0) {
|
||||||
sql = String.format("SELECT * FROM account WHERE id =?");
|
// throw new WebException(ErrorCode._FAILED);
|
||||||
String[] params1 = new String[1];
|
// }
|
||||||
params1[0] = accountid + "";
|
//
|
||||||
|
// ITObject userData = resultArray2.getTObject(0);
|
||||||
ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
// UpdateUserData(userData, accountid);
|
||||||
if (resultArray2.size() == 0) {
|
//
|
||||||
throw new WebException(ErrorCode._FAILED);
|
// acc_bean = AccountCache.getAccount(accountid);
|
||||||
}
|
// }
|
||||||
|
// String session = acc_bean.redis_key;
|
||||||
ITObject userData = resultArray2.getTObject(0);
|
// this.setSession(session);
|
||||||
UpdateUserData(userData, accountid);
|
//
|
||||||
|
// if (resultArray.size() > 0) {
|
||||||
acc_bean = AccountCache.getAccount(accountid);
|
// this.setSession(session);
|
||||||
}
|
// String old_nick = acc_bean.nick;
|
||||||
String session = acc_bean.redis_key;
|
// String old_portrait = acc_bean.portrait;
|
||||||
this.setSession(session);
|
// String new_nick = reqData.getUtfString("nick");
|
||||||
|
// String new_portrait = reqData.getUtfString("portrait");
|
||||||
if (resultArray.size() > 0) {
|
// if (!old_nick.equals(new_nick) || !old_portrait.equals(new_portrait)) {
|
||||||
this.setSession(session);
|
// ITObject userData = TObject.newInstance();
|
||||||
String old_nick = acc_bean.nick;
|
// userData.putUtfString("nick", object.get("nick").toString().replaceAll("\"", ""));
|
||||||
String old_portrait = acc_bean.portrait;
|
// userData.putUtfString("portrait", object.get("portrait").toString().replaceAll("\"", ""));
|
||||||
String new_nick = reqData.getUtfString("nick");
|
// userData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
||||||
String new_portrait = reqData.getUtfString("portrait");
|
// updateSession(reqData, accountid);
|
||||||
if (!old_nick.equals(new_nick) || !old_portrait.equals(new_portrait)) {
|
// }
|
||||||
ITObject userData = TObject.newInstance();
|
// }
|
||||||
userData.putUtfString("nick", object.get("nick").toString().replaceAll("\"", ""));
|
//
|
||||||
userData.putUtfString("portrait", object.get("portrait").toString().replaceAll("\"", ""));
|
// String idPwdBan = Redis.use("group1_db0").get(acc_bean.id + "_login_ban");
|
||||||
userData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
// if (StringUtil.isNotEmpty(idPwdBan)) {
|
||||||
updateSession(reqData, accountid);
|
// logger.error("id:" + acc_bean.id + " ban login");
|
||||||
}
|
// throw new WebException(ErrorCode.BAN_LOGIN);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String idPwdBan = Redis.use("group1_db0").get(acc_bean.id + "_login_ban");
|
// ITObject resData = fillLoginData(session, accountid);
|
||||||
if (StringUtil.isNotEmpty(idPwdBan)) {
|
// String token = Utils.getMD5Hash(acc + "_" + accountid + "_" + System.currentTimeMillis()
|
||||||
logger.error("id:" + acc_bean.id + " ban login");
|
// + "e4!Fesu]]{QyUuEA" + Math.random() * 1000000);
|
||||||
throw new WebException(ErrorCode.BAN_LOGIN);
|
//
|
||||||
}
|
// Redis.use("group1_db0").sadd(session + "_token", token);
|
||||||
|
//
|
||||||
ITObject resData = fillLoginData(session, accountid);
|
// Redis.use("group1_db0").hset(token, "user", session);
|
||||||
String token = Utils.getMD5Hash(acc + "_" + accountid + "_" + System.currentTimeMillis()
|
// Redis.use("group1_db0").hset(token, "create_time", "" + System.currentTimeMillis() / 1000);
|
||||||
+ "e4!Fesu]]{QyUuEA" + Math.random() * 1000000);
|
// Redis.use("group1_db0").expire(token, 172800);
|
||||||
|
//
|
||||||
Redis.use("group1_db0").sadd(session + "_token", token);
|
// Set<String> allToken = Redis.use("group1_db0").smembers(session + "_token");
|
||||||
|
// for (String temp : allToken) {
|
||||||
Redis.use("group1_db0").hset(token, "user", session);
|
// if (!Redis.use("group1_db0").exists(temp)) {
|
||||||
Redis.use("group1_db0").hset(token, "create_time", "" + System.currentTimeMillis() / 1000);
|
// Redis.use("group1_db0").srem(session + "_token", temp);
|
||||||
Redis.use("group1_db0").expire(token, 172800);
|
// logger.info("delte timeout token:" + temp);
|
||||||
|
// }
|
||||||
Set<String> allToken = Redis.use("group1_db0").smembers(session + "_token");
|
// }
|
||||||
for (String temp : allToken) {
|
//
|
||||||
if (!Redis.use("group1_db0").exists(temp)) {
|
// long tokenNum = Redis.use("group1_db0").scard(session + "_token");
|
||||||
Redis.use("group1_db0").srem(session + "_token", temp);
|
// if (tokenNum >= 10) {
|
||||||
logger.info("delte timeout token:" + temp);
|
// logger.warn("id:" + accountid + " repeat login, token count:" + tokenNum);
|
||||||
}
|
// }
|
||||||
}
|
// resData.putString("token", token);
|
||||||
|
// resData.putBoolean("havePassword", true);
|
||||||
long tokenNum = Redis.use("group1_db0").scard(session + "_token");
|
// resData.putBoolean("havegroup", true);
|
||||||
if (tokenNum >= 10) {
|
// resData.putString("isBangding", "1");
|
||||||
logger.warn("id:" + accountid + " repeat login, token count:" + tokenNum);
|
//
|
||||||
}
|
//// // 默认锁住账户
|
||||||
resData.putString("token", token);
|
//// String lockSql = "update account set is_lock=? WHERE id=?";
|
||||||
resData.putBoolean("havePassword", true);
|
//// String[] params3 = new String[2];
|
||||||
resData.putBoolean("havegroup", true);
|
//// params3[0] = 1 + "";
|
||||||
resData.putString("isBangding", "1");
|
//// params3[1] = accountid + "";
|
||||||
|
// //
|
||||||
// // 默认锁住账户
|
//// DataBase.use().executeUpdateLogin(lockSql, params3);
|
||||||
// String lockSql = "update account set is_lock=? WHERE id=?";
|
//
|
||||||
// String[] params3 = new String[2];
|
// this.sendResponse(ErrorCode._SUCC, resData);
|
||||||
// params3[0] = 1 + "";
|
// } finally {
|
||||||
// params3[1] = accountid + "";
|
// lock.unlock();
|
||||||
//
|
// }
|
||||||
// DataBase.use().executeUpdateLogin(lockSql, params3);
|
// }
|
||||||
|
|
||||||
this.sendResponse(ErrorCode._SUCC, resData);
|
|
||||||
} finally {
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue