package cn.com.ty.lift.ud.operation.mapper;


import cn.com.ty.lift.ud.operation.controller.query.VipFeeSettingQuery;
import cn.com.ty.lift.ud.operation.mapper.entity.VipFeeSettingEntity;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import  com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 会费设置;-Repository
 * 
 * @author Xson
 * @date 2020-06-19
 */
public interface VipFeeSettingMapper extends BaseMapper<VipFeeSettingEntity> {

    /**
     * 审批通过
     * @param id
     */
    @Update("update vip_fee_setting set examine_flag = 1 , not_examine_reason = '' where id = #{id} ")
    void examineById(Long id);

    /**
     * 审批驳回
     * @param id
     * @param notExamineReason
     */
    @Update("update vip_fee_setting set examine_flag = 2 ,not_examine_reason = #{notExamineReason} where id = #{id} ")
    void updateInfoById(@Param("id") Long id , @Param("notExamineReason")String notExamineReason);

    /**
     * 提交
     * @param id
     * @return
     */
    @Update("update vip_fee_setting set examine_flag = 0  where id = #{id} ")
    int submit(Long id);

    /**
     * 根据有效期和app角色ID查询会费
     * @param period
     * @param userLevelId
     * @return
     */
    @Select("select * from vip_fee_setting where period = #{period} and examine_flag  = 1 and user_level_id = #{userLevelId} ")
    VipFeeSettingEntity getByPeriodAndLevel(@Param("period")Integer period,@Param("userLevelId")Long userLevelId);

    /**
     * 后台分页查询
     *
     * @param condition
     * @param page
     * @return
     */
    List<VipFeeSettingEntity> selectByQuery(@Param("ew") Wrapper condition, @Param("page") VipFeeSettingQuery page);

    /**
     * 查询总数量
     *
     * @param condition
     * @return
     */
    int countByQuery(@Param("ew") Wrapper condition);
}
