活动:记录完成任务获得的点数
This commit is contained in:
@@ -72,6 +72,9 @@ export class RefreshTaskHandler {
|
|||||||
let rewardParamArr: Array<RewardParam> = stringToRewardParam(dailyItemData.reward);
|
let rewardParamArr: Array<RewardParam> = stringToRewardParam(dailyItemData.reward);
|
||||||
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardParamArr)
|
let result = await addReward(roleId, roleName, sid, serverId, funcs, rewardParamArr)
|
||||||
|
|
||||||
|
//获得点数
|
||||||
|
await ActivityRefreshTaskPointModel.addPoint(serverId, activityId, roleId, dailyItemData.point);
|
||||||
|
|
||||||
dailyItemData.receiveRewardCount += 1;
|
dailyItemData.receiveRewardCount += 1;
|
||||||
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
||||||
param: { activityId, roundIndex, pageIndex, id, type },
|
param: { activityId, roundIndex, pageIndex, id, type },
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export class ItemHandler {
|
|||||||
const funcs = session.get('funcs');
|
const funcs = session.get('funcs');
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
// let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
||||||
// if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
if (!consumeResult) return resResult(STATUS.ACTIVITY_RES_NOT_ENOUGH);
|
||||||
|
|
||||||
let dicGoods = gameData.goods.get(id);
|
let dicGoods = gameData.goods.get(id);
|
||||||
if (!dicGoods) {
|
if (!dicGoods) {
|
||||||
@@ -47,7 +47,7 @@ export class ItemHandler {
|
|||||||
}
|
}
|
||||||
let dicItid = ITID.get(dicGoods.itid);
|
let dicItid = ITID.get(dicGoods.itid);
|
||||||
if (!dicItid) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
if (!dicItid) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||||
if (dicItid.type != CONSUME_TYPE.CONSUME) {
|
if (dicItid.type != CONSUME_TYPE.GIFT_PACKAGE) {
|
||||||
return resResult(STATUS.NOT_CONSUME_GOODS);
|
return resResult(STATUS.NOT_CONSUME_GOODS);
|
||||||
}
|
}
|
||||||
let giftID = dicGoods.gift;
|
let giftID = dicGoods.gift;
|
||||||
|
|||||||
@@ -26,9 +26,19 @@ export default class Activity_Refresh_Task_Point extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
roleId: string; // 用户Id
|
roleId: string; // 用户Id
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
|
totalPoint: number; // 获得的总点数
|
||||||
|
@prop({ required: true })
|
||||||
records: Record[]; // 兑换红包消耗点数记录
|
records: Record[]; // 兑换红包消耗点数记录
|
||||||
|
|
||||||
//任务领取记录
|
|
||||||
|
//获得点数
|
||||||
|
public static async addPoint(serverId: number, activityId: number, roleId: string, point: number) {
|
||||||
|
let result: ActivityRefreshTaskPointModelType = await ActivityRefreshTaskPointModel.findOneAndUpdate({ serverId, roleId, activityId, },
|
||||||
|
{ $inc: { totalPoint: point } }, { upsert: true, new: true }).lean(true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//兑换记录
|
||||||
public static async addReceiveRecord(serverId: number, activityId: number, roleId: string, point: number) {
|
public static async addReceiveRecord(serverId: number, activityId: number, roleId: string, point: number) {
|
||||||
let result: ActivityRefreshTaskPointModelType = await ActivityRefreshTaskPointModel.findOneAndUpdate({ serverId, roleId, activityId, },
|
let result: ActivityRefreshTaskPointModelType = await ActivityRefreshTaskPointModel.findOneAndUpdate({ serverId, roleId, activityId, },
|
||||||
{ $push: { records: { point, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
{ $push: { records: { point, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
||||||
|
|||||||
@@ -94,13 +94,11 @@ export class RefreshTaskData extends ActivityBase {
|
|||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
item.totalCount = data[index].totalCount ? data[index].totalCount : 0;
|
item.totalCount = data[index].totalCount ? data[index].totalCount : 0;
|
||||||
item.receiveRewardCount = data[index].receiveRewardCount ? data[index].receiveRewardCount : 0;
|
item.receiveRewardCount = data[index].receiveRewardCount ? data[index].receiveRewardCount : 0;
|
||||||
if (item.receiveRewardCount) {
|
|
||||||
this.totalPoint += item.point;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.totalPoint = pointRecordData && pointRecordData.totalPoint ? pointRecordData.totalPoint : 0;
|
||||||
let pointRecords = pointRecordData && pointRecordData.records ? pointRecordData.records : [];
|
let pointRecords = pointRecordData && pointRecordData.records ? pointRecordData.records : [];
|
||||||
for (let record of pointRecords) {
|
for (let record of pointRecords) {
|
||||||
this.exchangePoint += record.point;
|
this.exchangePoint += record.point;
|
||||||
|
|||||||
Reference in New Issue
Block a user