fix:
十五天累计充值
This commit is contained in:
parent
f07b1fc0b7
commit
d060004609
@ -1,41 +1,43 @@
|
|||||||
import { UpdateFilter } from 'mongodb';
|
|
||||||
import {ApiCall} from "tsrpc";
|
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 {ReqOpen, ResOpen} from "../../../shared/protocols/event/shiwuleichong/PtlOpen";
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import {PayFun} from "../../../public/pay";
|
||||||
|
import {PublicShared} from "../../../shared/public/public";
|
||||||
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let db = await G.mongodb.cEvent('15leichong').findOne({ uid: call.uid, type: '15leichong' });
|
let payids = G.gc.shiwuleichong.tasks.map(
|
||||||
let update: UpdateFilter<CollectionEvent<'15leichong'>>;
|
(i) => i.payid
|
||||||
let sTime = PublicShared.getToDayZeroTime(G.time);
|
);
|
||||||
|
|
||||||
if (!db) {
|
let day: number = 1;
|
||||||
update = {
|
let _zt = PublicShared.getToDayZeroTime();
|
||||||
$set: { index: 0, sTime: sTime, recIndex: [] }
|
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 {
|
} else {
|
||||||
if (db.sTime + G.gc.shiwuleichong.data[db.index].time < G.time) {
|
if (pay.slice(-1)[0].time >= _zt) {
|
||||||
|
break
|
||||||
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: [] }
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
sTime = db.sTime;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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({
|
call.succ({
|
||||||
index: index,
|
day: day,
|
||||||
sTime: sTime,
|
payIds: Object.keys(pays)
|
||||||
recIndex: db?.recIndex || [],
|
|
||||||
payDay: await PayFun.getPayDaysBuyPayNum(call.uid, sTime, sTime + G.gc.shiwuleichong.data[index].time, G.gc.shiwuleichong.dayPayNeed)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -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.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)
|
_res.val.niudanji = await this.heiShiNiuDanJi(call)
|
||||||
Object.values(_res.val).forEach(x => _res.show = _res.show || x.show)
|
Object.values(_res.val).forEach(x => _res.show = _res.show || x.show)
|
||||||
return _res
|
return _res
|
||||||
@ -913,25 +913,25 @@ export class HuoDongHongDianFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**黑市 积天豪礼 */
|
/**黑市 积天豪礼 */
|
||||||
static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
|
// static async heiShiLCHongDian(call: ApiCall): Promise<hongdianVal> {
|
||||||
let _res: hongdianVal = {
|
// let _res: hongdianVal = {
|
||||||
show: false
|
// show: false
|
||||||
};
|
// };
|
||||||
let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
|
// let db = await G.mongodb.cEvent('15leichong').findOne({uid: call.uid, type: '15leichong'});
|
||||||
|
//
|
||||||
if (!db) return _res;
|
// if (!db) return _res;
|
||||||
|
//
|
||||||
let _con = G.gc.shiwuleichong.data[db.index];
|
// 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);
|
// 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++) {
|
// for (let index = 0; index < _con.tasks.length; index++) {
|
||||||
const element = _con.tasks[index];
|
// const element = _con.tasks[index];
|
||||||
if (db.recIndex.includes(index)) continue;
|
// if (db.recIndex.includes(index)) continue;
|
||||||
if (payDay < element.total) continue;
|
// if (payDay < element.total) continue;
|
||||||
_res.show = true;
|
// _res.show = true;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
return _res;
|
// return _res;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**黑市 扭蛋机 */
|
/**黑市 扭蛋机 */
|
||||||
static async heiShiNiuDanJi(call: ApiCall): Promise<hongdianVal> {
|
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
|
}, "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 } }
|
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天累充
|
* 进入15天累充
|
||||||
*/
|
*/
|
||||||
export type ReqOpen = {
|
export type ReqOpen = {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ResOpen = {
|
export type ResOpen = {
|
||||||
/**礼包组 取G.gc.shiwuleichong[index] */
|
/**礼包组 取G.gc.shiwuleichong[index] */
|
||||||
index: number;
|
day: number;
|
||||||
/**开始时间 倒计时显示 sTime+G.gc.shiwuleichong[index].time */
|
payIds: string[];
|
||||||
sTime: number;
|
|
||||||
/**已领取的奖励下标 */
|
|
||||||
recIndex: number[];
|
|
||||||
/**已充值的天数 */
|
|
||||||
payDay: number;
|
|
||||||
};
|
};
|
@ -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