Compare commits
No commits in common. "3c7985642e973655712a3bdcfb73212e091497f7" and "a0d06cdaf42f96811022fd68a4d78c9c515d65f8" have entirely different histories.
3c7985642e
...
a0d06cdaf4
@ -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, getCrossChatGroupByOpenDay } from '../../public/chat';
|
import { ChatFun } 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,8 +40,6 @@ 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;
|
||||||
|
@ -6,6 +6,7 @@ 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)
|
||||||
@ -15,11 +16,9 @@ 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] = payLog[key]?.filter(i => i.time > _hd.stime && i.time < _hd.etime)
|
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
|
||||||
|
@ -4,39 +4,30 @@ 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 || !call.req.recId) return call.errorCode(-1)
|
if (!gift) 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
|
||||||
let _payDiff = PublicShared.getDiff(payLog[0].time)
|
if (rec && (rec >= 3 || data?.record?.[gift.id] == call.req.recId)) return call.errorCode(-3)
|
||||||
_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${_hd.hdid}`).updateOne({uid: call.uid, type: `pobinglibao${_hd.hdid}`}, {
|
await G.mongodb.cEvent('pobinglibao').updateOne({uid: call.uid, type: 'pobinglibao'}, {
|
||||||
$push: {[`record.${gift.id}`]: call.req.recId},
|
$push: {[`record.${gift.id}`]: call.req.recId},
|
||||||
}, {upsert: true})
|
}, {upsert: true})
|
||||||
|
|
||||||
call.succ({prize: gift[call.req.recId]})
|
call.succ({})
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
HongDianChange.sendChangeKey(call.uid, ['huodonghd']);
|
||||||
}
|
}
|
||||||
|
@ -366,37 +366,22 @@ 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${_hd.hdid}`).findOne({
|
let data = await G.mongodb.cEvent('pobinglibao').findOne({uid: call.uid, type: 'pobinglibao'})
|
||||||
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
|
|
||||||
|
|
||||||
|
for (let item of _hd?.data?.gift){
|
||||||
let rec = data?.record?.[item.id]?.length
|
let rec = data?.record?.[item.id]?.length
|
||||||
let _payDiff = PublicShared.getDiff(payLog[0].time)
|
if (item.free== true && !item.payId) return {show: true}
|
||||||
_payDiff = _payDiff > 3 ? 3 : _payDiff
|
if (payLogs[item.payId]?.length && (!rec || rec < PublicShared.getDiff(payLogs[item.payId][0].time))) return {show: true}
|
||||||
let _endDiff = PublicShared.getDiff(_hd.etime)
|
|
||||||
if ((rec < _payDiff)) return {show: true}
|
|
||||||
if ((rec < 3 && _endDiff > 0)) return {show: true}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {show: false}
|
return {show:false}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**元旦活动红点 */
|
/**元旦活动红点 */
|
||||||
@ -671,8 +656,7 @@ 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.rtime)) * 10
|
let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.etime);
|
||||||
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;
|
||||||
|
@ -54,6 +54,7 @@ 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
|
||||||
}
|
}
|
||||||
@ -73,7 +74,6 @@ 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> = {
|
||||||
|
@ -3,7 +3,6 @@ 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,
|
||||||
@ -11,20 +10,6 @@ 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) {
|
||||||
@ -38,11 +23,7 @@ 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'){
|
||||||
//所有的子进程都会收到,不需要集群内分别广播
|
//所有的子进程都会收到,不需要集群内分别广播
|
||||||
if(sendData?.otherData?.group == getCrossChatGroupByOpenDay()){
|
|
||||||
//如果时候同一个分组的
|
|
||||||
delete sendData?.otherData?.group;
|
|
||||||
G.server.broadcastMsg('msg_s2c/Chat', sendData);
|
G.server.broadcastMsg('msg_s2c/Chat', sendData);
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
G.server.broadcastClusterMsg('msg_s2c/Chat', sendData);
|
G.server.broadcastClusterMsg('msg_s2c/Chat', sendData);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import {prizeType} from "../../type";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 破冰礼包领奖
|
* 破冰礼包领奖
|
||||||
*/
|
*/
|
||||||
export type ReqReceive = {
|
export interface ReqReceive {
|
||||||
id: string
|
id: string
|
||||||
recId: 'prize' | 'recPrize1' | 'recPrize2'
|
recId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ResReceive = {
|
export interface ResReceive {
|
||||||
prize: prizeType[]
|
|
||||||
}
|
}
|
||||||
|
@ -10602,49 +10602,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "recId",
|
"name": "recId",
|
||||||
"type": {
|
"type": {
|
||||||
"type": "Union",
|
"type": "String"
|
||||||
"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"
|
||||||
|
Loading…
Reference in New Issue
Block a user