import {ApiCall} from "tsrpc";
import {PayFun} from '../../public/pay';
import {ReqOpen, ResOpen} from "../../shared/protocols/chongzhi/PtlOpen";

export default async function (call: ApiCall<ReqOpen, ResOpen>) {

    let data = await G.mongodb.cPlayerInfo('chongzhi').findOne({uid: call.uid, type: 'chongzhi'});
    let logs = await PayFun.getPayLogs(call.uid);

    call.succ({
        payNum: Object.fromEntries(G.gc.chongzhi.payCom.map(pay => pay.payId).map(payId => [payId, logs?.[payId]?.length || 0])),
        giftBuy: data?.giftBy || {},
    });
}