每日礼包领取免费

This commit is contained in:
dy 2023-12-22 20:26:25 +08:00
parent d84173b67e
commit 7fc9b0564f

View File

@ -1,41 +1,34 @@
import { ApiCall } from "tsrpc";
import { PayFun } from '../../../public/pay';
import { PlayerFun } from '../../../public/player';
import { ReqRec, ResRec } from "../../../shared/protocols/event/136Gift/PtlRec";
import { prizeType } from '../../../shared/protocols/type';
import { PublicShared } from '../../../shared/public/public';
import { HongDianChange } from "../../hongdian/fun";
import {ApiCall} from "tsrpc";
import {PayFun} from '../../../public/pay';
import {PlayerFun} from '../../../public/player';
import {ReqRec, ResRec} from "../../../shared/protocols/event/136Gift/PtlRec";
import {prizeType} from '../../../shared/protocols/type';
import {PublicShared} from '../../../shared/public/public';
import {HongDianChange} from "../../hongdian/fun";
/**
*
* @param call
*/
export default async function (call: ApiCall<ReqRec, ResRec>) {
let conf = G.gc.dixiaheishi['136Gift'][call.req.index];
let buyLog = await PayFun.getPayLog(call.uid, G.gc.dixiaheishi['136Gift'][0].payId);
let buy60 = buyLog.slice(-1)[0]?.eTime >= G.time;
if (!conf) return call.error('', { code: -1 });
if (!buy60 && conf.payId) return call.error('', { code: -2 });
if (!conf || conf.payId) return call.error('', {code: -1});
// if (!buy60 && conf.payId) return call.error('', { code: -2 });
let prize: prizeType[] = [];
let pushIndex: number[] = [];
let db = await G.mongodb.cEvent('136Gift').findOne({ uid: call.uid, type: '136Gift' });
let db = await G.mongodb.cEvent('136Gift').findOne({uid: call.uid, type: '136Gift'});
if (call.req.index == 0) {
G.gc.dixiaheishi['136Gift'].forEach((c, i) => {
if (i == 0 || !c.payId || db.recIndex.includes(i)) return;
pushIndex.push(i);
prize.push(...G.gc.pay[c.payId].prize);
});
if (pushIndex.length < 1) return call.error('', { code: -4 });
} else {
if (db.recIndex.includes(call.req.index)) return call.error('', { code: -3 });
prize.push(...(conf.payId ? G.gc.pay[conf.payId].prize : conf.prize));
pushIndex.push(call.req.index);
}
if (db.recIndex.includes(call.req.index)) return call.error('', {code: -3});
prize.push(...(conf.payId ? G.gc.pay[conf.payId].prize : conf.prize));
pushIndex.push(call.req.index);
prize = PublicShared.mergePrize(prize);
await PlayerFun.sendPrize(call, prize);
G.mongodb.cEvent('136Gift').updateOne(
{ uid: call.uid, type: '136Gift' },
{ $push: { recIndex: { $each: pushIndex } } }
{uid: call.uid, type: '136Gift'},
{$push: {recIndex: {$each: pushIndex}}}
);
// HongDianChange.sendChangeKey(call.uid, ['heishihd', 'heishiMrjx'])