Compare commits
No commits in common. "86866e9233a18dd9486b8edaeba8b7635990b942" and "f6df6fd8bc940e416068c30193327d17c864f4e0" have entirely different histories.
86866e9233
...
f6df6fd8bc
@ -1,35 +1,32 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import {HuoDongFun} from "../../../public/huodongfun";
|
import { HuoDongFun } from "../../../public/huodongfun";
|
||||||
import {PayFun} from '../../../public/pay';
|
import { PayFun } from '../../../public/pay';
|
||||||
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/leijichongzhi/PtlOpen";
|
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/leijichongzhi/PtlOpen";
|
||||||
import {PublicShared} from '../../../shared/public/public';
|
import { PublicShared } from '../../../shared/public/public';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
||||||
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
||||||
// 无此活动
|
// 无此活动
|
||||||
return call.error('', {code: -1, message: globalThis.lng.huodong_open_1})
|
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
||||||
let sTime = db?.sTime || PublicShared.getToDayZeroTime(G.time);
|
let sTime = db?.sTime || PublicShared.getToDayZeroTime(G.time);
|
||||||
|
|
||||||
if (!db) {
|
if (!db) {
|
||||||
G.mongodb.cEvent(_dbType).updateOne(
|
G.mongodb.cEvent(_dbType).updateOne(
|
||||||
{uid: call.uid, type: _dbType},
|
{ uid: call.uid, type: _dbType },
|
||||||
{$set: {sTime: sTime, recIndex: []}},
|
{ $set: { sTime: sTime, recIndex: [] } },
|
||||||
{upsert: true}
|
{ upsert: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10
|
|
||||||
payNum = payNum - (db.round || 0) * R.compose(R.sum(), R.map(i => i.total))(_hdinfo.data.tasks)
|
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
sTime: sTime,
|
sTime: sTime,
|
||||||
recIndex: db?.recIndex || [],
|
recIndex: db?.recIndex || [],
|
||||||
payNum: payNum,
|
payNum: (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10,
|
||||||
hdinfo: _hdinfo,
|
hdinfo: _hdinfo
|
||||||
round: db.round || 0
|
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -1,42 +1,34 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import { ApiCall } from "tsrpc";
|
||||||
import {HuoDongFun} from "../../../public/huodongfun";
|
import { HuoDongFun } from "../../../public/huodongfun";
|
||||||
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/leijichongzhi/PtlRec";
|
import { ReqRec, ResRec } from "../../../shared/protocols/event/leijichongzhi/PtlRec";
|
||||||
import {HongDianChange} from "../../hongdian/fun";
|
import { HongDianChange } from "../../hongdian/fun";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||||
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
let _hdinfo = await HuoDongFun.getHdidInfo(call, call.req.hdid)
|
||||||
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
if (!_hdinfo || Object.keys(_hdinfo).length <= 0) {
|
||||||
// 无此活动
|
// 无此活动
|
||||||
return call.error('', {code: -1, message: globalThis.lng.huodong_open_1})
|
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
||||||
|
|
||||||
let conf = _hdinfo.data.tasks[call.req.index];
|
let conf = _hdinfo.data.tasks[call.req.index];
|
||||||
if (!conf) return call.error('', {code: -1});
|
if (!conf) return call.error('', { code: -1 });
|
||||||
|
|
||||||
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
let db = await G.mongodb.cEvent(_dbType).findOne({ uid: call.uid, type: _dbType });
|
||||||
if (db.recIndex.includes(call.req.index)) return call.error('', {code: -2});
|
if (db.recIndex.includes(call.req.index)) return call.error('', { code: -2 });
|
||||||
|
|
||||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10;
|
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10;
|
||||||
payNum = payNum - (db.round || 0) * R.compose(R.sum(), R.map(i => i.total))(_hdinfo.data.tasks)
|
if (payNum < conf.total) return call.error('', { code: -3 });
|
||||||
if (payNum < conf.total) return call.error('', {code: -3});
|
|
||||||
|
|
||||||
await PlayerFun.sendPrize(call, conf.prize);
|
await PlayerFun.sendPrize(call, conf.prize);
|
||||||
|
|
||||||
if (db.recIndex.length + 1 >= _hdinfo.data.tasks.length) {
|
G.mongodb.cEvent(_dbType).updateOne(
|
||||||
await G.mongodb.cEvent(_dbType).updateOne(
|
{ uid: call.uid, type: _dbType },
|
||||||
{uid: call.uid, type: _dbType},
|
{ $push: { recIndex: call.req.index } }
|
||||||
{$set: {recIndex: []}, $inc: {round: 1}}
|
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
await G.mongodb.cEvent(_dbType).updateOne(
|
|
||||||
{uid: call.uid, type: _dbType},
|
|
||||||
{$push: {recIndex: call.req.index}}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['huodonghd'])
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd'])
|
||||||
call.succ({
|
call.succ({
|
||||||
|
@ -29,5 +29,5 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
|
|
||||||
call.succ({})
|
call.succ({})
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
HongDianChange.sendChangeKey(call.uid, ['pobinglibao']);
|
||||||
}
|
}
|
||||||
|
@ -367,21 +367,17 @@ export class HuoDongHongDianFun {
|
|||||||
/**破冰礼包红点 */
|
/**破冰礼包红点 */
|
||||||
static async pobinglibao(call: ApiCall, _hd: ReqAddHuoDong): Promise<hongdianVal> {
|
static async pobinglibao(call: ApiCall, _hd: ReqAddHuoDong): Promise<hongdianVal> {
|
||||||
let gift = _hd?.data?.gift?.find(i => i.free == true && !i.payId)
|
let gift = _hd?.data?.gift?.find(i => i.free == true && !i.payId)
|
||||||
if (gift) return {show: true}
|
if (!gift) return {show: false}
|
||||||
|
|
||||||
let payIds = _hd?.data?.gift?.filter(i=>i.payId).map(i=>i.payId)
|
let payLog = await PayFun.getPayLog(call.uid, gift.payId)
|
||||||
let payLogs = await PayFun.getPayLogs(call.uid, payIds)
|
payLog = payLog?.filter(i => i.time >= _hd.stime && i.time <= _hd.etime) || []
|
||||||
|
if (!payLog || !payLog.length) return {show: false}
|
||||||
|
|
||||||
// 取奖励列表,判断是否有可领取奖励
|
// 取奖励列表,判断是否有可领取奖励
|
||||||
let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'})
|
let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'})
|
||||||
|
let rec = data?.record?.[call.req.id].length
|
||||||
for (let item of _hd?.data?.gift){
|
if (rec && (rec >= 3 || data?.record?.[gift.id] == call.req.recId)) return {show: false}
|
||||||
let rec = data?.record?.[item.id]?.length
|
return {show: true}
|
||||||
if (item.free== true && !item.payId) return {show: true}
|
|
||||||
if (payLogs[item.payId]?.length && (!rec || rec < PublicShared.getDiff(payLogs[item.payId][0].time))) return {show: true}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {show:false}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**元旦活动红点 */
|
/**元旦活动红点 */
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
import { patchFun, patchInit } from "../patch";
|
|
||||||
import { TanXianFun } from "../public/tanxian";
|
|
||||||
import { PublicShared } from "../shared/public/public";
|
|
||||||
|
|
||||||
class Path {
|
|
||||||
|
|
||||||
async fun1(a: any) {
|
|
||||||
let hdid = 1703860546;
|
|
||||||
let today_zero_time = PublicShared.getToDayZeroTime();
|
|
||||||
|
|
||||||
// 查询今天登录的用户
|
|
||||||
let today_login_users = await G.mongodb.collection("user").find(
|
|
||||||
{ loginTime: { $gte: today_zero_time } },
|
|
||||||
{ projection: { uid: 1 } }
|
|
||||||
).toArray();
|
|
||||||
|
|
||||||
for (let i = 0; i < today_login_users.length; i++) {
|
|
||||||
let uid = today_login_users[i].uid;
|
|
||||||
|
|
||||||
let init: boolean = false;
|
|
||||||
let hdata:any = await G.mongodb.cEvent(`yuandan${hdid}`).findOne({
|
|
||||||
uid: uid, type: `yuandan${hdid}`
|
|
||||||
});
|
|
||||||
if (!hdata) {
|
|
||||||
init = true;
|
|
||||||
hdata = {
|
|
||||||
uid: uid,
|
|
||||||
gift: {},
|
|
||||||
qiandao: {},
|
|
||||||
gameNum: 0,
|
|
||||||
exchange: {},
|
|
||||||
taskfinish: [],
|
|
||||||
taskval: {
|
|
||||||
"1": 1,
|
|
||||||
"2": 0,
|
|
||||||
"3": 0,
|
|
||||||
"4": 0,
|
|
||||||
"5": 0,
|
|
||||||
"6": 0,
|
|
||||||
"7": 0,
|
|
||||||
"8": 0,
|
|
||||||
"9": 0
|
|
||||||
},
|
|
||||||
qiandaoTime: 1,
|
|
||||||
refreshTime: G.time,
|
|
||||||
type: `yuandan${hdid}`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let taskval = {};
|
|
||||||
// taskid=1, stype=123 今日登录
|
|
||||||
taskval["1"] = 1;
|
|
||||||
|
|
||||||
// taskid=2, stype=158 今日参与抓娃娃次数
|
|
||||||
taskval["2"] = hdata.gameNum;
|
|
||||||
|
|
||||||
// taskid=3, stype=127 挑战 n 次清缴真主党
|
|
||||||
let myData = await G.mongodb.cPlayerInfo('qjzzd').findOne({ uid: uid, type: 'qjzzd' });
|
|
||||||
if (myData?.refreFightTime > PublicShared.getToDayZeroTime()) {
|
|
||||||
taskval["3"] = myData?.useFightNum || 0;
|
|
||||||
} else {
|
|
||||||
taskval["3"] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// taskid=4, stype=155 领取每日任务最终宝箱
|
|
||||||
let task = await G.mongodb.collection('task').findOne({ uid: uid, taskid: 25 });
|
|
||||||
if (task && task.lasttime >= today_zero_time && task.finish == 1) {
|
|
||||||
taskval["4"] = 1;
|
|
||||||
} else {
|
|
||||||
taskval["4"] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// taskid=5, stype=142 势力 配置xx 捐献进行 n 次捐献
|
|
||||||
let jxdata = await G.mongodb.collection('gonghuiUser').findOne({ uid: uid });
|
|
||||||
if (jxdata && jxdata.jx?.refreshTime > today_zero_time) {
|
|
||||||
if (jxdata.jx?.record) {
|
|
||||||
taskval["5"] = jxdata.jx?.record[2] || 0
|
|
||||||
}
|
|
||||||
taskval["5"] = 0
|
|
||||||
} else {
|
|
||||||
taskval["5"] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// taskid=6, stype=156 每日钻石消耗
|
|
||||||
taskval["6"] = 0;
|
|
||||||
let uselogs = (await G.mongodb.collection('rmbuse').find(
|
|
||||||
{ uid: uid, cTime: { $gte: today_zero_time }, isAdd: false },
|
|
||||||
{ projection: { change: 1 } }
|
|
||||||
).toArray()).forEach(e => { taskval["6"] += e.change; });
|
|
||||||
|
|
||||||
// taskid=7, stype=122 进行 n 次快速探险
|
|
||||||
taskval["7"] = 0;
|
|
||||||
const data = await G.mongodb.collection('tanxian').findOne({ uid: uid });
|
|
||||||
if (data?.resetTime > PublicShared.getToDayZeroTime()) {
|
|
||||||
taskval["7"] = data.useFastGuaJiNum || 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// taskid=8, stype=157 获得vip经验
|
|
||||||
let orde_logs = await G.mongodb.collection('payOrderLog' as any).find(
|
|
||||||
{ uid: uid, cTime: { $gte: today_zero_time * 1000 } },
|
|
||||||
).toArray();
|
|
||||||
|
|
||||||
taskval["8"] = 0;
|
|
||||||
orde_logs.forEach(e => {
|
|
||||||
let pay = G.gc.pay[e.payId];
|
|
||||||
if (pay) taskval["8"] += pay.payExp[0].n;
|
|
||||||
})
|
|
||||||
|
|
||||||
// taskid=9, stype=157 获得vip经验
|
|
||||||
taskval["9"] = 0;
|
|
||||||
orde_logs.forEach(e => {
|
|
||||||
let pay = G.gc.pay[e.payId];
|
|
||||||
if (pay) taskval["9"] += pay.payExp[0].n;
|
|
||||||
})
|
|
||||||
if (!init) {
|
|
||||||
await G.mongodb.cEvent(`yuandan${hdid}`).updateOne(
|
|
||||||
{ uid: uid, type: `yuandan${hdid}` },
|
|
||||||
{ $set: { taskval: taskval } }
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
hdata.taskval = taskval;
|
|
||||||
await G.mongodb.cEvent(`yuandan${hdid}`).updateOne({ uid: uid, type: `yuandan${hdid}` }, { $set: hdata }, { upsert: true })
|
|
||||||
}
|
|
||||||
console.log('玩家执行完成',uid)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return "sucess!!!"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async run() {
|
|
||||||
await this.fun1(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
await patchInit()
|
|
||||||
let patch = new Path();
|
|
||||||
await patch.run();
|
|
||||||
console.log("逻辑执行完成,等待退出");
|
|
||||||
setTimeout(function () {
|
|
||||||
console.log('结束程序');
|
|
||||||
process.exit();
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
main();
|
|
@ -16,6 +16,4 @@ export type ResOpen = {
|
|||||||
payNum: number;
|
payNum: number;
|
||||||
/**活动信息 */
|
/**活动信息 */
|
||||||
hdinfo: ReqAddHuoDong;
|
hdinfo: ReqAddHuoDong;
|
||||||
/** 当前领取轮次 */
|
|
||||||
round: number
|
|
||||||
};
|
};
|
@ -10263,13 +10263,6 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": "Reference",
|
"type": "Reference",
|
||||||
"target": "../../monopoly/protocols/PtlAddHuoDong/ReqAddHuoDong"
|
"target": "../../monopoly/protocols/PtlAddHuoDong/ReqAddHuoDong"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 4,
|
|
||||||
"name": "round",
|
|
||||||
"type": {
|
|
||||||
"type": "Number"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user