Compare commits

..

No commits in common. "c839d844ecfd40f27d9d898e20e87d34fc727c03" and "3899b9157cf09b69c12c9a4fedbaae0fed57763f" have entirely different histories.

11 changed files with 37 additions and 231 deletions

View File

@ -13,9 +13,6 @@ export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>
if (args.length < 1 || _ids.isDuplication() || heroIds.isDuplication()) return call.error(globalThis.lng.kbzz_1);
let event = await G.mongodb.cEvent('xstask').findOne({uid: call.uid, type: 'xstask'});
if (event?.receiveNum >= 8) return call.error(globalThis.lng.xstask_11);
//所有的任务
let taskList = await XstaskFun.getAllTask(call.uid);
//所有的任务id

View File

@ -34,7 +34,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
XstaskFun.changeInfo(call.uid, { $set: { ...changeInfo } });
XstaskFun.delTasks(call.uid, delTask.map(task => task._id));
XstaskFun.receiveNum(call.uid, true)
}
// needAddTask += await TeQuanFun.getXsTaskNum(call);

View File

@ -8,9 +8,6 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
if (call.req.heroIds.length < 1) return call.error(globalThis.lng.xstask_9);
if (call.req.heroIds.isDuplication()) return call.error(globalThis.lng.xstask_10);
let event = await G.mongodb.cEvent('xstask').findOne({uid: call.uid, type: 'xstask'});
if (event?.receiveNum >= 8) return call.error(globalThis.lng.xstask_11);
let task = await XstaskFun.getTask(call.uid, call.req._id);
let taskConf = G.gc.xstask[task?.taskId];
if (!task) return call.error(globalThis.lng.xstask_1);
@ -31,7 +28,6 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
heros: call.req.heroIds
};
XstaskFun.receiveNum(call.uid)
XstaskFun.receiveTask(call.uid, call.req._id, change);
HongDianChange.sendChangeKey(call.uid, ['xstaskhd', 'huodonghd']);

View File

@ -12,9 +12,6 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
if (delNum < 1) return call.error(globalThis.lng.xstask_11);
let event = await G.mongodb.cEvent('xstask').findOne({uid: call.uid, type: 'xstask'});
if (event?.receiveNum >= 8) return call.error(globalThis.lng.xstask_11);
let change: ResRefresh = {};
let needDel = taskList.filter(task => task.receiveData == undefined || task.receiveData.rec == true);

View File

@ -1,68 +0,0 @@
import {patchInit} from "../patch";
// import {addGameLog, connGameLogDB} from "../gameLog";
import {MongoClient} from "mongodb";
class Path {
async fun1(a: any) {
let logDB = await connGameLogDB();
console.log(11111,'开始查询')
let ab = await logDB.collection('gameLog').aggregate([
{$match: {"type": "kuangdong/YanShi", "req.hdid": {$lte: 21}}},
{$group: {_id: "$uid", total: {$sum: 1}}}
]).toArray()
let auids = ab.map(i => ({
uid: i._id,
type: 'yanshiNum',
time: G.time,
num: i.total,
data: {
...i
}
}))
console.log(auids)
// @ts-ignore
G.crossmongodb.collection('fupanLog').insertMany(auids)
return auids
}
async run() {
await this.fun1(1);
}
}
async function connGameLogDB() {
console.log('connect gamelog mongodb ......');
let logDBUrl:string;
if(G.config.isG123){
logDBUrl = "mongodb://root:lffu2bD%5eGn2%5eE%2bE7@blacklagoon-mongo-log-primary.pro.g123-cpp.com:3717,blacklagoon-mongo-log-secondary.pro.g123-cpp.com:3717?replicaSet=mgset-351742307";
}else{
logDBUrl = "mongodb://root:lyMaple525458@10.0.1.20:27017/heijiao_gamelog?authSource=admin";
}
let client = await MongoClient.connect(logDBUrl,{
maxPoolSize:10,
maxIdleTimeMS: 5*60*1000
});
return client.db(`gameLog${G.config.serverId}`);
}
async function main() {
await patchInit()
let patch = new Path();
await patch.run();
console.log("逻辑执行完成,等待退出");
setTimeout(function () {
console.log('结束程序');
process.exit();
}, 3000);
}
main();

View File

