后台:礼包码区分渠道
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { STATUS } from './../../../consts/statusCode';
|
||||
import { RoleModel, RoleType } from './../../../db/Role';
|
||||
import { UserModel } from '../../../db/User';
|
||||
import { UserModel, UserType } from '../../../db/User';
|
||||
import { GMUserModel } from '../../../db/GMUser';
|
||||
import { Application, HandlerService, pinus, } from 'pinus';
|
||||
import { FrontendSession } from 'pinus';
|
||||
@@ -68,7 +68,7 @@ export class EntryHandler {
|
||||
}
|
||||
let serverName = this.app.getServerId();
|
||||
await roleLogin(role.roleId, user.userCode, serverName, user.pkgName, role.createTime); // 保存在线用户
|
||||
await this.addSession(role, session);
|
||||
await this.addSession(user, role, session);
|
||||
saveLoginAndOutLog(LOG_TYPE.LOGIN, session);
|
||||
|
||||
addRoleToSysChannel(role.roleId, self.app.get('serverId'), role.serverId);
|
||||
@@ -99,7 +99,7 @@ export class EntryHandler {
|
||||
return resResult(STATUS.SUCCESS, { todayZeroPoint });
|
||||
}
|
||||
|
||||
async addSession(role: RoleType, session: FrontendSession) {
|
||||
async addSession(user: UserType, role: RoleType, session: FrontendSession) {
|
||||
const self = this;
|
||||
let ip = session.remoteAddress.ip.replace('::ffff:', '');
|
||||
|
||||
@@ -115,6 +115,7 @@ export class EntryHandler {
|
||||
session.set('guildCode', role.guildCode);
|
||||
session.set('ip', ip);
|
||||
session.set('vipStartTime', role.vipStartTime||0);
|
||||
session.set('channel', user.channelInfo?.platformAppid||'pc');
|
||||
session.push('userid', () => { });
|
||||
session.push('sid', () => { });
|
||||
session.push('roleId', () => { });
|
||||
@@ -126,6 +127,7 @@ export class EntryHandler {
|
||||
session.push('blockType', () => { });
|
||||
session.push('ip', () => { });
|
||||
session.push('vipStartTime', () => { });
|
||||
session.push('channel', () => { });
|
||||
// console.log(role.guildCode)
|
||||
// session.push('rid', function (err) {
|
||||
// if (err) {
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { getEvent } from '../../../services/eventSercive';
|
||||
import { getRandSingleEelm, resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { GMMailModel, GMMailType } from '../../../db/GMMail';
|
||||
import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { SendMailFun } from '../../../services/mailService';
|
||||
import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { MarqueeModel } from '../../../db/Marquee';
|
||||
import { ServerlistModel } from '../../../db/Serverlist';
|
||||
import { checkActivityEditable, checkActivityGroupType, checkActivityGroupTypeWithId } from '../../../services/activity/activityService';
|
||||
import { ActivityModel } from '../../../db/Activity';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
|
||||
@@ -149,6 +149,7 @@ export class ItemHandler {
|
||||
const roleName: string = session.get('roleName');
|
||||
const serverId: number = session.get('serverId');
|
||||
const sid: string = session.get('sid');
|
||||
const channel: string = session.get('channel');
|
||||
const { code } = msg;
|
||||
|
||||
let giftCodeDetail = await GiftCodeDetailModel.findByCode(code);
|
||||
@@ -166,6 +167,10 @@ export class ItemHandler {
|
||||
if (giftCode.beginTime > nowSeconds()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if (giftCode.endTime < nowSeconds()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
|
||||
if(giftCode.channel.indexOf('all') == -1 && giftCode.channel.indexOf(channel) == -1) {
|
||||
return resResult(STATUS.GIFT_CODE_CHANNEL_ERR);
|
||||
}
|
||||
|
||||
if (giftCodeDetail.roleIds.indexOf(roleId) != -1) {
|
||||
return resResult(STATUS.YOU_HAVE_USED_THIS_CODE);
|
||||
}
|
||||
|
||||
@@ -414,6 +414,7 @@ export const STATUS = {
|
||||
GIFT_CODE_NOT_START: { code: 31203, simStr: '礼包码未生效' },
|
||||
GIFT_CODE_HAS_EXPIRED: { code: 31204, simStr: '礼包码已失效' },
|
||||
GIFT_CODE_NOT_FOUND: { code: 31205, simStr: '未找到该礼包码' },
|
||||
GIFT_CODE_CHANNEL_ERR: { code: 31206, simStr: '礼包码在您的渠道不生效' },
|
||||
// 邮件相关 31301-31400
|
||||
MAIL_HAS_RECEIVE: { code: 31301, simStr: '邮件已领取'},
|
||||
EQUIP_IS_OVER: { code: 31302, simStr: '装备已超过上限,无法领取' },
|
||||
|
||||
@@ -43,6 +43,9 @@ export default class GiftCode extends BaseModel {
|
||||
@prop({ required: true, default: 0, enum: GIFT_GENERATE_TYPE })
|
||||
generateType: GIFT_GENERATE_TYPE; // 生成类型
|
||||
|
||||
@prop({ required: true, default: ['all'], type: String })
|
||||
channel: string[]; // 可使用渠道
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
generateCnt: number; // 生成条数,giftCodeDetail的数量
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class RoleRecord {
|
||||
}
|
||||
|
||||
/**
|
||||
* 举报记录
|
||||
* 领取记录
|
||||
**/
|
||||
@modelOptions({ schemaOptions: { id: false } })
|
||||
@index({ code: 1 })
|
||||
|
||||
@@ -42,7 +42,7 @@ export default class User extends BaseModel {
|
||||
channelId: string; // 渠道类型
|
||||
|
||||
@prop({ required: true, _id: false })
|
||||
channelInfo: LoginValidateData37|{}; // 渠道数据
|
||||
channelInfo: LoginValidateData37; // 渠道数据
|
||||
|
||||
@prop({ required: true, set: (val: string) => aesEncryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV), get: (val: string) => val?aesDecryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV):'' })
|
||||
tel: string; // 账号
|
||||
@@ -236,7 +236,7 @@ export default class User extends BaseModel {
|
||||
}
|
||||
|
||||
public static async findUserByToken(token: string) {
|
||||
const user: UserType = await UserModel.findOne({ token }).select('uid token serverType auth tel userCode pkgName ip').lean({ getters: true });
|
||||
const user: UserType = await UserModel.findOne({ token }).select('uid token serverType auth tel userCode pkgName ip channelInfo').lean({ getters: true });
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ export class UpdateMailParams {
|
||||
}
|
||||
|
||||
checkParams() {
|
||||
if(!this.title || !this.content || !this.sendName || !this.reason) return false;
|
||||
if(!this.title || !this.content || !this.sendName) return false;
|
||||
if(this.reason && !isString(this.reason)) return false;
|
||||
if(this.timeType == MAIL_TIME_TYPE.IMMEDIATE) {
|
||||
if(!this.expire) return false;
|
||||
} else if (this.timeType == MAIL_TIME_TYPE.DELAY) {
|
||||
@@ -191,6 +192,7 @@ export class CreateGiftCode {
|
||||
codeLen: number; // 礼包码位数
|
||||
remark: string = ''; // 备注
|
||||
generateType: GIFT_GENERATE_TYPE; // 生成类型
|
||||
channel: string[] = ['all'];
|
||||
code: string = '';
|
||||
|
||||
constructor(obj: any) {
|
||||
@@ -201,6 +203,7 @@ export class CreateGiftCode {
|
||||
this.codeLen = obj.codeLen;
|
||||
this.remark = obj.remark;
|
||||
this.generateType = obj.generateType;
|
||||
this.channel = obj.channel;
|
||||
this.code = obj.code;
|
||||
}
|
||||
|
||||
@@ -217,6 +220,7 @@ export class CreateGiftCode {
|
||||
return false
|
||||
}
|
||||
if(this.code != undefined && !isString(this.code)) return false
|
||||
if(!isArray(this.channel)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export interface LoginValidataReturn37 {
|
||||
data: LoginValidateData37;
|
||||
}
|
||||
|
||||
export type ChannelInfo = LoginValidataReturn37|{};
|
||||
export type ChannelInfo = LoginValidateData37;
|
||||
|
||||
export class PayCallback37Data {
|
||||
appid: string; // 平台id
|
||||
@@ -125,7 +125,7 @@ export class Chat37Params {
|
||||
}
|
||||
|
||||
setByMyRole(role: RoleType, user: UserType) {
|
||||
let channelInfo = <LoginValidateData37>user.channelInfo;
|
||||
let channelInfo = <ChannelInfo>user.channelInfo;
|
||||
this.username = channelInfo.uid;
|
||||
this.actor = role.roleName;
|
||||
this.actor_id = role.roleId;
|
||||
|
||||
Reference in New Issue
Block a user