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


import com.neusoft.smart.pos.trade.persistent.domain.BillShop;
import com.neusoft.smart.pos.trade.persistent.domain.BillShopExample;
import com.neusoft.smart.pos.trade.persistent.mapper.BillShopMapper;
import lombok.val;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zcf
 * @date 2018-11-05 10：43
 * @description 商户支结算门店信息管理使用Repository
 */
@Component
public class BillShopRepository {

	@Resource
	private BillShopMapper billShopMapper;
	
	/**
	 * 商户门店信息保存方法
	 * @return
	 */
	public Boolean saveBillShop(BillShop billShop){
		val count = billShopMapper.insertSelective(billShop);
		return count>0?true:false;
	}
	
	/**
	 * 结算门店信息查询方法
	 * @return
	 */
	public BillShop queryBillShopByShopId(Integer orgId,Integer shopId){
		val example = new BillShopExample();
		example.createCriteria().andOrgIdEqualTo(orgId)
				.andShopIdEqualTo(shopId);
		val billShops = billShopMapper.selectByExample(example);
		return billShops.size()>0?billShops.get(0):null;
	}
	
	/**
	 * 结算门店信息查询方法
	 * @return
	 */
	public BillShop queryBillShopByOrgId(Integer orgId){
		val example = new BillShopExample();
		example.createCriteria().andOrgIdEqualTo(orgId);
		example.setOrderByClause("created_at asc");
		val billShops = billShopMapper.selectByExample(example);
		return billShops.size()>0?billShops.get(0):null;
	}
	
}
