diff --git a/src/api_s2c/event/pobinglibao/ApiOpen.ts b/src/api_s2c/event/pobinglibao/ApiOpen.ts new file mode 100644 index 0000000..0bc97df --- /dev/null +++ b/src/api_s2c/event/pobinglibao/ApiOpen.ts @@ -0,0 +1,54 @@ +import {ApiCall} from "tsrpc"; +import {ReqOpen, ResOpen} from "../../../shared/protocols/event/zhoumolibao/PtlOpen"; +import {PayFun} from "../../../public/pay"; +import {HuoDongFun} from "../../../public/huodongfun"; +import {PublicShared} from "../../../shared/public/public"; + + +export default async function (call: ApiCall) { + let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'}) + + let gift = await getConf(call) + + let payIds = gift.filter(i => i.payId)?.map(i => i.payId) + + call.succ({ + record: data?.record || {}, + buyLog: await PayFun.getPayLogs(call.uid, payIds) + }) +} + +export async function getConf(call, args?: { id?: string; payId?: string }) { + let _hd = (await HuoDongFun.gethdList(call, 10))[0] + if (!_hd) return [] + if (args?.id) return _hd?.data?.gift?.find(i => i.id == args.id) + if (args?.payId) return _hd?.data?.gift?.find(i => i.payId == args.payId) + return _hd?.data?.gift +} + +export async function checkResetBuyLog(call) { + + + + + + // let zeroTime = PublicShared.getToDayZeroTime() + + // let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'}) + // if (!data?.refreshTime || data?.refreshTime < zeroTime) { + // G.mongodb.cEvent(`zhoumolibao`).updateOne( + // {uid: call.uid, type: `zhoumolibao`}, + // {$set: {record: {}, refreshTime: G.time}}, + // {upsert: true} + // ) + // } + // + // let gifts = await getConf(call) + // + // let payIds = gifts.filter(i => i.payId)?.map(i => i.payId) + // let payLogs = await PayFun.getPayLogs(call.uid, payIds) + // let payLogLength = R.flatten(R.values(payLogs)).filter(i => i.time < zeroTime).length + // if (payLogLength) { + // PayFun.delPayLog(call.uid, ...payIds.map(i => ({payId: i, val: []}))) + // } +} \ No newline at end of file diff --git a/src/api_s2c/event/pobinglibao/ApiReceive.ts b/src/api_s2c/event/pobinglibao/ApiReceive.ts new file mode 100644 index 0000000..b8e28c1 --- /dev/null +++ b/src/api_s2c/event/pobinglibao/ApiReceive.ts @@ -0,0 +1,32 @@ +import {ApiCall} from "tsrpc"; +import {ReqReceive, ResReceive} from "../../../shared/protocols/event/pobinglibao/PtlReceive"; +import {HuoDongFun} from "../../../public/huodongfun"; +import {PlayerFun} from "../../../public/player"; +import {HongDianChange} from "../../hongdian/fun"; +import {PayFun} from "../../../public/pay"; + +export default async function (call: ApiCall) { + // 查询活动是否有当前领奖的免费选项 + let _hd = (await HuoDongFun.gethdList(call, 10))[0] + let gift = _hd?.data?.gift?.find(i => i.id == call.req.id) + if (!gift) return call.errorCode(-1) + + let payLog = await PayFun.getPayLog(call.uid, gift.payId) + if (!payLog) return call.errorCode(-2) + + + // 取奖励列表,判断是否有可领取奖励 + let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'}) + let rec = data?.record?.[call.req.id].length + if (rec && rec >= 2) return call.errorCode(-3) + + await PlayerFun.sendPrize(call, gift.prize); + + await G.mongodb.cEvent('pobinglibao').updateOne({uid: call.uid, type: 'pobinglibao'}, { + $push: {[`record.${gift.id}`]: call.req.recId}, + }, {upsert: true}) + + call.succ({}) + + // HongDianChange.sendChangeKey(call.uid, ['pobinglibao']); +} diff --git a/src/module/collection_event.ts b/src/module/collection_event.ts index e1eeef3..d481b9b 100644 --- a/src/module/collection_event.ts +++ b/src/module/collection_event.ts @@ -21,6 +21,7 @@ import {ResOpen as ResOpenZhoulibao} from '../shared/protocols/event/zhoulibao/P import {ResOpen as ResOpenZixuanlibao} from '../shared/protocols/event/zixuanlibao/PtlOpen'; import {ResOpen as ResOpenKaifujingsai} from '../shared/protocols/kaifujingsai/PtlOpen'; import {ResOpen as ResOpenZhoumolibao} from '../shared/protocols/event/zhoumolibao/PtlOpen'; +import {ResOpen as ResOpenPobinglibao} from '../shared/protocols/event/pobinglibao/PtlOpen'; export type eventType = { shouchong: { @@ -48,6 +49,7 @@ export type eventType = { jierihuodong: Omit & { refreshTime: number; }; kaifujingsai: ResOpenKaifujingsai; zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; } + pobinglibao: ResOpenPobinglibao } & { [k: `${number}jijin`]: ResOpenYuedujijin; [k: `yangchengmubiao${number}`]: yangchengmubiao; diff --git a/src/shared/protocols/event/christmas/huodong.json b/src/shared/protocols/event/christmas/huodong.json deleted file mode 100644 index cea9f66..0000000 --- a/src/shared/protocols/event/christmas/huodong.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "hdid" : 91029302193, - "htype" : 8, - "stype" : 800, - "ttype" : 0, - "stime" : 1702396800, - "rtime" : 1703088000, - "etime" : 1703088000, - "name" : "christmas", - "icon" : "icon_xfdj", - "showtime" : "根据玩家注册时间,游戏返回时复写", - "data" : { - "task" : { - "1": { - "pval" : 1, - "stype" : "", - "cond": [], - "prize" : [ - { - "a" : "item", - "t" : "1", - "n" : 500000 - } - ], - "des" : "intr_cszl_des_1" - }, - "2": { - "pval" : 1, - "stype" : "101", - "cond": [], - "prize" : [ - { - "a" : "item", - "t" : "1", - "n" : 500000 - } - ], - "des" : "intr_cszl_des_1" - }, - "3": { - "pval" : 2, - "stype" : "101", - "cond": [], - "prize" : [ - { - "a" : "item", - "t" : "1", - "n" : 500000 - } - ], - "des" : "intr_cszl_des_1" - } - }, - "gameneed": [{"a": "attr", "t":"jinbi", "n": 1}], - "game": [0,1, 2, 3, 4, 5], - "gamefree": 3, - "zhanling":[{ - "val": 1, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 2, - "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}], - "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 3, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] - },{ - "val": 4, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 5, - "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}], - "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 6, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] - },{ - "val": 7, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 8, - "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}], - "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 9, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] - }], - "zlpayid":"ycmb_1_1", - "libao": { - "1": { - "payid": "", - "buynum": 2, - "basep": [{"a": "attr", "t":"rmbmoney", "n": 1}], - "des" : "intr_cszl_des_1", - "dlz": [ - { - "1": {"a": "attr", "t":"rmbmoney", "n": 1}, - "2": {"a": "attr", "t":"rmbmoney", "n": 2}, - "3": {"a": "attr", "t":"rmbmoney", "n": 3} - }, - { - "1": {"a": "attr", "t":"rmbmoney", "n": 1}, - "2": {"a": "attr", "t":"rmbmoney", "n": 2}, - "3": {"a": "attr", "t":"rmbmoney", "n": 3} - } - ] - }, - "2": { - "payid": "ycmb_1_2", - "buynum": 2, - "basep": [{"a": "attr", "t":"rmbmoney", "n": 2}], - "des" : "intr_cszl_des_2", - "dlz": [ - { - "1": {"a": "attr", "t":"rmbmoney", "n": 1}, - "2": {"a": "attr", "t":"rmbmoney", "n": 2}, - "3": {"a": "attr", "t":"rmbmoney", "n": 3} - }, - { - "1": {"a": "attr", "t":"rmbmoney", "n": 1}, - "2": {"a": "attr", "t":"rmbmoney", "n": 2}, - "3": {"a": "attr", "t":"rmbmoney", "n": 3} - } - ] - } - }, - "qiandao": [ - [{"a": "attr", "t":"jinbi", "n": 1}], - [{"a": "attr", "t":"jinbi", "n": 1}], - [{"a": "attr", "t":"jinbi", "n": 1}], - [{"a": "attr", "t":"jinbi", "n": 1}], - [{"a": "attr", "t":"jinbi", "n": 1}], - [{"a": "attr", "t":"jinbi", "n": 1}], - [{"a": "attr", "t":"jinbi", "n": 1}] - ] - - - } -} \ No newline at end of file diff --git a/src/shared/protocols/event/pobinglibao/PtlOpen.ts b/src/shared/protocols/event/pobinglibao/PtlOpen.ts new file mode 100644 index 0000000..f7c775b --- /dev/null +++ b/src/shared/protocols/event/pobinglibao/PtlOpen.ts @@ -0,0 +1,16 @@ + +/** + * 破冰礼包 + */ +export type ReqOpen = { + +}; + +export type ResOpen = { + record:{ + [k: string]: any; + } + buyLog:{ + [k: string]: any; + } +}; \ No newline at end of file diff --git a/src/shared/protocols/event/pobinglibao/PtlReceive.ts b/src/shared/protocols/event/pobinglibao/PtlReceive.ts new file mode 100644 index 0000000..bb057a3 --- /dev/null +++ b/src/shared/protocols/event/pobinglibao/PtlReceive.ts @@ -0,0 +1,11 @@ +/** + * 破冰礼包领奖 + */ +export interface ReqReceive { + id: string + recId: string +} + +export interface ResReceive { + +}