1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package cn.flightfeather.thirdappmodule.repository
 
import cn.flightfeather.thirdappmodule.bean.entity.Userinfo
import cn.flightfeather.thirdappmodule.common.net.ResponseBodyCallBack
import cn.flightfeather.thirdappmodule.common.net.ResultCallBack
import cn.flightfeather.thirdappmodule.common.net.ResultObserver
import cn.flightfeather.thirdappmodule.common.net.RetrofitFactory
import cn.flightfeather.thirdappmodule.httpservice.LedgerService
import cn.flightfeather.thirdappmodule.httpservice.UserInfoService
import cn.flightfeather.thirdappmodule.model.bean.LedgerRecord
import cn.flightfeather.thirdappmodule.model.bean.UserMap
 
/**
 * @author riku
 * Date: 2021/7/21
 * 连接飞羽环境系统
 * 台账相关数据接口
 */
class LedgerRepository private constructor(){
 
    companion object {
        @JvmStatic
        val instance: LedgerRepository by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { LedgerRepository()}
    }
 
    private val retrofit = RetrofitFactory.instance.retrofit2
 
    /**
     * 获取用户某月台账记录
     * @param userId (飞羽环境系统中)用户id
     * @param sceneType (飞羽环境系统中)场景类型,与本系统不同,需要转换
     * @param time 查询时间,yyyy-mm
     */
    fun getLedgerRecord(userId: String, sceneType: Int, time: String, resultCallBack: ResultCallBack<List<LedgerRecord>>) {
        val service = retrofit.create(LedgerService::class.java).getRecord(userId, sceneType, time)
 
        RetrofitFactory.executeResult(service, object : ResultObserver<List<LedgerRecord>>() {
            override fun onSuccess(result: List<LedgerRecord>?) {
                resultCallBack.onSuccess(result)
            }
 
            override fun onFailure(e: Throwable, isNetWorkError: Boolean) {
                resultCallBack.onFailure()
            }
        })
    }
 
//    fun getLedgerType(sceneType: Int, resultCallBack: ResultCallBack<List<LedgerRecord>>)
}