package com.cool.store.dao;

import com.alibaba.excel.util.CollectionUtils;
import com.alibaba.excel.util.StringUtils;
import com.cool.store.dto.contract.ContractCallbackDTO;
import com.cool.store.entity.SignFranchiseDO;
import com.cool.store.mapper.SignFranchiseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

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

/**
 * @Author: WangShuo
 * @Date: 2025/05/12/13:55
 * @Version 1.0
 * @注释:
 */
@Repository
public class SignFranchiseDAO {
    @Resource
    private SignFranchiseMapper signFranchiseMapper;

    public Integer updateSpecific(List<SignFranchiseDO> list){
        if (CollectionUtils.isEmpty(list)){
            return 0;
        }
        return signFranchiseMapper.updateSpecific(list);
    }

    public List<SignFranchiseDO> getSignType(List<Long> shopIds){
        if (CollectionUtils.isEmpty(shopIds)){
            return new ArrayList<>();
        }
        return signFranchiseMapper.getSignType(shopIds);
    }

    public SignFranchiseDO selectByShopId(Long shopId){
        return signFranchiseMapper.selectByShopId(shopId);
    }

    public void updateAuditByShopId(Long auditId, Long shopId, ContractCallbackDTO dto){
        if (dto==null || (StringUtils.isEmpty(dto.getReason())&&dto.getInfoConsistencyFlag()==null)){
            return;
        }
        signFranchiseMapper.updateAuditByShopId(auditId,shopId,dto);
    }

    public void updateAuditByShopId(Long auditId, Long shopId){
        signFranchiseMapper.updateAuditByShopId(auditId, shopId, null);
    }
}
