package cn.muchinfo.rma.view.base.home.tradingquery

import androidx.lifecycle.MutableLiveData
import cn.muchinfo.rma.global.GlobalDataCollection
import cn.muchinfo.rma.global.data.AmountLogData
import cn.muchinfo.rma.view.MyApplication
import cn.muchinfo.rma.view.base.BaseViewModel

class TradingQueryViewModel : BaseViewModel(){

    /**
     * 历史资金流水
     */
    val hisAmountLogDataList : MutableLiveData<List<AmountLogData>> = MutableLiveData()

    /**
     * 查询历史流水
     * @param startDate String 开始时间 闭区间，格式：yyyy-MM-dd
     * @param endDate String 结束时间 闭区间，格式：yyyy-MM-dd
     */
    fun queryHisAmountLog(startDate : String = "",endDate : String = ""){
        val params = mutableMapOf<String, String>().apply {
            put("accountID", GlobalDataCollection.instance?.loginRsp?.memberUserID.toString())
            if (startDate.isNotEmpty()){
                put("startDate", startDate)
            }
            if (endDate.isNotEmpty()){
                put("endDate",endDate)
            }
        }

        MyApplication.getInstance()?.tradingQueryManager?.queryHisAmountLog(params = params){isSuccess, respData, error ->
            if (isSuccess){
                hisAmountLogDataList.postValue(respData)
            }
        }

    }
}