/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.model.Sku;
import com.yami.shop.bean.po.FreightStatisticsPo;
import com.yami.shop.bean.po.SkuStatisticsPo;
import com.yami.shop.bean.vo.FreightStatisticsVo;
import com.yami.shop.bean.vo.SkuBuyTogetherOftenVo;
import com.yami.shop.bean.vo.SkuStatisticsVo;
import com.yami.shop.common.util.PageParam;
import org.apache.ibatis.annotations.Param;

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

public interface SkuMapper extends BaseMapper<Sku> {

    /**
     * 批量插入sku
     *
     * @param prodId  商品id
     * @param skuList sku列表
     */
    void insertBatch(@Param("prodId") Long prodId, @Param("skuList") List<Sku> skuList);

    List<Sku> listByProdId(@Param("prodId") Long prodId);

    List<Sku> listByProdIdAndPlatform(@Param("prodId") Long prodId, @Param("channelId") Long channelId, @Param("shopId") Long shopId);

    Sku listBySukIdAndPlatformShop(@Param("skuId") Long skuId, @Param("channelId") Long channelId, @Param("shopId") Long shopId);

    Sku listBySukIdAndPlatform(@Param("skuId") Long skuId, @Param("channelId") Long channelId);

    int updateStocks(@Param("sku") Sku sku);

    void deleteByProdId(@Param("prodId") Long prodId);

    void returnStock(@Param("skuCollect") Map<Long, Integer> skuCollect);

    /**
     * 通过海博单品编码查询商品
     *
     * @param hbSkuId 单品编码
     * @return 单品信息
     */
    Sku selectByHbSkuId(@Param("hbSkuId") String hbSkuId);

    IPage<SkuBuyTogetherOftenVo> buyTogetherOften(@Param("page") PageParam<SkuBuyTogetherOftenVo> page,
                                                  @Param("prodId") Long prodId, @Param("shopId") Long shopId,
                                                  @Param("channelId") Long channelId,
                                                  @Param("userId") String userId
    );

    Double goodsTotalPrice(@Param("po")SkuStatisticsPo po);
    Double totalPoints(@Param("po")SkuStatisticsPo po);
    Double totalCash(@Param("po")SkuStatisticsPo po);
    Double totalFreight(@Param("po")SkuStatisticsPo po);

    IPage<SkuStatisticsVo> skuStatisticsList(@Param("page") PageParam<SkuStatisticsPo> page, @Param("po") SkuStatisticsPo po);
    List<SkuStatisticsVo> skuStatisticsList2(@Param("po") SkuStatisticsPo po);

    IPage<FreightStatisticsVo> freightStatisticsList(@Param("page") PageParam<FreightStatisticsPo> page, @Param("po") FreightStatisticsPo po);
    List<FreightStatisticsVo> freightStatisticsList2(@Param("po") FreightStatisticsPo po);
}
