fix: 修复细节问题
This commit is contained in:
parent
40774138d2
commit
02dccd18a7
@ -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<OptionalId<ReqAddHuoDong>>;
|
||||
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;
|
||||
|
@ -86,8 +86,8 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
||||
} 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({ // 领取核心逻辑完成, 请求可以返回了
|
||||
|
@ -165,7 +165,7 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
|
||||
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;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export type ReqCanReceive = {
|
||||
activityId: number;
|
||||
activityId?: number;
|
||||
};
|
||||
|
||||
export type ResCanReceive = {
|
||||
|
@ -10113,7 +10113,8 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
"name": "activityId",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
}
|
||||
},
|
||||
"optional": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user