package com.hzs.sale.wares.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.domain.sale.wares.BdWaresExtend;
import com.hzs.sale.order.param.WaresNumberParam;
import com.hzs.sale.order.vo.WaresPreSaleVo;
import com.hzs.sale.wares.mapper.BdWaresExtendMapper;
import com.hzs.sale.wares.service.IBdWaresExtendService;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * 商品发布扩展表 服务实现类
 *
 * @author hzs
 * @since 2022-09-09
 */
@Service
public class BdWaresExtendServiceImpl extends ServiceImpl<BdWaresExtendMapper, BdWaresExtend> implements IBdWaresExtendService {

    /**
     * 修改销量
     *
     * @param waresNumberParamList
     */
    @Override
    public void updateWaresSalesAccrual(List<WaresNumberParam> waresNumberParamList) {
        if (CollectionUtil.isNotEmpty(waresNumberParamList)) {
            baseMapper.updateWaresSalesAccrual(waresNumberParamList);
        }
    }

    /**
     * 设置上下架时间
     *
     * @param waresId
     * @param putOnTime
     * @param putOffTime
     */
    @Override
    public void updatePutOnTimeAndPutOffTimeByWaresId(Integer waresId, Date putOnTime, Date putOffTime) {
        baseMapper.updatePutOnTimeAndPutOffTimeByWaresId(waresId, putOnTime, putOffTime);
    }

    /**
     * 根据商品编号查询 每个商品所剩余的预售数量
     *
     * @param waresCodeList
     * @param specialArea
     * @return
     */
    @Override
    public List<WaresPreSaleVo> selectByWaresCodeList(Collection<String> waresCodeList, Integer specialArea) {
        return baseMapper.selectByWaresCodeList(waresCodeList, specialArea);
    }
}
