✨ feat(活动): 添加关注豪礼
This commit is contained in:
@@ -6,7 +6,7 @@ import { DailyItem } from '../../../domain/activityField/dailyChallengesField';
|
||||
import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService';
|
||||
import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||
import { ActivityDailyChallengesModel } from '../../../db/ActivityDailyChallenges';
|
||||
import { getBindPhoneData } from '../../../services/activity/bindPhoneService';
|
||||
import { getBindPhoneData, getBindPhoneDataShow } from '../../../services/activity/bindPhoneService';
|
||||
import { ActivityBindPhoneRewardModel } from '../../../db/ActivityBindPhoneReward';
|
||||
|
||||
|
||||
@@ -19,6 +19,18 @@ export class BindPhoneHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
async getData(msg: { activityId: number }, session: BackendSession) {
|
||||
const { activityId } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
const uid = session.get('userid');
|
||||
|
||||
let playerData = await getBindPhoneDataShow(activityId, roleId, serverId, uid);
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
playerData
|
||||
})
|
||||
}
|
||||
|
||||
/************************绑定手机****************************/
|
||||
|
||||
/**
|
||||
@@ -36,8 +48,9 @@ export class BindPhoneHandler {
|
||||
const uid = session.get('userid');
|
||||
|
||||
let playerData = await getBindPhoneData(activityId, roleId, serverId, uid);
|
||||
if(!playerData) return resResult(STATUS.ACTIVITY_ID_ERROR);
|
||||
if(playerData.status != BIND_PHONE_STATUS.WAIT_BIND) return resResult(STATUS.ACTIVITY_HAS_BIND);
|
||||
let bindPhoneData = playerData?.bindPhone;
|
||||
if(!bindPhoneData) return resResult(STATUS.ACTIVITY_ID_ERROR);
|
||||
if(bindPhoneData.status != BIND_PHONE_STATUS.WAIT_BIND) return resResult(STATUS.ACTIVITY_HAS_BIND);
|
||||
|
||||
await ActivityBindPhoneRewardModel.addRecord(activityId, uid, BIND_PHONE_STATUS.HAS_BIND, { roleId, roleName, serverId });
|
||||
|
||||
@@ -62,12 +75,13 @@ export class BindPhoneHandler {
|
||||
const uid = session.get('userid');
|
||||
|
||||
let playerData = await getBindPhoneData(activityId, roleId, serverId, uid);
|
||||
if(!playerData) return resResult(STATUS.ACTIVITY_ID_ERROR);
|
||||
if(playerData.status == BIND_PHONE_STATUS.WAIT_BIND) return resResult(STATUS.ACTIVITY_BIND_ERR);
|
||||
if(playerData.status == BIND_PHONE_STATUS.RECEIVED) return resResult(STATUS.ACTIVITY_BIND_RECEIVED);
|
||||
let bindPhoneData = playerData?.bindPhone;
|
||||
if(!bindPhoneData) return resResult(STATUS.ACTIVITY_ID_ERROR);
|
||||
if(bindPhoneData.status == BIND_PHONE_STATUS.WAIT_BIND) return resResult(STATUS.ACTIVITY_BIND_ERR);
|
||||
if(bindPhoneData.status == BIND_PHONE_STATUS.RECEIVED) return resResult(STATUS.ACTIVITY_BIND_RECEIVED);
|
||||
|
||||
await ActivityBindPhoneRewardModel.addRecord(activityId, uid, BIND_PHONE_STATUS.RECEIVED, { roleId, roleName, serverId });
|
||||
let rewardArray = stringToRewardParam(playerData.rewards)
|
||||
let rewardArray = stringToRewardParam(bindPhoneData.rewards)
|
||||
let { goods, addHeros } = await addReward(roleId, roleName, sid, serverId, rewardArray, ITEM_CHANGE_REASON.ACT_BIND_PHONE);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -77,4 +91,24 @@ export class BindPhoneHandler {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取公众号口令奖励
|
||||
* @param {{ activityId: number}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof BindPhoneHandler
|
||||
*/
|
||||
async receiveGiftCode(msg: { activityId: number }, session: BackendSession) {
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 前往论坛,用于前往论坛任务
|
||||
* @param {{ activityId: number}} msg
|
||||
* @param {BackendSession} session
|
||||
* @memberof BindPhoneHandler
|
||||
*/
|
||||
async skipOutSide(msg: { activityId: number }, session: BackendSession) {
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ACTIVITY_TYPE } from '../../consts';
|
||||
import { ActivityModel, ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityBindPhoneRewardModel } from '../../db/ActivityBindPhoneReward';
|
||||
import { ActivityDailyChallengesModel, ActivityDailyChallengesModelType } from '../../db/ActivityDailyChallenges';
|
||||
import { LinkModel } from '../../db/Link';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
import { ServerlistModel } from '../../db/Serverlist';
|
||||
import { UserModel } from '../../db/User';
|
||||
@@ -28,9 +29,14 @@ export async function getBindPhoneData(activityId: number, roleId: string, serve
|
||||
let serverTime = await getServerCreateTime(serverId);
|
||||
let playerData = new BindPhoneData(activityData, createTime, serverTime);
|
||||
|
||||
let user = await UserModel.findUserByUid(uid);
|
||||
let receiveRec = await ActivityBindPhoneRewardModel.findByUid(activityId, uid);
|
||||
playerData.setRecord(user, receiveRec);
|
||||
let links = await LinkModel.findByServerId(serverId);
|
||||
playerData.setLinks(links);
|
||||
|
||||
if(playerData.bindPhone) {
|
||||
let user = await UserModel.findUserByUid(uid);
|
||||
let receiveRec = await ActivityBindPhoneRewardModel.findByUid(activityId, uid);
|
||||
playerData.setBindPhoneStatus(user, receiveRec);
|
||||
}
|
||||
|
||||
return playerData;
|
||||
}
|
||||
|
||||
@@ -123,6 +123,10 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
case 'activity.miniGameHandler.getMiniGameActivity':
|
||||
case 'activity.weeklyFundHandler.getData':
|
||||
case 'activity.monthlyFundHandler.getData':
|
||||
case 'activity.bindPhoneHandler.bind':
|
||||
case 'activity.bindPhoneHandler.receiveReward':
|
||||
case 'activity.bindPhoneHandler.receiveGiftCode':
|
||||
case 'activity.bindPhoneHandler.skipOutSide':
|
||||
{
|
||||
if(!checkNaturalNumbers(msg.activityId)) return false;
|
||||
break;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getCurTask, getPvpTask } from './task/taskService';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { Application, FrontendOrBackendSession, pinus, RpcClient } from 'pinus';
|
||||
import { getRandEelmWithWeight, resResult } from '../pubUtils/util';
|
||||
import { STATUS, PUSH_BATCH, PUSH_INTERVAL, CONSUME_TYPE, HERO_SELECT, ENTERY_ROLE_PICK, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT, PUSH_ROUTE, ARTIFACT_SELECT, ACTIVITYITEM_SELECT } from '../consts';
|
||||
import { STATUS, PUSH_BATCH, PUSH_INTERVAL, CONSUME_TYPE, HERO_SELECT, ENTERY_ROLE_PICK, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT, PUSH_ROUTE, ARTIFACT_SELECT, ACTIVITYITEM_SELECT, SNS_LINK_TYPE } from '../consts';
|
||||
import { getAllShopList } from './shopService';
|
||||
import { getGeneralRank, getRankFirstReward } from './rankService';
|
||||
import { getFriendList, getApplyList } from './friendService';
|
||||
@@ -52,6 +52,7 @@ import { PvpDataReturn } from '../domain/battleField/pvp';
|
||||
import { getHiddenData } from './dataService';
|
||||
import { ArtifactModel } from '../db/Artifact';
|
||||
import { ActivityItemModel } from '../db/ActivityItem';
|
||||
import { LinkModel } from '../db/Link';
|
||||
|
||||
/**
|
||||
* init: 初始的时候是否推送 true-推 false-不推
|
||||
@@ -87,6 +88,7 @@ const modules = [
|
||||
{ id: 26, type: 'survey', init: false, refresh: true, guild: false },
|
||||
{ id: 27, type: 'ladder', init: false, refresh: true, guild: false },
|
||||
{ id: 28, type: 'hiddenData', init: true, refresh: true, guild: false },
|
||||
{ id: 29, type: 'customerLink', init: true, refresh: true, guild: false },
|
||||
]
|
||||
|
||||
export async function pushData(hasInit: boolean, role: RoleType, session: FrontendOrBackendSession, pushType: 'entry' | 'refresh' = 'entry') {
|
||||
@@ -127,6 +129,7 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
let skins = await SkinModel.findbyRole(role.roleId, SKIN_SELECT.ENTRY);
|
||||
let artifacts = await ArtifactModel.findbyRole(role.roleId, ARTIFACT_SELECT.ENTRY);
|
||||
let activityItems = await ActivityItemModel.findbyRole(role.roleId, ACTIVITYITEM_SELECT.ENTRY);
|
||||
let link = await LinkModel.findByType(SNS_LINK_TYPE.CUSTOMER);
|
||||
|
||||
role['heros'] = heros.map(hero => new HeroParam(hero));
|
||||
role['jewels'] = jewels;
|
||||
@@ -142,6 +145,7 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
role.heads = role.heads.filter(cur => cur.status);
|
||||
role.frames = role.frames.filter(cur => cur.status);
|
||||
role.spines = role.spines.filter(cur => cur.status);
|
||||
role['customerLink'] = link?.link||'';
|
||||
return pick(role, ENTERY_ROLE_PICK);
|
||||
case 'shop': // 商店
|
||||
return await getAllShopList(roleId, serverId);
|
||||
|
||||
Reference in New Issue
Block a user