package com.wd.workoffice.ui.activity.bat.work;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.FareBean;
import com.wd.workoffice.bean.FareOrderBean;
import com.wd.workoffice.bean.event.FareConfirmEvent;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.ui.activity.bat.store.StoreSaleClientActivity;
import com.wd.workoffice.ui.adapter.FareOrderAdapter;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.util.WorkUtils;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import flexible.xd.android_base.network.rtfhttp.Transformer;
import io.reactivex.disposables.Disposable;

/**
 * 物流单确认详情
 * author : flexible
 * email : lgd19940421@163.com
 * github: https://github.com/FlexibleXd
 **/
public class FareDetailActivity extends WorkToolBarActivity {
    @BindView(R.id.rv_from)
    RecyclerView rvData;
    @BindView(R.id.et_logistics_price)
    TextView etLogisticsPrice;
    @BindView(R.id.ll_logistics_price)
    LinearLayout llLogisticsPrice;
    @BindView(R.id.et_tax)
    TextView etTax;
    @BindView(R.id.ll_tax)
    LinearLayout llTax;
    @BindView(R.id.et_logistics_code)
    TextView etLogisticsCode;
    @BindView(R.id.ll_logistics_code)
    LinearLayout llLogisticsCode;
    @BindView(R.id.tv_logistics_company)
    TextView tvLogisticsCompany;
    @BindView(R.id.rl_set)
    LinearLayout rlSet;
    private List<FareOrderBean.RecordsBean> dataList;
    private FareOrderAdapter dataAdapter;

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        rvData.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    }

    @Override
    protected void initData() {
        String data = getIntent().getStringExtra("data");
        if (!TextUtils.isEmpty(data)) {
            FareBean.RecordsBean fareBean = JSON.parseObject(data, FareBean.RecordsBean.class);
            etLogisticsPrice.setText(MathUtils.converData(fareBean.getFareMoney(),3));
            etTax.setText(MathUtils.converData(fareBean.getTax(),3));
            etLogisticsCode.setText(fareBean.getTrackingNumber());
            tvLogisticsCompany.setText(fareBean.getTransitPartName());
            dataList = new ArrayList<>();
            if (null != fareBean.getFareItemList()) {
                for (FareBean.RecordsBean.FareItemListBean fareItemListBean : fareBean.getFareItemList()) {
                    FareOrderBean.RecordsBean fareOrder = new FareOrderBean.RecordsBean();
                    fareOrder.setUpdatedTime(fareItemListBean.getCreatedTime());
                    fareOrder.setTotalWeight(fareItemListBean.getWeight());
                    fareOrder.setReceiveDeptName(fareItemListBean.getLaunchDeptName());
                    fareOrder.setOrderId(fareItemListBean.getOrderId());
                    dataList.add(fareOrder);
                }
            }
            dataAdapter = new FareOrderAdapter(R.layout.item_fare_order, dataList, 1);
            dataAdapter.bindToRecyclerView(rvData);
        }

    }

    @Override
    protected void initEvent() {
    }


    @Override
    protected int layoutId() {
        return R.layout.activity_fare_detail;
    }

}
