<?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>

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

    <update id="updateBalance">
        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>
    <select id="getRiderList" resultType="com.sqx.modules.app.entity.UserEntity">
        select * from tb_user u where 1=1
        <if test="userEntity.phone!=null and userEntity.phone!=''">
            and phone like concat("%",#{userEntity.phone},"%")
        </if>
        <if test="userEntity.nickName!=null and userEntity.nickName!=''">
            and nick_name like concat("%",#{userEntity.nickName},"%")
        </if>
        and user_type = 2
        and cash_deposit &gt;= #{deposit}
        order by create_time desc
    </select>

</mapper>