Merge remote-tracking branch 'origin/dev-leijichongzhi' into release

# Conflicts:
#	src/api_s2c/hongdian/ApiGet.ts
#	src/api_s2c/pushgift/ApiOpen.ts
#	src/globalListener.ts
#	src/module/collection_event.ts
#	src/public/pushgift.ts
#	src/shared/protocols/hongdian/PtlGet.ts
#	src/shared/protocols/msg_s2c/MsgPushGiftChange.ts
#	src/shared/protocols/serviceProto.ts
This commit is contained in:
dy 2023-12-22 22:50:59 +08:00
commit 38c1b28f9c
31 changed files with 3484 additions and 579 deletions

View File

@ -0,0 +1,21 @@
import {ApiCall} from "tsrpc";
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/leichonglibao/PtlOpen";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let data = await G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).findOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}
)
let change = {opentime: G.time}
if (!data) {
Object.assign(change, {sc: false, buy: []})
}
// 每天open红点
G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).updateOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}, {$set: change}, {upsert: true}
)
let temp = Object.assign((data || {}), change) as ResOpen & { opentime }
call.succ({sc: temp.sc, buy: temp.buy});
}

View File

@ -0,0 +1,120 @@
import {ApiCall} from "tsrpc";
import {HuoDongFun} from "../../../public/huodongfun";
import {ReqReceive, ResReceive} from "../../../shared/protocols/event/leichonglibao/PtlReceive";
import {PlayerFun} from "../../../public/player";
import {PublicShared} from "../../../shared/public/public";
export type LeiChongLiBaoData = {
intr: string
intr2: string
payRewardNum: number
dlz: { [key: string]: atn }[]
gift: {
id: string, name: string, need: atn[], free: boolean, payId: string, scale: number, buynum: number, prize: atn[]
}[]
}
export default async function (call: ApiCall<ReqReceive, ResReceive>) {
let hdinfo = await HuoDongFun.gethdList(call, 12);
if (hdinfo.length <= 0) {
// 无此活动
return call.error('', {code: -1, message: globalThis.lng.huodong_open_1})
}
let hddata = hdinfo.filter(i => i.hdid == call.req.hdid)[0].data as LeiChongLiBaoData;
let data = await G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).findOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}
)
if (data.sc) {
// 自选奖励已领取
return call.error('', {code: -1, message: globalThis.lng.task_finsh_3})
}
if (data.buy.length < hddata.payRewardNum) {
// 累计购买礼包次数不足
return call.error("", {code: -1, message: globalThis.lng.ljlibaotips_8})
}
let _prize: atn[] = [];
for (let i = 0; i < hddata.dlz.length; i++) {
_prize.push(hddata.dlz[i][call.req.select[i] || "1"])
}
// 修改领取标识
await G.mongodb.cEvent(`leichonglibao${call.req.hdid}`).updateOne(
{type: `leichonglibao${call.req.hdid}`, uid: call.uid}, {$set: {sc: true}}
)
PlayerFun.sendPrize(call, _prize)
call.succ({prize: _prize})
}
export async function LeiChongLiBaoBuyGift(call: ApiCall, payId: string) {
let hdinfo = await HuoDongFun.gethdList(call, 12);
if (hdinfo.length <= 0) {
console.log(call.uid, "购买累充礼包 但是活动没有开启", payId);
return
}
let gift: LeiChongLiBaoData["gift"][0];
let hdid = hdinfo[0].hdid;
let hddata = hdinfo[0].data as LeiChongLiBaoData;
for (let g of hddata.gift) {
if (g.payId == payId) {
gift = g;
break;
}
}
if (!gift) return; // 不是购买累充礼包
let mydata = await G.mongodb.cEvent(`leichonglibao${hdid}`).findOne(
{type: `leichonglibao${hdid}`, uid: call.uid}
)
if (mydata && mydata.buy.includes(gift.payId)) {
console.log(call.uid, "购买累充礼包 重复购买", payId);
return
}
let update;
if (mydata) {
update = {$push: {buy: payId}}
} else {
update = {$set: {opentime: G.time, sc: false, buy: [payId]}}
}
PlayerFun.sendPrize(call, gift.prize)
G.mongodb.cEvent(`leichonglibao${hdid}`).updateOne(
{uid: call.uid, type: `leichonglibao${hdid}`}, update
)
}
export async function LeiChongLiBaoGetHongDian(call: ApiCall) {
let hdinfo = await HuoDongFun.gethdList(call, 12);
if (hdinfo.length <= 0) {
return {show: false}
}
let hdid = hdinfo[0].hdid;
let hddata = hdinfo[0].data as LeiChongLiBaoData;
let mydata = await G.mongodb.cEvent(`leichonglibao${hdid}`).findOne(
{type: `leichonglibao${hdid}`, uid: call.uid}
)
if (!mydata || mydata.opentime < PublicShared.getToDayZeroTime()) {
return {show: true}
}
if (!mydata.sc && mydata.buy.length >= hddata.payRewardNum) {
return {show: true}
}
return {show: false}
}

