Compare commits
9 Commits
a0d06cdaf4
...
3c7985642e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3c7985642e | ||
![]() |
a50b2624ac | ||
![]() |
65d306227b | ||
![]() |
38b2f9a99e | ||
![]() |
3e1c45aaf9 | ||
![]() |
f1dacd19b6 | ||
a5e726e811 | |||
8afa624f44 | |||
![]() |
6ec6de4d56 |
@ -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<ReqSend, ResSend>) {
|
||||
|
||||
if (sendData.type == 'cross' && G.clientCross?.status == WsClientStatus.Opened) {
|
||||
//如果是跨服的话,调用跨服API的这条协议
|
||||
sendData.otherData.group = getCrossChatGroupByOpenDay();
|
||||
|
||||
G.clientCross.sendMsg('msg_cross/CrossChat', sendData);
|
||||
call.succ({});
|
||||
return;
|
||||
|
@ -6,7 +6,6 @@ import {PublicShared} from "../../../shared/public/public";
|
||||
|
||||
|
||||
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]
|
||||
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)
|
||||
|
||||
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
|
||||
|
@ -4,30 +4,39 @@ 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<ReqReceive, ResReceive>) {
|
||||
// 查询活动是否有当前领奖的免费选项
|
||||
|
||||
// 查询活动是否是可领取状态
|
||||
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)
|
||||
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 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']);
|
||||
}
|
||||
|
@ -366,22 +366,37 @@ export class HuoDongHongDianFun {
|
||||
|
||||
/**破冰礼包红点 */
|
||||
static async pobinglibao(call: ApiCall, _hd: ReqAddHuoDong): Promise<hongdianVal> {
|
||||
|
||||
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').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}
|
||||
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)
|
||||
_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 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;
|
||||
|
@ -54,7 +54,6 @@ export type eventType = {
|
||||
jierihuodong: Omit<ResOpenJierihuodong, 'taskFinish'> & { 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<ResOpenQiridenglu, 'recPrize'>;
|
||||
[k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number };
|
||||
[k: `yuandan${number}`]: ResOpenYuandan;
|
||||
[k: `pobinglibao${number}`]: ResOpenPobinglibao;
|
||||
};
|
||||
|
||||
export type CollectionEvent<T extends keyof eventType> = {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
import {prizeType} from "../../type";
|
||||
|
||||
/**
|
||||
* 破冰礼包领奖
|
||||
*/
|
||||
export interface ReqReceive {
|
||||
export type ReqReceive = {
|
||||
id: string
|
||||
recId: string
|
||||
recId: 'prize' | 'recPrize1' | 'recPrize2'
|
||||
}
|
||||
|
||||
export interface ResReceive {
|
||||
|
||||
export type ResReceive = {
|
||||
prize: prizeType[]
|
||||
}
|
||||
|
@ -10602,13 +10602,49 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
"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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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"
|
||||
|
Loading…
Reference in New Issue
Block a user