package com.xxrv.invoice.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.rv.component.utils.DateUtils;
import com.xxrv.invoice.R;
import com.xxrv.invoice.bean.OrderInvoicingCarBean;

import java.util.ArrayList;
import java.util.List;

/**
 * 开票详情查看订单
 */

public class CheckOrderInvoicingAdapter extends BaseQuickAdapter<OrderInvoicingCarBean.DataBeanX.DataBean, BaseViewHolder> {

    public CheckOrderInvoicingAdapter() {
        super(R.layout.rv_item_check_order_invoicing);
    }

    @Override
    protected void convert(BaseViewHolder helper, final OrderInvoicingCarBean.DataBeanX.DataBean item) {

        helper.setText(R.id.tv_name, item.getName());

        OrderInvoicingCarBean.DataBeanX.DataBean.OrderRentVehicleDetail orderRentVehicleDetail = item.getOrderRentVehicleDetail();
        OrderInvoicingCarBean.DataBeanX.DataBean.OrderTourDetail orderTourDetail = item.getOrderTourDetail();
        OrderInvoicingCarBean.DataBeanX.DataBean.OrderMemberDetail orderMemberDetail = item.getOrderMemberDetail();
        if (orderRentVehicleDetail != null) {
            helper.setText(R.id.tv_type, "租房车");
            helper.setText(R.id.tv_get_date, "取：" + DateUtils.timestampToString1(orderRentVehicleDetail.getStart_time()) + orderRentVehicleDetail.getStart_addr());
            helper.setText(R.id.tv_out_date, "还：" + DateUtils.timestampToString1(orderRentVehicleDetail.getEnd_time()) + orderRentVehicleDetail.getEnd_addr());
            helper.setText(R.id.tv_price, String.format("¥%1$s", item.getOrderRealAmount()));
        } else if (orderTourDetail != null) {
            helper.setText(R.id.tv_type, "房车游");
            helper.setText(R.id.tv_get_date, "出发时间：" + DateUtils.timestampToString1(orderTourDetail.getStartTime()));
            helper.setText(R.id.tv_out_date, "人数：" + orderTourDetail.getTotalNumber() + "人");
            helper.setText(R.id.tv_price, String.format("¥%1$s", item.getOrderRealAmount()));
        } else if (orderMemberDetail != null) {
            helper.setText(R.id.tv_type, "会员");
            helper.setText(R.id.tv_get_date, orderMemberDetail.getContent());
            helper.setText(R.id.tv_out_date, item.getCrtTime());
            helper.setText(R.id.tv_price, String.format("¥%1$s", item.getOrderRealAmount()));
        }
    }
}
