package com.game.business.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.game.business.domain.AppGameBetting;
import com.game.business.dto.FinTranRecordDTO;
import com.game.business.vo.AppGameBettingDetailsCountVO;
import com.game.business.vo.AppUserGameBettingCountVO;
import com.game.business.vo.AppUserGameBettingDetailsCountVO;
import com.game.business.vo.AppUserGameBettingWebCountVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

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

public interface AppGameBettingMapper extends BaseMapper<AppGameBetting> {

    List<AppGameBettingDetailsCountVO> getCount(@Param(value = "strDate") String strDate, @Param(value = "userId") Long userId,  @Param(value = "bettingType") Integer bettingType);
    List<AppUserGameBettingCountVO> getUserCount(@Param(value = "gameId") Long gameId, @Param(value = "userId") Long userId, @Param(value = "bettingType") Integer bettingType);
    List<AppUserGameBettingWebCountVO> getUserWebCount(@Param(value = "gameId") Long gameId, @Param(value = "userId") Long userId, @Param(value = "bettingType") Integer bettingType,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
    List<AppUserGameBettingDetailsCountVO> getUserBettingItemCount(@Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "userId") Long userId, @Param(value = "bettingType") Integer bettingType);
    Map<String, BigDecimal> getBettingAmountSum(Long userId);
    Map<String, BigDecimal> getBettingAmountByDateSum(FinTranRecordDTO finTranRecordDTO);

    Map<String, Double> getBettingAmountByDate(@Param(value = "gameId") Long gameId, @Param(value = "dateStr") String dateStr);
    List<AppUserGameBettingDetailsCountVO> getBettingAmountByGameDate(@Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingType") Integer bettingType);

    Integer getBettingCount(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingItem") String bettingItem);
    Integer getBettingItemCount(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingItem") String bettingItem);
    BigDecimal getBettingAmount(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingItem") String bettingItem);
    List<String> getBettingItem(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate);
    /**
     * 查询用户下注记录
     *
     * @param id 用户下注记录主键
     * @return 用户下注记录
     */
    public AppGameBetting selectAppGameBettingById(Long id);

    /**
     * 查询用户下注记录列表
     *
     * @param appGameBetting 用户下注记录
     * @return 用户下注记录集合
     */
    public List<AppGameBetting> selectAppGameBettingList(AppGameBetting appGameBetting);

    /**
     * 新增用户下注记录
     *
     * @param appGameBetting 用户下注记录
     * @return 结果
     */
    public int insertAppGameBetting(AppGameBetting appGameBetting);

    /**
     * 修改用户下注记录
     *
     * @param appGameBetting 用户下注记录
     * @return 结果
     */
    public int updateAppGameBetting(AppGameBetting appGameBetting);

    /**
     * 删除用户下注记录
     *
     * @param id 用户下注记录主键
     * @return 结果
     */
    public int deleteAppGameBettingById(Long id);

    /**
     * 批量删除用户下注记录
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAppGameBettingByIds(Long[] ids);

    /*@Select(" <script>" +
            " select ifNull(sum(betting_amount),0) from app_game_betting " +
            "  <where>" +
            "   <if test=\"userId != null \"> " +
            "       user_id = #{userId} " +
            "   </if> " +
            "   <if test=\"bettingType != null \"> " +
            "      and betting_type = #{bettingType} " +
            "   </if>" +
            "   <if test=\"beginTime != null and beginTime != '' \"> " +
            "      and create_time >= #{beginTime} " +
            "   </if>" +
            "   <if test=\"endTime != null and endTime != '' \"> " +
            "      and create_time <= #{endTime} " +
            "   </if>" +
            "  </where>" +
            " </script>")*/
    public Double sumBettingAmount(@Param("userId") Long userId, @Param("bettingType") Integer bettingType, @Param("beginTime") String beginTime, @Param("endTime") String endTime,@Param("gameId") Long gameId);

}
