package com.microservices.zone.member.mapper;

import com.microservices.zone.member.domain.points.ZonePointsApply;
import com.microservices.zone.member.domain.vo.ZonePointsApplySearchVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 积分申请表Mapper接口
 *
 * @author otto
 */
@Mapper
public interface ZonePointsApplyMapper {
    /**
     * 查询积分申请
     *
     * @param id 积分申请主键
     * @return 积分申请
     */
    public ZonePointsApply selectZonePointsApplyById(Long id);

    /**
     * 查询积分申请列表
     *
     * @param zonePointsApply 积分申请
     * @return 积分申请集合
     */
    public List<ZonePointsApply> selectZonePointsApplyList(ZonePointsApplySearchVo searchVo);

    /**
     * 新增积分申请
     *
     * @param zonePointsApply 积分申请
     * @return 结果
     */
    public int insertZonePointsApply(ZonePointsApply zonePointsApply);

    /**
     * 修改积分申请
     *
     * @param zonePointsApply 积分申请
     * @return 结果
     */
    public int updateZonePointsApply(ZonePointsApply zonePointsApply);

    /**
     * 删除积分申请
     *
     * @param id 积分申请主键
     * @return 结果
     */
    public int deleteZonePointsApplyById(Long id);

    /**
     * 批量删除积分申请
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteZonePointsApplyByIds(Long[] ids);

    /**
     * 根据用户ID和专区ID查询积分申请列表
     *
     * @param userId 用户ID
     * @param zoneId 专区ID
     * @return 积分申请列表
     */
    List<ZonePointsApply> selectZonePointsApplyByUserIdAndZoneId(@Param("userId") Long userId, @Param("zoneId") Long zoneId);

    /**
     * 统计用户某类型待处理的申请数量（幂等校验）
     *
     * @param userId    用户ID
     * @param zoneId    专区ID
     * @param applyType 申请类型
     * @return 待处理申请数量
     */
    int countPendingByUserZoneAndType(@Param("userId") Long userId, @Param("zoneId") Long zoneId, @Param("applyType") String applyType);
}