From 6ec6de4d568de257a1a6dfdcc6603ca2744ff44b Mon Sep 17 00:00:00 2001 From: dy Date: Thu, 4 Jan 2024 15:37:09 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=A0=B4=E5=86=B0=E7=A4=BC=E5=8C=85?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=89=8D=E7=AB=AF=E7=A9=BA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/pobinglibao/ApiReceive.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/api_s2c/event/pobinglibao/ApiReceive.ts b/src/api_s2c/event/pobinglibao/ApiReceive.ts index 1ca3b81..848c49b 100644 --- a/src/api_s2c/event/pobinglibao/ApiReceive.ts +++ b/src/api_s2c/event/pobinglibao/ApiReceive.ts @@ -6,6 +6,9 @@ import {HongDianChange} from "../../hongdian/fun"; import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { + + if (!call.req.id) return call.errorCode(-1) + // 查询活动是否有当前领奖的免费选项 let _hd = (await HuoDongFun.gethdList(call, 10))[0] let gift = _hd?.data?.gift?.find(i => i.id == call.req.id) From 8afa624f44797d1e1707a23dade2cc995848e331 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Thu, 4 Jan 2024 15:51:40 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=B7=A8=E6=9C=8D=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/chat/ApiSend.ts | 4 +++- src/public/chat.ts | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/api_s2c/chat/ApiSend.ts b/src/api_s2c/chat/ApiSend.ts index 4d182d0..7ae9a4c 100644 --- a/src/api_s2c/chat/ApiSend.ts +++ b/src/api_s2c/chat/ApiSend.ts @@ -1,6 +1,6 @@ import { ApiCall, WsClientStatus } from "tsrpc"; import { ActionLog } from '../../public/actionLog/actionLog'; -import { ChatFun } from '../../public/chat'; +import { ChatFun, getCrossChatGroupByOpenDay } from '../../public/chat'; import { ReqSend, ResSend } from "../../shared/protocols/chat/PtlSend"; import { chatMsgLog } from "../../shared/protocols/type" import { getGud } from "../../public/gud"; @@ -40,6 +40,8 @@ export default async function (call: ApiCall) { if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) { //如果是跨服的话,调用跨服API的这条协议 + sendData.otherData.group = getCrossChatGroupByOpenDay(); + G.clientCross.sendMsg('msg_cross/CrossChat', sendData); call.succ({}); return; diff --git a/src/public/chat.ts b/src/public/chat.ts index d0e2286..877f6fd 100644 --- a/src/public/chat.ts +++ b/src/public/chat.ts @@ -3,6 +3,7 @@ import { ApiCall } from 'tsrpc'; import { MsgChat } from '../shared/protocols/msg_s2c/MsgChat'; import { player } from '../shared/protocols/user/type'; import { chatLog, chatMsgLog } from '../shared/protocols/type' +import { PublicShared } from '../shared/public/public'; const msgListLen = { 'cross': 30, @@ -10,6 +11,20 @@ const msgListLen = { 'guild': 20 }; +/** + * 通过开服天数,获取跨服聊天分组 + */ +export function getCrossChatGroupByOpenDay(){ + let openday = PublicShared.getOpenServerDay(); + if(openday<=7){ + return 1; + }else if(openday <= 30){ + return 2; + }else{ + return 3; + } +} + export class ChatFun { /**新增消息 */ static async newMsg(sendData: MsgChat) { @@ -23,7 +38,11 @@ export class ChatFun { G.server.broadcastClusterMsg('msg_s2c/Chat', sendData,{ghId:(sendData.sender as player)?.ghId}); }else if(sendData.type == 'cross'){ //所有的子进程都会收到,不需要集群内分别广播 - G.server.broadcastMsg('msg_s2c/Chat', sendData); + if(sendData?.otherData?.group == getCrossChatGroupByOpenDay()){ + //如果时候同一个分组的 + delete sendData?.otherData?.group; + G.server.broadcastMsg('msg_s2c/Chat', sendData); + } }else{ G.server.broadcastClusterMsg('msg_s2c/Chat', sendData); } From f1dacd19b6c65705d114ab7084b1031a9b0c9bf4 Mon Sep 17 00:00:00 2001 From: dy Date: Thu, 4 Jan 2024 16:05:52 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E7=A0=B4=E5=86=B0=E7=A4=BC=E5=8C=85?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=AE=E6=AC=A1=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/pobinglibao/ApiOpen.ts | 5 +++-- src/api_s2c/event/pobinglibao/ApiReceive.ts | 11 ++++------- src/api_s2c/hongdian/fun.ts | 2 +- src/module/collection_event.ts | 2 +- .../protocols/event/pobinglibao/PtlReceive.ts | 8 +++++--- src/shared/protocols/serviceProto.ts | 15 ++++++++++++++- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/api_s2c/event/pobinglibao/ApiOpen.ts b/src/api_s2c/event/pobinglibao/ApiOpen.ts index 5677a06..c780f1a 100644 --- a/src/api_s2c/event/pobinglibao/ApiOpen.ts +++ b/src/api_s2c/event/pobinglibao/ApiOpen.ts @@ -6,7 +6,6 @@ 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 _hd = (await HuoDongFun.gethdList(call, 10))[0] if (!_hd) return call.errorCode(-1) @@ -16,9 +15,11 @@ export default async function (call: ApiCall) { let payLog: any = await PayFun.getPayLogs(call.uid, payIds) for (let key in payLog) { - payLog[key]?.filter(i => i.time > _hd.stime && i.time < _hd.etime) + payLog[key] = payLog[key]?.filter(i => i.time > _hd.stime && i.time < _hd.etime) } + let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}) + call.succ({ record: data?.record || {}, buyLog: payLog diff --git a/src/api_s2c/event/pobinglibao/ApiReceive.ts b/src/api_s2c/event/pobinglibao/ApiReceive.ts index 848c49b..735337a 100644 --- a/src/api_s2c/event/pobinglibao/ApiReceive.ts +++ b/src/api_s2c/event/pobinglibao/ApiReceive.ts @@ -7,30 +7,27 @@ import {PayFun} from "../../../public/pay"; export default async function (call: ApiCall) { - if (!call.req.id) return call.errorCode(-1) - // 查询活动是否有当前领奖的免费选项 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) + if (!gift || !call.req.recId) return call.errorCode(-1) let payLog = await PayFun.getPayLog(call.uid, gift.payId) payLog = payLog?.filter(i => i.time >= _hd.stime && i.time <= _hd.etime) || [] if (!payLog || !payLog.length) return call.errorCode(-2) - // 取奖励列表,判断是否有可领取奖励 - let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'}) + let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}) let rec = data?.record?.[call.req.id]?.length if (rec && (rec >= 3 || data?.record?.[gift.id] == call.req.recId)) return call.errorCode(-3) await PlayerFun.sendPrize(call, gift[call.req.recId]); - await G.mongodb.cEvent('pobinglibao').updateOne({uid: call.uid, type: 'pobinglibao'}, { + await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).updateOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}, { $push: {[`record.${gift.id}`]: call.req.recId}, }, {upsert: true}) - call.succ({}) + call.succ({prize: gift[call.req.recId]}) HongDianChange.sendChangeKey(call.uid, ['huodonghd']); } diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index ec2094a..4d66e88 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -373,7 +373,7 @@ export class HuoDongHongDianFun { let payLogs = await PayFun.getPayLogs(call.uid, payIds) // 取奖励列表,判断是否有可领取奖励 - let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'}) + let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}) for (let item of _hd?.data?.gift){ let rec = data?.record?.[item.id]?.length diff --git a/src/module/collection_event.ts b/src/module/collection_event.ts index d09d6eb..9679fcc 100644 --- a/src/module/collection_event.ts +++ b/src/module/collection_event.ts @@ -54,7 +54,6 @@ export type eventType = { jierihuodong: Omit & { refreshTime: number; }; kaifujingsai: ResOpenKaifujingsai; zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; }; - pobinglibao: ResOpenPobinglibao payForDiamond: { [time: number]: number } @@ -74,6 +73,7 @@ export type eventType = { [k: `qiridenglu${number}`]: Pick; [k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number }; [k: `yuandan${number}`]: ResOpenYuandan; + [k: `pobinglibao${number}`]: ResOpenPobinglibao; }; export type CollectionEvent = { diff --git a/src/shared/protocols/event/pobinglibao/PtlReceive.ts b/src/shared/protocols/event/pobinglibao/PtlReceive.ts index bb057a3..b9869a1 100644 --- a/src/shared/protocols/event/pobinglibao/PtlReceive.ts +++ b/src/shared/protocols/event/pobinglibao/PtlReceive.ts @@ -1,11 +1,13 @@ +import {prizeType} from "../../type"; + /** * 破冰礼包领奖 */ -export interface ReqReceive { +export type ReqReceive = { id: string recId: string } -export interface ResReceive { - +export type ResReceive = { + prize: prizeType[] } diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 2dc1df9..f0b3f0c 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -10560,7 +10560,20 @@ export const serviceProto: ServiceProto = { ] }, "event/pobinglibao/PtlReceive/ResReceive": { - "type": "Interface" + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "prize", + "type": { + "type": "Array", + "elementType": { + "type": "Reference", + "target": "type/prizeType" + } + } + } + ] }, "event/qirichongzhi/PtlOpen/ReqOpen": { "type": "Interface" From 38b2f9a99e5ad73915e5dbc7b9e57195714822b0 Mon Sep 17 00:00:00 2001 From: dy Date: Thu, 4 Jan 2024 16:50:16 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=A0=B4=E5=86=B0=E7=A4=BC=E5=8C=85?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=90=8E=E4=B8=80=E5=A4=A9=E5=8F=AF?= =?UTF-8?q?=E9=A2=86=E5=8F=96=E6=89=80=E6=9C=89=E5=A5=96=E5=8A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/pobinglibao/ApiReceive.ts | 5 ++- src/api_s2c/hongdian/fun.ts | 34 +++++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/api_s2c/event/pobinglibao/ApiReceive.ts b/src/api_s2c/event/pobinglibao/ApiReceive.ts index 735337a..8cd63ed 100644 --- a/src/api_s2c/event/pobinglibao/ApiReceive.ts +++ b/src/api_s2c/event/pobinglibao/ApiReceive.ts @@ -4,6 +4,7 @@ import {HuoDongFun} from "../../../public/huodongfun"; import {PlayerFun} from "../../../public/player"; import {HongDianChange} from "../../hongdian/fun"; import {PayFun} from "../../../public/pay"; +import {PublicShared} from "../../../shared/public/public"; export default async function (call: ApiCall) { @@ -19,7 +20,9 @@ export default async function (call: ApiCall) { // 取奖励列表,判断是否有可领取奖励 let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}) let rec = data?.record?.[call.req.id]?.length - if (rec && (rec >= 3 || data?.record?.[gift.id] == call.req.recId)) return call.errorCode(-3) + let _payDiff = PublicShared.getDiff(payLog[0].time) + let _endDiff = PublicShared.getDiff(_hd.etime) + if ((rec >= _payDiff && _endDiff < 1) || data?.record?.[gift.id] == call.req.recId) return call.errorCode(-3) await PlayerFun.sendPrize(call, gift[call.req.recId]); diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index 4d66e88..4400a21 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -366,22 +366,36 @@ export class HuoDongHongDianFun { /**破冰礼包红点 */ static async pobinglibao(call: ApiCall, _hd: ReqAddHuoDong): Promise { + let gift = _hd?.data?.gift?.find(i => i.free == true && !i.payId) if (gift) return {show: true} - let payIds = _hd?.data?.gift?.filter(i=>i.payId).map(i=>i.payId) + + let payIds = _hd?.data?.gift?.filter(i => i.payId).map(i => i.payId) let payLogs = await PayFun.getPayLogs(call.uid, payIds) - - // 取奖励列表,判断是否有可领取奖励 - let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}) - - for (let item of _hd?.data?.gift){ - let rec = data?.record?.[item.id]?.length - 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} + for (let key in payLogs) { + payLogs[key] = payLogs[key]?.filter(i => i.time > _hd.stime && i.time < _hd.etime) || [] } - return {show:false} + // 取奖励列表,判断是否有可领取奖励 + let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({ + uid: call.uid, + type: `pobinglibao${_hd.hdid}` + }) + for (let item of _hd?.data?.gift) { + if (item.free == true && !item.payId) return {show: true} + + let payLog = payLogs[item.payId] + if (!payLog.length) continue + + let rec = data?.record?.[item.id]?.length + let _payDiff = PublicShared.getDiff(payLog[0].time) + let _endDiff = PublicShared.getDiff(_hd.etime) + if ((rec < _payDiff)) return {show: true} + if ((rec < 3 && _endDiff > 0)) return {show: true} + } + + return {show: false} } /**元旦活动红点 */ From 65d306227bccd4de0642aabc75934e80656f80fe Mon Sep 17 00:00:00 2001 From: dy Date: Thu, 4 Jan 2024 16:56:33 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=A2=86=E5=A5=96=EF=BC=8C=E7=BA=A2?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/pobinglibao/ApiReceive.ts | 10 ++++++-- src/api_s2c/hongdian/fun.ts | 1 + .../protocols/event/pobinglibao/PtlReceive.ts | 2 +- src/shared/protocols/serviceProto.ts | 25 ++++++++++++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/api_s2c/event/pobinglibao/ApiReceive.ts b/src/api_s2c/event/pobinglibao/ApiReceive.ts index 8cd63ed..c97f0da 100644 --- a/src/api_s2c/event/pobinglibao/ApiReceive.ts +++ b/src/api_s2c/event/pobinglibao/ApiReceive.ts @@ -8,19 +8,25 @@ import {PublicShared} from "../../../shared/public/public"; 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 || !call.req.recId) return call.errorCode(-1) + // 查询购买状态 let payLog = await PayFun.getPayLog(call.uid, gift.payId) payLog = payLog?.filter(i => i.time >= _hd.stime && i.time <= _hd.etime) || [] if (!payLog || !payLog.length) return call.errorCode(-2) - // 取奖励列表,判断是否有可领取奖励 + /** + * 取奖励列表,判断是否有可领取奖励 + * 购买日起,每种礼包每天可领一次礼包,每种类型独立 + * 活动结束前的最后一天,可领取所有奖励 + */ let data = await G.mongodb.cEvent(`pobinglibao${_hd.hdid}`).findOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}) let rec = data?.record?.[call.req.id]?.length let _payDiff = PublicShared.getDiff(payLog[0].time) + _payDiff = _payDiff > 3 ? 3 : _payDiff let _endDiff = PublicShared.getDiff(_hd.etime) if ((rec >= _payDiff && _endDiff < 1) || data?.record?.[gift.id] == call.req.recId) return call.errorCode(-3) diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index 4400a21..fe16850 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -390,6 +390,7 @@ export class HuoDongHongDianFun { let rec = data?.record?.[item.id]?.length let _payDiff = PublicShared.getDiff(payLog[0].time) + _payDiff = _payDiff > 3 ? 3 : _payDiff let _endDiff = PublicShared.getDiff(_hd.etime) if ((rec < _payDiff)) return {show: true} if ((rec < 3 && _endDiff > 0)) return {show: true} diff --git a/src/shared/protocols/event/pobinglibao/PtlReceive.ts b/src/shared/protocols/event/pobinglibao/PtlReceive.ts index b9869a1..be8ddf7 100644 --- a/src/shared/protocols/event/pobinglibao/PtlReceive.ts +++ b/src/shared/protocols/event/pobinglibao/PtlReceive.ts @@ -5,7 +5,7 @@ import {prizeType} from "../../type"; */ export type ReqReceive = { id: string - recId: string + recId: 'prize' | 'recPrize1' | 'recPrize2' } export type ResReceive = { diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index f0b3f0c..b651d1e 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -10554,7 +10554,30 @@ export const serviceProto: ServiceProto = { "id": 1, "name": "recId", "type": { - "type": "String" + "type": "Union", + "members": [ + { + "id": 0, + "type": { + "type": "Literal", + "literal": "prize" + } + }, + { + "id": 1, + "type": { + "type": "Literal", + "literal": "recPrize1" + } + }, + { + "id": 2, + "type": { + "type": "Literal", + "literal": "recPrize2" + } + } + ] } } ] From a50b2624ac0fa58d8d1db45699d2ccbda210a96c Mon Sep 17 00:00:00 2001 From: dy Date: Thu, 4 Jan 2024 17:04:01 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=B4=AF=E8=AE=A1=E5=85=85=E5=80=BC?= =?UTF-8?q?=E7=BA=A2=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/hongdian/fun.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index fe16850..393fce9 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -671,7 +671,8 @@ export class HuoDongHongDianFun { let _con = hdCon.data.tasks; let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType}); let _mydata = db || {sTime: PublicShared.getToDayZeroTime(G.time), recIndex: []}; - let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.etime); + let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.rtime)) * 10 + payNum = payNum - (db?.round || 0) * R.sort((a, b) => b.total - a.total)(hdCon.data.tasks)[0].total for (let index = 0; index < _con.length; index++) { const element = _con[index]; if (_mydata.recIndex.includes(index)) continue;