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

import java.util.List;

import android.content.Context;

import cn.net.caoyao.cpzshandset.bean.ActivateBean;
import cn.net.caoyao.cpzshandset.common.config.ConfigDBCreateService;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.ActivateWithPackDal;

public class ActivateWithPackBll {
	private ActivateWithPackDal dal;
	public ActivateWithPackBll(Context context) {
		ConfigDBCreateService service = new ConfigDBCreateService();
		dal = service.createActivateWithPackDal(new CacheGet(), context);
//		dal = new LiqueurActivateWithPackDal(context);
	}
	public int insertActivatePack(ActivateBean activateBean){
		if (dal == null || activateBean == null) return 0;
		return dal.insertActivatePack(activateBean);
	}
	public List<ActivateBean> queryAllActivatePackList(){
		if(dal == null) return null;
		return dal.queryAllActivatePackList();
	}
	public List<ActivateBean> queryAllActivatePackListByASC(){
		if(dal == null) return null;
		return dal.queryAllActivatePackListByASC();
	}
	public ActivateBean queryActivatePackBeanById(int id){
		if(dal == null) return null;
		return dal.queryActivatePackBeanById(id);
	}
	public void updateActivatePack(ActivateBean activateBean){
		if(dal == null || activateBean == null) return;
		dal.updateActivatePack(activateBean);
	}
	public void delActivatePackById(ActivateBean activateBean){
		if(dal == null || activateBean == null) return;
		dal.delActivatePackById(activateBean);
	}
	/**
	 * 根据激活id更新激活的错误码
	 * 
	 * @param trainInvoice
	 */
	public void updateActivatePackErrorById(int errorCode,int id){
		if(dal == null) return;
		dal.updateActivatePackErrorById(errorCode, id);
	}
	/**
	 * 修改激活历史数据的状态
	 * @param status
	 * @param errorCode
	 * @param id
	 */
	public void updateActivatePackErrorStatusById(int status,int errorCode, int id){
		if(dal == null) return;
		dal.updateActivatePackErrorStatusById(status, errorCode, id);
	}
	/**
	 * 是否在别的打包中作为子标签使用
	 * @param labelId
	 * @return
	 */
	public boolean isSubLabelInOtherPack(String labelId){
		if(dal == null || labelId == null) return false;
		return dal.isSubLabelInOtherPack(labelId);
	}
	/**
	 * 该标签存在其他激活单中
	 * @param labelId
	 * @return
	 */
	public boolean packageIdIsExitInOtherActivate(String labelId, int id, boolean isCreate){
		if(dal == null || labelId == null) return false;
		return dal.packageIdIsExitInOtherActivate(labelId, id, isCreate);
	}
	public boolean isPackageIdInOtherPack(String labelId,int id){
		if(dal == null || labelId == null) return false;
		return dal.isPackageIdInOtherPack(labelId,id);
	}
	/**
	 * 作为packageId存在于激活打包列表中
	 * @param labelId
	 * @return
	 */
	public boolean isPackageIdInAWithPack(String labelId){
		if(dal == null || labelId == null) return false;
		return dal.isPackageIdInAWithPack(labelId);
	}
	
	/**
	 * 作为packageId存在于激活打包列表中
	 * @param labelId
	 * @return
	 */
	public boolean isExitPackageIdInAWithPack(String startLabel, String endLabel){
		if(dal == null || startLabel == null || endLabel == null) return false;
		return dal.isExitPackageIdInAWithPack(startLabel, endLabel);
	}
}
