<?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.sqx.modules.app.dao.UserMoneyDao">

    <update id="updateMayMoney">
        update user_money  set
        <if test="type==1">
            money=money+#{money}
        </if>
        <if test="type==2">
            money=money-#{money}
        </if>
        where user_id=#{userId}
    </update>

    <select id="selectMoney" resultType="com.sqx.modules.app.entity.UserMoney">
        select * from user_money where user_id = #{userId}
    </select>

    <update id="addMoney">
        update user_money set
        money = money+#{money}
        where user_id = #{userId}
    </update>

    <update id="addUserMoney">
        update user_money set
        <if test="type==1">
            money = money+#{money}
        </if>
        <if test="type==2">
            money = money-#{money}
        </if>
        where user_id = #{userId}
    </update>

    <update id="updateUserBalance">
        update tb_user set
        <if test="type==1">
            balance = balance+#{money}
        </if>
        <if test="type==2">
            balance = balance-#{money}
        </if>
        where user_id = #{userId}
    </update>

    <update id="updateCashDeposit">
        update tb_user set
        <if test="type==1">
            cash_deposit = cash_deposit+#{money}
        </if>
        <if test="type==2">
            cash_deposit = cash_deposit-#{money}
        </if>
        where user_id = #{userId}
    </update>

</mapper>