package com.cool.store.dao;

import com.alibaba.excel.util.CollectionUtils;
import com.cool.store.entity.BuildInformationDO;
import com.cool.store.entity.PosAndOrderInfoDO;
import com.cool.store.mapper.PosAndOrderInfoMapper;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: WangShuo
 * @Date: 2024/10/09/下午3:00
 * @Version 1.0
 * @注释:
 */
@Repository
public class PosAndOrderInfoDAO {
    @Resource
    private PosAndOrderInfoMapper posAndOrderInfoMapper;
    public Integer insertSelective(PosAndOrderInfoDO posAndOrderInfoDO) {
        if (posAndOrderInfoDO == null) {
            return 0;
        }
        return posAndOrderInfoMapper.insertSelective(posAndOrderInfoDO);
    }

    public Integer updateByShopIdSelective(PosAndOrderInfoDO posAndOrderInfoDO) {
        if (posAndOrderInfoDO == null) {
            return 0;
        }
        Example example = new Example(PosAndOrderInfoDO.class);
        example.createCriteria()
                .andEqualTo("shopId", posAndOrderInfoDO.getShopId())
                .andEqualTo("type",posAndOrderInfoDO.getType());
        return posAndOrderInfoMapper.updateByExampleSelective(posAndOrderInfoDO,example);
    }
    public PosAndOrderInfoDO selectOneByShopId(Long shopId,Integer type) {
        Example example = new Example(PosAndOrderInfoDO.class);
        example.createCriteria().andEqualTo("shopId",shopId).andEqualTo("type",type);
        return posAndOrderInfoMapper.selectOneByExample(example);
    }

    public List<PosAndOrderInfoDO> selectListByShopIdAndType(List<Long> shopIds, Integer type) {
        Example example = new Example(PosAndOrderInfoDO.class);
        example.createCriteria().andIn("shopId",shopIds).andEqualTo("type",type);
        return posAndOrderInfoMapper.selectByExample(example);
    }
    public Integer batchInsert(List<PosAndOrderInfoDO> posAndOrderInfoDOList){
        if(CollectionUtils.isEmpty(posAndOrderInfoDOList)){
            return 0;
        }
        return posAndOrderInfoMapper.batchInsert(posAndOrderInfoDOList);
    }
    //不通用只用于批量云流水修改备注
    public Integer batchUpdateYlsRemarkByShopCode(List<String> shopCodeList, String remark){
        if(CollectionUtils.isEmpty(shopCodeList)){
            return 0;
        }
        return posAndOrderInfoMapper.batchUpdateYlsRemarkByShopCode(shopCodeList,remark);
    }
}
