123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.game.business.mapper.AppGameBettingMapper">
- <resultMap type="com.game.business.domain.AppGameBetting" id="AppGameBettingResult">
- <result property="id" column="id" />
- <result property="classId" column="class_id" />
- <result property="gameId" column="game_id" />
- <result property="userId" column="user_id" />
- <result property="gameDate" column="game_date" />
- <result property="liveUserId" column="live_user_id" />
- <result property="liveRoomId" column="live_room_id" />
- <result property="moneyId" column="money_id" />
- <result property="isLive" column="is_live" />
- <result property="bettingType" column="betting_type" />
- <result property="bettingGameType" column="betting_game_type" />
- <result property="bettingItem" column="betting_item" />
- <result property="bettingMultiple" column="betting_multiple" />
- <result property="bettingAmount" column="betting_amount" />
- <result property="bettingCommission" column="betting_commission" />
- <result property="isWinning" column="is_winning" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <select id="getCount" resultType="com.game.business.vo.AppGameBettingDetailsCountVO">
- select
- game_id as gameId,
- count(id) as bettingCount,
- sum(betting_amount) as orderAmount,
- sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
- sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
- from app_game_betting where date_format(create_time, '%Y-%m-%d') = #{strDate} and user_id = #{userId}
- and betting_type = #{bettingType}
- group by game_id
- </select>
- <select id="getUserCount" resultType="com.game.business.vo.AppUserGameBettingCountVO">
- select tmp.*,
- agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate,agl.is_lottery as isLottery
- from (
- select
- game_date as gameDate,
- count(id) as bettingCount,
- sum(betting_amount) as orderAmount,
- sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
- sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
- from app_game_betting where game_id = #{gameId} and user_id = #{userId} and betting_type = #{bettingType}
- group by game_date
- ) tmp
- left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = #{gameId}
- order by tmp.gameDate desc
- </select>
- <select id="getUserWebCount" resultType="com.game.business.vo.AppUserGameBettingWebCountVO">
- select tmp.*,
- ag.name as gameName,
- agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate,agl.is_lottery as isLottery
- from (
- select
- user_id as userId,
- game_id as gameId,
- game_date as gameDate,
- betting_type as bettingType,
- betting_game_type as bettingGameType,
- min(create_time) as bettingDate,
- count(id) as bettingCount,
- sum(betting_amount) as orderAmount,
- sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
- sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
- from app_game_betting
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="gameId != null">
- and game_id = #{gameId}
- </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>
- group by user_id, game_id, game_date, betting_game_type
- ) tmp
- left join mugozbg_live.app_game ag on ag.id = tmp.gameId
- left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = tmp.gameId
- order by tmp.bettingDate desc
- </select>
- <select id="getUserBettingItemCount" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
- select
- betting_item as bettingTtem,
- sum(betting_amount) as orderAmount,
- sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
- sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
- from app_game_betting where game_id = #{gameId} and game_date = #{gameDate}
- and user_id = #{userId} and betting_type = #{bettingType} and betting_game_type = 0
- group by betting_item
- </select>
- <select id="getBettingAmountSum" resultType="java.util.Map">
- select
- ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
- ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
- from app_game_betting
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- </where>
- </select>
- <select id="getBettingAmountByDateSum" resultType="java.util.Map" parameterType="com.game.business.dto.FinTranRecordDTO">
- select
- ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
- ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum
- from app_game_betting
- <where>
- <if test="userId != null">
- and user_id = #{userId}
- </if>
- <if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
- and (date_format(create_time, '%Y-%m-%d') >= #{beginTime} and date_format(create_time, '%Y-%m-%d') <= #{endTime})
- </if>
- </where>
- </select>
- <select id="getBettingCount" resultType="java.lang.Integer">
- select ifnull(count(1), 0) as bettingCount from (
- select
- betting_item
- from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate} and betting_item != #{bettingItem}
- group by betting_item
- ) tmp
- </select>
- <select id="getBettingItem" resultType="java.lang.String">
- select
- betting_item
- from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
- group by betting_item
- </select>
- <select id="getBettingItemCount" resultType="java.lang.Integer">
- select
- ifnull(count(1), 0) as bettingCount
- from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
- <if test="bettingItem != null and bettingItem != ''">
- and betting_item = #{bettingItem}
- </if>
- </select>
- <select id="getBettingAmount" resultType="java.math.BigDecimal">
- select
- ifnull(sum(betting_amount), 0.00) as bettingAmount
- from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
- <if test="bettingItem != null and bettingItem != ''">
- and betting_item = #{bettingItem}
- </if>
- </select>
- <select id="getBettingAmountByDate" resultType="java.util.Map">
- select
- ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
- ifnull(sum(case when betting_type = 1 and is_winning = 1 then betting_amount * betting_multiple else 0.00 end), 0.00) as coinWin,
- ifnull(sum(case when betting_type = 1 and is_winning = 2 then betting_amount else 0.00 end), 0.00) as coinLose,
- ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum,
- ifnull(sum(case when betting_type = 0 and is_winning = 1 then betting_amount * betting_multiple else 0.00 end), 0.00) as diamondCoinWin,
- ifnull(sum(case when betting_type = 0 and is_winning = 2 then betting_amount else 0.00 end), 0.00) as diamondCoinLose
- from app_game_betting where game_id = #{gameId} and date_format(create_time, '%Y-%m-%d') = #{dateStr}
- </select>
- <select id="getBettingAmountByGameDate" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
- select
- betting_item as bettingTtem,
- sum(betting_amount) as orderAmount,
- sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
- sum(case when is_winning = 2 then betting_amount else 0.00 end) as loseAmount
- from app_game_betting where game_id = #{gameId} and game_date = #{gameDate} and betting_type = #{bettingType}
- group by betting_item
- </select>
- <sql id="selectAppGameBettingVo">
- select id, class_id, game_id, user_id, game_date, live_user_id, live_room_id, money_id, is_live, betting_type, betting_game_type, betting_item, betting_multiple, betting_amount, betting_commission, is_winning, create_time, update_time from app_game_betting
- </sql>
- <select id="selectAppGameBettingList" parameterType="com.game.business.domain.AppGameBetting" resultMap="AppGameBettingResult">
- <include refid="selectAppGameBettingVo"/>
- <where>
- <if test="classId != null "> and class_id = #{classId}</if>
- <if test="gameId != null "> and game_id = #{gameId}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="gameDate != null and gameDate != ''"> and game_date = #{gameDate}</if>
- <if test="liveUserId != null "> and live_user_id = #{liveUserId}</if>
- <if test="liveRoomId != null "> and live_room_id = #{liveRoomId}</if>
- <if test="moneyId != null "> and money_id = #{moneyId}</if>
- <if test="isLive != null and isLive != ''"> and is_live = #{isLive}</if>
- <if test="bettingType != null and bettingType != ''"> and betting_type = #{bettingType}</if>
- <if test="bettingGameType != null and bettingGameType != ''"> and betting_game_type = #{bettingGameType}</if>
- <if test="bettingItem != null and bettingItem != ''"> and betting_item = #{bettingItem}</if>
- <if test="bettingMultiple != null "> and betting_multiple = #{bettingMultiple}</if>
- <if test="bettingAmount != null "> and betting_amount = #{bettingAmount}</if>
- <if test="bettingCommission != null "> and betting_commission = #{bettingCommission}</if>
- <if test="isWinning != null and isWinning != ''"> and is_winning = #{isWinning}</if>
- <if test="beginTime != null and beginTime != ''"> and create_time > CONCAT(#{beginTime},' 00:00:00')</if>
- <if test="endTime != null and endTime != ''"> and create_time < CONCAT(#{endTime},' 23:59:59')</if>
- </where>
- order by create_time desc
- </select>
- <select id="selectAppGameBettingById" parameterType="Long" resultMap="AppGameBettingResult">
- <include refid="selectAppGameBettingVo"/>
- where id = #{id}
- </select>
- <insert id="insertAppGameBetting" parameterType="com.game.business.domain.AppGameBetting" useGeneratedKeys="true" keyProperty="id">
- insert into app_game_betting
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="classId != null">class_id,</if>
- <if test="gameId != null">game_id,</if>
- <if test="userId != null">user_id,</if>
- <if test="gameDate != null">game_date,</if>
- <if test="liveUserId != null">live_user_id,</if>
- <if test="liveRoomId != null">live_room_id,</if>
- <if test="moneyId != null">money_id,</if>
- <if test="isLive != null">is_live,</if>
- <if test="bettingType != null">betting_type,</if>
- <if test="bettingGameType != null">betting_game_type,</if>
- <if test="bettingItem != null">betting_item,</if>
- <if test="bettingMultiple != null">betting_multiple,</if>
- <if test="bettingAmount != null">betting_amount,</if>
- <if test="bettingCommission != null">betting_commission,</if>
- <if test="isWinning != null">is_winning,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="classId != null">#{classId},</if>
- <if test="gameId != null">#{gameId},</if>
- <if test="userId != null">#{userId},</if>
- <if test="gameDate != null">#{gameDate},</if>
- <if test="liveUserId != null">#{liveUserId},</if>
- <if test="liveRoomId != null">#{liveRoomId},</if>
- <if test="moneyId != null">#{moneyId},</if>
- <if test="isLive != null">#{isLive},</if>
- <if test="bettingType != null">#{bettingType},</if>
- <if test="bettingGameType != null">#{bettingGameType},</if>
- <if test="bettingItem != null">#{bettingItem},</if>
- <if test="bettingMultiple != null">#{bettingMultiple},</if>
- <if test="bettingAmount != null">#{bettingAmount},</if>
- <if test="bettingCommission != null">#{bettingCommission},</if>
- <if test="isWinning != null">#{isWinning},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updateAppGameBetting" parameterType="com.game.business.domain.AppGameBetting">
- update app_game_betting
- <trim prefix="SET" suffixOverrides=",">
- <if test="classId != null">class_id = #{classId},</if>
- <if test="gameId != null">game_id = #{gameId},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="gameDate != null">game_date = #{gameDate},</if>
- <if test="liveUserId != null">live_user_id = #{liveUserId},</if>
- <if test="liveRoomId != null">live_room_id = #{liveRoomId},</if>
- <if test="moneyId != null">money_id = #{moneyId},</if>
- <if test="isLive != null">is_live = #{isLive},</if>
- <if test="bettingType != null">betting_type = #{bettingType},</if>
- <if test="bettingGameType != null">betting_game_type = #{bettingGameType},</if>
- <if test="bettingItem != null">betting_item = #{bettingItem},</if>
- <if test="bettingMultiple != null">betting_multiple = #{bettingMultiple},</if>
- <if test="bettingAmount != null">betting_amount = #{bettingAmount},</if>
- <if test="bettingCommission != null">betting_commission = #{bettingCommission},</if>
- <if test="isWinning != null">is_winning = #{isWinning},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteAppGameBettingById" parameterType="Long">
- delete from app_game_betting where id = #{id}
- </delete>
- <delete id="deleteAppGameBettingByIds" parameterType="String">
- delete from app_game_betting where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="sumBettingAmount" resultType="java.lang.Double">
- select ifNull(sum(betting_amount),0) from app_game_betting
- <where>
- <if test="userId != null ">
- and user_id = #{userId}
- </if>
- <if test="gameId != null ">
- and game_id = #{gameId}
- </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>
- </select>
- </mapper>
|