diff --git a/src/api_s2c/event/payForDiamond/ApiCanReceive.ts b/src/api_s2c/event/payForDiamond/ApiCanReceive.ts index a39596f..addccf7 100644 --- a/src/api_s2c/event/payForDiamond/ApiCanReceive.ts +++ b/src/api_s2c/event/payForDiamond/ApiCanReceive.ts @@ -8,19 +8,20 @@ export async function playerCanReceive(call: ApiCall) { if (!activityInfo) { return call.error('No such activity'); } - const remaining = typeof activityInfo.data['remaining'] === 'number'? activityInfo.data['remaining'] : activityInfo.data['totalmoney']; + const remaining = activityInfo.data['totalmoney']; + const showOffList = activityInfo.data['showOffList'] || []; const zeroTime = PublicShared.getToDayZeroTime(); const dayPayInfo = await G.mongodb.collection('dayPay').findOne({ uid: call.uid, time: zeroTime }); if (!dayPayInfo || !dayPayInfo.payNum) { return { - payNum: 0, remaining, result: false, activityInfo + payNum: 0, remaining, result: false, activityInfo, showOffList }; } const payNum = dayPayInfo.payNum; // 玩家充值未达标或者奖池余额耗尽则不能领取 if (payNum < activityInfo.data['price'] || remaining <= 0) { return { - payNum, remaining, result: false, activityInfo + payNum, remaining, result: false, activityInfo, showOffList } } // 检查玩家今日是否已经领取 @@ -28,18 +29,19 @@ export async function playerCanReceive(call: ApiCall) { if (playerActivityInfo) { if (playerActivityInfo[zeroTime]?.length) { return { - payNum, remaining, result: false, activityInfo + payNum, remaining, result: false, activityInfo, showOffList }; } } return { - payNum, remaining, result: true, activityInfo + payNum, remaining, result: true, activityInfo, showOffList }; } export default async function (call: ApiCall) { const canReceiveResult = await playerCanReceive(call); if (canReceiveResult) { - call.succ(canReceiveResult); + const { payNum, remaining, result, showOffList } = canReceiveResult; + call.succ({ payNum, remaining, result, showOffList }); } } \ No newline at end of file diff --git a/src/api_s2c/event/payForDiamond/ApiReceive.ts b/src/api_s2c/event/payForDiamond/ApiReceive.ts index cb45b06..768fed2 100644 --- a/src/api_s2c/event/payForDiamond/ApiReceive.ts +++ b/src/api_s2c/event/payForDiamond/ApiReceive.ts @@ -62,31 +62,31 @@ export default async function (call: ApiCall) { if (!canReceiveResult.result) { return call.succ({ amount: 0, - timesRemaining: 0 + timesRemaining: 0, + showOff: false }); } const activityData = canReceiveResult.activityInfo.data; - const remaining = typeof activityData['remaining'] === 'number'? activityData['remaining'] : activityData['totalmoney']; + const remaining = activityData['totalmoney']; const { group, maxAmount } = randomWithWeight(activityData['groupConf']['base']['arr']); const gotAmount = calcDiamondGot(remaining, group, maxAmount); // 减去余额 const filter = { hdid: call.req.activityId, - $or: [ - {'data.remaining': { $exists: false }}, - {$expr: {$gte: [ `$data.remaining - ${gotAmount}`, 0 ]}}, - ], + $expr: {$gte: [ `$data.totalmoney - ${gotAmount}`, 0 ]}, }; const updateDoc = { - $set: { 'data.remaining': `$data.remaining - ${gotAmount}` } + $inc: { 'data.totalmoney': -1 * Math.abs(gotAmount) } } const updateResult = await G.mongodb.collection('hdinfo').updateOne(filter, updateDoc); // 更新成功 if (updateResult.modifiedCount) { + const showOff = gotAmount >= activityData['groupConf']['base']['loglimit']; // 请求返回 call.succ({ amount: gotAmount, - timesRemaining: 0 + timesRemaining: 0, + showOff, }); // 添加玩家领取记录 const zeroTime = PublicShared.getToDayZeroTime(); @@ -95,19 +95,11 @@ export default async function (call: ApiCall) { G.mongodb.cEvent('payForDiamond').updateOne({ uid: call.uid }, { $set: setObj }); + // 记录玩家日志. 仅保留最近 10 条 + if (showOff) { + G.mongodb.collection('hdinfo').updateOne({ hdid: call.req.activityId, }, { $push: { 'data.showOffList': { $each: [{ name: call.conn.gud.name, gotAmount }], $slice: -10 }}}); + } } - // 发送炫耀 - if (gotAmount >= activityData['groupConf']['base']['loglimit']) { - ChatFun.newMsg({ - type: 'local', - msg: G.gc.pmd.get_hero_star5_pmd, - time: G.time, - sender: 'system', - otherData: { - pmd: true, - args: [gotAmount] - } - }); - } + } } \ No newline at end of file diff --git a/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts b/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts index 8d905ec..e7c8b13 100644 --- a/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts +++ b/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts @@ -6,4 +6,5 @@ export type ResCanReceive = { payNum: number; remaining?: number; result: boolean; + showOffList: any[]; }; \ No newline at end of file diff --git a/src/shared/protocols/event/payForDiamond/PtlReceive.ts b/src/shared/protocols/event/payForDiamond/PtlReceive.ts index beb4bf8..6fe6681 100644 --- a/src/shared/protocols/event/payForDiamond/PtlReceive.ts +++ b/src/shared/protocols/event/payForDiamond/PtlReceive.ts @@ -5,4 +5,5 @@ export type ReqReceive = { export type ResReceive = { amount: number, timesRemaining: number; + showOff: boolean; }; diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index df7b3e4..a65e05e 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -10234,6 +10234,16 @@ export const serviceProto: ServiceProto = { "type": { "type": "Boolean" } + }, + { + "id": 3, + "name": "showOffList", + "type": { + "type": "Array", + "elementType": { + "type": "Any" + } + } } ] }, @@ -10265,6 +10275,13 @@ export const serviceProto: ServiceProto = { "type": { "type": "Number" } + }, + { + "id": 2, + "name": "showOff", + "type": { + "type": "Boolean" + } } ] },