Compare commits

...

14 Commits

Author SHA1 Message Date
dy
6ea5b82629 Merge branch 'master' into dev
# Conflicts:
#	src/shared/protocols/serviceProto.ts
2023-12-14 11:42:36 +08:00
dy
4f9c1276c4 Merge remote-tracking branch 'origin/dev' into dev 2023-12-14 11:38:57 +08:00
dy
bcab41c9bb proto 2023-12-14 11:38:15 +08:00
e0c0d03f4e Merge branch 'dev' of http://git.legu.cc/qixin/HJ_Server into dev 2023-12-14 11:33:14 +08:00
941d74195d Merge branch 'master' into dev 2023-12-14 11:28:52 +08:00
dy
3efb9d4075 Merge remote-tracking branch 'origin/dev' into dev 2023-12-14 11:22:57 +08:00
dy
e244b8b495 忽略列表 2023-12-14 11:22:46 +08:00
dy
f08ba5d44c 忽略列表 2023-12-14 11:21:30 +08:00
3d40edd421 动态调整mdb连接上限数 2023-12-14 11:20:35 +08:00
dy
e1f3e726b7 周末礼包 2023-12-14 11:06:54 +08:00
dy
312afa1b69 周末礼包 2023-12-14 11:04:16 +08:00
afbfa70926 根据开服天数,计算开启进程数量 2023-12-14 10:32:24 +08:00
dy
4fea8d6863 json 2023-12-14 09:59:06 +08:00
dy
c99b56b768 json 2023-12-14 09:52:34 +08:00
14 changed files with 634 additions and 406 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@
/.vscode
/dist
/doc
/src/config.json

View File

