4 Commits 4cbd856487 ... dadf356eac

Autor SHA1 Mensagem Data
  pigflower dadf356eac Merge branch '360test' of http://43.226.57.217:3000/yishanyou/GongFuServer into 360test 1 mês atrás
  pigflower af5ffbf2aa feat:抖音挂机 1 mês atrás
  pigflower 57dcedf8f5 Merge branch '360test' of http://43.226.57.217:3000/yishanyou/GongFuServer into 360test 1 mês atrás
  pigflower ab6d89f250 fix:区服列表bug修改 1 mês atrás

+ 3 - 0
script/common/ProtoID.lua

@@ -1827,3 +1827,6 @@ _ENV[1904]="CG_ZHUANPAN_DY_DESKTOP_SET"
 _ENV[1905]="CG_ZHUANPAN_DY_DESKTOP_QUERY"
 _ENV[1906]="GC_ZHUANPAN_DY_DESKTOP_QUERY"
 
+_ENV[1907]="CG_BATTLE_HANG_FULL_TIME_QUERY"
+_ENV[1908]="GC_BATTLE_HANG_FULL_TIME_QUERY"
+

+ 14 - 1
script/module/battle/BattleLogic.lua

@@ -2761,6 +2761,19 @@ local function hangExpGet(human,isDiamond)
     return 0, items
 end
 
+-- 下发挂机奖励满载时间戳
+-- fullTime = expTs1 + maxHangTime
+--   若 fullTime <= now  则奖励已满,满的时刻为 fullTime
+--   若 fullTime >  now  则奖励未满,将在 fullTime 时满
+function sendHangFullTime(human)
+    local tBattleOut = BattleLogic_GetBattleOut(human)
+    if not tBattleOut then return end
+    local maxHangTime = getHangMaxTime(human)
+    local msgRet = Msg.gc.GC_BATTLE_HANG_FULL_TIME_QUERY
+    msgRet.fullTime = tBattleOut.expTs1 + maxHangTime
+    Msg.send(msgRet, human.fd)
+end
+
 -- 获取挂机收益
 function hangGet(human,isDiamond)
     local ret, items = hangExpGet(human,false)
@@ -2770,7 +2783,7 @@ function hangGet(human,isDiamond)
         return Broadcast.sendErr(human, Lang.COMMON_ADD_JINBI_LIMIT)
     elseif ret == 0 then
         query(human)
-        
+        sendHangFullTime(human)
         RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1101)
         TreasureChestLogic.TreasureChestLogic_GetAllBoxNum(human)
     end

+ 4 - 0
script/module/battle/Handler.lua

@@ -12,6 +12,10 @@ function CG_BATTLE_HANG_GET(human)
 	BattleLogic.hangGet(human)
 end
 
+function CG_BATTLE_HANG_FULL_TIME_QUERY(human)
+	BattleLogic.sendHangFullTime(human)
+end
+
 function CG_BATTLE_NODE_SET(human, msg)
 	BattleLogic.nodeSet(human, msg.battleID)
 end

+ 9 - 0
script/module/battle/Proto.lua

@@ -153,6 +153,15 @@ GC_BATTLE_HANG_QUERY = {
 CG_BATTLE_HANG_GET = {
 }
 
+-- 挂机奖励满载时间查询
+-- fullTime: 满载时刻的Unix时间戳
+--   fullTime <= 当前时间  => 已经满了,满的时间是fullTime
+--   fullTime >  当前时间  => 还没满,将在fullTime时满
+CG_BATTLE_HANG_FULL_TIME_QUERY = {}
+
+GC_BATTLE_HANG_FULL_TIME_QUERY = {
+    {"fullTime", 1, "int"},   -- 挂机满载时的时间戳
+}
 
 -- 战役节点详细信息查询
 CG_BATTLE_NODE_DETAIL_QUERY = {

+ 1 - 0
webServer/src/channels/factory/ChannelFactory.ts

@@ -59,6 +59,7 @@ class ChannelFactory {
     this.registerHandler(18, new HongKongTaiwanChannelHandler()); // 港台渠道
     this.registerHandler(20, new ZeroOneChannelHandler()); // 0.1渠道
     this.registerHandler(21, new QingtianChannelHandler()); // 晴天SDK
+    this.registerHandler(22, new ZeroOneChannelHandler()); // 1折渠道
   }
 
   /**

+ 13 - 0
webServer/src/config/channelConfig.ts

@@ -362,4 +362,17 @@ export const channelConfigs: Record<number, ChannelConfig> = {
             productCode: QINGTIAN_PRODUCT_CODE,
         },
     },
+    22: {
+        // 0.1渠道 QuickSDK
+        channelId: 22,
+        name: "1zhe",
+        platform: "",
+        paymentConfig: {
+            signKey: ZERO_ONE_QUICK_MD5_KEY,
+            callbackKey: ZERO_ONE_QUICK_CALLBACK_KEY,
+        },
+        loginConfig: {
+            productCode: ZERO_ONE_QUICK_PRODUCT_CODE,
+        },
+    },
 };

+ 56 - 2
webServer/src/controller/ApiController.ts

@@ -18,7 +18,7 @@ import {
 import {PaymentHelper} from "../utils/PaymentHelper";
 import {SignatureVerifier} from "../utils/SignatureVerifier";
 import {ChannelConfigManager} from "../utils/ChannelConfigManager";
-import {getRoleInfoByUidAndServerId} from "../mongo/mongodb";
+import {getRoleInfoByUidAndServerId, getRoleListByUserId} from "../mongo/mongodb";
 import {min} from "moment-timezone";
 
 // platform内存缓存,key: ip:device_no,TTL 5分钟
@@ -852,7 +852,7 @@ class ApiController {
                 }
                 let minSid = 1
                 if (tag == 11) {
-                    minSid = Math.floor(((servers[0].sid || 1) - 1) / 10) * 10 + 1
+                    minSid = servers.length //新号没有角色,minsid = 最新的服
                 }
 
                 data.push({
@@ -1617,7 +1617,61 @@ class ApiController {
         }
     }
 
+    /**
+     * 通过 userId 查询该账号在各区服的角色列表
+     * 请求参数(GET/POST 均可):uid、channel_id
+     * 返回:[{ roleId, roleName, zhandouli, serverName, serverId, createTime }]
+     */
+    async getUserRoleList(ctx) {
+        const uid = ctx.query.uid || ctx.request.body?.uid;
+        const tag = ctx.query.channel_id || ctx.request.body?.channel_id || 1;
+
+        logger.info('getUserRoleList 请求参数:', {uid, tag});
+
+        if (!uid) {
+            ctx.body = ApiController.fail('uid 不能为空', -1);
+            return;
+        }
+
+        // 1. 查询该用户进入过的所有区服(join game_server 取 db_name 和区服名)
+        const enterServerList: any[] = await Server.getEnterServerListByUid(uid, tag);
+
+        logger.info('getUserRoleList enterServerList:', {
+            count: enterServerList?.length,
+            first: enterServerList?.[0] ? {
+                server_id: enterServerList[0].server_id,
+                db_name: enterServerList[0].db_name,
+                name: enterServerList[0].name,
+            } : null,
+        });
 
+        if (!enterServerList || enterServerList.length === 0) {
+            ctx.body = ApiController.success('请求成功', 1, false, []);
+            return;
+        }
+
+        // 去重(同一 server_id 可能有多条进区记录,取最新一条即可)
+        const seen = new Set<string>();
+        const uniqueServers = enterServerList.filter((s) => {
+            if (seen.has(String(s.server_id))) return false;
+            seen.add(String(s.server_id));
+            return true;
+        });
+
+        // 2. 并发查询每个区服的 MongoDB 角色信息
+        const roleList = await getRoleListByUserId(
+            uniqueServers.map((s) => ({
+                server_id: s.server_id,
+                db_name: s.db_name,
+                name: s.name,
+            })),
+            tag,
+            uid
+        );
+
+        logger.info('getUserRoleList 返回角色列表:', {uid, count: roleList.length});
+        ctx.body = ApiController.success('请求成功', 1, false, roleList);
+    }
 }
 
 module.exports = new ApiController();

+ 67 - 1
webServer/src/mongo/mongodb.ts

@@ -169,4 +169,70 @@ async function insertMailToPlayer(
     }
 }
 
