package cn.pluss.platform.deviceStock;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.dto.DeviceStockDTO;
import cn.pluss.platform.entity.DeviceStock;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.mapper.DeviceStockMapper;
import cn.pluss.platform.vo.DeviceNumVO;
import cn.pluss.platform.vo.DeviceStockVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

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

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author bzg
 * @since 2020-11-11
 */
public interface DeviceStockService extends IService<DeviceStock> {

    /**
     * 获取库存信息，总组数
     * @param groupNoList  商品code
     * @return
     */
    default List<Map<String, Object>> getStockInfoMaps(List<String> groupNoList) {
        return ((DeviceStockMapper) getBaseMapper()).selectStockInfoList(groupNoList);
    }

    default List<Map<String, Object>> getSoldStockMaps(List<String> groupNoList) {
        return ((DeviceStockMapper) getBaseMapper()).selectSoldStockList(groupNoList);
    }

    /**
     * 商户绑定付款码，付款码包含码牌和音箱
     * @param payCode   付款码code
     */
    void bindPayCode(String payCode);

    /**
     * 商户绑定付款码，付款码包含码牌和音箱
     * @param payCode   付款码code
     */
    void bindPayCode(String payCode, UserApp userApp);

    void unbind(Long id);

    DeviceStock getDevicebyNo(String deviceNo);

    /**
     * 获取设备统计详情
     * @param dto
     * @return
     */
    DeviceNumVO getStockTypeNumList(DeviceStockDTO dto);

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

    /**
     * 后台设备出库
     * @param ids
     * @param accpetUserId
     * @param orderNo
     * @return
     */
    Result<String> manageTransfer(List<Long> ids, Long accpetUserId,String orderNo);

    /**
     * 获取设备详情
     * @param dto
     * @return
     */
    DeviceStockVO detail(DeviceStockDTO dto);

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

    Page<DeviceStockVO> pageMercDevice(Page<DeviceStockVO> page, Long userId, Long cashPlaceId);

    Page<DeviceStockVO> apiPageMercDevice(Page<DeviceStockVO> page, Long cashPlaceId);

    /**
     * 绑定设备V2
     * @param dto
     */
    void bindDevcieV2(DeviceStockDTO dto);

    DeviceStock checkBind(String sn);
}
