每日礼包领取免费
This commit is contained in:
parent
d84173b67e
commit
7fc9b0564f
@ -1,41 +1,34 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { PayFun } from '../../../public/pay';
|
import {PayFun} from '../../../public/pay';
|
||||||
import { PlayerFun } from '../../../public/player';
|
import {PlayerFun} from '../../../public/player';
|
||||||
import { ReqRec, ResRec } from "../../../shared/protocols/event/136Gift/PtlRec";
|
import {ReqRec, ResRec} from "../../../shared/protocols/event/136Gift/PtlRec";
|
||||||
import { prizeType } from '../../../shared/protocols/type';
|
import {prizeType} from '../../../shared/protocols/type';
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import {PublicShared} from '../../../shared/public/public';
|
||||||
import { HongDianChange } from "../../hongdian/fun";
|
import {HongDianChange} from "../../hongdian/fun";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 黑市每日礼包改版,此接口只领取免费礼包
|
||||||
|
* @param call
|
||||||
|
*/
|
||||||
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||||
let conf = G.gc.dixiaheishi['136Gift'][call.req.index];
|
let conf = G.gc.dixiaheishi['136Gift'][call.req.index];
|
||||||
let buyLog = await PayFun.getPayLog(call.uid, G.gc.dixiaheishi['136Gift'][0].payId);
|
if (!conf || conf.payId) return call.error('', {code: -1});
|
||||||
let buy60 = buyLog.slice(-1)[0]?.eTime >= G.time;
|
// if (!buy60 && conf.payId) return call.error('', { code: -2 });
|
||||||
if (!conf) return call.error('', { code: -1 });
|
|
||||||
if (!buy60 && conf.payId) return call.error('', { code: -2 });
|
|
||||||
|
|
||||||
let prize: prizeType[] = [];
|
let prize: prizeType[] = [];
|
||||||
let pushIndex: number[] = [];
|
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) {
|
if (db.recIndex.includes(call.req.index)) return call.error('', {code: -3});
|
||||||
G.gc.dixiaheishi['136Gift'].forEach((c, i) => {
|
prize.push(...(conf.payId ? G.gc.pay[conf.payId].prize : conf.prize));
|
||||||
if (i == 0 || !c.payId || db.recIndex.includes(i)) return;
|
pushIndex.push(call.req.index);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
prize = PublicShared.mergePrize(prize);
|
prize = PublicShared.mergePrize(prize);
|
||||||
await PlayerFun.sendPrize(call, prize);
|
await PlayerFun.sendPrize(call, prize);
|
||||||
|
|
||||||
G.mongodb.cEvent('136Gift').updateOne(
|
G.mongodb.cEvent('136Gift').updateOne(
|
||||||
{ uid: call.uid, type: '136Gift' },
|
{uid: call.uid, type: '136Gift'},
|
||||||
{ $push: { recIndex: { $each: pushIndex } } }
|
{$push: {recIndex: {$each: pushIndex}}}
|
||||||
);
|
);
|
||||||
|
|
||||||
// HongDianChange.sendChangeKey(call.uid, ['heishihd', 'heishiMrjx'])
|
// HongDianChange.sendChangeKey(call.uid, ['heishihd', 'heishiMrjx'])
|
||||||
|
Loading…
Reference in New Issue
Block a user