@ -29,6 +29,25 @@ if (env.SERVER_ID) {
//读取服务配置
const config = fs.existsSync(path.resolve(__dirname, 'config.json')) ? JSON.parse(fs.readFileSync(path.resolve(__dirname, 'config.json'), 'utf-8')) : {};
const dis = config.serverId != undefined ? config.serverId : '0';
let instancesNum = 8;
if(config.openTime){
let openDate = new Date(config.openTime);
//计算openTime距离今天的天数
let today = new Date();
// 获取两个日期之间的毫秒差
let timeDiff = today.getTime() - openDate.getTime();
// 将毫秒差转换为天数
let daysDiff = Math.floor(timeDiff / (1000 * 3600 * 24));
console.log(`已开服天数:${daysDiff}`);
//如果开服超过3天的区则只开区2个进程
if(daysDiff > 3){
instancesNum = 2;
}
}
const localApps = [
{
// 应用程序名称
@ -38,7 +57,7 @@ const localApps = [
// 应用程序所在的目录
cwd: './',
//集群实例数量0表示根据cpu核心数自动控制
instances: 8,
instances: instancesNum,
// 传递给脚本的参数
args: '-serverType msg',
// 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。

View File

@ -0,0 +1,20 @@
import {ApiCall} from "tsrpc";
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/zhoumolibao/PtlOpen";
import {PayFun} from "../../../public/pay";
import {HuoDongFun} from "../../../public/huodongfun";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
let payIds = _hd?.data?.gift?.filter(i => i.payId)?.map(i => i.payId)
call.succ({
record: data?.record || {},
buyLog: await PayFun.getPayLogs(call.uid, payIds)
})
}

View File

@ -0,0 +1,25 @@
import {ApiCall} from "tsrpc";
import {ReqReceive, ResReceive} from "../../../shared/protocols/event/zhoumolibao/PtlReceive";
import {HuoDongFun} from "../../../public/huodongfun";
import {PlayerFun} from "../../../public/player";
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
// 查询活动是否有当前领奖的免费选项
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
let gift = _hd?.data?.gift?.find(i => i.free && i.id == call.req.id)
if (!gift) return call.errorCode(-1)
// 取奖励列表,判断是否有可领取奖励
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
let rec = data.record[call.req.id]
if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
await PlayerFun.sendPrize(call, gift.prize);
await G.mongodb.cEvent('zhoumolibao').updateOne({uid: call.uid, type: 'zhoumolibao'}, {
$inc: {[`record.${gift.id}`]: 1}
},{ upsert: true })
call.succ({})
}

View File

@ -1,7 +0,0 @@
{
"msgPort": 8100,
"openTime": "2023-12-01 00:00:02",
"httpPort": 8101,
"redisUrl": "redis://:lyMaple525458@10.0.1.20:6379/0",
"crossRedisUrl": "redis://:lyMaple525458@10.0.1.20:6379/1"
}

View File

@ -9,7 +9,7 @@ async function connGameLogDB() {
}else{
logDBUrl = "mongodb://root:lyMaple525458@10.0.1.20:27017/heijiao_gamelog?authSource=admin";
}
let client = await MongoClient.connect(logDBUrl);
let client = await MongoClient.connect(logDBUrl,{maxPoolSize:10});
logDB = client.db(`gameLog${G.config.serverId}`);
return logDB;
}

View File

@ -3275,10 +3275,10 @@
cxtime: 604800
}
},
{
"hdid" : 8000, // 唯一活动id 周末礼包
"htype" : 8, // 后端唯一识别标识
"stype" : 800, // 前端唯一识别标识(看前端需要是否修改)
{
"hdid" : 9000, // 唯一活动id 周末礼包
"htype" : 9, // 后端唯一识别标识
"stype" : 900, // 前端唯一识别标识(看前端需要是否修改)
"ttype" : 0, // 0 按照开服时间计算1 玩家注册时间计算 4 屏蔽此活动
"stime" : 0, // 活动开始天数
"rtime" : 30, // 活动显示结束天数
@ -3293,53 +3293,40 @@
//礼包
gift: [
{
need: [],
id: '1',
name: 'wkdtips_4',
need: [],
free: true,
payId: 'wkdlibao_1',
payId: '',
buyNum: 1,
prize: []
prize: [{'a': 'item', 't': '13', 'n': 600}]
},
{
need: [],
id: '2',
name: 'wkdtips_5',
need: [],
free: false,
payId: 'wkdlibao_1',
buyNum: 1,
prize: [{'a': 'item', 't': '4', 'n': 1},{'a': 'item', 't': '13', 'n': 800},{'a': 'item', 't': '2', 'n': 1000},{'a': 'item', 't': '1', 'n': 1000}]
},
{
id: '3',
name: 'wkdtips_6',
need: [],
free: false,
payId: 'wkdlibao_2',
buyNum: 1,
prize: []
buyNum: 2,
prize: [{'a': 'item', 't': '4', 'n': 2},{'a': 'item', 't': '13', 'n': 1000},{'a': 'item', 't': '2', 'n': 1200},{'a': 'item', 't': '1', 'n': 1200}]
},
{
need: [],
{
id: '4',
name: 'wkdtips_7',
need: [],
free: false,
payId: 'wkdlibao_3',
buyNum: 2,
prize: []
},
{
need: [],
free: false,
payId: 'wkdlibao_4',
buyNum: 2,
prize: []
},
{
need: [],
free: false,
payId: 'wkdlibao_5',
buyNum: 2,
prize: []
},
{
need: [],
free: false,
payId: 'wkdlibao_6',
buyNum: 3,
prize: []
},
{
need: [],
free: false,
payId: 'wkdlibao_7',
buyNum: 3,
prize: []
prize: [{'a': 'item', 't': '4', 'n': 5},{'a': 'item', 't': '13', 'n': 1200},{'a': 'item', 't': '2', 'n': 1200},{'a': 'item', 't': '1', 'n': 1200}]
}
]
}

View File

@ -1300,5 +1300,18 @@
"display": {
"lv": 20
}
},
"zhoumolibao": {
"name": "zhoumolibao",
"undefined": "周末礼包",
"and": {
"lv": 15
},
"or": {},
"time": 0,
"tips": "openCond_tips_96",
"display": {
"lv": 15
}
}
}

View File

