/*
 * @Author: WuWei
 * @Date: 2020-08-10 17:29:47
 * @LastEditors  : WuWei
 * @LastEditTime : 2023-08-14 10:21:32
 * @Description:
 */
import 'package:app_package/app_package.dart';
import '../pay_index_service.dart';
import '../../models/pay_list.dart';
import '../../models/pay_summary.dart';
import '../../models/pay_detail.dart';

class PayIndexServiceImpl implements PayIndexService {
  static String prefix = '/app/admin';

  @override
  Future<ResModel<PagingModel<PayListModel>>> getPayList(data) async {
    var res = await HttpUtil.instance.get(
      '$prefix/hgj/pay/record',
      queryParameters: data,
    );

    return ResModel<PagingModel<PayListModel>>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => PagingModel(
        json: v,
        to: (v) => v.toJson(),
        from: (v) => PayListModel.fromJson(v),
      ),
    );
  }

  @override
  Future<ResModel<PaySummaryModel>> getPaySummary(data) async {
    var res = await HttpUtil.instance.get(
      '$prefix/hgj/pay/statistics',
      queryParameters: data,
    );

    return ResModel<PaySummaryModel>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => PaySummaryModel.fromJson(v),
    );
  }

  @override
  Future<ResModel<PayDetail>> getPayDetail(id, data) async {
    var res = await HttpUtil.instance.get(
      '$prefix/hgj/pay/record/detail/$id',
      queryParameters: data,
    );

    return ResModel<PayDetail>(
      json: res.data,
      to: (v) => v.toJson(),
      from: (v) => PayDetail.fromJson(v),
    );
  }

  ///获取管理的小区列表-下拉选
  // Future<ResModel<List<CommunityPickerModel>>>
  //     getDomainCommunityListToPicker() async {
  //   var res =
  //       await HttpUtil.instance.get('/app/admin/employee/domainCommunitys');

  //   return ResModel<List<CommunityPickerModel>>(
  //     json: res.data,
  //     to: (v) => (v).map((f) => f.toJson()).toList(),
  //     from: (v) => (v ?? [])
  //         .map<CommunityPickerModel>((f) => CommunityPickerModel.fromJson(f))
  //         .toList(),
  //   );
  // }

  noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}
