diff --git a/src/api_s2c/event/huobanzhaomu/ApiRec.ts b/src/api_s2c/event/huobanzhaomu/ApiRec.ts index 3b8cd45..0c1dfba 100644 --- a/src/api_s2c/event/huobanzhaomu/ApiRec.ts +++ b/src/api_s2c/event/huobanzhaomu/ApiRec.ts @@ -1,27 +1,38 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../../public/player'; -import { ReqRec, ResRec } from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; -import { HongDianChange } from "../../hongdian/fun"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../../public/player'; +import {ReqRec, ResRec} from "../../../shared/protocols/event/huobanzhaomu/PtlRec"; +import {HongDianChange} from "../../hongdian/fun"; +import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { let conf = G.gc.huobanzhaomu[call.req.index]; - if (!conf) return call.error('', { code: -1 }); - if (conf.gudKey && call.conn.gud[conf.gudKey] < conf.total) return call.error('', { code: -2 }); + if (!conf) return call.error('', {code: -1}); + if (conf.gudKey && call.conn.gud[conf.gudKey] < conf.total) return call.error('', {code: -2}); - let db = await G.mongodb.cEvent('huobanzhaomu').findOne({ uid: call.uid, type: 'huobanzhaomu' }); - if (db?.rec.includes(call.req.index)) return call.error('', { code: -3 }); - if (!conf.gudKey && (db?.rec?.length || 0) < G.gc.huobanzhaomu.length - 1) return call.error('', { code: -4 }); + let db = await G.mongodb.cEvent('huobanzhaomu').findOne({uid: call.uid, type: 'huobanzhaomu'}); + if (db?.rec.includes(call.req.index)) return call.error('', {code: -3}); + + if (conf.gudKey == "chaozhiyueka") { + let logs = await PayFun.getPayLog(call.uid, "chaozhiyueka"); + if (!logs || logs.slice(-1)[0].eTime < G.time) { + return call.error('', {code: -4}); + } + } else { + if (!conf.gudKey && (db?.rec?.length || 0) < G.gc.huobanzhaomu.length - 1) { + return call.error('', {code: -4}); + } + } await PlayerFun.sendPrize(call, conf.prize); if (db?.rec?.length + 1 >= G.gc.huobanzhaomu.length) { - G.mongodb.collection('syncBtns').updateOne({ uid: call.uid }, { $set: { 'huobanzhaomu.active': false } }, { upsert: true }); + G.mongodb.collection('syncBtns').updateOne({uid: call.uid}, {$set: {'huobanzhaomu.active': false}}, {upsert: true}); } G.mongodb.cEvent('huobanzhaomu').updateOne( - { uid: call.uid, type: 'huobanzhaomu' }, - { $push: { rec: call.req.index } }, - { upsert: true } + {uid: call.uid, type: 'huobanzhaomu'}, + {$push: {rec: call.req.index}}, + {upsert: true} ); HongDianChange.sendChangeKey(call.uid, ['huobanzhaomuhd']) diff --git a/src/api_s2c/xstask/ApiAllGet.ts b/src/api_s2c/xstask/ApiAllGet.ts index f41ac3c..d89d696 100644 --- a/src/api_s2c/xstask/ApiAllGet.ts +++ b/src/api_s2c/xstask/ApiAllGet.ts @@ -1,15 +1,17 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../public/player'; -import { XstaskFun } from '../../public/xstask'; -import { ReqAllGet, ResAllGet } from "../../shared/protocols/xstask/PtlAllGet"; -import { HongDianChange } from "../hongdian/fun"; -import { PublicShared } from "../../shared/public/public"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../public/player'; +import {XstaskFun} from '../../public/xstask'; +import {ReqAllGet, ResAllGet} from "../../shared/protocols/xstask/PtlAllGet"; +import {HongDianChange} from "../hongdian/fun"; +import {PublicShared} from "../../shared/public/public"; +import {TeQuanFun} from "../../public/tequan"; export default async function (call: ApiCall) { const taskList = JSON.parse(JSON.stringify(await XstaskFun.getAllTask(call.uid))); let taskInfo = await XstaskFun.getInfo(call.uid); - let prizeArr:atn[] = [] - for(let task of taskList) { + let tequan = await TeQuanFun.getXsTaskNum(call); + let prizeArr: atn[] = [] + for (let task of taskList) { const taskConf = G.gc.xstask[task?.taskId]; if (!task) continue; if (task.receiveData == undefined) continue; @@ -23,12 +25,12 @@ export default async function (call: ApiCall) { // } continue } - let change: Parameters[1] = { $inc: {} }; + let change: Parameters[1] = {$inc: {}}; change.$inc[`finishNum.${taskConf.colour}`] = 1; // 比对派遣时间,如果小于当日0点,则更新新任务,否则该变领取状态为true - if(task.receiveData.time < PublicShared.getToDayZeroTime()) { + if (task.receiveData.time < PublicShared.getToDayZeroTime()) { // 更新任务 - let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) + let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) XstaskFun.updateTask(call.uid, task._id, newTask[0].taskId) } else { // 更新领取状态 @@ -38,6 +40,14 @@ export default async function (call: ApiCall) { XstaskFun.changeInfo(call.uid, change); await PlayerFun.sendPrize(call, taskConf.prize); HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']); + + if (!tequan) { + prizeArr.push(...taskConf.prize) + } else { + for (let i = 0; i < 3; i++) { + prizeArr.push(...taskConf.prize) + } + } prizeArr.push(...taskConf.prize) } call.succ({ diff --git a/src/api_s2c/xstask/ApiGet.ts b/src/api_s2c/xstask/ApiGet.ts index 62a5b1b..878052d 100644 --- a/src/api_s2c/xstask/ApiGet.ts +++ b/src/api_s2c/xstask/ApiGet.ts @@ -1,9 +1,10 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../public/player'; -import { XstaskFun } from '../../public/xstask'; -import { ReqGet, ResGet } from "../../shared/protocols/xstask/PtlGet"; -import { HongDianChange } from "../hongdian/fun"; -import { PublicShared } from '../../shared/public/public'; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../public/player'; +import {XstaskFun} from '../../public/xstask'; +import {ReqGet, ResGet} from "../../shared/protocols/xstask/PtlGet"; +import {HongDianChange} from "../hongdian/fun"; +import {PublicShared} from '../../shared/public/public'; +import {TeQuanFun} from "../../public/tequan"; export default async function (call: ApiCall) { @@ -23,24 +24,32 @@ export default async function (call: ApiCall) { } } - let change: Parameters[1] = { $inc: {} }; + let change: Parameters[1] = {$inc: {}}; change.$inc[`finishNum.${taskConf.colour}`] = 1; // 比对派遣时间,如果小于当日0点,则更新新任务,否则该变领取状态为true - if(task.receiveData.time < PublicShared.getToDayZeroTime()) { + if (task.receiveData.time < PublicShared.getToDayZeroTime()) { // 更新任务 - let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) + let newTask = XstaskFun.randomTasks(taskInfo?.lv, 1) XstaskFun.updateTask(call.uid, call.req._id, newTask[0].taskId) } else { // 更新领取状态 XstaskFun.finishTask(call.uid, call.req._id) } // XstaskFun.delTask(call.uid, call.req._id); + let send_prize = []; XstaskFun.changeInfo(call.uid, change); - await PlayerFun.sendPrize(call, taskConf.prize); + if (!await TeQuanFun.getXsTaskNum(call)) { + send_prize = taskConf.prize; + } else { + for (let i = 0; i < 3; i++) { + send_prize = send_prize.concat(taskConf.prize) + } + } + await PlayerFun.sendPrize(call, send_prize); HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']); call.succ({ taskList: await XstaskFun.getAllTask(call.uid), - prize: taskConf.prize + prize: send_prize }); } \ No newline at end of file diff --git a/src/api_s2c/xstask/ApiOpen.ts b/src/api_s2c/xstask/ApiOpen.ts index 4261a4c..3a65a5d 100644 --- a/src/api_s2c/xstask/ApiOpen.ts +++ b/src/api_s2c/xstask/ApiOpen.ts @@ -36,7 +36,7 @@ export default async function (call: ApiCall) { XstaskFun.delTasks(call.uid, delTask.map(task => task._id)); } - needAddTask += await TeQuanFun.getXsTaskNum(call); + // needAddTask += await TeQuanFun.getXsTaskNum(call); needAddTask && await XstaskFun.addTasks(call.uid, XstaskFun.randomTasks(taskInfo?.lv || changeInfo.lv, needAddTask)); let { _id, uid, type, ...info } = taskInfo || changeInfo as typeof taskInfo;