李泽帆 2026-03-27 16:25:13 +08:00
parent e9a92cf118
commit 223471291c
19 changed files with 835 additions and 244 deletions

View File

@ -99,7 +99,7 @@ public class EventController {
data.addInt(cur_diamo);
DataBase.use().prepareCallNonResult("sp_transfer_diamo", data);
if(groupId>0) {
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use("group1_db13").getJedis();
try {
CountUtil.countLog(String.format("g%s:diamo_cost",groupId), pay, jedis9);
if(pid > 0) {

View File

@ -7,84 +7,87 @@ import org.eclipse.jetty.util.log.Log;
import com.data.cache.GroupCache;
import com.data.util.CountUtil;
import com.data.util.Utility;
import com.evt.mgr.handler.HandlerGroupRound;
import com.taurus.core.entity.ITArray;
import com.taurus.core.plugin.redis.Redis;
import com.taurus.core.util.DateUtils;
import com.taurus.core.util.Logger;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
public class Utils {
static Logger log = Logger.getLogger(Utils.class);
public static final void countValidAndTotal(Jedis jedis10, Pipeline pipeline9, int uid, int groupId, int pid,
int valid_count, int valid_diamo, int all_count,int playerCount) {
if (valid_count > 0) {
String gmv = String.format("g{%s}:m%s:valid_round", groupId, uid);
CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
CountUtil.countLogByDay30(gmv + "_self", valid_count, pipeline9);
}
if (valid_diamo > 0) {
String gmv = String.format("g{%s}:m%s:valid_diamo", groupId, uid);
CountUtil.countLogByDay30(gmv, valid_diamo, pipeline9);
CountUtil.countLogByDay30(gmv + "_self", valid_diamo, pipeline9);
}
String gmr = String.format("g{%s}:m%s:round_log", groupId, uid);
CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
CountUtil.countLogByDay30(gmr + "_self", 1, pipeline9, true);
List<Integer> temp = Utility.getMemberParents(jedis10, groupId, uid, true);
if (temp != null && temp.size() > 0) {
int valid_count, int valid_diamo, int all_count, int playerCount) {
try {
if (valid_count > 0) {
String gmv = String.format("g{%s}:m%s:valid_round", groupId, uid);
CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
CountUtil.countLogByDay30(gmv + "_self", valid_count, pipeline9);
}
if (valid_diamo > 0) {
String gmv = String.format("g{%s}:m%s:valid_diamo", groupId, uid);
CountUtil.countLogByDay30(gmv, valid_diamo, pipeline9);
CountUtil.countLogByDay30(gmv + "_self", valid_diamo, pipeline9);
}
String gmr = String.format("g{%s}:m%s:round_log", groupId, uid);
CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
CountUtil.countLogByDay30(gmr + "_self", 1, pipeline9, true);
List<Integer> temp = Utility.getMemberParents(jedis10, groupId, uid, true);
log.info("temp:"+temp.size());
if (temp != null && temp.size() > 0) {
for (int i = 0; i < temp.size(); ++i) {
if(valid_count>0) {
int par = temp.get(i);
if (par != uid) {
String gmv2 = String.format("g{%s}:m%s:valid_round", groupId, par);
CountUtil.countLogByDay30(gmv2, 1, pipeline9);
}
int par = temp.get(i);
if (par != uid) {
String gmv = String.format("g{%s}:m%s:valid_round", groupId, par);
CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
}
String gmvp = String.format("g{%s}:m%s:valid_round:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmvp, 1, pipeline9);
log.info("par增加场次:"+par);
String gmvp = String.format("g{%s}:m%s:valid_round:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmvp, valid_count, pipeline9);
String gmvp2 = String.format("g{%s}:m%s:valid_round2:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmvp2, 1, pipeline9);
String gmvp2 = String.format("g{%s}:m%s:valid_round2:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmvp2, valid_count, pipeline9);
// boolean add_uid = (uid == par || i == 0);
// if (add_uid == true) {
String gmv = String.format("g{%s}:m%s:d_valid_round", groupId, par);
CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
// }
}
}
for (int i = 0; i < temp.size(); ++i) {
if (all_count > 0) {
int par = temp.get(i);
if (par != uid) {
gmr = String.format("g{%s}:m%s:round_log", groupId, par);
CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
CountUtil.countLogByDay30(gmv, 1, pipeline9);
}
}
gmr = String.format("g{%s}:m%s:valid_diamo:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmr, valid_diamo, pipeline9);
for (int i = 0; i < temp.size(); ++i) {
if(valid_count>0) {
int par = temp.get(i);
if (par != uid) {
gmr = String.format("g{%s}:m%s:round_log", groupId, par);
CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
}
gmr = String.format("g{%s}:m%s:all_count:p%s", groupId, par, pid);
gmr = String.format("g{%s}:m%s:valid_diamo:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmr, valid_diamo, pipeline9);
CountUtil.countLogByDay30(gmr, all_count, pipeline9, true);
gmr = String.format("g{%s}:m%s:all_count:p%s", groupId, par, pid);
CountUtil.countLogByDay30(gmr, all_count, pipeline9, true);
// boolean add_uid = (uid == par || i == 0);
// if (add_uid == true) {
gmr = String.format("g{%s}:m%s:d_round_log", groupId, par);
CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
// }
}
}
}
}catch (Exception e) {
log.error("计入统计出错:",e);
}
}
public static final void countValidAndTotal(Pipeline pipeline9, ITArray playerList, int groupId, int pid,
@ -98,17 +101,32 @@ public class Utils {
int uid = playerList.getInt(i);
EventServer.log.info("uid:" + uid);
EventServer.log.info("win_player:" + win_player);
//平局两边都需要增加场次
if(valid_count==0) {
EventServer.log.info("平局player:" + uid);
countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, 1, valid_diamo, all_count, 1);
if (win_player == uid) {
}else if (win_player == uid) {
// 大赢家增加场次
EventServer.log.info("win_player:" + uid);
countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, valid_count, valid_diamo, all_count,1);
countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, valid_count, valid_diamo, all_count, 1);
} else {
EventServer.log.info("lost_player:" + uid);
countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, 0, valid_diamo, all_count,1);
}else {
//输家不增加场次
EventServer.log.info("win_player:" + uid);
countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, 0, valid_diamo, all_count, 1);
}
// if (win_player == uid) {
// // 大赢家增加场次
// EventServer.log.info("win_player:" + uid);
// countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, valid_count, valid_diamo, all_count, 1);
//
// } else {
// EventServer.log.info("lost_player:" + uid);
// countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, 0, valid_diamo, all_count, 1);
//
// }
}
} finally {
@ -147,7 +165,7 @@ public class Utils {
if (add_uid == true) {
key = String.format("g{%s}:m%s:d_total_win", groupId, par);
EventServer.log.info("par:" + par+"获得:"+score);
EventServer.log.info("par:" + par + "获得:" + score);
CountUtil.countLogByDay30(key, score, pipeline9);
}
@ -157,7 +175,7 @@ public class Utils {
if (par != uid) {
key = String.format("g{%s}:m%s:total_win", groupId, par);
EventServer.log.info("par:" + par+"获得:"+score);
EventServer.log.info("par:" + par + "获得:" + score);
CountUtil.countLogByDay30(key, score, pipeline9);
}

View File

@ -86,23 +86,23 @@ public class HandlerGroupMemberRound implements IHandler {
String gmrp_key = String.format("g%s:m%s:round:p%s", groupId, uid, pid);
String gmr_key = String.format("g%s:m%s:round", groupId, uid);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis13 = Redis.use("group1_db13").getJedis();
try {
CountUtil.countLog(gmrp_key, 1, jedis9);
CountUtil.countLog(gmr_key, 1, jedis9);
CountUtil.countLog(gmrp_key, 1, jedis13);
CountUtil.countLog(gmr_key, 1, jedis13);
Pipeline pipeline9 = jedis9.pipelined();
Pipeline pipeline13 = jedis13.pipelined();
if(score>0) {
Utils.countRoundWin(pipeline9, groupId, pid, uid, win == 1, score - pumpReal);
Utils.countRoundWin(pipeline13, groupId, pid, uid, win == 1, score - pumpReal);
}else {
Utils.countRoundWin(pipeline9, groupId, pid, uid, win == 1, score);
Utils.countRoundWin(pipeline13, groupId, pid, uid, win == 1, score);
}
pipeline9.sync();
pipeline13.sync();
} finally {
jedis9.close();
jedis13.close();
}
return 0;
}

View File

@ -6,20 +6,24 @@ import com.evt.mgr.Utils;
import com.taurus.core.entity.ITArray;
import com.taurus.core.entity.ITObject;
import com.taurus.core.plugin.redis.Redis;
import com.taurus.core.util.Logger;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
public class HandlerGroupRound implements IHandler{
public class HandlerGroupRound implements IHandler {
static Logger log = Logger.getLogger(HandlerGroupRound.class);
@Override
public int process(int uid, ITObject param) throws Exception {
public int process(int uid, ITObject param) throws Exception {
// TODO Auto-generated method stub
return 0;
}
@Override
public int processGroup(int groupId, ITObject param) throws Exception {
log.info("统计场次:");
int pid = param.getInt("pid");
int valid = param.getInt("valid");
ITArray playerList = param.getTArray("player_list");
@ -28,45 +32,43 @@ public class HandlerGroupRound implements IHandler{
int valid_count = param.getInt("valid_count");
int valid_diamo = 0;
int all_count = 0;
if (param.containsKey("valid_diamo"))
{
if (param.containsKey("valid_diamo")) {
valid_diamo = param.getInt("valid_diamo");
}
if (param.containsKey("all_count"))
{
if (param.containsKey("all_count")) {
all_count = param.getInt("all_count");
}
String rp_key = String.format("g%s:round:p%s",groupId,pid);
String round_key = String.format("g%s:round",groupId);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
String rp_key = String.format("g%s:round:p%s", groupId, pid);
String round_key = String.format("g%s:round", groupId);
Jedis jedis13 = Redis.use("group1_db13").getJedis();
log.info("统计场次1:");
try {
Pipeline pipeline9 = jedis9.pipelined();
CountUtil.countLog(rp_key, playerList.size(), pipeline9,false,true);
CountUtil.countLog(round_key, playerList.size(), pipeline9,true);
if(valid == 1) {
String valid_key = String.format("g%s:valid_room",groupId);
String p_valid_key = String.format("g%s:valid_room:p%s",groupId,pid);
CountUtil.countLogByDay(p_valid_key, 1, pipeline9,true);
CountUtil.countLog(valid_key, 1, pipeline9);
}else {
String no_valid_key = String.format("g%s:no_valid_room",groupId);
String p_no_valid_key = String.format("g%s:no_valid_room:p%s",groupId,pid);
CountUtil.countLogByDay(p_no_valid_key, playerList.size(), pipeline9,true);
CountUtil.countLog(no_valid_key, playerList.size(), pipeline9);
}
Utils.countValidAndTotal(pipeline9, playerList, groupId, pid, valid_count, valid_diamo, all_count,win_player);
pipeline9.sync();
}finally {
jedis9.close();
log.info("统计场次3:");
Pipeline pipeline13 = jedis13.pipelined();
CountUtil.countLog(rp_key, playerList.size(), pipeline13, false, true);
CountUtil.countLog(round_key, playerList.size(), pipeline13, true);
String valid_key = String.format("g%s:valid_room", groupId);
String p_valid_key = String.format("g%s:valid_room:p%s", groupId, pid);
CountUtil.countLogByDay(p_valid_key, valid_count==0?2:1, pipeline13, true);
CountUtil.countLog(valid_key, valid_count==0?2:1, pipeline13);
Utils.countValidAndTotal(pipeline13, playerList, groupId, pid, valid_count, valid_diamo, all_count,
win_player);
log.info("统计场次4:");
pipeline13.sync();
}catch (Exception e) {
log.error("统计场次5异常",e);
} finally {
jedis13.close();
}
return 0;
}

View File

@ -30,6 +30,10 @@ public class HandlerHpConsume implements IHandler {
private static boolean hpConsume(int gid, int uid, int pid, int hp, int cur_hp, int reason, String roomid, int time,
String desc) throws SQLException {
log.info("uid:" + uid);
log.info("当前HP:" + hp);
log.info("当前cur_hp:" + cur_hp);
String sql = String.format("{call sp_update_hp(%s,%s,%s,%s,%s,%s,'%s',%s,'%s')}", gid, uid, hp, cur_hp, reason,
pid, roomid, time, desc);
Utility.evtdb(gid, 2, sql);
@ -103,7 +107,7 @@ public class HandlerHpConsume implements IHandler {
// Redis.use(DB).incrBy(all_key, reward_value);
useValue += reward_value;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use("group1_db13").getJedis();
try {
String desc = "" + uid;
long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s", groupId, parentId),
@ -195,7 +199,7 @@ public class HandlerHpConsume implements IHandler {
key = String.format("g{%s}:m%s:d_reward", groupId, gb.owner);
CountUtil.countLogByDay30(key, leftValue, pipeline);
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use("group1_db13").getJedis();
EventServer.log.info("leftValue:" + leftValue);
try {
@ -295,8 +299,8 @@ public class HandlerHpConsume implements IHandler {
// String all_key = String.format("g{%s}:m%s:all_reward_hp", groupId,parentId);
// Redis.use(DB).incrBy(all_key, reward_value);
String key = String.format("g{%s}:m%s:total_win", groupId, parentId);
CountUtil.countLogByDay30(key, -real_pump, pipeline);
String key = String.format("g{%s}:m%s:total_win", groupId, parentId);
CountUtil.countLogByDay30(key, -real_pump, pipeline);
}
}
log.info("洗牌分给到盟主");
@ -337,7 +341,7 @@ public class HandlerHpConsume implements IHandler {
key = String.format("g{%s}:m%s:d_xipai_reward", groupId, gb.owner);
CountUtil.countLogByDay30(key, leftValue, pipeline);
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use("group1_db13").getJedis();
try {
String desc = "" + uid;
long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s", groupId, gb.owner), leftValue,
@ -405,10 +409,8 @@ public class HandlerHpConsume implements IHandler {
try {
int hp = param.getInt("hp");
// int cur_hp = param.getInt("cur_hp");
//查询mysql的hp
String hpSql = String.format(
"SELECT hp FROM `group_member` WHERE uid=%s and groupId=%s",
uid,groupId);
// 查询mysql的hp
String hpSql = String.format("SELECT hp FROM `group_member` WHERE uid=%s and groupId=%s", uid, groupId);
ITArray arr = DataBase.use().executeQueryByTArray(hpSql);
int cur_hp = arr.getTObject(0).getInt("hp").intValue();
@ -419,7 +421,6 @@ public class HandlerHpConsume implements IHandler {
int pumpBaseWin = 0;// 大赢家保底抽水
int hpReal = 0;// 大赢家保底抽水
String roomid = param.getString("room");
int pid = param.getInt("pid");
int time = param.getInt("time");
@ -490,25 +491,40 @@ public class HandlerHpConsume implements IHandler {
String desc = param.getString("desc");
desc = StringUtil.isNotEmpty(desc) ? desc : StringUtil.Empty;
if (hp != 0 && !is_xipai && pumpReal != 0 ) {
log.info("结算到这里1:"+cur_hp);
cur_hp = cur_hp+hp;
if(hp<0) {
// 保底抽水
if (pumpBaseWin > 0) {
if (hp > 0 && !is_xipai && pumpReal > 0) {
log.info("保底赢家抽水到这里cur_hp:" + cur_hp);
log.info("保底抽水到这里pumpReal:" + pumpReal);
log.info("保底只抽大赢家pumpBaseWin:" + pumpBaseWin);
if (pumpBaseWin == 0) {
hpConsume(groupId, uid, pid, hp, cur_hp, ConsumeCode.HP_CLEARING, roomid, time, desc);
hpConsume(groupId, uid, pid, -pumpReal, cur_hp, ConsumeCode.HP_PUMP, roomid, time, desc);
} else {
hpConsume(groupId, uid, pid, hp, cur_hp, ConsumeCode.HP_CLEARING, roomid, time, desc);
}
} else {
log.info("保底输家cur_hp:" + cur_hp);
log.info("保底输家:" + hp);
hpConsume(groupId, uid, pid, hp, cur_hp, ConsumeCode.HP_CLEARING, roomid, time, desc);
}else {
cur_hp = cur_hp-pumpReal;
hpConsume(groupId, uid, pid, hp-pumpReal, cur_hp-pumpReal, ConsumeCode.HP_CLEARING, roomid, time, desc);
}
}
// 正常抽水
else if (hp != 0 && !is_xipai && pumpReal > 0) {
log.info("正常抽水结算到这里:" + cur_hp);
cur_hp = cur_hp + hp;
if (hp < 0) {
hpConsume(groupId, uid, pid, hp, cur_hp, ConsumeCode.HP_CLEARING, roomid, time, desc);
} else {
cur_hp = cur_hp - pumpReal;
hpConsume(groupId, uid, pid, hp, cur_hp - pumpReal, ConsumeCode.HP_CLEARING, roomid, time, desc);
hpConsume(groupId, uid, pid, -pumpReal, cur_hp, ConsumeCode.HP_PUMP, roomid, time, desc);
}
} else if (hp > 0 && pumpBase != 0 && !is_xipai) {
log.info("抽水到这里cur_hp:"+cur_hp);
log.info("抽水到这里pumpBase:"+pumpBase);
hpConsume(groupId, uid, pid, -pumpBase, cur_hp - pumpBase, ConsumeCode.HP_PUMP, roomid, time, desc);
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use("group1_db13").getJedis();
try {
String key = String.format("g%s:m%s:consume_hp", groupId, uid);
@ -532,7 +548,7 @@ public class HandlerHpConsume implements IHandler {
if (xipai > 0) {
CountUtil.countLogByDay(key, -xipai, jedis9, 691200);
time += 1;
hpConsume(groupId, uid, pid, -xipai, cur_hp-xipai, ConsumeCode.HP_XIPAI_PUMP, roomid, time, desc);
hpConsume(groupId, uid, pid, -xipai, cur_hp - xipai, ConsumeCode.HP_XIPAI_PUMP, roomid, time, desc);
CountUtil.countLog(String.format("g%s:hp_cost", groupId), xipai, jedis9);
CountUtil.countLogByDay(String.format("g%s:hp_cost:p%s", groupId, pid), xipai, jedis9);
@ -551,7 +567,8 @@ public class HandlerHpConsume implements IHandler {
log.info("pumpBaseWin:" + pumpBaseWin);
log.info("pumpReal:" + pumpReal);
if ((reward_value > 0 || (rewardValueType == 2 && is_pump)) && pumpReal != 0 && pumpBaseWin == 0) {
if (hp != 0 && (reward_value > 0 || (rewardValueType == 2 && is_pump)) && pumpReal != 0
&& pumpBaseWin == 0) {
log.info("分层抽水");
time += 1;
@ -559,32 +576,34 @@ public class HandlerHpConsume implements IHandler {
time, max_player);
} else {
// 平局则把保底分给到群主
if (pumpBase > 0 && is_pump && pumpBaseWin != 0) {
if (hp > 0 && pumpBase > 0 && is_pump && pumpBaseWin != 0) {
log.info("平局抽赢家保底分");
hpConsume(groupId, uid, pid, -pumpBase, cur_hp - pumpBase, ConsumeCode.HP_PUMP, roomid, time, desc);
hpConsume(groupId, uid, pid, -pumpBaseWin, cur_hp - pumpBase, ConsumeCode.HP_PUMP, roomid, time,
desc);
GroupBean gb = GroupCache.getGroup(groupId);
// 给到群主时要刷新mysql的hp值
String rewardsql = String.format(
"update group_member set bank_hp=bank_hp+ %s where uid = %s AND groupId = %s", pumpBase, gb.owner,
groupId);
"update group_member set bank_hp=bank_hp+ %s where uid = %s AND groupId = %s",
pumpBaseWin, gb.owner, groupId);
Utility.evtdb(groupId, 1, rewardsql);
long qunzhu_cur_hp = CountUtil.countLogByDay3(
String.format("g%s:hp_reward:m%s", groupId, gb.owner), pumpBase, jedis9);
String.format("g%s:hp_reward:m%s", groupId, gb.owner), pumpBaseWin, jedis9);
String sql = String.format(
"INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,roomid,time,round,info) "
+ "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,'" + "保底抽水" + "')",
groupId, gb.owner, ConsumeCode.HP_PARTNER_REWARD, pumpBase, qunzhu_cur_hp, pid, roomid,
time, 0);
groupId, gb.owner, ConsumeCode.HP_PARTNER_REWARD, pumpBaseWin, qunzhu_cur_hp, pid,
roomid, time, 0);
DataBase.use().executeUpdate(sql);
to_reward_base(pipeline, uid, param.getString("prs"), -pumpBase, groupId, true);
to_reward_base(pipeline, uid, param.getString("prs"), -pumpBaseWin, groupId, true);
} else if (pumpBase > 0 && !is_xipai && is_pump && pumpBaseWin == 0) {
log.info("平局抽双方保底分");
hpConsume(groupId, uid, pid, -pumpBase, cur_hp - pumpBase, ConsumeCode.HP_PUMP, roomid, time, desc);
hpConsume(groupId, uid, pid, -pumpBase, cur_hp - pumpBase, ConsumeCode.HP_PUMP, roomid, time,
desc);
GroupBean gb = GroupCache.getGroup(groupId);
long qunzhu_cur_hp = CountUtil.countLogByDay3(
@ -592,8 +611,8 @@ public class HandlerHpConsume implements IHandler {
// 给到群主时要刷新mysql的hp值
String rewardsql = String.format(
"update group_member set bank_hp=bank_hp+ %s where uid = %s AND groupId = %s", pumpBase, gb.owner,
groupId);
"update group_member set bank_hp=bank_hp+ %s where uid = %s AND groupId = %s", pumpBase,
gb.owner, groupId);
Utility.evtdb(groupId, 1, rewardsql);
String sqllog = String.format(

View File

@ -80,11 +80,16 @@ public class EventController {
Global.logger.info("maxPlayer:" + maxPlayer);
Global.logger.info("valid:" + valid);
if (valid == 1 && maxPlayer > 0) {
data.putInt("valid_count", 100);
data.putInt("valid_count", 1);
// data.putInt("valid_count", 100 / maxPlayer);
} else {
data.putInt("valid_count", 0);
if (winner.totalHp() == 0) {
data.putInt("valid_count", 0);
} else {
data.putInt("valid_count", 1);
}
}
if (maxPlayer > 0) {
@ -142,8 +147,6 @@ public class EventController {
data.putInt("cur_hp", cur_hp);
data.putUtfString("room", room.roomid);
int maxPlayer = owner.room.getValidPlayer();
Global.logger.info("maxPlayer:" + maxPlayer);
Global.logger.info("hpPump:" + hpPump);
// if (hpPump && maxPlayer > 0) {
data.putInt("valid_count", 100 / maxPlayer);
@ -158,12 +161,12 @@ public class EventController {
* redis reward
*/
public long redisFag(Player owner, int hp, boolean hpPump, boolean mengzhu_reward, int xipai_score, boolean xipai,
String desc) {
String desc, int baodiHp) {
Room room = owner.room;
String gm_key = GroupMemberCache.genKey(room.groupId, owner.playerid);
Global.logger.info("playid:" + owner.playerid + "hp:" + hp + "total_hp:" + owner.hp.total_hp + "hpPump:"
+ hpPump + "mr:" + mengzhu_reward + "xp:" + xipai_score + "xipai:" + xipai + "desc:" + desc
+ "owner.practicalHpPumpReal:" + owner.practicalHpPumpReal);
// Global.logger.info("playid:" + owner.playerid + "hp:" + hp + "total_hp:" + owner.hp.total_hp + "hpPump:"
// + hpPump + "mr:" + mengzhu_reward + "xp:" + xipai_score + "xipai:" + xipai + "desc:" + desc
// + "owner.practicalHpPumpReal:" + owner.practicalHpPumpReal);
long cur_hp = 0;
if (hpPump) {
String strCurHp = Redis.use("group1_db10").hget(gm_key, "hp");
@ -177,7 +180,17 @@ public class EventController {
}
}
}
Global.logger.info("当前cur_hp:" + cur_hp);
Global.logger.info("当前owner.practicalHpPumpReal:" + owner.practicalHpPumpReal);
cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", -owner.practicalHpPumpReal);
Global.logger.info("修改后cur_hp:" + owner.hp.total_hp);
Global.logger.info("owner.hp.total_hp:" + owner.hp.total_hp);
if (owner.hp.total_hp == 0 && !xipai) {
// 如果平局则每人抽保底的一半
// String qunzhu_key = GroupMemberCache.genKey(room.groupId, gb.owner);
// Redis.use("group1_db10").hincrBy(qunzhu_key, "hp", room.basePump);
}
} else if (xipai) {
String strCurHp = Redis.use("group1_db10").hget(gm_key, "hp");
if (StringUtil.isNotEmpty(strCurHp)) {
@ -191,7 +204,11 @@ public class EventController {
}
cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", -xipai_score);
} else {
Global.logger.info("当前cur_hpgm_key-hp:" + hp);
cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", hp);
Global.logger.info("修改后cur_hpgm_key:" + cur_hp);
}
ITObject data = TObject.newInstance();
@ -201,19 +218,13 @@ public class EventController {
Redis.use("group1_db10").hincrBy(gm_key, "bank_hp", del_value);
data.putInt("hp_than_max_value", (int) del_value);
}
if (owner.hp.total_hp == 0 && !xipai) {
// 如果平局则每人抽保底的一半
Redis.use("group1_db10").hincrBy(gm_key, "hp", -room.basePump);
GroupBean gb = GroupCache.getGroup(room.groupId);
// String qunzhu_key = GroupMemberCache.genKey(room.groupId, gb.owner);
// Redis.use("group1_db10").hincrBy(qunzhu_key, "hp", room.basePump);
}
Global.logger.info("hp:" + hp);
Global.logger.info("cur_hp:" + cur_hp);
Global.logger.info("owner.prs:" + owner.prs);
Global.logger.info("owner.hp.total_hp:" + owner.hp.total_hp);
data.putInt("hp", hp);
data.putInt("hp", hp + baodiHp);
data.putInt("cur_hp", (int) cur_hp);
data.putInt("pid", room.groupPid);
data.putInt("uid", owner.playerid);
@ -248,15 +259,21 @@ public class EventController {
}
data.putInt("pumpReal", 0);
if (UpperLimit > readScore && mengzhu_reward && readScore > 0) {
if (UpperLimit > readScore && mengzhu_reward && readScore == 0 && !xipai) {
// 如果平局则扣双方
Global.logger.info("平局抽水:" + room.basePump);
Redis.use("group1_db10").hincrBy(gm_key, "hp", -room.basePump);
data.putInt("pumpBase", room.basePump);
} else if (owner.hp.total_hp != 0 && UpperLimit > Math.abs(readScore) && mengzhu_reward) {
// 如果输赢低于UpperLimit的分数则只扣除大赢家
Global.logger.info("保底抽水:" + UpperLimitReward);
data.putInt("pumpBase", UpperLimitReward);
data.putInt("pumpReal", owner.practicalHpPumpReal);
data.putInt("pumpBaseWin", UpperLimitReward);
} else if (UpperLimit > readScore && mengzhu_reward && readScore == 0 && !xipai) {
// 如果平局则扣双方
data.putInt("pumpBase", room.basePump);
} else {
// 否则不扣保底分
if (hpPump) {
@ -265,12 +282,9 @@ public class EventController {
data.putInt("pumpBase", 0);
data.putInt("pumpReal", owner.practicalHpPumpReal);
data.putInt("hpReal", hp);
Global.logger.info("输赢抽水:" + owner.practicalHpPumpReal);
}
Global.logger.info("mengzhu_reward:" + mengzhu_reward);
Global.logger.info("readScore:" + readScore);
Global.logger.info("room.basePump:" + data.getInt("pumpBase"));
if (hpPump || room.basePump != 0) {
data.putInt("pump", owner.practicalHpPump);

View File

@ -1135,8 +1135,8 @@ public class Room implements Runnable {
}
Global.logger.info("scoreWin:" + scoreWin + "|room.basepump:" + this.basePump
+ "room UpperLimitRewardsub" + UpperLimitRewardsub);
Global.logger.info("roomMoney:" + roomMoney + "|room.basepump:" + this.basePump + "hpPump" + hpPump
+ "practicalHpPump:" + player.practicalHpPump + "aHeadReward:" + aHeadReward);
Global.logger.info("roomMoney:" + roomMoney + " | room.basepump:" + this.basePump + " | hpPump" + hpPump
+ "| practicalHpPump:" + player.practicalHpPump + "| aHeadReward:" + aHeadReward);
// 抽水
if (aHeadReward == false && roomMoney > 0) {
if (UpperLimitRewardsub == 1) {
@ -1145,7 +1145,13 @@ public class Room implements Runnable {
player.practicalHpPumpReal = roomMoney;
this.basePump = 0;
} else {
player.practicalHpPump = 0;
// 这里只扣输家流水
Global.logger.info("输家" + player.playerid);
Global.logger.info("输家:" + player.hp.total_hp);
player.practicalHpPumpReal = roomMoney;
player.practicalHpPump = 1;
curHp = Global.eventCtr.redisFag(player, 0, hpPump, true, 0, false, null,player.hp.total_hp);
}
} else {
// 扣两人
@ -1155,24 +1161,26 @@ public class Room implements Runnable {
}
}
// if (this.basePump != 0) {
// player.practicalHpPump = 0;
// player.practicalHpPumpReal = 0;
// }
if (player.hp.total_hp > 0 && scoreWin > 0) {
curHp = Global.eventCtr.redisFag(player, 0, hpPump || player.practicalHpPump > 0, true, 0,
false, null);
curHp = Global.eventCtr.redisFag(player, player.hp.total_hp,
hpPump || player.practicalHpPump > 0, true, 0, false, null,0);
} else {
curHp = Global.eventCtr.redisFag(player, 0, hpPump || player.practicalHpPump > 0, true, 0,
false, null);
Global.logger.info("输家执行了1次" + player.hp.total_hp);
Global.logger.info("输家执行了hpPump次" + hpPump);
Global.logger.info("player.practicalHpPumpReal=="+player.practicalHpPumpReal);
Global.logger.info("player.practicalHpPump=="+player.practicalHpPump);
Global.logger.info("player.hp.cur_hp:" + player.hp.cur_hp);
curHp = Global.eventCtr.redisFag(player, 0, false, false, 0,
false, null,0);
}
} else {
// if (this.basePump != 0) {
// player.practicalHpPump = 0;
// player.practicalHpPumpReal = 0;
// }
curHp = Global.eventCtr.redisFag(player, player.hp.total_hp, hpPump || player.practicalHpPump > 0, false, 0, false,
null);
curHp = Global.eventCtr.redisFag(player, player.hp.total_hp, hpPump || player.practicalHpPump > 0,
false, 0, false, null,0);
}
Global.logger.info("scoreWin:" + scoreWin + "|room.basepump:" + this.basePump
@ -1344,7 +1352,7 @@ public class Room implements Runnable {
? (int) Math.ceil(_pumpProportion / alreadyRoundPlayer().size())
: 0;
} else {
practicalHpPump = player.hpPumpValue() >= _upperLimit ? _pumpProportion : 0;
practicalHpPump = player.hpPumpValue() >= _upperLimit ? _pumpProportion : 0;
}
} else if (this.hpData.containsKey("rewards_list")) {
// 新数据 - 期间
@ -1390,7 +1398,7 @@ public class Room implements Runnable {
// 这里需要抽一人一半
player.practicalHpPumpReal = practicalHpPump;
for (Entry<Integer, Player> entry : this.playerMapById.entrySet()) {
Global.logger.error("palyerId:"+entry.getValue().playerid);
Global.logger.error("palyerId:" + entry.getValue().playerid);
entry.getValue().practicalHpPump = practicalHpPump / 2;
@ -1549,11 +1557,11 @@ public class Room implements Runnable {
if (player.hp.cur_hp - (long) hp < 0) {
if (player.hp.cur_hp > 0) {
player.hp.cur_hp = Global.eventCtr.redisFag(player, 0, false, false, (int) player.hp.cur_hp, true,
"洗牌");
"洗牌",0);
player.xi_pai_total += (int) player.hp.cur_hp;
}
} else {
player.hp.cur_hp = Global.eventCtr.redisFag(player, 0, false, false, hp, true, "洗牌");
player.hp.cur_hp = Global.eventCtr.redisFag(player, 0, false, false, hp, true, "洗牌",0);
player.xi_pai_total += hp;
}
}
@ -1624,7 +1632,7 @@ public class Room implements Runnable {
// player.hp.cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", hp);
//
// }
player.hp.cur_hp = Global.eventCtr.redisFag(player, hp, false, false, 0, false, null);
player.hp.cur_hp = Global.eventCtr.redisFag(player, hp, false, false, 0, false, null,0);
redisCountBlack(player, hp);
// 重新设置房间最低分数
@ -1680,11 +1688,11 @@ public class Room implements Runnable {
try {
int black_value = Integer.parseInt(str_black_value);
if (black_value >= black_max_value) {
//Redis.use("group1_db10").hset(black_key, "black", "0");
//Redis.use("group1_db10").hset(black_key, "group_black", "0");
//Redis.use("group1_db10").hset(black_key, "group_black_rate", "0");
//Redis.use("group1_db10").hset(black_key, "group_black_max_value", "0");
//Redis.use("group1_db10").hset(black_key, "group_black_now_value", "0");
// Redis.use("group1_db10").hset(black_key, "black", "0");
// Redis.use("group1_db10").hset(black_key, "group_black", "0");
// Redis.use("group1_db10").hset(black_key, "group_black_rate", "0");
// Redis.use("group1_db10").hset(black_key, "group_black_max_value", "0");
// Redis.use("group1_db10").hset(black_key, "group_black_now_value", "0");
}
} catch (NumberFormatException e) {
return;
@ -1716,11 +1724,11 @@ public class Room implements Runnable {
try {
int black_value = Integer.parseInt(str_black_value);
if (black_value >= black_max_value) {
//Redis.use("group1_db10").hset(black_key, "black", "0");
//Redis.use("group1_db10").hset(black_key, "group_black", "0");
//Redis.use("group1_db10").hset(black_key, "group_black_rate", "0");
//Redis.use("group1_db10").hset(black_key, "group_black_max_value", "0");
//Redis.use("group1_db10").hset(black_key, "group_black_now_value", "0");
// Redis.use("group1_db10").hset(black_key, "black", "0");
// Redis.use("group1_db10").hset(black_key, "group_black", "0");
// Redis.use("group1_db10").hset(black_key, "group_black_rate", "0");
// Redis.use("group1_db10").hset(black_key, "group_black_max_value", "0");
// Redis.use("group1_db10").hset(black_key, "group_black_now_value", "0");
}
} catch (NumberFormatException e) {
return;

View File

@ -127,6 +127,9 @@ public class EXGameController extends GameController {
if(Global.loggerDebug) {
Global.logger.info(player + " cardlist:" + player.cardInhand);
}
Global.logger.info("红中麻将:"+player.playerid + ",player.black_white_rate:" +
player.black_white_rate+",player.is_white:"+player.is_white+",room.white_value:"+owner.white_value);
ITObject param = new TObject();
ITArray handCard = Util.toTArray(player.cardInhand);
param.putTArray("card_list", handCard);

View File

@ -125,6 +125,9 @@ public class EXGameController extends GameController {
if(Global.loggerDebug) {
Global.logger.info(player + " cardlist:" + player.cardInhand);
}
Global.logger.info("转转麻将:"+player.playerid + ",player.black_white_rate:" +
player.black_white_rate+",player.is_white:"+player.is_white+",room.white_value:"+owner.white_value);
ITObject param = new TObject();
ITArray handCard = Util.toTArray(player.cardInhand);
param.putTArray("card_list", handCard);

View File

@ -182,6 +182,9 @@ public class EXGameController extends GameController {
for (Entry<Integer, Player> entry : owner.playerMapBySeat.entrySet()) {
EXPlayer player = (EXPlayer) entry.getValue();
tmpPlayerList.add(player);
Global.logger.info("跑得快:"+player.playerid + ",player.black_white_rate:" +
player.black_white_rate+",player.is_white:"+player.is_white+",white_rate:"+white_rate+",room.white_value:"+owner.white_value);
}
Collections.shuffle(tmpPlayerList);

View File

@ -180,7 +180,9 @@ public class EXGameController extends GameController {
player.sendEvent(Config.GAME_EVT_PLAYER_DEAL, param);
player.cur_huxi = 0;
player.stateMachine.changeState(Global.getState(PlayerWaitState.class));
Global.logger.info("放炮罚:"+player.playerid + ",player.black_white_rate:" +
player.black_white_rate+",player.is_white:"+player.is_white+",room.white_value:"+owner.white_value);
logger.info("roomId:" + owner.roomid + ",round:" + owner.round + ",player:" + player + ",cardInhand:" + player.cardInhand);
}

View File

@ -133,7 +133,7 @@ public class Protocol {
/** 获取玩家详细体力值*/
public static final String GET_HPLOG_DETAIL_INFO = "get_hplog_detail_info";
/** 获取抽水体力值详细*/
/** 获取盟主统计*/
public static final String GET_HPLOG_PUMP = "get_hplog_pump";
/** 设置奖励*/
public static final String GROUP_SET_REWARD = "set_reward";
@ -219,5 +219,7 @@ public class Protocol {
/** 重置设备锁定*/
public static final String GROUP_RESET_LOCK = "group_reset_lock";
/**获得所有合伙人*/
public static final String GROUP_GET_PARTNER = "get_partner";
}

View File

@ -219,7 +219,8 @@ public class GroupController extends Controller {
ITObject resData = GroupService.findMember(groupId, parentid, parentid, parentid.toString());
sendResponse(0, resData);
} else {
ITObject resData = GroupService.findMember(groupId, uid, tagId, tagName);
Integer parentid = GroupService.getParents(groupId, tagId);
ITObject resData = GroupService.findMember(groupId, uid, tagId, parentid.toString());
sendResponse(0, resData);
}
}
@ -1591,4 +1592,32 @@ public class GroupController extends Controller {
DataBase.use().executeUpdateLogin(sql, params1);
this.sendResponse(0, null);
}
@ActionKey(value = Protocol.GROUP_GET_PARTNER, validate = WebInterceptor.V_SESSION | WebInterceptor.V_GROUP
| WebInterceptor.V_GROUP_MGR_OR_PARTNER)
public final void getPartner() throws Exception {
ITObject reqData = this.getParams();
int groupId = reqData.getInt("id");
GroupBean gb = GroupCache.getGroup(groupId);
logger.info("查看伞下合伙人数据" + Protocol.GROUP_GET_PARTNER);
String session = this.getSession();
AccountBean acc = AccountCache.getAccount(session);
if(gb.owner==acc.id) {
//获取所有合伙人
ITObject resData = GroupService.getAllPartner(groupId,acc.id);
sendResponse(0, resData);
}else {
//获取所有合伙人
ITObject resData = GroupService.getAllPartner(groupId,acc.id);
sendResponse(0, resData);
}
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
}
}

View File

@ -52,6 +52,8 @@ public class GroupLogService {
private static final int CHOOSE_TAKE_REWARD = 64;
// 洗牌
private static final int CHOOSE_XIPAI = 128;
private static final String redisdb = "group1_db13";
/**
*
*/
@ -202,7 +204,7 @@ public class GroupLogService {
total = obj.getLong("total").intValue();
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
String key = String.format("g%s:m%s:consume_hp", groupId, uid);
@ -272,7 +274,7 @@ public class GroupLogService {
String gp_key = GroupCache.genPidsKey(groupId);
Set<String> pids = Redis.use("group1_db11").zrangeByScore(gp_key, 10, 11);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
ITArray arr = TArray.newInstance();
try {
for (String pid : pids) {
@ -351,7 +353,7 @@ public class GroupLogService {
ITArray temp = TArray.newInstance();
ITArray list = DataBase.use().executeQueryByTArray(sql);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
for (int i = 0; i < list.size(); ++i) {
@ -446,7 +448,7 @@ public class GroupLogService {
ITArray temp = TArray.newInstance();
int allTotalWin = 0;
ITArray list = DataBase.use().executeQueryByTArray(sql);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
for (int i = 0; i < list.size(); ++i) {
@ -496,7 +498,7 @@ public class GroupLogService {
ITArray temp = TArray.newInstance();
ITArray list = DataBase.use().executeQueryByTArray(sql);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
for (int i = 0; i < list.size(); ++i) {
@ -507,7 +509,7 @@ public class GroupLogService {
int tagUid = objLine.getInt("uid");
AccountBean acc = AccountCache.getAccount(tagUid);
objLine.putString("nick", acc.nick);
objLine.putString("nick",acc==null?"": acc.nick);
if (tagUid != uid) {
// int newBeginTime = beginTime - 86400 * 30;
@ -654,7 +656,7 @@ public class GroupLogService {
ITArray temp = TArray.newInstance();
ITArray list = DataBase.use().executeQueryByTArray(sql);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
for (int i = 0; i < list.size(); ++i) {
@ -809,7 +811,7 @@ public class GroupLogService {
log.info("统计sql:" + sql);
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
Jedis jedis10 = Redis.use("group1_db10").getJedis();
try {
@ -819,7 +821,10 @@ public class GroupLogService {
ITObject objLine = list.getTObject(i);
int tagUid = objLine.getInt("uid");
AccountBean acc = AccountCache.getAccount(tagUid);
objLine.putString("nick", acc.nick);
if (acc != null) {
objLine.putString("nick", acc.nick);
}
getMemberData(jedis9, tagUid, objLine, groupId, timeType, beginTime, endTime, true, true);
}
@ -875,7 +880,7 @@ public class GroupLogService {
list = DataBase.use().executeQueryByTArray(sql);
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
Jedis jedis10 = Redis.use("group1_db10").getJedis();
try {
@ -885,7 +890,7 @@ public class GroupLogService {
ITObject objLine = list.getTObject(i);
int tagUid = objLine.getInt("uid");
AccountBean acc = AccountCache.getAccount(tagUid);
objLine.putString("nick", acc.nick);
objLine.putString("nick", acc==null?"":acc.nick);
getMemberData(jedis9, tagUid, objLine, groupId, timeType, beginTime, endTime, true, true);
}
@ -936,15 +941,19 @@ public class GroupLogService {
int total_round = _getCountValue(jedis9, key + "round_log" + self, beginTime, endTime);
String roundSql = "select ifnull(sum(round_cnt),0) round_cnt,ifnull(sum(bigwin_cnt),0) bigwin_cnt from team_round_stat_day where uid=" + uid + " and stat_day>="
+ beginTime +" and stat_day<"+endTime;
String roundSql = "select ifnull(sum(round_cnt),0) round_cnt,ifnull(sum(bigwin_cnt),0) bigwin_cnt from team_round_stat_day where uid="
+ uid + " and stat_day>=" + beginTime + " and stat_day<" + endTime;
log.info("roundSql:" + roundSql);
ITArray roundArr = DataBase.use().executeQueryByTArray(roundSql);
if (roundArr.size() > 0) {
ITObject userData = roundArr.getTObject(0);
total_round = userData.getDouble("round_cnt").intValue()>0?userData.getDouble("round_cnt").intValue():total_round;
valid_round = userData.getDouble("bigwin_cnt").intValue()>0?userData.getDouble("bigwin_cnt").intValue():valid_round;
total_round = userData.getDouble("round_cnt").intValue() > 0
? userData.getDouble("round_cnt").intValue()
: total_round;
valid_round = userData.getDouble("bigwin_cnt").intValue() > 0
? userData.getDouble("bigwin_cnt").intValue()
: valid_round;
}
// if (beginTime==1753286400&&endTime==1753372800){
// param.putInt("total_round" , total_round+valid_round/100);
@ -1230,7 +1239,7 @@ public class GroupLogService {
log.info("查询sql:" + sql);
ITArray arr = DataBase.use().executeQueryByTArray(sql);
if (arr.size() > 0) {
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
String strtmp = "";
for (int i = 0; i < arr.size(); ++i) {
@ -1649,7 +1658,7 @@ public class GroupLogService {
int beginTime = DateUtils.getBeginDay() - 9 * 24 * 3600;
long upper_count = 0;
long sub_count = 0;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
String str = null;
for (int i = 0; i < 10; ++i) {
@ -1751,7 +1760,7 @@ public class GroupLogService {
if (type == 1) {
String sql = String.format("SELECT uid FROM group_member WHERE groupId =%s AND lev <3", groupId);
ITArray arr = DataBase.use().executeQueryByTArray(sql);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
ITArray list = TArray.newInstance();
for (int i = 0; i < arr.size(); ++i) {
@ -1765,7 +1774,7 @@ public class GroupLogService {
jedis9.close();
}
} else {
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
ITArray list = TArray.newInstance();
ITObject info = _getHpLogMgrInfo(jedis9, groupId, uid, beginTime, endTime, type == 1);
@ -1809,22 +1818,26 @@ public class GroupLogService {
int reward_hpnum = 0;
if (limit == 0) {
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
String hp_cost_key = String.format("g%s:hp_cost", groupId);
String hp_reward_key = String.format("g%s:hp_reward", groupId);
String total_round = String.format("g%s:round", groupId);
String valid_round = String.format("g%s:valid_room", groupId);
log.info("盟主号大赢家总数:" + _getCountValue(jedis9, valid_round, beginTime, endTime));
valid_count = _getCountValue(jedis9, valid_round, beginTime, endTime);
GroupBean gb = GroupCache.getGroup(groupId);
String roundSql = "select ifnull(sum(round_cnt),0) round_cnt,ifnull(sum(bigwin_cnt),0) bigwin_cnt from team_round_stat_day where uid=" + gb.owner + " and stat_day>="
+ beginTime +" and stat_day<"+endTime;
String roundSql = "select ifnull(sum(round_cnt),0) round_cnt,ifnull(sum(bigwin_cnt),0) bigwin_cnt from team_round_stat_day where uid="
+ gb.owner + " and stat_day>=" + beginTime + " and stat_day<" + endTime;
ITArray roundArr = DataBase.use().executeQueryByTArray(roundSql);
if (roundArr.size() > 0) {
ITObject userData = roundArr.getTObject(0);
valid_count = userData.getDouble("bigwin_cnt").intValue()>0?userData.getDouble("bigwin_cnt").intValue():valid_count;
valid_count = userData.getDouble("bigwin_cnt").intValue() > 0
? userData.getDouble("bigwin_cnt").intValue()
: valid_count;
}
// String reward_hp = String.format("g{%s}:m%s:", groupId,uids);
@ -1862,9 +1875,11 @@ public class GroupLogService {
ITArray xipaiArray = DataBase.use().executeQueryByTArray(xipaisql);
if (xipaiArray.size() == 0) {
// 获得赠送
resData.putDouble("pump", pump);
} else {
ITObject xipaiData = xipaiArray.getTObject(0);
// 获得赠送
resData.putDouble("pump", pump - xipaiData.getDouble("hp"));
}
@ -1873,7 +1888,10 @@ public class GroupLogService {
// resData.putInt("pump", hp_cost);
resData.putInt("gains", hp_cost - hp_reward);
// 总数
resData.putInt("count", count);
// 场次
log.info("valid_count:" + valid_count);
resData.putInt("valid_count", valid_count);
return resData;
@ -2106,7 +2124,7 @@ public class GroupLogService {
String hp_cost_key = String.format("g%s:hp_cost%s", groupId, p_key);
String hp_reward_key = String.format("g%s:hp_reward%s", groupId, p_key);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
int v_round = _getCountValue(jedis9, valid_key, beginTime, endTime);
int round = _getCountValue(jedis9, round_key, beginTime, endTime);
@ -2209,7 +2227,7 @@ public class GroupLogService {
String gp_key = GroupCache.genPidsKey(groupId);
Set<String> pids = Redis.use("group1_db11").zrangeByScore(gp_key, 10, 11);
GroupMemberBean uid_bean = GroupCache.getMember(groupId, uid);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
ITArray arr = TArray.newInstance();
try {
if (uid_bean.lev < 3) {
@ -2219,6 +2237,8 @@ public class GroupLogService {
String round_key = String.format("g%s:round:p%s", groupId, pid);
obj.putInt("round", _getCountValue(jedis9, round_key, beginTime, endTime) * 100);
String valid_key = String.format("g%s:valid_room:p%s", groupId, pid);
obj.putInt("valid", _getCountValue(jedis9, valid_key, beginTime, endTime) * 100);
@ -2237,16 +2257,16 @@ public class GroupLogService {
for (String pid : pids) {
ITObject obj = TObject.newInstance();
String round_key = String.format("g{%s}:m%s:all_count:p%s", groupId, uid, pid);
String round_key = String.format("g{%s}:m%s:valid_round2:p%s", groupId, uid, pid);
int all_round = _getCountValue(jedis9, round_key, beginTime, endTime);
obj.putInt("round", all_round);
obj.putInt("round", all_round*100);
String valid_key = String.format("g{%s}:m%s:valid_round2:p%s", groupId, uid, pid);
int valid = _getCountValue(jedis9, valid_key, beginTime, endTime);
obj.putInt("valid", valid);
obj.putInt("valid", valid*100);
int no_valid_key = all_round - valid;
obj.putInt("no_valid", no_valid_key);
obj.putInt("no_valid", no_valid_key*100);
String diamo_cost_key = String.format("g{%s}:m%s:valid_diamo:p%s", groupId, uid, pid);
obj.putInt("diamo_cost", _getCountValue(jedis9, diamo_cost_key, beginTime, endTime));
@ -2271,7 +2291,7 @@ public class GroupLogService {
public static final ITArray getRoundCount(int groupId, int pid) {
int bengin = DateUtils.getBeginDay() - 29 * 86400;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
ITArray arr = TArray.newInstance();
try {
String p_key = pid > 0 ? (":p" + pid) : StringUtil.Empty;
@ -2303,7 +2323,7 @@ public class GroupLogService {
public static final ITArray getHpConsumeCount(int groupId, int uid) {
int bengin = DateUtils.getBeginDay() - 2 * 86400;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
ITArray arr = TArray.newInstance();
try {
String key = String.format("g%s:m%s:consume_hp", groupId, uid);

View File

@ -1,5 +1,6 @@
package com.group.service;
import java.sql.SQLException;
import java.util.*;
import javax.xml.bind.annotation.XmlElementDecl.GLOBAL;
@ -54,6 +55,8 @@ public class GroupService {
/** 禁止同桌 */
public static final int PERMISSION_BAN_DESKMATE = 16;
public static final String redisdb = "group1_db9";
private static ITObject getGroupData(int uid, int groupId, Jedis jedis11, Jedis jedis10) {
GroupBean gb = GroupCache.getGroup(groupId);
if (gb == null)
@ -1241,7 +1244,7 @@ public class GroupService {
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("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
hp = Math.abs(hp);
CountUtil.countLogByDay(hp_mgr_key, hp, jedis9);
@ -1251,7 +1254,7 @@ public class GroupService {
}
} else {
String hp_par_id_key = String.format("g%s:hp_par:%s:u%s", groupId, c_tem, uid);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
hp = Math.abs(hp);
CountUtil.countLogByDay(hp_par_id_key, hp, jedis9);
@ -1304,7 +1307,7 @@ public class GroupService {
long day_rewad_1 = 0;
long day_rewad_2 = 0;
// int all_day_reward = 0;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
String key = String.format("g%s:hp_reward:m%s", groupId, tagId);
day_rewad = CountUtil.getCountLogByDay(key, jedis9);
@ -1357,7 +1360,7 @@ public class GroupService {
}
int day_rewad = 0;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
String key = String.format("g%s:hp_reward:m%s", groupId, tagId);
day_rewad = CountUtil.getCountLogByDay(key, jedis9);
@ -1612,7 +1615,7 @@ public class GroupService {
}
public static final ITObject takeBankHp(int groupId, int uid, int tagId, long hp) throws Exception {
log.info("takeBankHp uid:" + uid + " tagId:" + tagId + " hp:" + hp / 1000);
log.info("takeBankHp uid:" + uid + " tagId:" + tagId + " hp:" + hp / 100);
if (hp <= 0) {
throw new WebException(ErrorCode._FAILED);
}
@ -1933,7 +1936,7 @@ public class GroupService {
String delnick = delacc.nick;
String delPortrait = delacc.portrait;
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
ITObject obj = new TObject();
try {
GroupLogService.getMemberData(jedis9, delid, obj, groupId, 1, 0, 0, true, true);
@ -1974,7 +1977,7 @@ public class GroupService {
public static final ITArray getKickLog(int groupId, int id, int limit, int num) throws Exception {
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
ITArray kickLogList = TArray.newInstance();
try {
@ -2702,7 +2705,7 @@ public class GroupService {
obj.putInt("online", 1);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
int endtime = DateUtils.getBeginDay() + 86400;
int begintime = endtime - 86400 * 1;
@ -2821,7 +2824,7 @@ public class GroupService {
obj.putString("parentId_nick", StringUtil.Empty);
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
int endtime = DateUtils.getBeginDay() + 86400;
int begintime = endtime - 86400 * 1;
@ -2930,7 +2933,7 @@ public class GroupService {
obj.putInt("online", 1);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
int endtime = DateUtils.getBeginDay() + 86400;
int begintime = endtime - 86400 * 1;
@ -3247,7 +3250,7 @@ public class GroupService {
} finally {
jedis1b.close();
}
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
int endtime = DateUtils.getBeginDay() + 86400;
int begintime = endtime - 86400 * 1;
@ -3262,8 +3265,10 @@ public class GroupService {
if (StringUtil.isNotEmpty(tagName)) {
// String sql = String.format("select id from account as a " + "right join group_member as b "
// + "on a.id = b.uid and b.groupId =%s " + "where nick like '%%%s%%'", groupId, tagName);
String sql = String.format("select id from account as a " + "right join group_member as b "
+ "on a.id = b.uid and b.groupId =%s " + "where nick like '%%%s%%'", groupId, tagName);
+ "on a.id = b.uid and b.groupId =%s " + "where id ='%s'", groupId, tagName);
ITArray arr = DataBase.use().executeQueryByTArray(sql);
if (arr.size() > 0) {
@ -3279,6 +3284,9 @@ public class GroupService {
gm_key = GroupMemberCache.genKey(groupId, tag);
map = jedis10.hgetAll(gm_key);
if (map == null || map.get("opt") == null) {
continue;
}
if (map.size() == 0 || Integer.parseInt(map.get("opt")) == 2) {
continue;
}
@ -3346,8 +3354,8 @@ public class GroupService {
temp.putInt("queueid", Integer.parseInt(map.get("queueid") == null ? "0" : map.get("queueid")));
temp.putInt("seeid", Integer.parseInt(map.get("seeid") == null ? "0" : map.get("seeid")));
AccountBean acc = AccountCache.getAccount(tag);
temp.putString("nick", acc.nick);
temp.putString("portrait", acc.portrait);
temp.putString("nick", acc==null?"":acc.nick);
temp.putString("portrait", acc==null?"":acc.portrait);
String last_time = map.get("last_time");
temp.putInt("last_time", StringUtil.isNotEmpty(last_time) ? Integer.parseInt(last_time) : 0);
String permission = map.get("permission");
@ -3356,7 +3364,7 @@ public class GroupService {
// --调控
Jedis jedis1bb = Redis.use("group1_db1").getJedis();
try {
String diaokongid = jedis1bb.hget("gods_value", Integer.toString(acc.id));
String diaokongid = jedis1bb.hget("gods_value", Integer.toString(tag));
if (StringUtil.isNotEmpty(diaokongid)) {
temp.putInt("diaokongid", Integer.parseInt(diaokongid));
} else {
@ -4411,7 +4419,7 @@ public class GroupService {
+ hpOnOff);
Jedis jedis11 = Redis.use("group1_db11").getJedis();
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
RedisLock lock = null;
try {
@ -4648,7 +4656,7 @@ public class GroupService {
String gp_key = GroupCache.genPidsKey(groupId);
String p_key = GroupCache.genPlayKey(groupId, pid);
RedisLock lock = new RedisLock(gp_key, jedis11);
Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis9 = Redis.use(redisdb).getJedis();
try {
lock.lock();
@ -5053,7 +5061,6 @@ public class GroupService {
}
}
// Jedis jedis9 = Redis.use("group1_db9").getJedis();
Jedis jedis10 = Redis.use("group1_db10").getJedis();
try {
for (int i = 0; i < list.size(); ++i) {
@ -5552,4 +5559,84 @@ public class GroupService {
}
return 1;
}
/**
*
*
* @param groupId
* @param uid
* @param limit
* @param num
* @param minus_only
* @param type 1 2
* @return
* @throws Exception
*/
public static final ITObject getAllPartner(int groupId, int uid) throws Exception {
ITObject obj1 = TObject.newInstance();
GroupBean gb = GroupCache.getGroup(groupId);
if (gb.owner == uid) {
// 查看所有合伙人
String sql = "select gm.uid,gm.partnerLev,a.nick from group_member gm,account a where gm.uid=a.id and gm.groupId=? and gm.partnerLev>0";
String[] params1 = new String[1];
params1[0] = groupId + "";
ITArray arr = DataBase.use().executeQueryByTArrayLogin(sql, params1);
if (arr.size() > 0) {
obj1.putTArray("partners", arr);
}
} else {
// 查看伞下合伙人
ITArray allPartners = getAllUnderPartnersBatch(groupId, uid);
obj1.putTArray("partners", allPartners);
}
return obj1;
}
/**
*
*/
public static ITArray getAllUnderPartnersBatch(int groupId, int uid) {
try {
ITArray allPartners = TArray.newInstance();
Set<Integer> processedUids = new HashSet<>(); // 防止循环引用
Queue<Integer> uidQueue = new LinkedList<>();
uidQueue.add(uid);
while (!uidQueue.isEmpty()) {
Integer currentUid = uidQueue.poll();
// 查询当前用户的下属合伙人
String sql = "select gm.uid,gm.partnerLev,a.nick from group_member gm,account a where gm.uid=a.id and gm.groupId=? and gm.partnerLev>0 and gm.parentId=?";
String[] params1 = new String[2];
params1[0] = groupId + "";
params1[1] = currentUid + "";
ITArray directPartners;
directPartners = DataBase.use().executeQueryByTArrayLogin(sql, params1);
for (int i = 0; i < directPartners.size(); i++) {
ITObject partner = directPartners.getTObject(i);
Integer partnerUid = partner.getInt("uid");
// 避免重复处理
if (!processedUids.contains(partnerUid)) {
processedUids.add(partnerUid);
allPartners.addTObject(partner);
uidQueue.add(partnerUid); // 加入队列继续查询其下属
}
}
}
return allPartners;
} catch (Exception e) {
log.error("查询伞下合伙人失败", e);
}
return null;
}
}

View File

@ -88,6 +88,8 @@ public class Protocol {
/**绑定账号*/
public static final String LOCK_DEVICE ="lock_device";
/**手机验证*/
public static final String PHONE_CHECK ="phone_check";
}

View File

@ -21,6 +21,8 @@ import java.util.Random;
import java.util.Set;
import java.util.UUID;
import org.eclipse.jetty.util.log.Log;
import com.aliyuncs.utils.StringUtils;
import com.data.bean.AccountBean;
import com.data.bean.GameBean;
@ -343,13 +345,15 @@ public class AccountService extends Controller {
userData.putUtfString("nick", "景都" + id + "");
userData.putInt("sex", 1);
userData.putUtfString("portrait", StringUtil.Empty);
userData.putUtfString("acc", reqData.getUtfString("phone") + "_" + UUID.randomUUID());
} else {
userData.putUtfString("acc", reqData.getUtfString("acc"));
userData.putUtfString("portrait", reqData.getUtfString("portrait"));
String nick = reqData.getUtfString("nick");
nick = nick.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5]", " ");
userData.putUtfString("nick", nick);
int sex = reqData.getInt("sex");
int sex = reqData.getInt("sex") == null ? 1 : reqData.getInt("sex");
if (sex == 0) {
sex = 1;
reqData.putInt("sex", sex);
@ -726,6 +730,7 @@ public class AccountService extends Controller {
reqData.putUtfString("nick", strNick);
int accountid = 0;
if (resultArray.size() == 0) {
reqData.putInt("sex", Integer.parseInt(object.get("sex").toString().replaceAll("\"", "")));
accountid = register(reqData);
// if (deviceCode == null) {
@ -1030,6 +1035,7 @@ public class AccountService extends Controller {
}
resData.putUtfString("groupWeb", MainServer.GROUP_WEB_URL);
logger.info("reqData:" + resData);
return resData;
}
@ -1540,7 +1546,7 @@ public class AccountService extends Controller {
// }
// logger.info(resData.getBoolean("havegroup"));
//保存设备登录日志
// 保存设备登录日志
String loginSql = String.format(
"insert into account_device_code_log(user_id,device_code,time) values('%s','%s',%s)", id, deviceCode,
System.currentTimeMillis() / 1000);
@ -2525,6 +2531,200 @@ public class AccountService extends Controller {
}
}
@ActionKey(value = Protocol.PHONE_LOGIN_2)
public final void phoneLogin2() throws Exception {
ITObject reqData = this.getParams();
reqData.putString("phone", "phone");
String decryptedText = RSAUtils.decrypt(reqData.getString("data"));
String loginToken = reqData.getString("loginToken");
logger.info("==========>decryptedText = " + decryptedText);
logger.info("==========>loginToken = " + loginToken);
JsonObject object = new Gson().fromJson(decryptedText, JsonObject.class);
String deviceCode = object.get("deviceCode").toString().replaceAll("\"", "");
// String loginToken = object.get("loginToken").toString().replaceAll("\"", "");
String phone = "";
// 加密后的phone
// Response: {"id":1086340087656099840,"code":8000,"content":"get phone success","exID":null,"phone":"BdmUpwKjrxxdBKivExn2DirpAq0/XkKcg1u2B3Jbd45npyn8Z6ZAa+Wzuj31FQ05y00llfilZT1dB9+0T4Gb9XZgXB1Ti+ohAVCbRXV8JeRzIY1gcQEhdKS+Ei5LBiEdWQAV09o4nFzAQIOwSojzZwJeuQF1Nh00I89lYzHzjEM=","score":0,"riskCheck":{"code":0,"content":"success","score":0,"tags":null,"detail":null}}
try {
String phoneJson = PhoneCheck.getCheck(loginToken);
JsonObject phoneObject = new Gson().fromJson(phoneJson, JsonObject.class);
String phoneRSA = phoneObject.get("phone").toString();
phone = PhoneRSAUtils.decrypt(phoneRSA);
logger.info("==========>phone = " + phone);
} catch (Exception e) {
throw new WebException(ErrorCode._FAILED);
}
if (phone.length() < 11) {
throw new WebException(ErrorCode._FAILED);
}
if (StringUtils.isEmpty(deviceCode)) {
logger.error("deviceCode:null" + "--" + ErrorCode._FAILED);
throw new WebException(ErrorCode._FAILED);
}
String accessDevice = Redis.use("group1_db0").hget("device:accessDevice", deviceCode);
if (StringUtil.isNotEmpty(accessDevice)) {
String accessDeviceCount = Redis.use("group1_db0").hget("device:accessDevice", deviceCode);
long count = Long.parseLong(accessDeviceCount);
if (count < 1000) {
count = count + 1;
Redis.use("group1_db0").hset("device:accessDevice", deviceCode, count + "");
Redis.use("group1_db0").expire("device:accessDevice", 86400);
} else {
throw new WebException(ErrorCode._NO_SESSION);
}
} else {
Redis.use("group1_db0").hset("device:accessDevice", deviceCode, "1");
Redis.use("group1_db0").expire("device:accessDevice", 86400);
}
String sql = String.format("SELECT a.* FROM account a,account_phone ap WHERE ap.phone=? and ap.uid=a.id");
String[] params1 = new String[1];
params1[0] = phone + "";
ITArray resultArray = DataBase.use().executeQueryByTArrayLogin(sql, params1);
if (resultArray.size() == 0) {
// 手机号码第一次注册
int accountid = register(reqData);
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);
ITObject resData = fillLoginData(session, accountid);
// 保存手机号码
String phoneSql = String.format("insert into account_phone(uid,phone) values('%s','%s')", accountid, phone);
DataBase.use().executeUpdate(phoneSql);
String token = Utils.getMD5Hash(accountid + "_" + phone + "_" + 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.putInt("is_lock", 1);
// 保存设备登录日志
String loginSql = String.format(
"insert into account_device_code_log(user_id,device_code,time) values('%s','%s',%s)", accountid,
deviceCode, System.currentTimeMillis() / 1000);
DataBase.use().executeUpdate(loginSql);
this.sendResponse(ErrorCode._SUCC, resData);
}
if (resultArray.size() > 0) {
// 判断设备是否已经锁定
int isLock = resultArray.getTObject(0).getInt("is_lock");
String saveDeviceCode = resultArray.getTObject(0).getString("device_code");
if (isLock == 1 && !deviceCode.equalsIgnoreCase(saveDeviceCode)) {
throw new WebException(ErrorCode.IS_LOCK);
}
Set<String> banDeviceList = Redis.use("group1_db1").smembers("bandevice");
for (String banDevice : banDeviceList) {
if (banDevice.equalsIgnoreCase(deviceCode)) {
logger.error("deviceCode:" + deviceCode + "--" + ErrorCode._FAILED);
throw new WebException(ErrorCode._FAILED);
}
}
ITObject userData = resultArray.getTObject(0);
int accountid = userData.getInt("id");
UpdateUserData(userData, accountid);
AccountBean acc_bean = AccountCache.getAccount(accountid);
String session = acc_bean.redis_key;
this.setSession(session);
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 userData1 = TObject.newInstance();
userData1.putUtfString("nick", userData.getUtfString("nick"));
userData1.putUtfString("portrait", userData.getUtfString("portrait"));
userData1.putInt("sex", userData.getInt("sex"));
updateSession(userData, accountid);
}
logger.info("phone:" + phone + ", device_code=" + deviceCode);
ITObject resData = fillLoginData(session, accountid);
String token = Utils.getMD5Hash(accountid + "_" + phone + "_" + 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.putInt("is_lock", isLock);
// 保存设备登录日志
String loginSql = String.format(
"insert into account_device_code_log(user_id,device_code,time) values('%s','%s',%s)", accountid,
deviceCode, System.currentTimeMillis() / 1000);
DataBase.use().executeUpdate(loginSql);
this.sendResponse(ErrorCode._SUCC, resData);
}
}
public static void main(String[] args) {
String[] params1 = new String[2];
params1[0] = "123" + "";

View File

@ -0,0 +1,67 @@
package com.mjlogin.service;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.HttpResponse;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.Header;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class PhoneCheck {
public static String getCheck(String loginToken) {
CloseableHttpClient httpClient = HttpClients.createDefault();
String responseBody = "";
try {
HttpPost httpPost = new HttpPost("https://api.verification.jpush.cn/v2/web/loginTokenVerify");
// 设置请求头
httpPost.setHeader("Content-Type", "application/json");
// 设置Basic认证 (7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1)
String appKey= "b887e7338c27611c29bcdab4";
String appSecret= "026877ccc36d03b0a673dc26";
String auth = appKey+":"+appSecret;
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
String authHeader = "Basic " + new String(encodedAuth);
httpPost.setHeader("Authorization", authHeader);
// 设置请求体
String jsonBody = "{\"loginToken\":\"" + loginToken + "\"}";
StringEntity entity = new StringEntity(jsonBody, StandardCharsets.UTF_8);
httpPost.setEntity(entity);
// 执行请求
HttpResponse response = httpClient.execute(httpPost);
// 获取响应
responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
int statusCode = response.getStatusLine().getStatusCode();
System.out.println("Status Code: " + statusCode);
System.out.println("Response: " + responseBody);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return responseBody;
}
public static void main(String[] args) {
PhoneCheck.getCheck(
"RuyXf6ioDCqBm1ZRlH307AktN1On5MO6M5cg6S9iuioioQ3X/rG6xcIWUKhgmTwu9Yh6zREiZAbNj3tGdBcHYLIRRWBFVLe90/RiPqO1QTQwYe5Yw0juorBokpDGo9huIPN8FWPfmb77vG9EqiCbV2v9shizPSkTnSCaum3akOO2wHkflf6piqheaKHYKmkdxSJLNodogQ6OtZB4RCyKvbjYAwK/+yHQDIwJiodQme7XkQ2xqsnRfLbu7fzwCwFwH91PCwbHcLodn2WbgTJp4QBOA/pQCSUA9eA2Mx3cZllHcWPo85Ww9HCssb/V1G0GOkObf03Ko6bbPs/9d7uH9BIvOSBII+r9Z5Y/fNQlzHa1DCGC+k/RQa85XstqBii7q+dtyoL2puv6beTlU1ZQnqTWglqbk1x5JAQbt3HdNiDRXX31kn3O2klOZHprlxHbtobvOU2/LOpCc2a+a7UrQEKSpgyZ5vhTOiEsJOAxYE2/QGIwqr+BSxsjTwX1bPEOKxgdak4G2Z9hiXxLBtZ96Q==");
}
}

View File

@ -0,0 +1,112 @@
package com.mjlogin.service;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.JsonObject;
import javax.crypto.Cipher;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
/**
* Created By Rock-Ayl on 2020-10-14
* RSA
* 0.
* 1.
* 2.
*/
public class PhoneRSAUtils {
protected static Logger logger = LoggerFactory.getLogger(PhoneRSAUtils.class);
// public static String appIdPublicKey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEApqOWMi9qWZ1e0TfzsuP+cstS6J7O+cRSX+m/dF7gHp4Yxp0iEOHCFskb7XkCTyqXCazVVkzrw5u1h/oXLCTBNtRlzR2BtFpX+Ad1i8PoObur5yqt6Yr3A/JmUV6BQzQw9pH+9pLPUtdO3nArF4bj80SqC2FqTSGj9Jx2qoM1E2zDSyAhPyEPc27wtakbZKzp2pteT/Gd7yteXk4vEf/MNS0iWOxtC/lAYwNZUzlE6dD/7iXb5L6GnFormDnrZE5P70PKjU9iRj3DZ0CZvh9JriTfub8yrFkHqs1BOS9s+RT0q+ngh2+mrAKcPIUn3MyBUjV0ZTR2yuRZZH/OAGCeyu2RYDVLqWlq4CUZNeW4agbOh84R1/upBLl4nu9JT94w3AahYyG5emC6a7YcNfbhqHFo7eFaf0WkpJ1NvLxsLHNt3RpIUPZzuz795nzxgAR+mGNSv+3jPr299cxJn/ass/CoWTHXrwSVLEcLHto70Dj3TRDCCa88hMrz2j89RRoIR6M4zCG7sfKg3PA3iteqJV+HlBh+gz5fmQ8QCaH3i15MSMtWsW4EhcPs0sIahuB1vXI3A3um/1Md8vuvkoHrJMT52uMlz+YQGw9b6MsPcBa9BEKV/WCBYhAYYauAaiLk1rrUYNrS9H/u7biYSg7N0DzxnDc4L0hbSc8n0Kaxcq8CAwEAAQ==";
// private static String appIdPrivateKey = "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";
//RSA-公钥
public static String PublicKey="MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAmZLmb4paD13E2uOueFStT1g8OnA4JQYkN4PZl/il7Nb05EbZrRbQz/5VbiZxc+S4asfFrrU0d++gjiluiAbBBhgtQSi+eNZuJ2wrBxjvN3W9d14XMmZKDg21Knu7tDUwOlEfCPVMZ/nJ+9YU6mnEvme29UgpI4RbEIIWPuDW3DavbaOvZ/cYP+0m2pxU3mETwDbVpbM3LimJ4JOBIs7XhV2UqEUfRVCYiuZUkydOCs1TgTJRJC5qgYpx4wUZ0ja7t9jP3klg/vjjyA1SDnC98bQLR5QzVJE1LvI2Rr3AHfZS0hckg0WAR87D1R8sGjmQ0TUi4qanpQYhEL4dBH8a6TX/xssobM7M+XgFsGiT4fWG18JhJM98rhVEk2AUaXgnFNf3OyLP+NuYrqjYamuug00s2azCl/rQCkvnLWO4W+lPn27ZinnBRg1+r2fNws7dPPa/8tWScRcTtfaidYsQP2lnYJvFgc299HdQL7iFgL336NihUxll09Hhm7vf8+N0ZP5TLE8SRoSfHNgHup6k9YG5e+V9bW4VckQFgPPBlHSS0mDEOvD9d54+F1cBg/sG8XMduW5WhfroYsMbRzB9a4rIfctn6yqpM+ot2EW8CKgiOVM5lJQhBwX5rMKnMTaApt6EIigY6jRVFNCOtQPDZ9prLBsp3asQxf7Vg9kfrVUCAwEAAQ==";
//RSA-私钥
private static String PrivateKey="MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALHmd2wIJ/lhQHAp"
+ "VqMXU7y+WvBK578bFquEBTaKuWHUHM22Iqn20XhqG9n0JRWf6+yYOZy8rTHEa3RG"
+ "bxO6R5e3z0LRcmwKpDAmNP4k4vC1uW8kWNnnnYbDFfM+hgABI1p88VyB05dId6bi"
+ "XWDRpIagvQ8XMCY6u+DAac7o9o/rAgMBAAECgYAmlBfpsYsZpWFX8V78Vx6tm4oU"
+ "+elvo+wynZqTzVmOQXVNluXFfeTG/Bu2FB/GpLuAvzIfLztPw4yZ1nxYBtlnTKDu"
+ "IDTzCa1f69OP9r0x9JNi0UwVxf50q225pkhWKuMu8wO3Eou3UriqML0RrswOOKrz"
+ "doBCoMCl2Vp+KOtwYQJBAOEEGgcEFksY+B4I1epX+TzDnjFd9uagjPxTGmTQWEl6"
+ "/4qp45DP05Zz2yta9dB/wwIEZ4ApQ4TgDkp62s1YebUCQQDKZYRGqjk9jhJ4p5Xs"
+ "DryldszCASwG5G4bKaVC3pKMVIakak7SjwHClkK4GoMACBG2C4MIleNXMhfh7tF2"
+ "KGcfAkBtqdYVfURwLScfXCcFIwLxPlUmsijWlYCgqM/AOloM1ckdB1dFCESSmrxC"
+ "EP6kMuATZ5oZuAKUC65rVhy0313RAkAxZm3OwaWO/KpNgLn7D+3DhSedAqQ4WnD1"
+ "eEi59ZFXZxol7zyl7/nCAOLwBKiMzWtlP5IP+mWu1q81mhDOAjaJAkEAsgi/Poht"
+ "Lkr8xRLznEArcexj5dXPAcxozR2B/2+WyX1VWrM9daev5p/cRAU+GJWUHviRKrFC"
+ "/6WJe6x+LiPFBA==";
// //初始化
// static {
// try {
// //KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
// KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
// //初始化密钥对生成器密钥大小为96-1024位
// keyPairGen.initialize(4096, new SecureRandom());
// //生成一对密钥
// KeyPair keyPair = keyPairGen.generateKeyPair();
// //公钥存储
// appIdPublicKey = new String(Base64.encodeBase64(keyPair.getPublic().getEncoded()));
// //私钥存储
// appIdPrivateKey = new String(Base64.encodeBase64((keyPair.getPrivate().getEncoded())));
// } catch (NoSuchAlgorithmException e) {
// logger.error("RSA生成秘钥异常:[{}]", e);
// }
// }
/**
* RSA
*
* @param str
* @param privateKey
* @return
* @throws Exception
*/
public static String decrypt(String str) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(Base64.decodeBase64(PrivateKey))));
return new String(cipher.doFinal(Base64.decodeBase64(str.getBytes("UTF-8"))));
}
/**
* RSA
*
* @param str
* @param publicKey
* @return
* @throws Exception
*/
public static String appIdencrypt(String str, String appIdpublicKey) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decodeBase64(appIdpublicKey))));
return Base64.encodeBase64String(cipher.doFinal(str.getBytes("UTF-8")));
}
//测试
public static void main(String[] args) throws Exception {
String phone = decrypt("BdmUpwKjrxxdBKivExn2DirpAq0/XkKcg1u2B3Jbd45npyn8Z6ZAa+Wzuj31FQ05y00llfilZT1dB9+0T4Gb9XZgXB1Ti+ohAVCbRXV8JeRzIY1gcQEhdKS+Ei5LBiEdWQAV09o4nFzAQIOwSojzZwJeuQF1Nh00I89lYzHzjEM=");
System.out.println("解密后:"+phone);
// String appid = "wx40ac640ee6bd1116";
// String appSecret = "cde030153f5b97874c5e6063c70c0f97";
// JsonObject object = new JsonObject();
// object.addProperty("appid", appid);
// object.addProperty("appSecret", appSecret);
// String encryptText = RSAUtils.encrypt(appid.toString(), RSAUtils.appIdPublicKey);
// System.out.println("加密后的数据:"+encryptText);
}
}