活动:任务完成关联活动积分点数
This commit is contained in:
@@ -10,6 +10,7 @@ import { DicDailyTask, DicAchievement, DicMainTask } from "../../../pubUtils/dic
|
||||
import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask } from "../../../services/taskService";
|
||||
import { TASK } from "../../../pubUtils/dicParam";
|
||||
import { newHeroGiftPoint } from "../../../services/activity/newHeroGiftsService";
|
||||
import { ActivityTaskPointModel } from "../../../db/ActivityTaskPoint";
|
||||
|
||||
export default function (app: Application) {
|
||||
return new ShopHandler(app);
|
||||
@@ -58,20 +59,19 @@ export class ShopHandler {
|
||||
}
|
||||
point = userTask.dailyTaskPoint;
|
||||
weeklyPoint = userTask.dailyTaskPointWeekly;
|
||||
let addPointActivityId = 0;//点数关联的活动id
|
||||
if (addPointActivityId) {
|
||||
await newHeroGiftPoint(serverId, addPointActivityId, roleId, point);
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
this.app.get('channelService').pushMessageByUids('addPoint', resResult(STATUS.SUCCESS, { activityId: addPointActivityId, addPoint: point }), uids);
|
||||
}
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
let dic = <DicAchievement>dicTask;
|
||||
let userTask = await UserTaskModel.incInfo(roleId, { achievementPoint: dic.point });
|
||||
point = userTask.achievementPoint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//任务完成后关联活动的积分
|
||||
let activityTaskPoint = await ActivityTaskPointModel.findData(type, id);
|
||||
if (activityTaskPoint) {
|
||||
await newHeroGiftPoint(serverId, activityTaskPoint.activityId, roleId, activityTaskPoint.point);
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
this.app.get('channelService').pushMessageByUids('addPoint', resResult(STATUS.SUCCESS, { activityId: activityTaskPoint.activityId, addPoint: point }), uids);
|
||||
}
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
|
||||
|
||||
47
shared/db/ActivityTaskPoint.ts
Normal file
47
shared/db/ActivityTaskPoint.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 游戏中的任务完成后,增加的积分点数关联到活动数据
|
||||
*/
|
||||
@index({ taskId: 1 })
|
||||
|
||||
export default class Activity_Task_Point extends BaseModel {
|
||||
// @prop({ required: true })
|
||||
// serverId: number; // 服Id
|
||||
@prop({ required: true })
|
||||
taskType: number; // 任务类型TASK_FUN_TYPE 1.主线,2每日,3.成就
|
||||
@prop({ required: true })
|
||||
taskId: number; // 任务id
|
||||
@prop({ required: true })
|
||||
activityId: number; // 关联的活动id
|
||||
@prop({ required: true })
|
||||
point: number; // 增加点数
|
||||
|
||||
//更新活动数据
|
||||
public static async updateData(taskType: number, taskId: number, activityId: number, point: number) {
|
||||
let result: ActivityTaskPointModelType = await ActivityTaskPointModel.findOneAndUpdate(
|
||||
{ taskType, taskId }, { $set: { activityId, point } }, { upsert: true, new: true }
|
||||
).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询数据
|
||||
public static async findData(taskType: number, taskId: number) {
|
||||
let result: ActivityTaskPointModelType = await ActivityTaskPointModel.findOne(
|
||||
{ taskType, taskId }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除数据
|
||||
public static async deleteData(taskType: number, taskId: number, activityId: number) {
|
||||
await ActivityTaskPointModel.deleteOne({ taskType, taskId, activityId });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const ActivityTaskPointModel = getModelForClass(Activity_Task_Point);
|
||||
|
||||
export interface ActivityTaskPointModelType extends Pick<DocumentType<Activity_Task_Point>, keyof Activity_Task_Point> { }
|
||||
export type ActivityTaskPointModelTypeParam = Partial<ActivityTaskPointModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user