fix:
十五天累计充值
This commit is contained in:
parent
f07b1fc0b7
commit
d060004609
@ -1,41 +1,43 @@
|
||||
import { UpdateFilter } from 'mongodb';
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { CollectionEvent } from '../../../module/collection_event';
|
||||
import { PayFun } from '../../../public/pay';
|
||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/shiwuleichong/PtlOpen";
|
||||
import { PublicShared } from '../../../shared/public/public';
|
||||
import {ApiCall} from "tsrpc";
|
||||
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/shiwuleichong/PtlOpen";
|
||||
import {PayFun} from "../../../public/pay";
|
||||
import {PublicShared} from "../../../shared/public/public";
|
||||
|
||||
|
||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
let db = await G.mongodb.cEvent('15leichong').findOne({ uid: call.uid, type: '15leichong' });
|
||||
let update: UpdateFilter<CollectionEvent<'15leichong'>>;
|
||||
let sTime = PublicShared.getToDayZeroTime(G.time);
|
||||
let payids = G.gc.shiwuleichong.tasks.map(
|
||||
(i) => i.payid
|
||||
);
|
||||
|
||||
if (!db) {
|
||||
update = {
|
||||
$set: { index: 0, sTime: sTime, recIndex: [] }
|
||||
};
|
||||
} else {
|
||||
if (db.sTime + G.gc.shiwuleichong.data[db.index].time < G.time) {
|
||||
|
||||
db.sTime = sTime;
|
||||
db.index = G.gc.shiwuleichong.data[db.index + 1] == undefined ? db.index : db.index + 1;
|
||||
db.recIndex = [];
|
||||
|
||||
update = {
|
||||
$set: { index: db.index, sTime: db.sTime, recIndex: [] }
|
||||
};
|
||||
let day: number = 1;
|
||||
let _zt = PublicShared.getToDayZeroTime();
|
||||
let pays = await PayFun.getPayLogs(call.uid, payids);
|
||||
for (; day <= G.gc.shiwuleichong.tasks.length; day++) {
|
||||
let pay = pays[G.gc.shiwuleichong.tasks[day].payid];
|
||||
if (!pay) {
|
||||
break
|
||||
} else {
|
||||
sTime = db.sTime;
|
||||
if (pay.slice(-1)[0].time >= _zt) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update && G.mongodb.cEvent('15leichong').updateOne({ uid: call.uid, type: '15leichong' }, update, { upsert: true });
|
||||
let index = db?.index || 0;
|
||||
// 如果是最后一天奖励 并且 充值订单隔天了
|
||||
if (
|
||||
day == G.gc.shiwuleichong.tasks.length &&
|
||||
pays[G.gc.shiwuleichong.tasks[day - 1].payid] &&
|
||||
pays[G.gc.shiwuleichong.tasks[day - 1].payid].slice(-1)[0].time < _zt
|
||||
) {
|
||||
// 重置所有订单
|
||||
await PayFun.delPayLog(call.uid, ...payids.map(i => {
|
||||
return {payId: i, val: []}
|
||||
}))
|
||||
day = 1;
|
||||
pays = {};
|
||||
}
|
||||
|
||||
call.succ({
|
||||
index: index,
|
||||
sTime: sTime,
|
||||
recIndex: db?.recIndex || [],
|
||||
payDay: await PayFun.getPayDaysBuyPayNum(call.uid, sTime, sTime + G.gc.shiwuleichong.data[index].time, G.gc.shiwuleichong.dayPayNeed)
|
||||
day: day,
|
||||
payIds: Object.keys(pays)
|
||||
});
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { PayFun } from '../../../public/pay';
|
||||
import { PlayerFun } from '../../../public/player';
|
||||
import { ReqRec, ResRec } from "../../../shared/protocols/event/shiwuleichong/PtlRec";
|
||||
|
||||
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||
let db = await G.mongodb.cEvent('15leichong').findOne({ uid: call.uid, type: '15leichong' });
|
||||
let confArr = G.gc.shiwuleichong.data[db.index];
|
||||
|
||||
if (!confArr.tasks[call.req.index]) return call.error('', { code: -1 });
|
||||
if (db.recIndex.includes(call.req.index)) return call.error('', { code: -2 });
|
||||
|
||||
let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + confArr.time, G.gc.shiwuleichong.dayPayNeed);
|
||||
if (payDay < confArr.tasks[call.req.index].total) return call.error('', { code: -3 });
|
||||
|
||||
await PlayerFun.sendPrize(call, confArr.tasks[call.req.index].prize);
|
||||
|
||||
G.mongodb.cEvent('15leichong').updateOne(
|
||||
{ uid: call.uid, type: '15leichong' },
|
||||
{ $push: { recIndex: call.req.index } }
|
||||
);
|
||||
|
||||
call.succ({
|
||||
prize: confArr.tasks[call.req.index].prize
|
||||
});
|
||||
}
|
@ -877,7 +877,7 @@ export class HuoDongHongDianFun {
|
||||
}
|
||||
};
|
||||
_res.val.meirijingxuan = await this.heiShiHongDian(call)
|
||||
_res.val.jitianhaoli = await this.heiShiLCHongDian(call)
|
||||
// _res.val.jitianhaoli = await this.heiShiLCHongDian(call)
|
||||
_res.val.niudanji = await this.heiShiNiuDanJi(call)
|
||||
Object.values(_res.val).forEach(x => _res.show = _res.show || x.show)
|
||||
return _res
|
||||
@ -913,25 +913,25 @@ export class HuoDongHongDianFun {
|
||||
}
|
||||
|
||||
/**黑市 积天豪礼 */
|
||||
static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
|
||||
let _res: hongdianVal = {
|
||||
show: false
|
||||
};
|
||||
let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
|
||||
|
||||
if (!db) return _res;
|
||||
|
||||
let _con = G.gc.shiwuleichong.data[db.index];
|
||||
let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + _con.time, G.gc.shiwuleichong.dayPayNeed);
|
||||
for (let index = 0; index < _con.tasks.length; index++) {
|
||||
const element = _con.tasks[index];
|
||||
if (db.recIndex.includes(index)) continue;
|
||||
if (payDay < element.total) continue;
|
||||
_res.show = true;
|
||||
break;
|
||||
}
|
||||
return _res;
|
||||
}
|
||||
// static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
|
||||
// let _res: hongdianVal = {
|
||||
// show: false
|
||||
// };
|
||||
// let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
|
||||
//
|
||||
// if (!db) return _res;
|
||||
//
|
||||
// let _con = G.gc.shiwuleichong.data[db.index];
|
||||
// let payDay = await PayFun.getPayDaysBuyPayNum(call.uid, db.sTime, db.sTime + _con.time, G.gc.shiwuleichong.dayPayNeed);
|
||||
// for (let index = 0; index < _con.tasks.length; index++) {
|
||||
// const element = _con.tasks[index];
|
||||
// if (db.recIndex.includes(index)) continue;
|
||||
// if (payDay < element.total) continue;
|
||||
// _res.show = true;
|
||||
// break;
|
||||
// }
|
||||
// return _res;
|
||||
// }
|
||||
|
||||
/**黑市 扭蛋机 */
|
||||
static async heiShiNiuDanJi(call: ApiCall): Promise<hongdianVal> {
|
||||
|
@ -1179,7 +1179,7 @@ type gc_shiwucom = {
|
||||
}, "comment": { "jichu_colour": string, "fujia_colour": string, "fujianum_colour": string, "putongxilian": string, "gaojixilian": string, "hero_zhuanshu": string, "buff_zhuanshu": string, "skill_zhuanshu": string, "chongzhuneed": string, "chongzhurate": string, "tilianhuobi": string, [x: string]: any }, [x: string]: any
|
||||
}
|
||||
|
||||
type gc_shiwuleichong = { "dayPayNeed": number, "data": { "time": number, "tasks": { "total": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any }[], [x: string]: any }[], [x: string]: any }
|
||||
type gc_shiwuleichong = { tasks: { day: number, payid: string }[] }
|
||||
|
||||
type gc_shoot = { [key: string]: { "name": string, "num": number, "speed": number, "cartridge": number, "time": number, "prize": { [key: string]: { "describe": string, "hit": number, "content": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any } }, [x: string]: any } }
|
||||
|
||||
|
@ -1,18 +1,10 @@
|
||||
|
||||
/**
|
||||
* 进入15天累充
|
||||
*/
|
||||
export type ReqOpen = {
|
||||
|
||||
};
|
||||
export type ReqOpen = {};
|
||||
|
||||
export type ResOpen = {
|
||||
/**礼包组 取G.gc.shiwuleichong[index] */
|
||||
index: number;
|
||||
/**开始时间 倒计时显示 sTime+G.gc.shiwuleichong[index].time */
|
||||
sTime: number;
|
||||
/**已领取的奖励下标 */
|
||||
recIndex: number[];
|
||||
/**已充值的天数 */
|
||||
payDay: number;
|
||||
day: number;
|
||||
payIds: string[];
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
import { prizeType } from '../../type';
|
||||
|
||||
|
||||
/**
|
||||
* 领取15天累充奖励
|
||||
*/
|
||||
export type ReqRec = {
|
||||
index: number;
|
||||
};
|
||||
|
||||
export type ResRec = {
|
||||
prize: prizeType[];
|
||||
};
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user