package cn.muchinfo.rma.business.financial

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

    /**
     * 查询财务管理款项列表
     * @param params Map<String, String>
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<FinancialManageData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun queryBusinessKx(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<FinancialManageData>?, error: Error?) -> Unit
    ) {
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance()
                .getString(Constant.goCommonSearchUrl) + "/Ermcp/QueryBusinessKx",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<FinancialManageData>>>() {
                override fun onResponse(response: BaseResult<List<FinancialManageData>>?, 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<FinancialManageData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun queryBusinessFp(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<FinancialManageData>?, error: Error?) -> Unit
    ) {
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance()
                .getString(Constant.goCommonSearchUrl) + "/Ermcp/QueryBusinessFp",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<FinancialManageData>>>() {
                override fun onResponse(response: BaseResult<List<FinancialManageData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

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

            }
        )
    }


}