Compare commits

..

9 Commits

8 changed files with 115 additions and 30 deletions

View File

@ -1,6 +1,6 @@
import { ApiCall, WsClientStatus } from "tsrpc"; import { ApiCall, WsClientStatus } from "tsrpc";
import { ActionLog } from '../../public/actionLog/actionLog'; 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 { ReqSend, ResSend } from "../../shared/protocols/chat/PtlSend";
import { chatMsgLog } from "../../shared/protocols/type" import { chatMsgLog } from "../../shared/protocols/type"
import { getGud } from "../../public/gud"; import { getGud } from "../../public/gud";
@ -40,6 +40,8 @@ export default async function (call: ApiCall<ReqSend, ResSend>) {
if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) { if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) {
//如果是跨服的话调用跨服API的这条协议 //如果是跨服的话调用跨服API的这条协议
sendData.otherData.group = getCrossChatGroupByOpenDay();
G.clientCross.sendMsg('msg_cross/CrossChat', sendData); G.clientCross.sendMsg('msg_cross/CrossChat', sendData);
call.succ({}); call.succ({});
return; return;

View File

@ -6,7 +6,6 @@ import {PublicShared} from "../../../shared/public/public";
export default async function (call: ApiCall<ReqOpen, ResOpen>) { export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'})
let _hd = (await HuoDongFun.gethdList(call, 10))[0] let _hd = (await HuoDongFun.gethdList(call, 10))[0]
if (!_hd) return call.errorCode(-1) if (!_hd) return call.errorCode(-1)
@ -16,9 +15,11 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let payLog: any = await PayFun.getPayLogs(call.uid, payIds) let payLog: any = await PayFun.getPayLogs(call.uid, payIds)
for (let key in payLog) { 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({ call.succ({
record: data?.record || {}, record: data?.record || {},
buyLog: payLog buyLog: payLog

View File

@ -4,30 +4,39 @@ import {HuoDongFun} from "../../../public/huodongfun";
import {PlayerFun} from "../../../public/player"; import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun"; import {HongDianChange} from "../../hongdian/fun";
import {PayFun} from "../../../public/pay"; import {PayFun} from "../../../public/pay";
import {PublicShared} from "../../../shared/public/public";
export default async function (call: ApiCall<ReqReceive, ResReceive>) { export default async function (call: ApiCall<ReqReceive, ResReceive>) {
// 查询活动是否有当前领奖的免费选项
// 查询活动是否是可领取状态
let _hd = (await HuoDongFun.gethdList(call, 10))[0] let _hd = (await HuoDongFun.gethdList(call, 10))[0]
let gift = _hd?.data?.gift?.find(i => i.id == call.req.id) 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) let payLog = await PayFun.getPayLog(call.uid, gift.payId)
payLog = payLog?.filter(i => i.time >= _hd.stime && i.time <= _hd.etime) || [] payLog = payLog?.filter(i => i.time >= _hd.stime && i.time <= _hd.etime) || []
if (!payLog || !payLog.length) return call.errorCode(-2) 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 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)
_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)
await PlayerFun.sendPrize(call, gift[call.req.recId]); 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}, $push: {[`record.${gift.id}`]: call.req.recId},
}, {upsert: true}) }, {upsert: true})
call.succ({}) call.succ({prize: gift[call.req.recId]})
HongDianChange.sendChangeKey(call.uid, ['huodonghd']); HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
} }

View File

@ -366,22 +366,37 @@ 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: 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 payLogs = await PayFun.getPayLogs(call.uid, payIds)
for (let key in payLogs) {
// 取奖励列表,判断是否有可领取奖励 payLogs[key] = payLogs[key]?.filter(i => i.time > _hd.stime && i.time < _hd.etime) || []
let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'})
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}
} }
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)
_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}
}
return {show: false}
} }
/**元旦活动红点 */ /**元旦活动红点 */
@ -656,7 +671,8 @@ export class HuoDongHongDianFun {
let _con = hdCon.data.tasks; let _con = hdCon.data.tasks;
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 _mydata = db || {sTime: PublicShared.getToDayZeroTime(G.time), recIndex: []}; 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++) { for (let index = 0; index < _con.length; index++) {
const element = _con[index]; const element = _con[index];
if (_mydata.recIndex.includes(index)) continue; if (_mydata.recIndex.includes(index)) continue;

View File

@ -54,7 +54,6 @@ export type eventType = {
jierihuodong: Omit<ResOpenJierihuodong, 'taskFinish'> & { refreshTime: number; }; jierihuodong: Omit<ResOpenJierihuodong, 'taskFinish'> & { refreshTime: number; };
kaifujingsai: ResOpenKaifujingsai; kaifujingsai: ResOpenKaifujingsai;
zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; }; zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; };
pobinglibao: ResOpenPobinglibao
payForDiamond: { payForDiamond: {
[time: number]: number [time: number]: number
} }
@ -74,6 +73,7 @@ export type eventType = {
[k: `qiridenglu${number}`]: Pick<ResOpenQiridenglu, 'recPrize'>; [k: `qiridenglu${number}`]: Pick<ResOpenQiridenglu, 'recPrize'>;
[k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number }; [k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number };
[k: `yuandan${number}`]: ResOpenYuandan; [k: `yuandan${number}`]: ResOpenYuandan;
[k: `pobinglibao${number}`]: ResOpenPobinglibao;
}; };
export type CollectionEvent<T extends keyof eventType> = { export type CollectionEvent<T extends keyof eventType> = {

View File

@ -3,6 +3,7 @@ import { ApiCall } from 'tsrpc';
import { MsgChat } from '../shared/protocols/msg_s2c/MsgChat'; import { MsgChat } from '../shared/protocols/msg_s2c/MsgChat';
import { player } from '../shared/protocols/user/type'; import { player } from '../shared/protocols/user/type';
import { chatLog, chatMsgLog } from '../shared/protocols/type' import { chatLog, chatMsgLog } from '../shared/protocols/type'
import { PublicShared } from '../shared/public/public';
const msgListLen = { const msgListLen = {
'cross': 30, 'cross': 30,
@ -10,6 +11,20 @@ const msgListLen = {
'guild': 20 '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 { export class ChatFun {
/**新增消息 */ /**新增消息 */
static async newMsg(sendData: MsgChat) { 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}); G.server.broadcastClusterMsg('msg_s2c/Chat', sendData,{ghId:(sendData.sender as player)?.ghId});
}else if(sendData.type == 'cross'){ }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{ }else{
G.server.broadcastClusterMsg('msg_s2c/Chat', sendData); G.server.broadcastClusterMsg('msg_s2c/Chat', sendData);
} }

View File

@ -1,11 +1,13 @@
import {prizeType} from "../../type";
/** /**
* *
*/ */
export interface ReqReceive { export type ReqReceive = {
id: string id: string
recId: string recId: 'prize' | 'recPrize1' | 'recPrize2'
} }
export interface ResReceive { export type ResReceive = {
prize: prizeType[]
} }

View File

@ -10602,13 +10602,49 @@ export const serviceProto: ServiceProto<ServiceType> = {
"id": 1, "id": 1,
"name": "recId", "name": "recId",
"type": { "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"
}
}
]
} }
} }
] ]
}, },
"event/pobinglibao/PtlReceive/ResReceive": { "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": { "event/qirichongzhi/PtlOpen/ReqOpen": {
"type": "Interface" "type": "Interface"