diff --git a/src/api_s2c/event/payForDiamond/ApiCanReceive.ts b/src/api_s2c/event/payForDiamond/ApiCanReceive.ts index e356c2f..8a4a0a5 100644 --- a/src/api_s2c/event/payForDiamond/ApiCanReceive.ts +++ b/src/api_s2c/event/payForDiamond/ApiCanReceive.ts @@ -3,16 +3,28 @@ import { HuoDongFun } from "../../../public/huodongfun"; import { ReqCanReceive, ResCanReceive } from '../../../shared/protocols/event/payForDiamond/PtlCanReceive'; import { PublicShared } from "../../../shared/public/public"; import { ActionLog } from "../../../public/actionLog/actionLog"; +import { WithId, OptionalId } from "mongodb"; +import { ReqAddHuoDong } from "../../../monopoly/protocols/PtlAddHuoDong"; const hasGotKeyPrefix = 'payForDiamond:hasGot:'; // 已领取额度 const showOffListKeyPrefix = 'payForDiamond:ShowOff:'; // 需要炫耀的玩家列表。 其中需要包含信息:玩家区服, 玩家玩家名称, 领到的数量 -export async function playerCanReceive(call: ApiCall) { - const activityId = call.req.activityId; - const activityInfo = await HuoDongFun.getHdidInfo(call, activityId); - if (!activityInfo) { - return call.error('No such activity'); +export async function playerCanReceive(call: ApiCall, callError : boolean = true) { + let activityId = call.req.activityId; + let activityInfo: WithId>; + if (!activityId) { + activityInfo = (await HuoDongFun.gethdList(call, 13))[0]; + } else { + activityInfo = await HuoDongFun.getHdidInfo(call, activityId); } + if (!activityInfo && callError) { + if (callError) { + return call.error('', { code: -1, message: lng.huodong_open_1 }); + } else { + return { result: false }; + } + } + activityId = activityInfo.hdid; const hasReceivedKey = hasGotKeyPrefix + activityId; const hasReceivedStr = await G.iorediscross.get(hasReceivedKey); const hasReceived = hasReceivedStr? parseInt(hasReceivedStr) : 0; diff --git a/src/api_s2c/event/payForDiamond/ApiReceive.ts b/src/api_s2c/event/payForDiamond/ApiReceive.ts index 3343409..6165737 100644 --- a/src/api_s2c/event/payForDiamond/ApiReceive.ts +++ b/src/api_s2c/event/payForDiamond/ApiReceive.ts @@ -86,8 +86,8 @@ export default async function (call: ApiCall) { } else { const { group, maxAmount } = randomWithWeight(activityData['groupConf']['base']['arr']); const gotAmount = calcDiamondGot(remaining, group, maxAmount); - await G.iorediscross.incrby(hasReceivedKey, -1 * Math.abs(gotAmount)); // 添加已领取的额度 - await G.iorediscross.del(); // 移除锁 + await G.iorediscross.incrby(hasReceivedKey, Math.abs(gotAmount)); // 添加已领取的额度 + await G.iorediscross.del(hasGotLockKey); // 移除锁 await PlayerFun.sendPrize(call, [{ 'a': 'attr', 't': 'rmbmoney', 'n': gotAmount }]); const showOff = gotAmount >= activityData['groupConf']['base']['loglimit']; call.succ({ // 领取核心逻辑完成, 请求可以返回了 diff --git a/src/api_s2c/hongdian/ApiGet.ts b/src/api_s2c/hongdian/ApiGet.ts index 8572c81..4d36f30 100644 --- a/src/api_s2c/hongdian/ApiGet.ts +++ b/src/api_s2c/hongdian/ApiGet.ts @@ -165,7 +165,7 @@ export default async function (call: ApiCall) { res[key] = await HongDianFun.zhoumolibao(call); break; case 'payForDiamond': - const receiveResult = await playerCanReceive(call); + const receiveResult = await playerCanReceive(call, false); res[key] = { show: receiveResult && receiveResult.result }; break; } diff --git a/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts b/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts index 1683937..cd0b089 100644 --- a/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts +++ b/src/shared/protocols/event/payForDiamond/PtlCanReceive.ts @@ -1,5 +1,5 @@ export type ReqCanReceive = { - activityId: number; + activityId?: number; }; export type ResCanReceive = { diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 2a66905..8b3c4a8 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -10113,7 +10113,8 @@ export const serviceProto: ServiceProto = { "name": "activityId", "type": { "type": "Number" - } + }, + "optional": true } ] },