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();