View File

@ -1,11 +1,12 @@
import { ApiCall } from "tsrpc";
import { RedisCollections2 } from '../../module/redis';
import { ReqGetList, ResGetList } from "../../shared/protocols/hero/PtlGetList";
import {ApiCall} from "tsrpc";
import {RedisCollections2} from '../../module/redis';
import {ReqGetList, ResGetList} from "../../shared/protocols/hero/PtlGetList";
import {PeijianShared} from "../../shared/public/peijian";
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
let list: ResGetList['list'] = {};
//let kvList: k_v<RedisCollections2['hero']> = {};
let arrList = await G.mongodb.collection('hero').find({ uid: call.uid }).toArray();
let arrList = await G.mongodb.collection('hero').find({uid: call.uid}).toArray();
let heroCon = G.gc.hero;
let color = {};
@ -19,14 +20,47 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
if (!color[heroCon[v.heroId].colour]) color[heroCon[v.heroId].colour] = 0;
color[heroCon[v.heroId].colour] += 1;
});
// 修复配件数据
let peijianids = [];
Object.values(list).map(hero => {
hero.peijian && Object.values(hero.peijian).map(
i => peijianids.push(G.mongodb.conversionId(PeijianShared.fmt(i)._id))
)
});
let peijians = (await G.mongodb.collection("peijian").find(
{uid: call.uid, _id: {$in: peijianids}}, {projection: {_id: 1}}
).toArray()).map(temp => G.mongodb.conversionId(temp._id));
let changes = {};
Object.values(list).map(hero => {
for (let pos in hero.peijian) {
if (!peijians.includes(PeijianShared.fmt(hero.peijian[pos])._id)) {
hero.peijian[pos] = "";
changes[hero._id] = hero.peijian;
}
}
})
for (let oid in changes) {
// 修复数据
G.mongodb.collection("hero").updateOne(
G.mongodb.conversionIdObj({_id: oid}), {$set: {peijian: changes[oid]}}
)
}
// 记录玩家最大等级,颜色相关数据 注册任务用
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({ uid: call.conn.uid, type: 'usertasklog' },
{ $set: { maxherolv: maxherolv, herocolor: color } }, { upsert: true });
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
{$set: {maxherolv: maxherolv, herocolor: color}}, {upsert: true});
//G.redis.set('hero', call.uid, kvList);
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({ uid: call.conn.uid, type: 'lshd_hero' });
let { uid, _id, type, ...heros } = (recLshd || {});
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({
uid: call.conn.uid,
type: 'lshd_hero'
});
let {uid, _id, type, ...heros} = (recLshd || {});
call.conn.lshd.hero = heros || {};
@ -34,6 +68,6 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
list: list,
pos: call.conn.heroPos,
lshd: heros || {},
gbzj: (await G.mongodb.cPlayerInfo('gbzj').findOne({ uid: call.uid, type: 'gbzj' }))?.rec || {}
gbzj: (await G.mongodb.cPlayerInfo('gbzj').findOne({uid: call.uid, type: 'gbzj'}))?.rec || {}
});
}

View File