@ -1,59 +0,0 @@
import {log} from "console";
import {patchFun, patchInit} from "../patch";
import {TanXianFun} from "../public/tanxian";
import {PublicShared} from "../shared/public/public";
import {addGameLog} from "../gameLog";
class Path {
async fun1(a: any) {
// 查询今天登录的用户
let today_login_users = await G.mongodb.collection("actionLog").find(
{"log.use_attr_rmbmoney": {$gte: 100000}},
{projection: {uid: 1, "log.use_attr_rmbmoney": 1}}
).toArray();
let uids = today_login_users.map(i => i.uid)
let users = await G.mongodb.collection("user").find({
uid: {$in: uids},
vip: {$lte: 6}
}, {projection: {uid: 1, vip: 1, lv: 1}}).toArray()
let auids = users.map(i => ({
uid: i.uid,
type: 'shuazuanshi',
time: G.time,
data: {
vip: i.vip,
lv: i.lv,
rmbmoney: today_login_users.find(v => v.uid == i.uid)?.log?.use_attr_rmbmoney
}
}))
console.log(auids)
// @ts-ignore
G.crossmongodb.collection('fupanLog').insertMany(auids)
return auids
}
async run() {
await this.fun1(1);
}
}
async function main() {
await patchInit()
let patch = new Path();
await patch.run();
console.log("逻辑执行完成,等待退出");
setTimeout(function () {
console.log('结束程序');
process.exit();
}, 3000);
}
main();

View File