-export { getDb, getCollection, closeConnection, getRoleInfoById, connectToMongo, getGuildInfoById, getRoleInfoByUidAndServerId, insertMailToPlayer };
+/**
+ * 批量查询某用户在多个区服的角色信息
+ * @param serverList  已加入区服列表,每项包含 { server_id, db_name, name (区服名) }
+ * @param tag         渠道标识(用于拼 newUniqueTag)
+ * @param uid         用户账号
+ */
+async function getRoleListByUserId(
+    serverList: Array<{ server_id: string; db_name: string; name: string }>,
+    tag: number | string,
+    uid: string
+): Promise<Array<{
+    roleId: string;
+    roleName: string;
+    roleLevel: number;
+    zhandouli: number;
+    serverName: string;
+    serverId: string;
+    createTime: number;
+}>> {
+    const results: Array<{
+        roleId: string;
+        roleName: string;
+        roleLevel: number;
+        zhandouli: number;
+        serverName: string;
+        serverId: string;
+        createTime: number;
+    }> = [];
+
+    if (!client) {
+        await connectToMongo();
+    }
+
+    for (const server of serverList) {
+        console.log(`[getRoleListByUserId] server:`, JSON.stringify(server));
+        if (!server.db_name) {
+            console.log(`[getRoleListByUserId] 跳过 server_id=${server.server_id},db_name 为空`);
+            continue;
+        }
+        try {
+            const database = client!.db(server.db_name);
+            const collection = database.collection('char');
+            const newUniqueTag = `${tag}|${server.server_id}|${uid}`;
+            console.log(`[getRoleListByUserId] 查询 db=${server.db_name} newUniqueTag=${newUniqueTag}`);
+            // MongoDB v2.x 使用 fields 而非 projection
+            const doc = await collection.findOne({ newUniqueTag });
+            console.log(`[getRoleListByUserId] 查询结果:`, doc ? `找到 name=${doc.name}` : 'null');
+            if (doc) {
+                results.push({
+                    roleId: doc._id.toString(),
+                    roleName: doc.name || '',
+                    roleLevel: doc.lv || 0,
+                    zhandouli: doc.zhandouli || 0,
+                    serverName: server.name || '',
+                    serverId: server.server_id,
+                    createTime: doc.createTime || 0,
+                });
+            }
+        } catch (error) {
+            console.error(`[getRoleListByUserId] 查询区服 ${server.server_id} 异常:`, error);
+        }
+    }
+
+    return results;
+}
+
+export { getDb, getCollection, closeConnection, getRoleInfoById, connectToMongo, getGuildInfoById, getRoleInfoByUidAndServerId, insertMailToPlayer, getRoleListByUserId };

+ 3 - 0
webServer/src/router/index.ts

@@ -92,4 +92,7 @@ router.post("/qqReport", TencentController.qqReport);
 // mianyou开服同步
 router.post("/mianyou/syncServer", ApiController.mianyouSyncServer);
 
+// 通过 userId 查询角色列表(战力、角色名、角色id、区服、创建时间)
+router.get("/getUserRoleList", ApiController.getUserRoleList);
+
 module.exports = router;