@ -20,6 +20,7 @@ import {ResOpen as ResOpenZhanLing} from '../shared/protocols/event/zhanling/Ptl
import {ResOpen as ResOpenZhoulibao} from '../shared/protocols/event/zhoulibao/PtlOpen';
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';
export type eventType = {
shouchong: {
@ -45,7 +46,8 @@ export type eventType = {
xianshizhaomu: ResOpenXianshizhaomu & { refreshTime: number; };
qirichongzhi: Omit<ResOpenQirichongzhi, 'finished'>;
jierihuodong: Omit<ResOpenJierihuodong, 'taskFinish'> & { refreshTime: number; };
kaifujingsai: ResOpenKaifujingsai
kaifujingsai: ResOpenKaifujingsai;
zhoumolibao: ResOpenZhoumolibao;
} & {
[k: `${number}jijin`]: ResOpenYuedujijin;
[k: `yangchengmubiao${number}`]: yangchengmubiao;

View File

@ -37,6 +37,7 @@ export class HuoDongFun {
let openTime = PublicShared.getToDayZeroTime(G.openTime)
let _sDay = Number((G.time - openTime) / 86400)
// ttype为0 根据开服时间计算ttype为1根据用户注册时间计算
let _where = {
$or: [
{

View File

@ -5,6 +5,7 @@ import {
IndexDescription,
IndexSpecification,
MongoClient,
MongoClientOptions,
ObjectId,
OptionalId
} from 'mongodb';
@ -16,6 +17,7 @@ import {MongodbCollections} from './module/mongodb';
import {HuoDongFun} from './public/huodongfun';
import {zbsGroup} from './api_s2c/hbzb/zbs/fun';
import {clusterRunOnce} from './clusterUtils';
import { PublicShared } from './shared/public/public';
const indexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[] }> = {
item: [
@ -349,9 +351,37 @@ const indexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[] }> =
};
const crossIndexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[] }> = {
email: [
{
key: {sid: 1}
},
{
key: {uid: 1}
}
],
fightLog: [
{
key: {uid: 1, type: 1}
},
{
key: {uid: 1}
},
{
key: {ttl: 1}, expireAfterSeconds: 7 * 24 * 3600
}
],
hbzb_user_cross: [
{
key: {uid: 1}, unique: true
},
{
key: {jifen: 1}
},
{
key: {rank: 1}
},
{
key: {zbsgroup: 1}
}
],
hbzb_user_zbs: [
@ -377,13 +407,52 @@ const crossIndexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[]
rankList: [
{
key: {type: 1, idKey: 1}, unique: true
}
},
{
key: {valArr: -1}
},
],
wzry_fight: [
{
key: {jifen: 1}
},
{
key: {uid: 1}
},
{
key: {zkey: 1}
},
],
wzry_user_cross: [
{
key: {jifen: 1}
},
{
key: {uid: 1}
},
{
key: {zkey: 1}
},
]
};
export async function initMongoDB() {
//mongodb连接数说明https://blog.csdn.net/for_cxc/article/details/116859714
//可结合查看node_modules\mongodb\lib\connection_string.js
//maxPoolSize默认值100
let option:MongoClientOptions;
//跨服只有1个直接采用默认配置就行
if(G.argv.serverType != 'cross'){
if(PublicShared.getOpenServerDay() > 3){
option = {
maxPoolSize: 10
}
}
}
console.log('connect mongodb ......');
let client = await MongoClient.connect(G.argv.serverType == 'cross' ? G.config.crossMongodbUrl : G.config.mongodbUrl);
let client = await MongoClient.connect(G.argv.serverType == 'cross' ? G.config.crossMongodbUrl : G.config.mongodbUrl, option);
G.mongodb = new _mongodb(client.db(G.config.dbName || ''));
console.log('connect mongodb succ');
@ -391,7 +460,9 @@ export async function initMongoDB() {
if (G.argv.serverType != 'cross') {
console.log('connect crossmongodb ......');
//本服里,维持住跟跨服数据库的链接
let crossClient = await MongoClient.connect(G.config.crossMongodbUrl);
let crossClient = await MongoClient.connect(G.config.crossMongodbUrl,{
maxPoolSize:10
});
G.crossmongodb = new _mongodb(crossClient.db(G.config.corssDBName || ""));
console.log('connect crossmongodb succ');
}

View File

@ -0,0 +1,16 @@
/**
*
*/
export type ReqOpen = {
};
export type ResOpen = {
record:{
[k: string]: number;
}
buyLog:{
[k: string]: number;
}
};

View File

@ -0,0 +1,10 @@
/**
*
*/
export interface ReqReceive {
id: string
}
export interface ResReceive {
}

File diff suppressed because it is too large Load Diff