package cn.muchinfo.rma.business.report

import cn.muchinfo.rma.global.data.ExposureReportData
import cn.muchinfo.rma.global.data.FinancialReportData
import cn.muchinfo.rma.global.data.SpotReportData
import cn.muchinfo.rma.netManage.base.ResponseCallback
import cn.muchinfo.rma.netManage.utils.MyOkHttpUtils
import cn.muchinfo.rma.view.base.app.BaseResult
import cn.muchinfo.rma.view.base.app.Constant
import com.blankj.utilcode.util.SPUtils
import okhttp3.Call
import java.lang.Exception

/**
 * 报表查询管理类
 */
class ReportManager {

    /**
     * 查询财务日报表发票(菜单:报表查询/财务报表/日报表/发票)
     * @param params Map<String, String> userid : 用户ID / tradedate : 交易日(格式:yyyyMMdd)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<FinancialReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportDayFinanceFp(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<FinancialReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportDayFinanceFp",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<FinancialReportData>>>(){
                override fun onResponse(response: BaseResult<List<FinancialReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询财务日报表款项(菜单:报表查询/财务报表/日报表/款项)
     * @param params Map<String, String> userid : 用户ID / tradedate : 交易日(格式:yyyyMMdd)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<FinancialReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportDayFinanceKx(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<FinancialReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportDayFinanceKx",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<FinancialReportData>>>(){
                override fun onResponse(response: BaseResult<List<FinancialReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询财务日报表(菜单:报表查询/财务报表/日报表)
     * @param params Map<String, String> userid : 用户ID / tradedate : 交易日(格式:yyyyMMdd)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<FinancialReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportDayFinance(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<FinancialReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportDayFinance",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<FinancialReportData>>>(){
                override fun onResponse(response: BaseResult<List<FinancialReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询财务月报表(菜单:报表查询/财务报表/月报表)
     * @param params Map<String, String> userid : 用户ID / cycletime : 周期时间:月(格式:yyyyMM)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<FinancialReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportMonthFinance(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<FinancialReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportMonthFinance",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<FinancialReportData>>>(){
                override fun onResponse(response: BaseResult<List<FinancialReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询敞口日报表(菜单:报表查询/敞口报表/敞口日报表)
     * @param params Map<String, String> userid : 用户ID / tradedate : 交易日(格式:yyyyMMdd)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<ExposureReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportDayExposure(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<ExposureReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportDayExposure",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<ExposureReportData>>>(){
                override fun onResponse(response: BaseResult<List<ExposureReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询现货报表-日报表
     * @param params Map<String, String> userid : 用户ID / tradedate : 交易日(格式:yyyyMMdd)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<SpotReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportDaySpot(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<SpotReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportDaySpot",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<SpotReportData>>>(){
                override fun onResponse(response: BaseResult<List<SpotReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询现货报表-月报表
     * @param params Map<String, String> userid : 用户ID / cycletime : 周期时间:月(格式:yyyyMM)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<SpotReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportMonthSpot(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<SpotReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportMonthSpot",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<SpotReportData>>>(){
                override fun onResponse(response: BaseResult<List<SpotReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询现货日报表详情(菜单:报表查询/现货报表/现货日报表详情)
     * @param params Map<String, String> userid : 用户ID / wrstandardid : 现货商品id / tradedate : 交易日(格式:yyyyMMdd)
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<SpotReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportDaySpotDetail(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<SpotReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportDaySpotDetail",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<SpotReportData>>>(){
                override fun onResponse(response: BaseResult<List<SpotReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

    /**
     * 查询现货月报表详情(菜单:报表查询/现货月报表/现货月报表详情)
     * @param params Map<String, String>
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<SpotReportData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun qryReportMonthSpotDetail(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<SpotReportData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Ermcp/QryReportMonthSpotDetail",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<SpotReportData>>>(){
                override fun onResponse(response: BaseResult<List<SpotReportData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

                override fun onError(call: Call?, e: Exception?, id: Int) {
                    responseBack(false, null, Error(e?.message))
                }

            }
        )
    }

}