package cn.pluss.platform.mapper;

import cn.pluss.platform.dto.DeviceStockDTO;
import cn.pluss.platform.entity.DeviceStock;
import cn.pluss.platform.vo.DeviceStockVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author bzg
 * @since 2020-11-11
 */
public interface DeviceStockMapper extends BaseMapper<DeviceStock> {

    /**
     * 查询库存信息
     * @param groupNoList  商品code
     * @return
     */
    List<Map<String, Object>> selectStockInfoList(@Param("groupNoList") List<String> groupNoList);

    /**
     * 查询已售库存信息
     * @param groupNoList  商品code
     * @return
     */
    List<Map<String, Object>> selectSoldStockList(@Param("groupNoList") List<String> groupNoList);

    /**
     * 获取用户设备统计信息
     * @param dto
     * @return
     */
    List<DeviceStockVO> getStockTypeNumList(DeviceStockDTO dto);

    /**
     * 分页查询指定设备类型设备信息
     * @param page
     * @param dto
     * @return
     */
    Page<DeviceStockVO> pageInfo(Page<DeviceStockVO> page, @Param("dto") DeviceStockDTO dto);

    DeviceStockVO detail(DeviceStockDTO dto);

    /**
     * 获取商户信息
     * @param dto
     * @return
     */
    DeviceStockVO getMercInfo(DeviceStockDTO dto);

    @Select("SELECT * FROM tb_pluss_device_stock where snNo = #{snNo} limit 1")
    DeviceStock getDeviceBySnNo(String snNo);


    Page<DeviceStockVO> pageDeviceStock(Page<DeviceStockVO> page, @Param("userId") Long userId, @Param("cashPlaceId") Long cashPlaceId);

    @Select("SELECT * FROM tb_pluss_device_stock where deviceNo = #{deviceNo} limit 1")
    DeviceStock getDeviceByDeviceNo(@Param("deviceNo") String deviceNo);
}
