Compare commits

..

No commits in common. "ddabcbe8ac5127c6c7c8ab9f9ca5e33ed21e9fdc" and "c18c0fcb7666946ffbadb4a20de532d6a1d8244a" have entirely different histories.

2 changed files with 8 additions and 42 deletions

View File

@ -3,32 +3,13 @@ import { patchFun, patchInit } from "../patch";
class Path {
async huodong2(a: any) {
const con ={
2002:[
{ payId: '', num: 1, prize: [{a: 'item', t: '50', n: 20}, {a: 'attr', t: 'rmbmoney', n: 200}], free: true },
{ payId: 'duihuan_1_1', prize: [{a: 'item', t: '50', n: 50}, {a: 'attr', t: 'rmbmoney', n: 600}], free: false },
{ payId: 'duihuan_1_2', prize: [{a: 'item', t: '50', n: 100}, {a: 'attr', t: 'rmbmoney', n: 1360}], free: false },
{ payId: 'duihuan_1_3', prize: [{a: 'item', t: '50', n: 200}, {a: 'attr', t: 'rmbmoney', n: 2560}], free: false },
{ payId: 'duihuan_1_4', prize: [{a: 'item', t: '50', n: 600}, {a: 'attr', t: 'rmbmoney', n: 6560}], free: false },
{ payId: 'duihuan_1_5', prize: [{a: 'item', t: '50', n: 1200}, {a: 'attr', t: 'rmbmoney', n: 12960}], free: false },
],
2003: [
{ payId: '', num: 1, prize: [{a: 'item', t: '50', n: 20}, {a: 'attr', t: 'rmbmoney', n: 200}], free: true },
{ payId: 'duihuan_1_1', prize: [{a: 'item', t: '50', n: 50}, {a: 'attr', t: 'rmbmoney', n: 600}], free: false },
{ payId: 'duihuan_1_2', prize: [{a: 'item', t: '50', n: 100}, {a: 'attr', t: 'rmbmoney', n: 1360}], free: false },
{ payId: 'duihuan_1_3', prize: [{a: 'item', t: '50', n: 200}, {a: 'attr', t: 'rmbmoney', n: 2560}], free: false },
{ payId: 'duihuan_1_4', prize: [{a: 'item', t: '50', n: 600}, {a: 'attr', t: 'rmbmoney', n: 6560}], free: false },
{ payId: 'duihuan_1_5', prize: [{a: 'item', t: '50', n: 1200}, {a: 'attr', t: 'rmbmoney', n: 12960}], free: false },
]
}
const hdids = [2002,2003]
const hdinfos = await G.mongodb.find('hdinfo', { hdid: { $in: hdids } })
for (let i = 0; i < hdinfos.length; i++) {
let hdinfo = hdinfos[i]
hdinfo.data.event.gift = con[hdinfo.hdid]
hdinfo.data.gift = {}
await G.mongodb.collection('hdinfo').updateOne({ "hdid": hdinfo.hdid}, { "$set": {"data.event.gift": hdinfo.data.event.gift}});
await G.mongodb.collection('hdinfo').updateOne({ "hdid": hdinfo.hdid}, { "$set": {"data.figt": {}} });
console.log(hdinfo.hdid,"finish")
}
return "sucess!!!"

View File

@ -4,7 +4,6 @@ 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';
import { clusterRunOnce } from '../clusterUtils';
const msgListLen = {
'cross': 30,
@ -29,9 +28,13 @@ export function getCrossChatGroupByOpenDay(){
export class ChatFun {
/**新增消息 */
static async newMsg(sendData: MsgChat) {
let addToDB = 0;
G.mongodb.collection('chat').updateOne(
{ type: `${sendData.type}${sendData.type == 'guild' ? (sendData.sender as player)?.ghId : ''}` },
{ $push: { list: { $each: [sendData], $slice: -msgListLen[sendData.type] } } },
{ upsert: true }
);
if (sendData.type == 'guild') {
addToDB = 1;
G.server.broadcastClusterMsg('msg_s2c/Chat', sendData,{ghId:(sendData.sender as player)?.ghId});
}else if(sendData.type == 'cross'){
//所有的子进程都会收到,不需要集群内分别广播
@ -39,27 +42,9 @@ export class ChatFun {
//如果时候同一个分组的
delete sendData?.otherData?.group;
G.server.broadcastMsg('msg_s2c/Chat', sendData);
addToDB = 2;
}
}else{
G.server.broadcastClusterMsg('msg_s2c/Chat', sendData);
addToDB = 1;
}
if(addToDB == 1){
G.mongodb.collection('chat').updateOne(
{ type: `${sendData.type}${sendData.type == 'guild' ? (sendData.sender as player)?.ghId : ''}` },
{ $push: { list: { $each: [sendData], $slice: -msgListLen[sendData.type] } } },
{ upsert: true }
);
}else if(addToDB == 2){
clusterRunOnce(()=>{
G.mongodb.collection('chat').updateOne(
{ type: `${sendData.type}${sendData.type == 'guild' ? (sendData.sender as player)?.ghId : ''}` },
{ $push: { list: { $each: [sendData], $slice: -msgListLen[sendData.type] } } },
{ upsert: true }
);
})
}
}