<?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="cn.wisenergy.mapper.UserRechargeMapper"> <resultMap id="userMap" type="cn.wisenergy.model.app.UserRecharge"> <id column="id" property="id"/> <result column="user_id" property="userId"/> <result column="currency_id" property="currencyId"/> <result column="name" property="name"/> <result column="type" property="type"/> <result column="receive_addr" property="receiveAddr"/> <result column="from_addr" property="fromAddr"/> <result column="amount" property="amount"/> <result column="hash" property="hash"/> <result column="detail" property="detail"/> <result column="payer" property="payer"/> <result column="bank_name" property="bankName"/> <result column="bank_real_name" property="bankRealName"/> <result column="bank_card" property="bankCard"/> <result column="method" property="method"/> <result column="operate" property="operate"/> <result column="operate_at" property="operateAt"/> <result column="note" property="note"/> <result column="status" property="status"/> <result column="created_at" property="createdAt"/> <result column="updated_at" property="updatedAt"/> </resultMap> <sql id="table"> user_recharge </sql> <sql id="cols_all"> id, <include refid="cols_exclude_id"/> </sql> <sql id="cols_exclude_id"> user_id, currency_id, `name`, `type`, receive_addr, from_addr, amount, hash, detail, payer, bank_name, bank_real_name, bank_card, method, operate, operate_at, note, status, created_at, updated_at </sql> <sql id="vals"> #{userId},#{currencyId},#{name},#{type},#{receiveAddr},#{fromAddr},#{amount},#{hash},#{detail},#{payer}, #{bankName},#{bankRealName},#{bankCard},#{method},#{operate},#{operateAt},#{note},#{status},now(),now() </sql> <sql id="updateCondition"> <if test="userId != null">user_id = #{userId},</if> <if test="currencyId != null">currency_id =#{currencyId},</if> <if test="name != null">`name` =#{name},</if> <if test="type != null">`type` =#{type},</if> <if test="receiveAddr != null">receive_addr =#{receiveAddr},</if> <if test="fromAddr != null">from_addr = #{fromAddr},</if> <if test="amount != null">amount =#{amount},</if> <if test="hash != null">hash =#{hash},</if> <if test="detail != null">detail =#{detail},</if> <if test="payer != null">payer = #{payer},</if> <if test="token != null">token = #{token},</if> <if test="hash != null">hash =#{hash},</if> <if test="bankName != null">bank_name =#{bankName},</if> <if test="bankRealName != null">bank_real_name =#{bankRealName},</if> <if test="bankCard != null">bank_card =#{bankCard},</if> <if test="method != null">method = #{method},</if> <if test="operate != null">operate =#{operate},</if> <if test="operateAt != null">operate_at =#{operateAt},</if> <if test="note != null">note =#{note},</if> <if test="status != null">status = #{status},</if> update_time =now() </sql> <sql id="criteria"> <if test="id != null">id = #{id}</if> <if test="userId != null">and user_id = #{userId}</if> <if test="currencyId != null">and currency_id =#{currencyId}</if> <if test="name != null">and `name` =#{name}</if> <if test="type != null">and `type` =#{type}</if> <if test="receiveAddr != null">and receive_addr =#{receiveAddr}</if> <if test="fromAddr != null">and from_addr = #{fromAddr}</if> <if test="amount != null">and amount =#{amount}</if> <if test="hash != null">and hash =#{hash}</if> <if test="detail != null">and detail =#{detail}</if> <if test="payer != null">and payer = #{payer}</if> <if test="token != null">and token = #{token}</if> <if test="hash != null">and hash =#{hash}</if> <if test="bankName != null">and bank_name =#{bankName}</if> <if test="bankRealName != null">and bank_real_name =#{bankRealName}</if> <if test="bankCard != null">and bank_card =#{bankCard}</if> <if test="method != null">and method = #{method}</if> <if test="operate != null">and operate =#{operate}</if> <if test="operateAt != null">and operate_at =#{operateAt}</if> <if test="note != null">and note =#{note}</if> <if test="status != null">and status = #{status}</if> <if test="createdAt != null">and created_at >= #{createdAt}</if> <if test="updatedAt != null">and #{updatedAt} >= updated_at</if> </sql> <select id="getTotalRecharge" resultType="java.lang.Double"> select sum(amount) from user_recharge where status=1 and user_id=#{userId} </select> </mapper>