From 1a703f1ecd9cbae787e826734b2d7d0ffd90c1d3 Mon Sep 17 00:00:00 2001 From: dy Date: Tue, 19 Dec 2023 14:59:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E5=85=85=E6=94=B9=E4=B8=BA=E7=9B=B4?= =?UTF-8?q?=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/shouchong/ApiOpen.ts | 11 +++-- src/api_s2c/event/shouchong/ApiReceive.ts | 46 ++++++++++--------- src/module/collection_event.ts | 3 ++ .../protocols/event/shouchong/PtlOpen.ts | 4 +- src/shared/protocols/serviceProto.ts | 20 +++++--- 5 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/api_s2c/event/shouchong/ApiOpen.ts b/src/api_s2c/event/shouchong/ApiOpen.ts index 010d12f..4f6fb4b 100644 --- a/src/api_s2c/event/shouchong/ApiOpen.ts +++ b/src/api_s2c/event/shouchong/ApiOpen.ts @@ -1,11 +1,14 @@ import { ApiCall } from "tsrpc"; import { ReqOpen, ResOpen } from "../../../shared/protocols/event/shouchong/PtlOpen"; +import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { - let data = await G.mongodb.cEvent('shouchong').findOne({ uid: call.uid, type: 'shouchong' }); + let data = await G.mongodb.cEvent('shouchongzhigou').findOne({uid: call.uid, type: 'shouchongzhigou'}) + + let payIds = R.compose(R.map(i=>i.payid),R.values())(G.gc.shouchong) call.succ({ - payNum: call.conn.gud.payExp / 10, - receive: Object.fromEntries(Object.keys(G.gc.shouchong).map(k => [k, data?.receive?.[k] || []])) - }); + receive: data?.receive || {}, + buyLog: await PayFun.getPayLogs(call.uid, payIds) + }) } \ No newline at end of file diff --git a/src/api_s2c/event/shouchong/ApiReceive.ts b/src/api_s2c/event/shouchong/ApiReceive.ts index 6e29d12..e5debb9 100644 --- a/src/api_s2c/event/shouchong/ApiReceive.ts +++ b/src/api_s2c/event/shouchong/ApiReceive.ts @@ -1,28 +1,31 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../../public/player'; -import { ReqReceive, ResReceive } from "../../../shared/protocols/event/shouchong/PtlReceive"; -import { PublicShared } from '../../../shared/public/public'; -import { HongDianChange } from "../../hongdian/fun"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../../public/player'; +import {ReqReceive, ResReceive} from "../../../shared/protocols/event/shouchong/PtlReceive"; +import {PublicShared} from '../../../shared/public/public'; +import {HongDianChange} from "../../hongdian/fun"; +import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { let conf = G.gc.shouchong[call.req.k]; - if (!conf) return call.error(globalThis.lng.pata_getprize_1); - let data = await G.mongodb.cEvent('shouchong').findOne({ uid: call.uid, type: 'shouchong' }); + let payLog = await PayFun.getPayLog(call.uid, conf.payid) + if (!payLog) return call.errorCode(-1) + + let data = await G.mongodb.cEvent('shouchongzhigou').findOne({ uid: call.uid, type: 'shouchongzhigou' }); let recArr = data?.receive?.[call.req.k] || []; - if (call.conn.gud.payExp < conf.paynum) return call.error(globalThis.lng.event_kfkh_9); + // if (call.conn.gud.payExp < conf.paynum) return call.error(globalThis.lng.event_kfkh_9); if (recArr.length >= conf.prize.length) return call.error(globalThis.lng.event_kfkh_3); if (recArr.slice(-1)[0] && PublicShared.getToDayZeroTime() < recArr.slice(-1)[0]) return call.error(globalThis.lng.event_kfkh_10); await PlayerFun.sendPrize(call, conf.prize[recArr.length]); - await G.mongodb.cEvent('shouchong').updateOne( - { uid: call.uid, type: 'shouchong' }, + await G.mongodb.cEvent('shouchongzhigou').updateOne( + { uid: call.uid, type: 'shouchongzhigou' }, { $push: G.mongodb.createTreeObj({ key: 'receive', k: call.req.k, val: G.time }) }, { upsert: true } ); @@ -40,17 +43,16 @@ export default async function (call: ApiCall) { } export async function getShouChongRedPoint(call: ApiCall) { - let res = { show: false }; - let data = await G.mongodb.cEvent('shouchong').findOne({ uid: call.uid, type: 'shouchong' }); + // let data = await G.mongodb.cEvent('shouchong').findOne({ uid: call.uid, type: 'shouchong' }); + // + // for (let [id, conf] of Object.entries(G.gc.shouchong)) { + // let rec = data?.receive?.[id] || []; + // if (call.conn.gud.payExp / 10 < conf.paynum || rec.length >= conf.prize.length) continue; + // if (rec.length == 0 || rec.slice(-1)[0] < PublicShared.getToDayZeroTime(G.time)) { + // res = { show: true }; + // break; + // } + // } - for (let [id, conf] of Object.entries(G.gc.shouchong)) { - let rec = data?.receive?.[id] || []; - if (call.conn.gud.payExp / 10 < conf.paynum || rec.length >= conf.prize.length) continue; - if (rec.length == 0 || rec.slice(-1)[0] < PublicShared.getToDayZeroTime(G.time)) { - res = { show: true }; - break; - } - } - - return res; + return {show: false}; } \ No newline at end of file diff --git a/src/module/collection_event.ts b/src/module/collection_event.ts index e1eeef3..6681c58 100644 --- a/src/module/collection_event.ts +++ b/src/module/collection_event.ts @@ -26,6 +26,9 @@ export type eventType = { shouchong: { receive: k_v; }; + shouchongzhigou: { + receive: k_v; + }; kaifukuanghuan: Omit; dayjijin: Omit; dengjijijin: Omit; diff --git a/src/shared/protocols/event/shouchong/PtlOpen.ts b/src/shared/protocols/event/shouchong/PtlOpen.ts index cad5f93..d839863 100644 --- a/src/shared/protocols/event/shouchong/PtlOpen.ts +++ b/src/shared/protocols/event/shouchong/PtlOpen.ts @@ -8,8 +8,10 @@ export type ReqOpen = { }; export type ResOpen = { - payNum: number; receive: { [k: string]: number[]; }; + buyLog:{ + [k: string]: any; + } }; \ No newline at end of file diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 5c4141b..c60ab37 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -10262,13 +10262,6 @@ export const serviceProto: ServiceProto = { "properties": [ { "id": 0, - "name": "payNum", - "type": { - "type": "Number" - } - }, - { - "id": 1, "name": "receive", "type": { "type": "Interface", @@ -10282,6 +10275,19 @@ export const serviceProto: ServiceProto = { } } } + }, + { + "id": 1, + "name": "buyLog", + "type": { + "type": "Interface", + "indexSignature": { + "keyType": "String", + "type": { + "type": "Any" + } + } + } } ] },