package cn.net.caoyao.cpzshandset.service.bll;

import java.util.List;

import android.content.Context;
import cn.net.caoyao.cpzshandset.bean.TruckInvoiceBean;
import cn.net.caoyao.cpzshandset.common.config.ConfigDBCreateService;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.TruckInvoiceDal;

public class TruckInvoiceBll {
	private TruckInvoiceDal dal;
	public TruckInvoiceBll(Context context) {
		ConfigDBCreateService service = new ConfigDBCreateService();
		dal = service.createTruckInvoiceDal(new CacheGet(), context);
	}
	/**
	 * 插入线上获取的运单信息
	 * @param invoice
	 * @return
	 */
	public long insertOnlineTruckInvoice(TruckInvoiceBean invoice){
		return dal.insertOnlineTruckInvoice(invoice);
	}
	/**
	 * 插入汽车运单信息
	 * @param invoice
	 */
	public int insertTruckInvoice(TruckInvoiceBean invoice){
		return dal.insertTruckInvoice(invoice);
	}
	
	/**
	 * 修改汽车订单的提交状态
	 * @param status
	 * @param errorCode
	 * @param tBean
	 */
	public void updateTruckSubmitStatus(int status,int errorCode, int id){
		dal.updateTruckInvoiceStatus(status, errorCode, id);
	}
	
	/**
	 * 修改汽车订单的提交状态
	 * @param status
	 * @param errorCode
	 * @param tBean
	 */
	public void updateTruckSubmitStatusByLId(int status,int errorCode, long id){
		dal.updateTruckSubmitStatusByLId(status, errorCode, id);
	}
	/**
	 * 修改当前订单单个标签的上传类型
	 * @param invoice
	 * @return
	 */
	public TruckInvoiceBean updateTruckLabelMode(TruckInvoiceBean invoice){
		return dal.updateTruckLabelMode(invoice);
	}
	/**
	 * 修改汽车运单信息
	 * @param invoice
	 */
	public void updateTruckInvoice(TruckInvoiceBean invoice){
		dal.updateTruckInvoice(invoice);
	}
	/**
	 * 根据订单id,删除订单信息
	 * @param status 0:有效   1:无效
	 * @param id
	 */
	public void deleteTruckInvoiceById(TruckInvoiceBean invoice){
		dal.deleteTruckInvoiceById(invoice);
	}
	
	/**
	 * 查询所有的汽车运单信息
	 * @return
	 */
	public List<TruckInvoiceBean> queryAllTruckInvoices(){
		return dal.queryAllTruckInvoices();
	}
	
	public List<TruckInvoiceBean> queryAllTruckInvoicesASC(){
		return dal.queryAllTruckInvoicesASC();
	}
	/**
	 * 通过责任人查询所有的汽车发发运单
	 * @return
	 */
	public List<TruckInvoiceBean> queryAllTruckInvoicesByUsr(String userAccount){
		return dal.queryAllTruckInvoicesByUsr(userAccount);
	}
	public List<TruckInvoiceBean> queryAllTruckInvoicesASCByUsr(String userAccount){
		return dal.queryAllTruckInvoicesASCByUsr(userAccount);
	}
	/**
	 * 通过运单ID，查询运单信息
	 * @param id
	 * @return
	 */
	public TruckInvoiceBean queryTruckInvoiceById(int id){
		return dal.queryTruckInvoiceById(id);
	}
	
	/**
	 * 通过运单ID，查询运单信息
	 * @param id
	 * @return
	 */
	public TruckInvoiceBean queryOnlineTruckInvoiceById(long id){
		return dal.queryOnlineTruckInvoiceById(id);
	}
	/**
	 * 插入时检测已经数据库中已经存在该订单
	 * @param trainInvoice
	 * @return
	 */
	public boolean insertHasExist(TruckInvoiceBean truckInvoice){
		return dal.insertHasExist(truckInvoice);
	}
	
	/**
	 * 修改时检测数据库中已经存在该订单
	 * @param trainInvoice
	 * @return
	 */
	public boolean updateHasExist(TruckInvoiceBean truckInvoice){
		return dal.updateHasExist(truckInvoice);
	}
}
