import {ApiCall} from "tsrpc";
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/yuandan/PtlOpen";
import {HuoDongFun} from "../../../public/huodongfun";
import {PayFun} from "../../../public/pay";
import {Yuandanfun} from "./fun";
import {PublicShared} from "../../../shared/public/public";

export default async function (call: ApiCall<ReqOpen, ResOpen>) {
    let _hd = await Yuandanfun.getCon(call)
    if (!_hd) return call.errorCode(-1)

    let payIds = _hd.data.gift.filter(i => i.payid).map(i => i.payid)

    let data = await Yuandanfun.getData(call, _hd.hdid)

    call.succ({
        data: {...data, isSameDay: PublicShared.chkSameDate(data.qiandaoTime, G.time)},
        payLog: await PayFun.getPayLogs(call.uid, payIds),
    })
}