package com.neusoft.smart.pos.inventory.persistent.mapper;

import com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreBatch;
import com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreBatchExample;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface InventoryStoreBatchMapper {
    
    int countByExample(InventoryStoreBatchExample example);
    
    BigDecimal sumByExample(InventoryStoreBatchExample example);
    
    int deleteByExample(InventoryStoreBatchExample example);
    
    int deleteByPrimaryKey(Integer id);
    
    int insert(InventoryStoreBatch record);
    
    int insertSelective(InventoryStoreBatch record);
    
    List<InventoryStoreBatch> selectByExample(InventoryStoreBatchExample example);
    
    InventoryStoreBatch selectByPrimaryKey(Integer id);
    
    int updateByExampleSelective(@Param("record") InventoryStoreBatch record, @Param("example") InventoryStoreBatchExample example);
    
    int updateByExample(@Param("record") InventoryStoreBatch record, @Param("example") InventoryStoreBatchExample example);
    
    int updateByPrimaryKeySelective(InventoryStoreBatch record);
    
    int updateByPrimaryKey(InventoryStoreBatch record);
    
    void batchInsert(@Param("items") List<InventoryStoreBatch> items);
    
    List<InventoryStoreBatch> selectMaxIdBatchByGoodsId(InventoryStoreBatchExample example);
    
    List<InventoryStoreBatch> selectMinIdBatchByGoodsId(InventoryStoreBatchExample example);
    
    BigDecimal getAvgPrice(InventoryStoreBatchExample example);
    
    
    int deductionStorage(@Param("batchId") Integer batchId,
            @Param("count") Integer count,
            @Param("status") String status,
            @Param("version") Integer version,
            @Param("isLock") Boolean isLock);
    
    int handleLockStorage(@Param("batchId") Integer batchId,
            @Param("deductLockedCount") Integer deductLockedCount,
            @Param("releaseCount") Integer releaseCount,
            @Param("canNegativeStorage") Boolean canNegativeStorage,
            @Param("version") Integer version);
    
    int returnStorage(@Param("batchId") Integer batchId,
            @Param("returnCount") Integer returnCount,
            @Param("version") Integer version);
}