package cn.muchinfo.rma.business.management

import cn.muchinfo.rma.global.data.BusinessData
import cn.muchinfo.rma.global.data.HedgePlanData
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 BusinessManager {

    /**
     * 业务管理点价列表
     * @param params Map<String, String>
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<BusinessData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun queryBusinessDJ(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<BusinessData>?, error: Error?) -> Unit
    ) {
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance()
                .getString(Constant.goCommonSearchUrl) + "/Ermcp/QueryBusinessDj",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<BusinessData>>>() {
                override fun onResponse(response: BaseResult<List<BusinessData>>?, 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<BusinessData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun queryBusinessJSEx(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<BusinessData>?, error: Error?) -> Unit
    ) {
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance()
                .getString(Constant.goCommonSearchUrl) + "/Ermcp/QueryBusinessJsEx",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<BusinessData>>>() {
                override fun onResponse(response: BaseResult<List<BusinessData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

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

            }
        )
    }

    /**
     * 业务管理结算详情
     */
    fun queryBusinessJSDetail(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<BusinessData>?, error: Error?) -> Unit
    ) {
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance()
                .getString(Constant.goCommonSearchUrl) + "/Ermcp/QueryBusinessJs",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<BusinessData>>>() {
                override fun onResponse(response: BaseResult<List<BusinessData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

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

            }
        )
    }

}