package cn.muchinfo.rma.business.tradingquery

import cn.muchinfo.rma.global.data.AmountLogData
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 TradingQueryManager {

    /**
     * 资金流水查询（历史）
     * @param params Map<String, String> accountID : 资金账户 - 格式：1,2,3
     * @param responseBack Function3<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] List<BusinessData>?, [@kotlin.ParameterName] Error?, Unit>
     */
    fun queryHisAmountLog(
        params: Map<String, String>,
        responseBack: (isSuccess: Boolean, respData: List<AmountLogData>?, error: Error?) -> Unit
    ){
        MyOkHttpUtils().query(
            URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/TaAccount/QueryHisAmountLog",
            params = params,
            type = "1",
            callback = object : ResponseCallback<BaseResult<List<AmountLogData>>>(){
                override fun onResponse(response: BaseResult<List<AmountLogData>>?, id: Int) {
                    responseBack(true, response?.data, null)
                }

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

}