1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?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.txz.cif.dao.AccountMapper">
- <resultMap id="BaseResultMap" type="com.txz.cif.model.Account">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
- <result column="aliases" jdbcType="VARCHAR" property="aliases" />
- <result column="subject_type" jdbcType="INTEGER" property="subjectType" />
- <result column="biz_type" jdbcType="INTEGER" property="bizType" />
- <result column="user_id" jdbcType="BIGINT" property="userId" />
- <result column="name" jdbcType="VARCHAR" property="name" />
- <result column="direction" jdbcType="VARCHAR" property="direction" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="balance" jdbcType="DECIMAL" property="balance" />
- <result column="freeze_amount" jdbcType="DECIMAL" property="freezeAmount" />
- <result column="before_day_balance" jdbcType="DECIMAL" property="beforeDayBalance" />
- <result column="before_day_init_balance" jdbcType="DECIMAL" property="beforeDayInitBalance" />
- <result column="total_in_amount" jdbcType="DECIMAL" property="totalInamount" />
- <result column="total_out_amount" jdbcType="DECIMAL" property="totalOutAmount" />
- <result column="before_day_time" jdbcType="TIMESTAMP" property="beforeDayTime" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="version" jdbcType="VARCHAR" property="version" />
- </resultMap>
- <select id="sumTodayInit" resultType="java.math.BigDecimal" >
- select sum(before_day_init_balance) from c_account where DATE(before_day_time) = CURDATE() and aliases like #{aliases} ;
- </select>
- <select id="sumBeforInit" resultType="java.math.BigDecimal" >
- select sum(before_day_balance) from c_account where DATE(before_day_time) != CURDATE() and aliases like #{aliases};
- </select>
- <select id="sumTodayEnd" resultType="java.math.BigDecimal" >
- select sum(before_day_balance) from c_account where DATE(before_day_time) = CURDATE() and aliases like #{aliases};
- </select>
- <select id="sumBeforEnd" resultType="java.math.BigDecimal" >
- select sum(balance) from c_account where DATE(before_day_time) != CURDATE() and aliases like #{aliases};
- </select>
- <update id="dealWithDayCut" >
- update c_account
- set balance = balance + #{amount}
- ,before_day_time = CURRENT_DATE
- ,before_day_init_balance = before_day_balance
- ,before_day_balance = balance
- where id = #{accountId}
- <if test="accountId != 5">
- and balance + #{amount} >= 0
- </if>
- and DATE_FORMAT( before_day_time, '%Y-%m-%d' ) != CURRENT_DATE
- </update>
- <update id="deal">
- UPDATE c_account
- SET balance = balance + #{amount},
- total_in_amount = total_in_amount + CASE
- WHEN #{amount} > 0 THEN #{amount}
- ELSE 0
- END,
- total_out_amount = total_out_amount + CASE
- WHEN 0 > #{amount} THEN -#{amount}
- ELSE 0
- END
- WHERE id = #{accountId}
- <choose>
- <when test="accountId != 5">
- AND balance + #{amount} >= 0
- </when>
- <otherwise>
- <!-- 账户ID为5时的特殊处理 -->
- AND 1=1
- </otherwise>
- </choose>
- </update>
- <update id="dealFreeze" >
- update c_account set freeze_amount = freeze_amount + #{amount} where id = #{accountId} and freeze_amount + #{amount} >= 0
- </update>
- </mapper>
|