import { prop } from "@typegoose/typegoose"; import { SDK_37_CONST, SDK_PUSH_TARGET_TYPE } from "../consts"; import { RoleType } from "../db/Role"; import { UserType } from "../db/User"; import { DicPushMessage } from "../pubUtils/dictionary/DicPushMessage"; import { nowSeconds } from "../pubUtils/timeUtil"; // 37的登录验证返回参数 export class LoginValidateData37 { @prop({ required: true }) uid: number; // 用户uid @prop({ required: true }) is_phone_bind: number; // 是否绑定手机 @prop({ required: true }) is_idcard_bind: number; // 是否绑定身份证 @prop({ required: true }) is_adult: number; // 是否成年 @prop({ required: true }) vip_level: number; // vip等级 @prop({ required: true }) is_youke: number; // 是否为第三方来源 @prop({ required: true }) is_bind_alias: number; // 是否绑定平台个性账号 @prop({ required: true }) birth: number; // 用户生日 @prop({ required: true }) age: number; // 用户年龄 @prop({ required: true }) unique_realname_id: string; // 用户身份证唯一标识 @prop({ required: true }) childGameId: string; // 子游戏id @prop({ required: true }) platformAppid: string; // 渠道标识 } export interface LoginValidataReturn37 { code: number; msg: string; data: LoginValidateData37; } export type ChannelInfo = LoginValidateData37; export class PayCallback37Data { appid: string; // 平台id uid: number; // 37用户id game_id: number; // 游戏id fc_c_game_id: string; // 子游戏id sid: string; // 区服id actor_id: string; // 角色id order_id: string; // 37平台id order_no: string; // 我方订单id money: string; // 订单金额 game_coin: number; // 元宝数 product_id: string; // 商品id time: number; // 请求时间 ext: string; // 扩展参数 sign: string; constructor(params: PayCallback37Data) { this.appid = params.appid; this.uid = params.uid; this.game_id = params.game_id; this.fc_c_game_id = params.fc_c_game_id; this.sid = params.sid; this.actor_id = params.actor_id; this.order_id = params.order_id; this.order_no = params.order_no; this.money = params.money; this.game_coin = params.game_coin; this.product_id = params.product_id; this.time = params.time; this.ext = params.ext; this.sign = params.sign; } getBody() { let { appid, uid, game_id, sid, actor_id, order_id, order_no, money, game_coin, product_id, time, ext } = this; return { appid, uid, game_id, sid, actor_id, order_id, order_no, money, game_coin, product_id, time, ext } } } export class Chat37Params { game_key: string; sid: number; // 游戏区 username: number; // channelInfo.uid actor: string; // roleName actor_id: string; // roleId content: string; // 聊天内容 channel: number; // 世界=1,私聊=2,队伍=3,工会=4 ip: string; // 玩家ip time: number; // unix时间戳 sign: string; op: string; // channelInfo.platformAppid actor_level: number; // 等级 actor_recharge_gold: number; // 元宝 guildid: string = ''; // 公会id to_username: number|string = ''; // 对方channelInfo.uid to_actor: string = ''; // 对方roleName to_actor_id: string = ''; // 对方roleId to_actor_level: number|string = ''; // 对方等级 to_actor_recharge_gold: number|string = ''; // 对方元宝 constructor(content: string, channel: number) { this.game_key = SDK_37_CONST.GAME_KEY; this.content = content; this.channel = channel; this.time = nowSeconds(); } setByMyRole(role: RoleType, user: UserType) { let channelInfo = user.channelInfo; this.username = channelInfo.uid; this.actor = role.roleName; this.actor_id = role.roleId; this.ip = user.ip; this.op = channelInfo.platformAppid; this.actor_level = role.lv; this.actor_recharge_gold = role.gold; this.sid = role.serverId; } setByGuild(guildCode: string) { this.guildid = guildCode; } setByTargetRole(role: RoleType, user: UserType) { let channelInfo = user.channelInfo; if(channelInfo) { this.to_username = channelInfo.uid; this.to_actor = role.roleName; this.to_actor_id = role.roleId; this.to_actor_level = role.lv; this.to_actor_recharge_gold = role.gold; } } setSign(sign: string) { this.sign = sign; } } export class CheckName37Params { game_key: string; sid: number; // 游戏区 username: number; // channelInfo.uid actor: string; // roleName actor_id: string; // roleId ip: string; // 玩家ip time: number; // unix时间戳 sign: string; constructor(role: RoleType, roleName: string, user: UserType) { let channelInfo = user.channelInfo; this.game_key = SDK_37_CONST.GAME_KEY; this.sid = role.serverId; this.username = channelInfo.uid; this.actor = roleName; this.actor_id = role.roleId; this.ip = user.ip; this.time = nowSeconds(); } getBody() { let { game_key, sid, username, actor_id, ip, time } = this; return { game_key, sid, username, actor_id, ip, time } } setSign(sign: string) { this.sign = sign; } } export class PostName37Params { game_key: string; sid: number; // 游戏区 username: number; // channelInfo.uid actor: string; // roleName actor_id: string; // roleId ip: string; // 玩家ip time: number; // unix时间戳 sign: string; constructor(role: RoleType, roleName: string, user: UserType) { let channelInfo = user.channelInfo; this.game_key = SDK_37_CONST.GAME_KEY; this.sid = role.serverId; this.username = channelInfo.uid; this.actor = roleName; this.actor_id = role.roleId; this.ip = user.ip; this.time = nowSeconds(); } getBody() { let { game_key, sid, username, actor_id, ip, time } = this; return { game_key, sid, username, actor_id, ip, time } } setSign(sign: string) { this.sign = sign; } } export class CheckGuild37Params { game_key: string; sid: number; // 游戏区 guildid: string; // 军团code time: number; // unix时间戳 sign: string; type: number; content: string; // 内容 constructor(guildCode: string, serverId: number, type: number, content: string) { this.game_key = SDK_37_CONST.GAME_KEY; this.sid = serverId; this.guildid = guildCode; this.time = nowSeconds(); this.type = type; this.content = content; } getBody() { let { game_key, sid, time, type } = this; return { game_key, sid, time, type } } setSign(sign: string) { this.sign = sign; } } export class PostGuild37Params { game_key: string; sid: number; // 游戏区 guildid: string; // 军团code time: number; // unix时间戳 sign: string; type: number; content: string; // 内容 constructor(guildCode: string, serverId: number, type: number, content: string) { this.game_key = SDK_37_CONST.GAME_KEY; this.sid = serverId; this.guildid = guildCode; this.time = nowSeconds(); this.type = type; this.content = content; } getBody() { let { game_key, sid, time, type } = this; return { game_key, sid, time, type } } setSign(sign: string) { this.sign = sign; } } export class RoleNameCallBackParam { username: number; // 玩家账号 game_key: string; // 游戏标识 sid: number; // 区服标识 actor: string; // 玩家角色名称 actor_id: string; // 玩家角色名id time: number; // 时间戳 sign: string; constructor(param: any) { this.username = param.username; this.game_key = param.game_key; this.sid = param.sid; this.actor = param.actor; this.actor_id = param.actor_id; this.time = param.time; this.sign = param.sign; } checkParams() { return this.username != undefined && this.game_key != undefined && this.sid != undefined && this.actor != undefined && this.actor_id != undefined && this.time != undefined && this.sign != undefined } getBody() { let { username, game_key, sid, actor_id, time } = this; return { username, game_key, sid, actor_id, time } } } export class GuildNameCallBackParam { game_key: string; // 游戏标识 sid: number; // 区服标识 type: number; // 类型 1-公会名 2-公会公告 guildid: string; // 公会id time: number; // 时间戳 sign: string; constructor(param: any) { this.game_key = param.game_key; this.sid = param.sid; this.type = param.type; this.guildid = param.guildid; this.time = param.time; this.sign = param.sign; } checkParams() { return this.game_key != undefined && this.sid != undefined && this.type != undefined && this.guildid != undefined && this.time != undefined && this.sign != undefined } getBody() { let { game_key, sid, type, guildid, time, sign } = this; return { game_key, sid, type, guildid, time, sign } } } export class GetGuildInfoByUserParam { game_key: string; // 游戏标识 uid: number; // 账号名 time: number; // 时间戳 sid: number; // 区服id sign: string; constructor(param: any) { this.game_key = param.game_key; this.uid = param.uid; this.time = param.time; this.sid = param.sid; this.sign = param.sign; } checkParams() { return this.game_key != undefined && this.uid != undefined && this.sid != undefined && this.time != undefined && this.sign != undefined } getBody() { let { game_key, sid, uid, time, sign } = this; return { game_key, sid, uid, time, sign } } } export class GetWordParam { game_key: string; // 游戏标识 time: number; // 时间戳 sign: string; constructor() { this.game_key = SDK_37_CONST.GAME_KEY; this.time = nowSeconds(); } getBody() { let { game_key, time } = this; return { game_key, time } } setSign(sign: string) { this.sign = sign; } } export class GetServerListParam { appid: string; // 联运商ID gid: number; // 游戏id time: number; // 时间戳 ext: string; // 扩展参数 sign: string; constructor(param: GetServerListParam) { this.appid = param.appid; this.gid = param.gid; this.time = param.time; this.ext = param.ext; this.sign = param.sign; } checkParams() { return this.appid != undefined && this.gid != undefined && this.time != undefined && this.sign != undefined } } export class IOSRefundParam { appid: string; // pid, 平台id uid: number; // 用户id game_id: number; // 发行游戏id fx_c_game_id: string; // 子游戏id sid: number; // 游戏服id actor_id: string; // 角色id order_id: string; // 37订单号 order_no: string; // 本地订单号 money: number; // 金额 game_coin: number; // 元宝数 product_id: string; // 商品id time: number; // 请求时间 ext: string; // 扩展参数 sign: string; // 签名 constructor(data: any) { this.appid = data.appid; this.uid = data.uid; this.game_id = data.game_id; this.fx_c_game_id = data.fx_c_game_id; this.sid = data.sid; this.actor_id = data.actor_id; this.order_id = data.order_id; this.order_no = data.order_no; this.money = data.money; this.game_coin = data.game_coin; this.product_id = data.product_id; this.time = data.time; this.ext = data.ext; this.sign = data.sign; } getBody() { let { appid, uid, game_id, sid, actor_id, order_id, order_no, money, game_coin, product_id, time, ext } = this; return { appid, uid, game_id, sid, actor_id, order_id, order_no, money, game_coin, product_id, time, ext } } } export class PushMsg37Param { notify_id: string; // 消息唯一标号,毫秒时间戳 game_id: number; // 游戏id // c_game_id: number; // 子游戏id title: string; // 消息标题 text: string; // 消息正文 target: SDK_PUSH_TARGET_TYPE; // 推送目标类型 audience: string; // 用户uid,最多200个 click_type: string; // 点击通知后续动作 url: string; // 网页地址 intent: string; // 打开特定页面 time: string; // 当前请求时间 sign: string; // 签名 source: number; // 推送来源表 type: string; // 推送内容 constructor(code: string) { this.notify_id = code; this.game_id = SDK_37_CONST.PUSH_GAME_ID; // this.c_game_id = SDK_37_CONST.FX_C_GAME_ID; this.time = Math.floor(Date.now()/1000).toString(); this.source = 0; // 0: 游戏内 } public setMsgInfo(dic: DicPushMessage, target: SDK_PUSH_TARGET_TYPE, audience: string) { this.title = dic.title; this.text = dic.description; this.target = target; this.audience = audience; this.click_type = dic.clickType; if(dic.url != '&') this.url = dic.url; if(dic.intent != '&') this.intent = dic.intent; this.type = dic.pushMsgType; } public setSign(sign: string) { this.sign = sign; } } export class SendGiftCodeParam { user_id: number; // 用户id server_id: number; // 区服id role_id: string; // 角色id gift_id: string; // 礼包id order_id: string; // 订单号 time: number; // 时间戳 sign: string; // 37给的签名 constructor(data: any) { this.user_id = data.user_id; this.server_id = data.server_id; this.role_id = data.role_id; this.gift_id = data.gift_id; this.order_id = data.order_id; this.time = data.time; this.sign = data.sign; } checkParams() { return this.user_id != undefined && this.server_id != undefined && this.gift_id != undefined && this.order_id != undefined && this.time != undefined && this.sign != undefined } getBody() { let { user_id, server_id, role_id, gift_id, order_id, time } = this; return { user_id, server_id, role_id, gift_id, order_id, time } } } export class GetRoleByServerParam { user_id: number; // 用户id server_id: number; // 区服id time: number; // 时间戳 sign: string; // 37给的签名 constructor(data: any) { this.user_id = data.user_id; this.server_id = data.server_id; this.time = data.time; this.sign = data.sign; } checkParams() { return this.user_id != undefined && this.server_id != undefined && this.time != undefined && this.sign != undefined } } export class GetRoleByUidParam { user_id: number; // 用户id time: number; // 时间戳 sign: string; // 37给的签名 constructor(data: any) { this.user_id = data.user_id; this.time = data.time; this.sign = data.sign; } checkParams() { return this.user_id != undefined && this.time != undefined && this.sign != undefined } } export class GetServerParam { server_id: number; // 用户id time: number; // 时间戳 sign: string; // 37给的签名 constructor(data: any) { this.server_id = data.server_id; this.time = data.time; this.sign = data.sign; } checkParams() { return this.server_id != undefined && this.time != undefined && this.sign != undefined } } export class GetServerAndUidParam { time: number; appid: string; gid: string; uid: number; dsid: number; sign: string; constructor(data: any) { this.time = data.time; this.appid = data.appid; this.gid = data.gid; this.uid = data.uid; this.dsid = data.dsid; this.sign = data.sign; } checkParams() { return this.appid != undefined && this.time != undefined && this.gid != undefined && this.uid != undefined && this.dsid != undefined && this.sign != undefined } }