后台:礼包码区分渠道

This commit is contained in:
luying
2022-04-09 15:20:04 +08:00
parent a23759335e
commit 6b13034c62
9 changed files with 24 additions and 15 deletions
@@ -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);
}