game-api/ff-admin/src/main/resources/mapper/common/TenantGameQuotaFlowMapper.xml

121 lines
6.4 KiB
XML

<?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.ff.common.mapper.TenantGameQuotaFlowMapper">
<resultMap type="TenantGameQuotaFlow" id="TenantGameQuotaFlowResult">
<result property="id" column="id" />
<result property="tenantKey" column="tenant_key" />
<result property="memberId" column="member_id" />
<result property="isOut" column="is_out" />
<result property="operationType" column="operation_type" />
<result property="balanceBefore" column="balance_before" />
<result property="balance" column="balance" />
<result property="balanceAfter" column="balance_after" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTenantGameQuotaFlowVo">
select id, tenant_key, member_id, is_out, operation_type, balance_before, balance, balance_after, remark, create_by, create_time, update_by, update_time from ff_tenant_game_quota_flow
</sql>
<select id="selectTenantGameQuotaFlowList" parameterType="TenantGameQuotaFlow" resultMap="TenantGameQuotaFlowResult">
<include refid="selectTenantGameQuotaFlowVo"/>
<where>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="memberId != null "> and member_id = #{memberId}</if>
<if test="isOut != null "> and is_out = #{isOut}</if>
<if test="operationType != null "> and operation_type = #{operationType}</if>
<if test="balanceBefore != null "> and balance_before = #{balanceBefore}</if>
<if test="balance != null "> and balance = #{balance}</if>
<if test="balanceAfter != null "> and balance_after = #{balanceAfter}</if>
</where>
</select>
<select id="selectTenantGameQuotaFlowById" parameterType="Long" resultMap="TenantGameQuotaFlowResult">
<include refid="selectTenantGameQuotaFlowVo"/>
where id = #{id}
</select>
<insert id="insertTenantGameQuotaFlow" parameterType="TenantGameQuotaFlow" useGeneratedKeys="true" keyProperty="id">
insert into ff_tenant_game_quota_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key,</if>
<if test="memberId != null">member_id,</if>
<if test="isOut != null">is_out,</if>
<if test="operationType != null">operation_type,</if>
<if test="balanceBefore != null">balance_before,</if>
<if test="balance != null">balance,</if>
<if test="balanceAfter != null">balance_after,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">#{tenantKey},</if>
<if test="memberId != null">#{memberId},</if>
<if test="isOut != null">#{isOut},</if>
<if test="operationType != null">#{operationType},</if>
<if test="balanceBefore != null">#{balanceBefore},</if>
<if test="balance != null">#{balance},</if>
<if test="balanceAfter != null">#{balanceAfter},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTenantGameQuotaFlow" parameterType="TenantGameQuotaFlow">
update ff_tenant_game_quota_flow
<trim prefix="SET" suffixOverrides=",">
<if test="tenantKey != null and tenantKey != ''">tenant_key = #{tenantKey},</if>
<if test="memberId != null">member_id = #{memberId},</if>
<if test="isOut != null">is_out = #{isOut},</if>
<if test="operationType != null">operation_type = #{operationType},</if>
<if test="balanceBefore != null">balance_before = #{balanceBefore},</if>
<if test="balance != null">balance = #{balance},</if>
<if test="balanceAfter != null">balance_after = #{balanceAfter},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTenantGameQuotaFlowById" parameterType="Long">
delete from ff_tenant_game_quota_flow where id = #{id}
</delete>
<delete id="deleteTenantGameQuotaFlowByIds" parameterType="String">
delete from ff_tenant_game_quota_flow where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getBalanceByMemberId" parameterType="TenantGameQuotaFlow" resultType="java.math.BigDecimal">
select ifnull(sum(balance),0) from ff_tenant_game_quota_flow
<where>
<if test="tenantKey != null and tenantKey != ''"> and tenant_key = #{tenantKey}</if>
<if test="memberId != null "> and member_id = #{memberId}</if>
<if test="isOut != null "> and is_out = #{isOut}</if>
<if test="operationType != null "> and operation_type = #{operationType}</if>
<if test="balanceBefore != null "> and balance_before = #{balanceBefore}</if>
<if test="balance != null "> and balance = #{balance}</if>
<if test="balanceAfter != null "> and balance_after = #{balanceAfter}</if>
</where>
group by member_id
</select>
</mapper>