package cn.pluss.platform.mapper;

import cn.pluss.platform.entity.Cash;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface CashMapper extends BaseMapper<Cash> {

    List<Cash> queryCashPage(Map<String, Object> map);

    IPage<Cash> queryCashPage2(IPage<Cash> page, @Param(Constants.WRAPPER) Wrapper<Cash> wrapper);

    Integer queryCashPageCount(Map<String, Object> map);

    /**
     * 已经成功提现的金额/申请提现中的金额(粉丝分润)
     *
     * @param map
     * @return
     */
    Double sumFansSuccessCash(Map<String, Object> map);

    /**
     * 已经成功提现(粉丝分润)
     *
     * @return
     */
    Double sumFansAreadlyCash(Map<String, Object> map);


    /**
     * 已经成功提现的金额/申请提现中的金额(推广分润)
     *
     * @return
     */
    Double sumMerChantSuccessCash(@Param(value = "userId") Long userId);

    /**
     * 已经成功提现(推广分润)
     *
     * @return
     */
    Double sumMerChantAreadlyCash(@Param(value = "userId") Long userId);

    @Select("SELECT * FROM tb_pluss_cash WHERE id = #{id} FOR UPDATE")
    Cash selectLockById(@Param(value = "id") Serializable id);

    /**
     * @param params:
     * @return java.util.Map<java.lang.String, java.lang.Object>
     * @description:统计提现信息记录
     * @date: 2021/10/15 16:39
     */
    Map<String, Object> getCashCountData(Map<String, Object> params);

    /**
     * 查询提现总金额
     *
     * @param userId 用户id
     * @return 提现总金额
     */
    BigDecimal selectCashAmtTotal(@Param("userId") String userId, @Param("statusArr") int... statusArr);
}

