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


import com.neusoft.smart.pos.trade.persistent.domain.BillDetailProfit;
import com.neusoft.smart.pos.trade.persistent.domain.BillDetailProfitExample;
import com.neusoft.smart.pos.trade.persistent.mapper.BillDetailProfitMapper;
import lombok.val;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zcf
 * @date 2018-11-08 10：43
 * @description 商户分润详情信息管理使用Repository
 */
@Component
public class BillDetailProfitRepository {

	@Resource
	private BillDetailProfitMapper billDetailProfitMapper;
	
	
	/**
	 * 商户分润详情信息保存方法
	 * @return
	 */
	public Boolean saveBillDetailProfit(BillDetailProfit billDetailProfit){
		val count = billDetailProfitMapper.insertSelective(billDetailProfit);
		return count>0?true:false;
	}
	
	/**
	 * 商户分润详情信息批量保存方法
	 * @return
	 */
	public void saveBillDetailProfitBatch(List<BillDetailProfit> billDetailProfitList){
		billDetailProfitMapper.batchInsert(billDetailProfitList);
	}
	
	/**
	 * 结算单明细数据查询方法
	 * @return
	 */
	public List<BillDetailProfit> queryBillDetailProfitByOrderNumber(Integer orgId,Integer shopId,String orderNumber,String billNumber){
		val example = new BillDetailProfitExample();
		example.createCriteria()
				.andOrgIdEqualTo(orgId)
				.andShopIdEqualTo(shopId)
				.andOrderNumberEqualTo(orderNumber)
				.andBillNumberEqualTo(billNumber);
		return billDetailProfitMapper.selectByExample(example);
	}
	
	/**
	 * 删除账单信息方法
	 * @return
	 */
	public Integer deleteBillDetailProfitByBillNumber(Integer orgId,String billNumber){
		val example = new BillDetailProfitExample();
		example.createCriteria().andOrgIdEqualTo(orgId).andBillNumberEqualTo(billNumber);
		return billDetailProfitMapper.deleteByExample(example);
	}
	
}
