package com.ruoyi.ibs.draw.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.ibs.draw.domain.entity.DrawShapeCust;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author 吴凯程
 * @Date 2024/12/20
 **/
@Mapper
public interface DrawShapeCustMapper extends BaseMapper<DrawShapeCust> {
    int batchInsert(@Param("custList") List<DrawShapeCust> custList, @Param("dept") String dept);

    int batchDelete(@Param("shapeId") Long shapeId, @Param("dept") String dept);

    @Select("SELECT COUNT(DISTINCT cust_id) FROM draw_shape_cust WHERE shape_id = #{shapeId} and cust_type = '0'")
    Long countRetail(@Param("shapeId") Long shapeId);

    @Select("SELECT COUNT(DISTINCT cust_id) FROM draw_shape_cust WHERE shape_id = #{shapeId} and cust_type = '2'")
    Long countBusiness(@Param("shapeId") Long shapeId);

    @Select("SELECT COUNT(DISTINCT cust_id) FROM draw_shape_cust WHERE shape_id = #{shapeId} and cust_type = '1'")
    Long countMerchant(@Param("shapeId") Long shapeId);
}