@ -15,12 +15,13 @@ import {md_redPoint} from '../gongyu/mingdao/ApiOpen';
import {HongDianFun, HuoDongHongDianFun} from "./fun";
import {FunWeiXiuChang} from "../../public/weixiuchang";
import {getShouChongRedPoint} from "../event/shouchong/ApiReceive";
import {LeiChongLiBaoGetHongDian} from "../event/leichonglibao/ApiReceive";
import { playerCanReceive } from '../event/payForDiamond/ApiCanReceive';
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai', 'zhoumolibao', 'pobinglibao', 'payForDiamond'];
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai', 'zhoumolibao', 'pobinglibao', 'leichonglibao', 'payForDiamond'];
export default async function (call: ApiCall<ReqGet, ResGet>) {
@ -164,6 +165,9 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
case 'zhoumolibao':
res[key] = await HongDianFun.zhoumolibao(call);
break;
case "leichonglibao":
res[key] = await LeiChongLiBaoGetHongDian(call)
break;
case 'payForDiamond':
const receiveResult = await playerCanReceive(call, false);
res[key] = { show: receiveResult && receiveResult.result };

View File

@ -365,7 +365,6 @@ export class HuoDongHongDianFun {
// 检测 htype 8 圣诞活动红点
ishd = await this.christmasHongDian(call, element)
}
if (element.htype == 10) {
// 检测 htype 10 破冰活动红点
ishd = await this.pobinglibao(call, element)

View File

@ -9,6 +9,7 @@ import {ReqLottery, ResLottery} from "../../shared/protocols/jiuba/PtlLottery";
import {PublicShared} from '../../shared/public/public';
import {HongDianChange} from '../hongdian/fun';
import {RankKfjs} from "../../public/rank/rank_kfjs";
import {PushGiftFun} from "../../public/pushgift";
export default async function (call: ApiCall<ReqLottery, ResLottery>) {
@ -142,4 +143,8 @@ export default async function (call: ApiCall<ReqLottery, ResLottery>) {
valArr: [await rankKfjs.getRankScore(call.uid) + call.req.type]
});
// 十连抽推送礼包
if (call.req.type == 10) {
PushGiftFun.chkRecruitGift(call.uid)
}
}

View File

@ -132,6 +132,9 @@ async function doLogin(call: ApiCall<ReqLogin, ResLogin>) {
//await G.redis.set('user', gud.uid, gud);
await initGud(gud.uid, gud);
// 修复公会id
await fixUnionData(gud);
//记录玩家所在的进程change: 更换到处理完踢线操作在写入。
// setUidProcessId(gud.uid);
@ -278,4 +281,19 @@ async function LoginFun(call: ApiCall<ReqLogin, ResLogin>) {
//
// G.mongodb.collection("hero").findOneAndUpdate({_id: i._id}, {$set: {shiwu: shiwuChange}})
// })
// }
// }
// 修复玩家退出公会 但是gud中残留公会id
async function fixUnionData(gud: ResLogin["gud"]) {
if (gud.ghId) {
let ghdata = await G.mongodb.collection("gonghui").findOne(
{_id: G.mongodb.conversionId(gud.ghId), 'players.uid': gud.uid}
)
if (!ghdata) {
gud.ghId = "";
gud.ghName = "";
gud.ghLevel = 0;
PlayerFun.changeAttr(gud.uid, {ghId: '', ghLevel: 0})
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
import {ctor} from "../global";
import {initMongoDB} from "../setMongodb";
async function start() {
await initMongoDB()
let datas = await G.mongodb.collection("event").find(
{type: {$in: ["yangchengmubiao100", "yangchengmubiao101"]}}
).toArray();
for (let i = 0; i < datas.length; i++) {
let add = 0;
let data = datas[i];
if (!Array.isArray(data.taskval)) continue;
let taskval: { [taskid: string]: number } = {};
for (let i = 0; i < data.taskval.length; i++) {
if (data.taskval[i] === null) continue;
if (typeof data.taskval[i] == "number") {
add = data.taskval[i];
} else {
taskval = Object.assign(taskval, data.taskval[i]);
}
}
for (let taskid in taskval) {
taskval[taskid] = (taskval[taskid] || 0) + add;
}
await G.mongodb.collection("event").updateOne(
{uid: data.uid, type: data.type}, {$set: {taskval: taskval}}
)
console.log(`修复玩家${data.uid}人才计划数据完成...`);
}
}
ctor();
start().then(() => {
setInterval(() => {
console.log(new Date().format("MM-dd hh:mm:ss"));
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -1,6 +1,6 @@
import {ctor} from "./global";
import {initMongoDB} from "./setMongodb";
import {yangchengmubiao} from "./shared/protocols/event/yangchengmubiao/PtlOpen";
import {ctor} from "../global";
import {initMongoDB} from "../setMongodb";
import {yangchengmubiao} from "../shared/protocols/event/yangchengmubiao/PtlOpen";
async function start() {
await initMongoDB()

View File

@ -0,0 +1,126 @@
import {ctor} from "../global";
import {initMongoDB} from "../setMongodb";
import {yangchengmubiao} from "../shared/protocols/event/yangchengmubiao/PtlOpen";
import {number} from "mathjs";
import {PublicShared} from "../shared/public/public";
async function start() {
await initMongoDB()
const task = {
'2001': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 50,
'cond': [],
'stype': 118
},
'2002': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 100,
'cond': [],
'stype': 118
},
'2003': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '626', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 200,
'cond': [],
'stype': 118
},
'2004': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 250,
'cond': [],
'stype': 118
},
'2005': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 300,
'cond': [],
'stype': 118
},
'2006': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 400,
'cond': [],
'stype': 118
},
'2007': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 500,
'cond': [],
'stype': 118
}
};
let hdid = [100, 101];
let openday = PublicShared.getOpenServerDay();
let openhdlist = await G.mongodb.collection("hdinfo").find(
{hdid: {$in: hdid}, stime: {$lte: openday}, etime: {$gte: openday}}
).toArray();
// 没有开启的活动 返回
if (openhdlist.length <= 0) {
return;
} else {
hdid = openhdlist.map(hd => hd.hdid);
}
let datas: yangchengmubiao[];
datas = await G.mongodb.cEvent(`yangchengmubiao${hdid[0]}`).find(
{type: `yangchengmubiao${hdid[0]}`}
).toArray();
for (let i = 0; i < datas.length; i++) {
let data = datas[i];
let finishid = new Set(data.finishid["2"]);
// 查找任务未完成 但设置了领奖标识
for (let taskid in task) {
let con = task[taskid];
let taskval = data.taskval || {};
if (finishid.has(number(taskid)) && (taskval[taskid] || 0) < con.pval) {
finishid.delete(number(taskid));
}
}
// 没有删除的
if (finishid.size == data.finishid["2"].length) {
continue
}
await G.mongodb.collection("event").updateOne(
{"uid": data.uid, "type": data.type}, {$set: {"finishid.2": [...finishid]}}
)
console.log(`修复玩家${data.uid}人才计划${data.type}数据完成...`);
}
}
ctor();
start().then(() => {
let s = 0;
setInterval(() => {
s += 1;
console.log(new Date().format("MM-dd hh:mm:ss"));
if (s >= 3) process.exit(1);
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -0,0 +1,98 @@
import {ctor} from "../global";
import {_mongodb} from "../setMongodb";
import {MongoClient} from "mongodb";
async function initMongoDB() {
console.log('connect mongodb ......');
let client = await MongoClient.connect(G.config.mongodbUrl);
G.mongodb = new _mongodb(client.db(G.config.dbName || ''));
console.log('connect mongodb succ');
}
async function start() {
await initMongoDB()
const task = {
'2001': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 50,
'cond': [],
'stype': 118
},
'2002': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 100,
'cond': [],
'stype': 118
},
'2003': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '626', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 200,
'cond': [],
'stype': 118
},
'2004': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 250,
'cond': [],
'stype': 118
},
'2005': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 300,
'cond': [],
'stype': 118
},
'2006': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 400,
'cond': [],
'stype': 118
},
'2007': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 500,
'cond': [],
'stype': 118
}
};
let hdid = [100, 101];
await G.mongodb.collection("hdinfo").updateMany(
{hdid: {$in: hdid}}, {$set: {"data.tasklist.2": task}}
)
console.log(`修复区服${G.config.serverId}人才计划活动数据完成...`);
}
ctor();
start().then(() => {
let s = 0;
setInterval(() => {
s += 1;
console.log(new Date().format("MM-dd hh:mm:ss"));
if (s >= 3) process.exit(1);
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -0,0 +1,22 @@
import {initMongoDB} from "../setMongodb";
import {ctor} from "../global";
async function start() {
await initMongoDB();
let emails = await G.mongodb.collection("email").find({
title: {$regex: "wzry"}
}).toArray();
for (let i = 0; i < emails.length; i++) {
console.log();
}
}
ctor();
start().then(() => {
setInterval(() => {
console.log(new Date().format("MM-dd hh:mm:ss"));
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -1,5 +1,5 @@
import {ctor} from './global';
import {initMongoDB} from './setMongodb';
import {ctor} from '../global';
import {initMongoDB} from '../setMongodb';
async function start() {
//连接mongodb

View File

@ -1,5 +1,5 @@
import {ctor} from "./global";
import {initMongoDB} from "./setMongodb";
import {ctor} from "../global";
import {initMongoDB} from "../setMongodb";
async function start() {
await initMongoDB()

View File

@ -0,0 +1,47 @@
import fs from "fs";
import {MongoClient} from "mongodb";
async function start() {
let mongodbUrl = "mongodb://blacklagoon:lffu2bD%5eGn2%5eE%2bE7@blacklagoon-mongo-secondary.pro.g123-cpp.com:3717,blacklagoon-mongo-primary.pro.g123-cpp.com:3717?replicaSet=mgset-351738825"
//连接mongodb
let client = await MongoClient.connect(mongodbUrl);
console.log('链接成功');
let user2email: { [uid: string]: { [title: string]: { prize: any, get_num: number, unget_num: number } } } = {};
for (let i = 1; i < 49; i++) {
let dbName = `blacklagoon_s${i}`
console.log(dbName)
let mongodb = client.db(dbName);
let emails = await mongodb.collection("email").find({
title: {$regex: "wzry"}
}).toArray();
for (let i = 0; i < emails.length; i++) {
let email = emails[i];
if (!email.prizeData?.prize) continue;
if (!user2email[email.uid]) {
user2email[email.uid] = {};
}
if (!user2email[email.uid][email.title]) {
user2email[email.uid][email.title] = {
prize: email.prizeData.prize,
get_num: 0,
unget_num: 0,
}
}
if (email.prizeData.isGet) {
user2email[email.uid][email.title].get_num += 1;
} else {
user2email[email.uid][email.title].unget_num += 1;
}
}
}
fs.writeFileSync('email.json', JSON.stringify(user2email, null, 2))
}
start().then(() => {
process.exit()
});

View File

@ -1,6 +1,6 @@
import {ctor} from './global';
import {initMongoDB} from './setMongodb';
import {initRedis} from './setRedis';
import {ctor} from '../global';
import {initMongoDB} from '../setMongodb';
import {initRedis} from '../setRedis';
async function start() {
//连接mongodb

View File

@ -18,6 +18,7 @@ import { setGud } from './public/gud';
import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen";
import {Christmasfun} from "./api_s2c/event/christmas/fun";
import {PushGiftFun} from "./public/pushgift";
import {LeiChongLiBaoBuyGift} from "./api_s2c/event/leichonglibao/ApiReceive";
export type gEventType = {
/**玩家断开连接 */
@ -201,7 +202,8 @@ export function addListener() {
{ $inc: { payNum: conf.money } },
{ upsert: true }
);
PushGiftFun.buy(player.uid, payId) // 推送礼包
await PushGiftFun.buy(player.uid, payId) // 推送礼包
await LeiChongLiBaoBuyGift(call, payId) // 累充礼包
});
G.on("FIRST_LOGIN_EVERY_DAY", (gud, lastTime, curTime) => {

View File

@ -1773,6 +1773,24 @@ type gc_yuyuemail = {
'prize': { "a": string, "t": string, "n": number, [x: string]: any }[]
};
type gc_push_gift = {
[k: string]: {
/**礼包id*/
id: number
/**礼包类型*/
type: number
/**礼包参数*/
num: any[]
/**购买id*/
payId: string[]
/**持续时间*/
time: number
/**冷却时间*/
displayCD: number
/**显示返利比*/
scale: number
}
}
type gcType = {
[key: string]: any
@ -1922,6 +1940,7 @@ type gcType = {
kfcb_content: gc_kfcb_content
kfcb_prize: gc_kfcb_prize
yuyuemail: gc_yuyuemail
tuisonglibao: gc_push_gift
}

View File

@ -351,7 +351,7 @@ class Lng {
huoqupaihang: "huoqupaihang";
wucigonghui: "wucigonghui";
nameyicunzai: "nameyicunzai";
ljlibaotips_8:"ljlibaotips_8";
"11111" = "globalThis.lng.chat_1"
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });

View File

@ -22,6 +22,7 @@ import {ResOpen as ResOpenZixuanlibao} from '../shared/protocols/event/zixuanlib
import {ResOpen as ResOpenKaifujingsai} from '../shared/protocols/kaifujingsai/PtlOpen';
import {ResOpen as ResOpenZhoumolibao} from '../shared/protocols/event/zhoumolibao/PtlOpen';
import {ResOpen as ResOpenPobinglibao} from '../shared/protocols/event/pobinglibao/PtlOpen';
import {ResOpen as ResOpenLeiChongLiBao} from '../shared/protocols/event/leichonglibao/PtlOpen';
export type eventType = {
shouchong: {
@ -51,7 +52,7 @@ export type eventType = {
qirichongzhi: Omit<ResOpenQirichongzhi, 'finished'>;
jierihuodong: Omit<ResOpenJierihuodong, 'taskFinish'> & { refreshTime: number; };
kaifujingsai: ResOpenKaifujingsai;
zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; }
zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; };
pobinglibao: ResOpenPobinglibao
payForDiamond: {
[time: number]: number
@ -65,6 +66,7 @@ export type eventType = {
[k: `zixuanlibao${number}`]: ResOpenZixuanlibao;
[k: `leijichongzhi${number}`]: Omit<ResOpenLeijichongzhi, 'payNum'>;
[k: `qiridenglu${number}`]: Pick<ResOpenQiridenglu, 'recPrize'>;
[k: `leichonglibao${number}`]: ResOpenLeiChongLiBao & { opentime: number };
};
export type CollectionEvent<T extends keyof eventType> = {

View File

@ -0,0 +1,13 @@
import {ObjectId} from "mongodb";
import {ResOpen} from "../shared/protocols/pushgift/PtlOpen";
export type Gift = {
id: string
uid: string
buy: number[]
ctime: number
passTime: number
ext_data: { [key: string]: any }
}
export type CollectionPushGift = Gift & { _id: ObjectId };

View File

@ -59,6 +59,7 @@ import {CollectionPlayerBehavior} from "./collection_player_behavior";
import {CollectionRmbuse} from "./collection_rmbuse";
import {CollectionFightLog} from "./collection_fightLog";
import {CollectionShop} from "./collection_shop";
import {CollectionPushGift} from "./collection_pushgift";
export type MongodbCollections = {
user: CollectionUser;
@ -131,4 +132,5 @@ export type MongodbCollections = {
rmbuse: CollectionRmbuse
fightLog: CollectionFightLog
shop: CollectionShop
pushgift:CollectionPushGift
};

View File

@ -14,9 +14,10 @@ import {PublicShared} from '../shared/public/public';
import {HeroFun} from './hero';
import {ShiwuFun} from './shiwu';
import {UserFun} from './user';
import { getItemByItemId, getItemNum } from './item';
import { getGud, setGud } from './gud';
import {getItemByItemId, getItemNum} from './item';
import {getGud, setGud} from './gud';
import {addGameLog} from "../gameLog";
import {PushGiftFun} from "./pushgift";
export type call = {
@ -35,7 +36,7 @@ export type call = {
};
service: { name: string };
addEventMsg: ApiCall['addEventMsg'];
req: { }
req: {}
};
export class PlayerFun {
@ -66,6 +67,8 @@ export class PlayerFun {
if (has < atn.n) {
if (err) {
// 消耗不足 触发推送礼包
PushGiftFun.chkItemGift(call.uid, atn)
throw new TsrpcError('', {code: -104, atn: atn});
} else {
return {isOk: false, atn: atn};
@ -143,15 +146,15 @@ export class PlayerFun {
shiwu.length > 0 && this.addShiwu(call, shiwu),
peijian.length > 0 && this.addPeijian(call, peijian)
]);
return prizeList;
};
//attr里的指定字段的值不能小于0
static fixAttrLteZero(t:string, val:number){
if(['jinbi','rmbmoney','payExp','nexp'].includes(t) && val < 0){
static fixAttrLteZero(t: string, val: number) {
if (['jinbi', 'rmbmoney', 'payExp', 'nexp'].includes(t) && val < 0) {
return 0
}else{
} else {
return val;
}
}
@ -198,6 +201,16 @@ export class PlayerFun {
// 修改属性应在相关奖励领取之前,否则奖励内获取的用户数据是旧数据
// await this.changeAttr(call.conn.uid, change);
call.addEventMsg('msg_s2c/PlayerChange', change);
// 等级改变 触发推送礼包
if (change["lv"]) {
PushGiftFun.chkLvGift(call.uid, change["lv"])
}
// 关卡改变 触发推送礼包
if (change["mapId"]) {
PushGiftFun.chkLevelGift(call.uid, change["mapId"])
}
}
static async changeAttrLog(uid: string, change, atn, before) {
@ -216,9 +229,9 @@ export class PlayerFun {
static async changeAttr(uid: string, change: Partial<player>) {
//for (let k in change) {
//G.redis.set('user', uid, k as any, change[k]);
//G.redis.set('user', uid, k as any, change[k]);
//}
setGud(uid,change);
setGud(uid, change);
G.mongodb.collection('user').updateOne({uid: uid}, {$set: change});
@ -299,7 +312,11 @@ export class PlayerFun {
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
addGameLog(call.uid, "_itemChange", {"additem":1}, {"filter": upObj.filter, "update": upObj.update, "options": upObj.options})
addGameLog(call.uid, "_itemChange", {"additem": 1}, {
"filter": upObj.filter,
"update": upObj.update,
"options": upObj.options
})
} else {
if (item.num + atn.n <= 0) {
await Promise.all([
@ -311,13 +328,13 @@ export class PlayerFun {
//await G.redis.del('item', call.uid, atn.t);
//await G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t});
call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0});
addGameLog(call.uid, "_itemChange",{"delitem":1}, {"itemId": atn.t})
addGameLog(call.uid, "_itemChange", {"delitem": 1}, {"itemId": atn.t})
} else {
await Promise.all([
////去掉item Redis相关
//G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime),
//G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n),
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options)
]);
// await G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime);
@ -327,7 +344,12 @@ export class PlayerFun {
num: item.num + atn.n,
lastTime: upObj.update.$set.lastTime
});
addGameLog(call.uid, "_itemChange",{"attritem":1}, {"filter": upObj.filter, "update": upObj.update, "options": upObj.options,newNum:item.num + atn.n})
addGameLog(call.uid, "_itemChange", {"attritem": 1}, {
"filter": upObj.filter,
"update": upObj.update,
"options": upObj.options,
newNum: item.num + atn.n
})
}
}
}
@ -353,7 +375,7 @@ export class PlayerFun {
}).reduce((a, b) => a.concat(b));
let result = await G.mongodb.collection('equip').insertMany(insertData);
addGameLog(call.uid, "_addEquip",{}, insertData)
addGameLog(call.uid, "_addEquip", {}, insertData)
insertData.forEach((v, key) => {
let id = result.insertedIds[key].toHexString();
@ -400,7 +422,7 @@ export class PlayerFun {
G.mongodb.collection('equip').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
call.addEventMsg('msg_s2c/EquipChange', _id, {num: 0});
addGameLog(call.uid, "_cutEquip",{}, {_id:_id})
addGameLog(call.uid, "_cutEquip", {}, {_id: _id})
}
}
@ -428,7 +450,7 @@ export class PlayerFun {
});
let result = await G.mongodb.collection('hero').insertMany(insertData);
addGameLog(call.uid, "_addHero",{}, insertData)
addGameLog(call.uid, "_addHero", {}, insertData)
for (let key = 0; key < insertData.length; key++) {
let v = insertData[key]
@ -483,7 +505,7 @@ export class PlayerFun {
G.redis.del('hero', call.uid, _id);
G.mongodb.collection('hero').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
call.addEventMsg('msg_s2c/HeroChange', _id, {num: 0});
addGameLog(call.uid, "_cutHero",{}, {_id:_id})
addGameLog(call.uid, "_cutHero", {}, {_id: _id})
}
}
@ -514,7 +536,7 @@ export class PlayerFun {
}).reduce((a, b) => a.concat(b));
let result = await G.mongodb.collection('shiwu').insertMany(insertData);
addGameLog(call.uid, "_addShiWu",{}, insertData)
addGameLog(call.uid, "_addShiWu", {}, insertData)
insertData.forEach((v, key) => {
let id = result.insertedIds[key].toHexString();
@ -546,7 +568,7 @@ export class PlayerFun {
// G.redis.del('shiwu', call.uid, _id);
G.mongodb.collection('shiwu').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
call.addEventMsg('msg_s2c/ShiwuChange', _id, {num: 0});
addGameLog(call.uid, "_cutShiwu",{}, {_id:_id})
addGameLog(call.uid, "_cutShiwu", {}, {_id: _id})
}
}
@ -568,7 +590,7 @@ export class PlayerFun {
}).reduce((a, b) => a.concat(b));
let result = await G.mongodb.collection('peijian').insertMany(insertData);
addGameLog(call.uid, "_addPeiJian",{}, insertData)
addGameLog(call.uid, "_addPeiJian", {}, insertData)
insertData.forEach((v, key) => {
let {_id, uid, ...ops} = v;
@ -609,7 +631,7 @@ export class PlayerFun {
G.redis.del('peijian', call.uid, _id);
G.mongodb.collection('peijian').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
call.addEventMsg('msg_s2c/PeijianChange', _id, {num: 0});
addGameLog(call.uid, "_cutPeijian",{}, {_id:_id})
addGameLog(call.uid, "_cutPeijian", {}, {_id: _id})
}
}

View File

@ -1,35 +0,0 @@
import {MongoClient} from "mongodb";
import * as ramda from 'ramda'
import fs from "fs";
let R = ramda
async function start() {
//连接mongodb
let client = await MongoClient.connect('mongodbUrl');
console.log('链接成功')
let a: any = {}
for (let i = 1; i < 20; i++) {
let dbName = `blacklagoon_s${i}`
console.log(dbName)
let mongodb = client.db(dbName);
a[dbName] = {};
(await mongodb.collection('email').find({type: 'gm', uid: 'system'}).toArray()).map(i => {
a[dbName][i.title] = R.compose(R.map(i => ({[i[0]]: i.length})), R.values, R.filter(i => i.length > 1), R.groupBy(i => i))(i.prizelist)
console.log(a[dbName][i.title])
})
console.log(dbName, '查询完成')
}
fs.writeFileSync('tab.json', JSON.stringify(a, null, 2))
}
//定义全局变量
// ctor();
//启动服务
start().then(() => {
process.exit()
});

View File

@ -98,6 +98,15 @@ function setWs(server: WsServer<ServiceType>) {
//执行 API 接口实现之前
server.flows.preApiCallFlow.push(async call => {
// 临时停服维护方案
// let lng = {
// "zh-TW": "停服維護中,請等待!",
// "ko": "서버 점검 중, 잠시만 기다려 주세요.",
// "ja": "サーバーメンテナンス中、しばらくお待ちください。",
// "en": "Server under maintenance. Please wait.",
// }
// call.error("", {code: -1, message: lng[call.req.lng] || lng["ja"]})
// return null;
//是否短时间内重复请求某个api
// let timeIntervalLimit = call.service.conf?.timeIntervalLimit == undefined ? 500 : call.service.conf?.timeIntervalLimit;

View File

@ -0,0 +1,8 @@
export type ReqOpen = {
hdid: number
}
export type ResOpen = {
sc: boolean // 自选奖励领取标识
buy: string[] // 特价礼包购买记录
}

View File

@ -0,0 +1,10 @@
import {prizeType} from "../../type";
export interface ReqReceive {
hdid: number
select: string[]
}
export interface ResReceive {
prize: prizeType[]
}

View File

@ -53,8 +53,8 @@ export type hongdianKey =
| 'kaifujingsai'
| 'zhoumolibao'
| 'pobinglibao'
| 'payForDiamond';
| 'payForDiamond'
| 'leichonglibao';
export type hongdianVal = {
show?: boolean;
// 看功能需要

View File

@ -0,0 +1,5 @@
import {Gift} from "../../../module/collection_pushgift";
export type ReqOpen = {}
export type ResOpen = { gifts: Gift[] }

File diff suppressed because it is too large Load Diff