import { ApiCall } from "tsrpc";
import { KuangDongfun } from "../../public/kuangdong";
import { ReqOpen, ResOpen } from "../../shared/protocols/kuangdong/PtlOpen";
import { PublicShared } from "../../shared/public/public";

export default async function (call: ApiCall<ReqOpen, ResOpen>) {
    /**查询所有矿洞信息 */
    let myData = await KuangDongfun.getNumInfo(call)
    let result = await KuangDongfun.getKaiCaiList(call.uid)

    let changeData = {
        mydata: myData,
        prize: result["prize"][call.uid] || []
    }

    if (result["kdinfo"]) {
        changeData["kdList"] = result["kdinfo"]
    }

    if (changeData.prize) {
        changeData.prize = PublicShared.mergePrize(changeData.prize)
    }

    call.succ(changeData);
}