增加登录接口,修改存储过程
parent
e1b9392271
commit
eeba27679b
|
|
@ -640,7 +640,9 @@ public class GameController implements IController {
|
|||
owner.destroy(true);
|
||||
|
||||
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)) {
|
||||
ITObject data = new TObject();
|
||||
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.routes.ActionKey;
|
||||
import com.taurus.core.util.StringUtil;
|
||||
import com.taurus.core.util.Utils;
|
||||
import com.taurus.web.Controller;
|
||||
import com.taurus.web.WebException;
|
||||
|
||||
|
|
@ -487,39 +488,39 @@ public class GroupController extends Controller {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建圈子玩法
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ActionKey(value = Protocol.UPDATE_PLAY, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
|
||||
| WebInterceptor.V_GROUP_MGR | WebInterceptor.V_GROUP_PLAY)
|
||||
public final void updatePlay() throws Exception {
|
||||
ITObject reqData = this.getParams();
|
||||
|
||||
int groupId = reqData.getInt("id");
|
||||
int groupType = reqData.getInt("gtype");
|
||||
int hpOnOff = reqData.getInt("hpOnOff");
|
||||
if (hpOnOff == 0 && groupType == 2) {
|
||||
throw new WebException(ErrorCode.GROUP_TYPE2_MUST_HP);
|
||||
}
|
||||
int pid = reqData.getInt("pid");
|
||||
int gameId = reqData.getInt("gameId");
|
||||
ITObject config = reqData.getTObject("config");
|
||||
String name = reqData.getString("name");
|
||||
ITObject hpData = reqData.getTObject("hpData");
|
||||
int deskId = reqData.containsKey("deskId") ? reqData.getInt("deskId") : 0;
|
||||
|
||||
GroupService.updatePlay(groupId, pid, gameId, name, deskId, config, hpData, hpOnOff);
|
||||
int maxPlayers = config.getInt("maxPlayers");
|
||||
int maxRound = config.getInt("maxRound");
|
||||
|
||||
ITObject params = TObject.newInstance();
|
||||
params.putInt("maxPlayers", maxPlayers);
|
||||
params.putInt("maxRound", maxRound);
|
||||
|
||||
this.sendResponse(0, params);
|
||||
}
|
||||
// /**
|
||||
// * 修改圈子玩法
|
||||
// *
|
||||
// * @throws Exception
|
||||
// */
|
||||
// @ActionKey(value = Protocol.UPDATE_PLAY, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
|
||||
// | WebInterceptor.V_GROUP_MGR | WebInterceptor.V_GROUP_PLAY)
|
||||
// public final void updatePlay() throws Exception {
|
||||
// ITObject reqData = this.getParams();
|
||||
//
|
||||
// int groupId = reqData.getInt("id");
|
||||
// int groupType = reqData.getInt("gtype");
|
||||
// int hpOnOff = reqData.getInt("hpOnOff");
|
||||
// if (hpOnOff == 0 && groupType == 2) {
|
||||
// throw new WebException(ErrorCode.GROUP_TYPE2_MUST_HP);
|
||||
// }
|
||||
// int pid = reqData.getInt("pid");
|
||||
// int gameId = reqData.getInt("gameId");
|
||||
// ITObject config = reqData.getTObject("config");
|
||||
// String name = reqData.getString("name");
|
||||
// ITObject hpData = reqData.getTObject("hpData");
|
||||
// int deskId = reqData.containsKey("deskId") ? reqData.getInt("deskId") : 0;
|
||||
//
|
||||
// GroupService.updatePlay(groupId, pid, gameId, name, deskId, config, hpData, hpOnOff);
|
||||
// int maxPlayers = config.getInt("maxPlayers");
|
||||
// int maxRound = config.getInt("maxRound");
|
||||
//
|
||||
// ITObject params = TObject.newInstance();
|
||||
// params.putInt("maxPlayers", maxPlayers);
|
||||
// params.putInt("maxRound", maxRound);
|
||||
//
|
||||
// this.sendResponse(0, params);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除圈子玩法
|
||||
|
|
@ -1565,21 +1566,21 @@ public class GroupController extends Controller {
|
|||
sendResponse(0, resData);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 重置用户密码
|
||||
// */
|
||||
// @ActionKey(value = Protocol.GROUP_RESET_PASSWORD, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP)
|
||||
// public final void resetPassword() throws Exception {
|
||||
// ITObject reqData = this.getParams();
|
||||
// String session = this.getSession();
|
||||
// int tagId = reqData.getInt("tagId");
|
||||
// String password = reqData.getString("password");
|
||||
//
|
||||
//// AccountBean acc = AccountCache.getAccount(session);
|
||||
// String sql = "UPDATE account SET password='" + Utils.getMD5Hash(password) + "' where id=" + tagId;
|
||||
// DataBase.use().executeUpdate(sql);
|
||||
// this.sendResponse(0, null);
|
||||
// }
|
||||
/**
|
||||
* 重置用户密码
|
||||
*/
|
||||
@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 {
|
||||
ITObject reqData = this.getParams();
|
||||
String session = this.getSession();
|
||||
int tagId = reqData.getInt("tagId");
|
||||
String password = reqData.getString("password");
|
||||
|
||||
// AccountBean acc = AccountCache.getAccount(session);
|
||||
String sql = "UPDATE account SET password='" + Utils.getMD5Hash(password) + "' where id=" + tagId;
|
||||
DataBase.use().executeUpdate(sql);
|
||||
this.sendResponse(0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置设备锁定状态
|
||||
|
|
|
|||
|
|
@ -1961,8 +1961,8 @@ public class GroupLogService {
|
|||
// resData.putInt("pump", hp_cost);
|
||||
|
||||
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",
|
||||
beginTime, endTime,gb.owner);
|
||||
" 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,gb.owner);
|
||||
// log.info("rewardsql:" + rewardsql);
|
||||
|
||||
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
||||
|
|
|
|||
|
|
@ -120,6 +120,9 @@ public class GroupService {
|
|||
try {
|
||||
ITArray list = TArray.newInstance();
|
||||
String key = GroupCache.genGroupsKey(uid);
|
||||
log.info("key:"+key);
|
||||
log.info("uid:"+uid);
|
||||
|
||||
Set<String> groups = jedis11.zrevrange(key, 0, -1);
|
||||
for (String tem : groups) {
|
||||
ITObject obj = getGroupData(uid, Integer.parseInt(tem), jedis11, jedis10);
|
||||
|
|
@ -667,14 +670,26 @@ public class GroupService {
|
|||
|
||||
try {
|
||||
int mgn_uid = mgn_lev == 3 ? uid : 0;
|
||||
String sql = String.format("{call sp_add_member(%s,%s,%s)}", groupId, mgn_uid, tagId);
|
||||
log.info("addMember addsql:" + sql);
|
||||
Utility.evtdb(groupId, 2, sql);
|
||||
log.info("addMember add:" + groupId + "--" + mgn_uid + "--" + tagId);
|
||||
long time = System.currentTimeMillis() / 1000;
|
||||
// String sql = String.format("{call sp_add_member(%s,%s,%s)}", groupId, mgn_uid, tagId);
|
||||
// Utility.evtdb(groupId, 2, sql);
|
||||
|
||||
// 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);
|
||||
|
||||
long time = System.currentTimeMillis() / 1000;
|
||||
log.info("addMember time:" + time);
|
||||
Map<String, String> redis_map = memberToRedis(groupId + "", tagId, 3, 0, mgn_uid, time);
|
||||
|
||||
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("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);
|
||||
|
||||
String sql = "";
|
||||
|
||||
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();
|
||||
|
|
@ -1325,8 +1583,9 @@ public class GroupService {
|
|||
|
||||
if (gb.owner == tagId) {
|
||||
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",
|
||||
DateUtils.getBeginDay() - 3600 * 48, DateUtils.getEndDay(), gb.owner);
|
||||
" 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, gb.owner);
|
||||
|
||||
// log.info("rewardsql:" + rewardsql);
|
||||
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
||||
if (rewardArray.size() != 0) {
|
||||
|
|
@ -1343,9 +1602,9 @@ public class GroupService {
|
|||
}
|
||||
} else {
|
||||
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",
|
||||
DateUtils.getBeginDay() - 3600 * 48, DateUtils.getEndDay(), tagId);
|
||||
// log.info("rewardsql:" + rewardsql);
|
||||
"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(), groupId, tagId);
|
||||
log.info("rewardsql:" + rewardsql);
|
||||
ITArray rewardArray = DataBase.use().executeQueryByTArray(rewardsql);
|
||||
if (rewardArray.size() != 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_2", day_rewad_2);
|
||||
log.info("resData:"+resData);
|
||||
log.info("resData:" + resData);
|
||||
return resData;
|
||||
}
|
||||
|
||||
|
|
@ -1496,11 +1755,19 @@ public class GroupService {
|
|||
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||
int _r_hp = arr.get(0).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);
|
||||
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("{call sp_take_reward_hp(%s,%s,%s,%s)}", groupId, tagId, (int) hp, mhp);
|
||||
// Utility.evtdb(groupId, 2, sql);
|
||||
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);
|
||||
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();
|
||||
resData.putInt("hp", mhp);
|
||||
resData.putLong("r_hp", _r_hp);
|
||||
|
|
@ -1731,11 +1998,18 @@ public class GroupService {
|
|||
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||
long mhp = arr.get(0).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);
|
||||
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("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, -(int) hp, mhp);
|
||||
// Utility.evtdb(groupId, 2, sql);
|
||||
|
||||
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);
|
||||
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);
|
||||
ITObject resData = TObject.newInstance();
|
||||
resData.putLong("hp", mhp);
|
||||
|
|
@ -1809,12 +2083,20 @@ public class GroupService {
|
|||
ArrayList<Long> arr = (ArrayList<Long>) obj;
|
||||
long mhp = arr.get(0).longValue();
|
||||
long b_hp = arr.get(1).longValue();
|
||||
String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, hp, mhp);
|
||||
Utility.evtdb(groupId, 2, sql);
|
||||
// String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, tagId, hp, mhp);
|
||||
// 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);
|
||||
|
||||
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();
|
||||
resData.putLong("hp", mhp);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package com.mjlogin;
|
|||
|
||||
public class Protocol {
|
||||
// ======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";
|
||||
|
|
|
|||
|
|
@ -563,301 +563,301 @@ public class AccountService extends Controller {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ActionKey(value = Protocol.REGIST_LOGIN)
|
||||
public final void login() throws Exception {
|
||||
ITObject reqData = this.getParams();
|
||||
String acc = reqData.getUtfString("acc");
|
||||
logger.info("acc:" + acc + " regist login");
|
||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
||||
String deviceCode = reqData.getUtfString("deviceCode");
|
||||
logger.info("deviceCode:" + deviceCode);
|
||||
logger.info("reqData:" + reqData);
|
||||
|
||||
boolean havePassword = false;
|
||||
if (acc.length() < 10) {
|
||||
throw new WebException(ErrorCode._FAILED);
|
||||
}
|
||||
try {
|
||||
// String sql = "SELECT id FROM account WHERE acc ='" + acc + "'";
|
||||
// ITArray resultArray = DataBase.use().executeQueryByTArray(sql);
|
||||
String sql = "SELECT id FROM account WHERE acc =?";
|
||||
String[] params2 = new String[1];
|
||||
params2[0] = acc + "";
|
||||
|
||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params2);
|
||||
|
||||
String strNick = reqData.getUtfString("nick");
|
||||
strNick = StringUtil.filterEmoji(strNick);
|
||||
reqData.putUtfString("nick", strNick);
|
||||
|
||||
// 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'",
|
||||
// strNick, deviceCode);
|
||||
// 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);
|
||||
|
||||
int accountid = 0;
|
||||
if (resultArray.size() == 0) {
|
||||
accountid = register(reqData);
|
||||
reqData.putUtfString("isBangding", "0");
|
||||
|
||||
} else {
|
||||
ITObject obj = resultArray.getTObject(0);
|
||||
accountid = obj.getInt("id");
|
||||
String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
||||
+ accountid;
|
||||
DataBase.use().executeUpdate(updateDeviceCodeSql);
|
||||
reqData.putUtfString("isBangding", obj.getInt("is_bangding") + "");
|
||||
|
||||
}
|
||||
|
||||
if (acc.equals(accountid + "")) {
|
||||
logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
||||
throw new WebException(ErrorCode._FAILED);
|
||||
}
|
||||
|
||||
AccountBean acc_bean = AccountCache.getAccount(accountid);
|
||||
if (acc_bean == null) {
|
||||
sql = String.format("SELECT * FROM account WHERE id =?");
|
||||
String[] params = new String[1];
|
||||
params[0] = accountid + "";
|
||||
|
||||
ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
||||
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) {
|
||||
// /**
|
||||
// * 登录
|
||||
// *
|
||||
// * @throws Exception
|
||||
// */
|
||||
// @ActionKey(value = Protocol.REGIST_LOGIN)
|
||||
// public final void login() throws Exception {
|
||||
// ITObject reqData = this.getParams();
|
||||
// String acc = reqData.getUtfString("acc");
|
||||
// logger.info("acc:" + acc + " regist login");
|
||||
// Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
// RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
||||
// String deviceCode = reqData.getUtfString("deviceCode");
|
||||
// logger.info("deviceCode:" + deviceCode);
|
||||
// logger.info("reqData:" + reqData);
|
||||
//
|
||||
// boolean havePassword = false;
|
||||
// if (acc.length() < 10) {
|
||||
// throw new WebException(ErrorCode._FAILED);
|
||||
// }
|
||||
// try {
|
||||
//// String sql = "SELECT id FROM account WHERE acc ='" + acc + "'";
|
||||
//// ITArray resultArray = DataBase.use().executeQueryByTArray(sql);
|
||||
// String sql = "SELECT id FROM account WHERE acc =?";
|
||||
// String[] params2 = new String[1];
|
||||
// params2[0] = acc + "";
|
||||
//
|
||||
// ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params2);
|
||||
//
|
||||
// String strNick = reqData.getUtfString("nick");
|
||||
// strNick = StringUtil.filterEmoji(strNick);
|
||||
// reqData.putUtfString("nick", strNick);
|
||||
//
|
||||
//// 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'",
|
||||
//// strNick, deviceCode);
|
||||
//// 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);
|
||||
//
|
||||
// int accountid = 0;
|
||||
// if (resultArray.size() == 0) {
|
||||
// accountid = register(reqData);
|
||||
// reqData.putUtfString("isBangding", "0");
|
||||
//
|
||||
// } else {
|
||||
// ITObject obj = resultArray.getTObject(0);
|
||||
// accountid = obj.getInt("id");
|
||||
// String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
||||
// + accountid;
|
||||
// DataBase.use().executeUpdate(updateDeviceCodeSql);
|
||||
// reqData.putUtfString("isBangding", obj.getInt("is_bangding") + "");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (acc.equals(accountid + "")) {
|
||||
// logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
||||
// throw new WebException(ErrorCode._FAILED);
|
||||
// }
|
||||
//
|
||||
// AccountBean acc_bean = AccountCache.getAccount(accountid);
|
||||
// if (acc_bean == null) {
|
||||
// sql = String.format("SELECT * FROM account WHERE id =?");
|
||||
// String[] params = new String[1];
|
||||
// params[0] = accountid + "";
|
||||
//
|
||||
// ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
||||
// if (resultArray2.size() == 0) {
|
||||
// throw new WebException(ErrorCode._FAILED);
|
||||
// }
|
||||
// resData.putBoolean("havegroup", true);
|
||||
// } else {
|
||||
// resData.putBoolean("havegroup", false);
|
||||
//
|
||||
// ITObject userData = resultArray2.getTObject(0);
|
||||
// UpdateUserData(userData, accountid);
|
||||
//
|
||||
// acc_bean = AccountCache.getAccount(accountid);
|
||||
// }
|
||||
// logger.info("havePassword:" + resData.getBoolean("havePassword"));
|
||||
// logger.info("havegroup:" + resData.getBoolean("havegroup"));
|
||||
// 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);
|
||||
//// }
|
||||
//// 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 {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密登录2
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ActionKey(value = Protocol.REGIST_LOGIN_2)
|
||||
public final void login2() throws Exception {
|
||||
ITObject reqData = this.getParams();
|
||||
|
||||
String decryptedText = RSAUtils.decrypt(reqData.getString("data"));
|
||||
JsonObject object = new Gson().fromJson(decryptedText, JsonObject.class);
|
||||
String deviceCode = object.get("deviceCode").toString().replaceAll("\"", "");
|
||||
String acc = object.get("acc").toString().replaceAll("\"", "");
|
||||
reqData.putUtfString("acc", acc);
|
||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
||||
logger.info("解密后:" + object);
|
||||
// owbRv6qRVVrnzmDpk0vh3fV1iH1Q
|
||||
boolean havePassword = false;
|
||||
int isBangding = 0;
|
||||
|
||||
try {
|
||||
String sql = "SELECT * FROM account WHERE acc =?";
|
||||
String[] params = new String[1];
|
||||
params[0] = reqData.getUtfString("acc") + "";
|
||||
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
||||
|
||||
String strNick = object.get("nick").toString().replaceAll("\"", "");
|
||||
strNick = StringUtil.filterEmoji(strNick);
|
||||
reqData.putUtfString("nick", strNick);
|
||||
int accountid = 0;
|
||||
if (resultArray.size() == 0) {
|
||||
reqData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
||||
accountid = register(reqData);
|
||||
} else {
|
||||
ITObject obj = resultArray.getTObject(0);
|
||||
accountid = obj.getInt("id");
|
||||
String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
||||
+ accountid;
|
||||
DataBase.use().executeUpdate(updateDeviceCodeSql);
|
||||
isBangding = obj.getInt("is_bangding");
|
||||
|
||||
}
|
||||
|
||||
if (acc.equals(accountid + "")) {
|
||||
logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
||||
throw new WebException(ErrorCode._FAILED);
|
||||
}
|
||||
|
||||
AccountBean acc_bean = AccountCache.getAccount(accountid);
|
||||
if (acc_bean == null) {
|
||||
sql = String.format("SELECT * FROM account WHERE id =?");
|
||||
String[] params1 = new String[1];
|
||||
params1[0] = accountid + "";
|
||||
|
||||
ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||
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", object.get("nick").toString().replaceAll("\"", ""));
|
||||
userData.putUtfString("portrait", object.get("portrait").toString().replaceAll("\"", ""));
|
||||
userData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
||||
updateSession(reqData, accountid);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
resData.putString("isBangding", "1");
|
||||
|
||||
// // 默认锁住账户
|
||||
// String lockSql = "update account set is_lock=? WHERE id=?";
|
||||
// String[] params3 = new String[2];
|
||||
// params3[0] = 1 + "";
|
||||
// params3[1] = accountid + "";
|
||||
//
|
||||
// DataBase.use().executeUpdateLogin(lockSql, params3);
|
||||
|
||||
this.sendResponse(ErrorCode._SUCC, resData);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 加密登录2
|
||||
// *
|
||||
// * @throws Exception
|
||||
// */
|
||||
// @ActionKey(value = Protocol.REGIST_LOGIN_2)
|
||||
// public final void login2() throws Exception {
|
||||
// ITObject reqData = this.getParams();
|
||||
//
|
||||
// String decryptedText = RSAUtils.decrypt(reqData.getString("data"));
|
||||
// JsonObject object = new Gson().fromJson(decryptedText, JsonObject.class);
|
||||
// String deviceCode = object.get("deviceCode").toString().replaceAll("\"", "");
|
||||
// String acc = object.get("acc").toString().replaceAll("\"", "");
|
||||
// reqData.putUtfString("acc", acc);
|
||||
// Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
// RedisLock lock = new RedisLock("wx_" + acc, jedis0);
|
||||
// logger.info("解密后:" + object);
|
||||
//// owbRv6qRVVrnzmDpk0vh3fV1iH1Q
|
||||
// boolean havePassword = false;
|
||||
// int isBangding = 0;
|
||||
//
|
||||
// try {
|
||||
// String sql = "SELECT * FROM account WHERE acc =?";
|
||||
// String[] params = new String[1];
|
||||
// params[0] = reqData.getUtfString("acc") + "";
|
||||
// ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params);
|
||||
//
|
||||
// String strNick = object.get("nick").toString().replaceAll("\"", "");
|
||||
// strNick = StringUtil.filterEmoji(strNick);
|
||||
// reqData.putUtfString("nick", strNick);
|
||||
// int accountid = 0;
|
||||
// if (resultArray.size() == 0) {
|
||||
// reqData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
||||
// accountid = register(reqData);
|
||||
// } else {
|
||||
// ITObject obj = resultArray.getTObject(0);
|
||||
// accountid = obj.getInt("id");
|
||||
// String updateDeviceCodeSql = "update account set device_code ='" + deviceCode + "' where id="
|
||||
// + accountid;
|
||||
// DataBase.use().executeUpdate(updateDeviceCodeSql);
|
||||
// isBangding = obj.getInt("is_bangding");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// if (acc.equals(accountid + "")) {
|
||||
// logger.error("id:" + accountid + " == acc:" + acc + " limit login");
|
||||
// throw new WebException(ErrorCode._FAILED);
|
||||
// }
|
||||
//
|
||||
// AccountBean acc_bean = AccountCache.getAccount(accountid);
|
||||
// if (acc_bean == null) {
|
||||
// sql = String.format("SELECT * FROM account WHERE id =?");
|
||||
// String[] params1 = new String[1];
|
||||
// params1[0] = accountid + "";
|
||||
//
|
||||
// ITArray resultArray2 = DataBase.use().executeQueryByTArrayLogin(sql, params1);
|
||||
// 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", object.get("nick").toString().replaceAll("\"", ""));
|
||||
// userData.putUtfString("portrait", object.get("portrait").toString().replaceAll("\"", ""));
|
||||
// userData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
|
||||
// updateSession(reqData, accountid);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// 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);
|
||||
// resData.putString("isBangding", "1");
|
||||
//
|
||||
//// // 默认锁住账户
|
||||
//// String lockSql = "update account set is_lock=? WHERE id=?";
|
||||
//// String[] params3 = new String[2];
|
||||
//// params3[0] = 1 + "";
|
||||
//// params3[1] = accountid + "";
|
||||
// //
|
||||
//// DataBase.use().executeUpdateLogin(lockSql, params3);
|
||||
//
|
||||
// this.sendResponse(ErrorCode._SUCC, resData);
|
||||
// } finally {
|
||||
// lock.unlock();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 登录
|
||||
|
|
|
|||
Loading…
Reference in New Issue