package com.neusoft.smart.pos.trade.repository;


import com.neusoft.smart.pos.trade.persistent.domain.BillSettlementTask;
import com.neusoft.smart.pos.trade.persistent.domain.BillSettlementTaskExample;
import com.neusoft.smart.pos.trade.persistent.mapper.BillSettlementTaskMapper;
import lombok.val;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zcf
 * @date 2018-12-10 10：43
 * @description 账单结算任务信息管理使用Repository
 */
@Component
public class BillSettlementTaskRepository {

	@Resource
	private BillSettlementTaskMapper billSettlementTaskMapper;
	
	
	/**
	 * 结算任务信息保存方法
	 * @return
	 */
	public Boolean saveBillSettlementTask(BillSettlementTask billSettlementTask){
		val count = billSettlementTaskMapper.insertSelective(billSettlementTask);
		return count>0?true:false;
	}
	
	/**
	 * 结算任务查询方法
	 * @return
	 */
	public BillSettlementTask queryBillSettlementTask(Integer orgId,String billNumber){
		val example = new BillSettlementTaskExample();
		example.createCriteria()
				.andOrgIdEqualTo(orgId)
				.andBillNumberEqualTo(billNumber);
		val billSettlementTasks =  billSettlementTaskMapper.selectByExample(example);
		return billSettlementTasks.size()>0?billSettlementTasks.get(0):null;
	}
	
	/**
	 * 结算任务信息删除方法
	 * @return
	 */
	public Integer deleteBillSettlementTask(Integer orgId,String billNumber){
		val example = new BillSettlementTaskExample();
		example.createCriteria().andOrgIdEqualTo(orgId).andBillNumberEqualTo(billNumber);
		return billSettlementTaskMapper.deleteByExample(example);
	}
	
	/**
	 * 结算任务信息更新方法
	 * @return
	 */
	public Integer updateBillSettlementTask(BillSettlementTask billSettlementTask,Integer orgId,String billNumber){
		val example = new BillSettlementTaskExample();
		example.createCriteria().andOrgIdEqualTo(orgId).andBillNumberEqualTo(billNumber);
		return billSettlementTaskMapper.updateByExampleSelective(billSettlementTask,example);
	}
}