@ -1,5 +1,4 @@
import { Db, MongoClient } from "mongodb";
import { Logger } from "tsrpc";
let logDB:Db;
let errorLogDB:Db;
@ -29,28 +28,13 @@ async function connGameLogDB() {
return logDB;
}
export let mylogger: Logger = {
debug(...args: any[]){
console.debug(...args);
},
log(...args: any[]){
console.log(...args);
},
warn(...args: any[]){
console.warn(...args);
},
error(...args: any[]){
addErrorLog( args );
console.error(...args);
}
}
process.on('uncaughtException',function(err:Error){
addErrorLog( (err?.stack || err)?.toString() );
addErrorLog((err?.stack)?.toString());
})
process.on('unhandledRejection', function (err:Error, promise) {
addErrorLog( (err?.stack || err)?.toString() );
addErrorLog((err?.stack)?.toString());
})
async function addErrorLog(errData:any){

View File

@ -58,10 +58,6 @@ export type eventType = {
payForDiamond: {
[time: number]: number
}
xstask: {
refreshTime: number,
receiveNum: number
}
} & {
[k: `${number}jijin`]: ResOpenYuedujijin;

View File

@ -401,6 +401,7 @@ export class PlayerFun {
*/
static async cutEquip(call: call, _idArr: string[]) {
for (let _id of _idArr) {
G.redis.del('equip', call.uid, _id);
G.mongodb.collection('equip').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
call.addEventMsg('msg_s2c/EquipChange', _id, {num: 0});
@ -471,6 +472,7 @@ export class PlayerFun {
static async cutHero(call: call, _idArr: string[]) {
for (let _id of _idArr) {
await HeroFun.delHero(call, _id);
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})

View File

@ -5,26 +5,21 @@ import {CollectionXstask} from '../module/collection_xstask';
import { PublicShared } from '../shared/public/public';
export class XstaskFun {
/**所有玩家的悬赏任务缓存 */
static uidTask: k_v<CollectionXstask[]> = {};
/**获取单个悬赏任务 */
static async getTask(uid: string, _id: string) {
return this.uidTask[uid]?.find(task => task._id == _id) || await G.mongodb.collection('xstask').findOne({
uid: uid,
_id: G.mongodb.conversionId(_id)
});
return this.uidTask[uid]?.find(task => task._id == _id) || await G.mongodb.collection('xstask').findOne({ uid: uid, _id: G.mongodb.conversionId(_id) });
}
/**获取所有悬赏任务 */
static async getAllTask(uid: string) {
let taskList = this.uidTask[uid];
if (!taskList) {
taskList = this.uidTask[uid] = (await G.mongodb.collection('xstask').find({ uid: uid }).toArray()).map(task => G.mongodb.conversionIdObj(task));
}
;
};
return taskList;
}
@ -32,10 +27,7 @@ export class XstaskFun {
/**完成任务标记 */
static async finishTask(uid: string, _id: string) {
// 修改数据库
G.mongodb.collection('xstask').updateOne({
uid: uid,
_id: G.mongodb.conversionId(_id)
}, {$set: {'receiveData.rec': true}});
G.mongodb.collection('xstask').updateOne({ uid: uid, _id: G.mongodb.conversionId(_id) }, { $set: { 'receiveData.rec': true } });
// 修改缓存
let index = this.uidTask[uid]?.findIndex(task => task._id == _id);
this.uidTask[uid][index].receiveData.rec = true
@ -44,10 +36,7 @@ export class XstaskFun {
/**更新任务单个 */
static async updateTask(uid: string, _id: string, taskId: string) {
G.mongodb.collection('xstask').updateOne({
uid: uid,
_id: G.mongodb.conversionId(_id)
}, {$unset: {receiveData: 1}, $set: {taskId: taskId}});
G.mongodb.collection('xstask').updateOne({ uid: uid, _id: G.mongodb.conversionId(_id) }, { $unset: { receiveData: 1 }, $set: {taskId: taskId} });
let index = this.uidTask[uid]?.findIndex(task => task._id == _id);
delete this.uidTask[uid][index].receiveData;
this.uidTask[uid][index].taskId = taskId;
@ -61,13 +50,11 @@ export class XstaskFun {
G.mongodb.collection('xstask').deleteOne({ uid: uid, _id: G.mongodb.conversionId(_id) });
}
/**删除多个悬赏任务 */
static async delTasks(uid: string, _id: string[]) {
for (let id of _id) await this.delTask(uid, id);
}
/**添加多个悬赏任务 */
static async addTasks(uid: string, taskArr: { taskId: string; }[]) {
@ -89,17 +76,12 @@ export class XstaskFun {
return this.uidTask[uid];
}
/**派遣任务任务 */
static async receiveTask(uid: string, _id: string, d: CollectionXstask['receiveData']) {
let cache = this.uidTask[uid]?.find(task => task._id == _id);
if (cache) cache.receiveData = d;
G.mongodb.collection('xstask').updateOne({
uid: uid,
_id: G.mongodb.conversionId(_id)
}, {$set: {receiveData: d}});
G.mongodb.collection('xstask').updateOne({ uid: uid, _id: G.mongodb.conversionId(_id) }, { $set: { receiveData: d } });
}
/**获取所有已被派遣的英雄 */
static async getAllReceiveHero(uid: string) {
let heroIds: string[] = [];
@ -109,12 +91,10 @@ export class XstaskFun {
return heroIds;
}
/**获取悬赏任务记录信息 */
static async getInfo(uid: string) {
return await G.mongodb.collection('playerInfo', 'xstask').findOne({ uid: uid, type: 'xstask' });
}
/**修改悬赏任务记录信息 */
static async changeInfo(uid: string, change: Pick<UpdateFilter<OptionalId<playerInfoType['xstask']>>, '$inc' | '$set'>) {
@ -124,7 +104,6 @@ export class XstaskFun {
{ upsert: true }
);
}
/**随机任务 */
static randomTasks(lv: number, num: number) {
let tasks = Object.values(G.gc.xstask).filter(task => G.gc.xstaskcom.lv[lv].taskColor.includes(task.colour)).sort(function () {
@ -157,18 +136,4 @@ export class XstaskFun {
}
return _res;
}
/**
* 8
*/
static async receiveNum(uid: string, refresh = false) {
if (refresh) {
G.mongodb.cEvent('xstask').updateOne({uid: uid, type: 'xstask'},
{$set: {refreshTime: G.time, receiveNum: 0}}, {upsert: true});
} else {
G.mongodb.cEvent('xstask').updateOne({uid: uid, type: 'xstask'},
{$inc: {receiveNum: 1}}, {upsert: true});
}
}
}

View File

@ -13,7 +13,6 @@ import {player} from './shared/protocols/user/type';
import {unQueueByConn} from './api_s2c/user/ApiLogin';
import {clusterPublish, setUidProcessId} from './clusterUtils';
import {clearGud, getGud} from './public/gud';
import { mylogger } from './gameLog';
export async function createWs() {
@ -26,8 +25,7 @@ export async function createWs() {
json: true,
//API超时时间5分钟为登陆排队做准备
apiTimeout: 300000,
logLevel: G.argv.logModel as LogLevel,
logger:mylogger
logLevel: G.argv.logModel as LogLevel
});
setCrossWs(G.serverCross);
await G.serverCross.autoImplementApi(resolve(__dirname, 'api_cross'), true);
@ -39,7 +37,6 @@ export async function createWs() {
wss: getWssFile(),
//API超时时间5分钟为登陆排队做准备只针对游服
apiTimeout: 300000,
logger:mylogger
});
setWs(G.server);
await G.server.autoImplementApi(resolve(__dirname, 'api_s2c'), true);