|
@@ -1,86 +1,86 @@
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<?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">
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.txz.cif.dao.RedEnvelopeMapper">
|
|
<mapper namespace="com.txz.cif.dao.RedEnvelopeMapper">
|
|
|
- <resultMap id="BaseResultMap" type="com.txz.cif.model.RedEnvelope">
|
|
|
|
|
- <!--
|
|
|
|
|
- WARNING - @mbg.generated
|
|
|
|
|
- -->
|
|
|
|
|
- <id column="id" jdbcType="BIGINT" property="id" />
|
|
|
|
|
- <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
|
|
|
|
|
- <result column="tran_no" jdbcType="VARCHAR" property="tranNo" />
|
|
|
|
|
- <result column="user_id" jdbcType="BIGINT" property="userId" />
|
|
|
|
|
- <result column="amount" jdbcType="DECIMAL" property="amount" />
|
|
|
|
|
- <result column="balance" jdbcType="DECIMAL" property="balance" />
|
|
|
|
|
- <result column="debit_account" jdbcType="BIGINT" property="debitAccount" />
|
|
|
|
|
- <result column="credit_account" jdbcType="BIGINT" property="creditAccount" />
|
|
|
|
|
- <result column="status" jdbcType="INTEGER" property="status" />
|
|
|
|
|
- <result column="biz_type" jdbcType="INTEGER" property="bizType" />
|
|
|
|
|
- <result column="trans_time" jdbcType="TIMESTAMP" property="transTime" />
|
|
|
|
|
- <result column="settle_time" jdbcType="TIMESTAMP" property="settleTime" />
|
|
|
|
|
- <result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
|
|
|
|
- <result column="update_user" jdbcType="VARCHAR" property="updateUser" />
|
|
|
|
|
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
|
|
|
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
|
|
|
- <result column="version" jdbcType="VARCHAR" property="version" />
|
|
|
|
|
|
|
+ <resultMap id="BaseResultMap" type="com.txz.cif.model.RedEnvelope">
|
|
|
|
|
+ <!--
|
|
|
|
|
+ WARNING - @mbg.generated
|
|
|
|
|
+ -->
|
|
|
|
|
+ <id column="id" jdbcType="BIGINT" property="id"/>
|
|
|
|
|
+ <result column="order_no" jdbcType="VARCHAR" property="orderNo"/>
|
|
|
|
|
+ <result column="tran_no" jdbcType="VARCHAR" property="tranNo"/>
|
|
|
|
|
+ <result column="user_id" jdbcType="BIGINT" property="userId"/>
|
|
|
|
|
+ <result column="amount" jdbcType="DECIMAL" property="amount"/>
|
|
|
|
|
+ <result column="balance" jdbcType="DECIMAL" property="balance"/>
|
|
|
|
|
+ <result column="debit_account" jdbcType="BIGINT" property="debitAccount"/>
|
|
|
|
|
+ <result column="credit_account" jdbcType="BIGINT" property="creditAccount"/>
|
|
|
|
|
+ <result column="status" jdbcType="INTEGER" property="status"/>
|
|
|
|
|
+ <result column="biz_type" jdbcType="INTEGER" property="bizType"/>
|
|
|
|
|
+ <result column="trans_time" jdbcType="TIMESTAMP" property="transTime"/>
|
|
|
|
|
+ <result column="settle_time" jdbcType="TIMESTAMP" property="settleTime"/>
|
|
|
|
|
+ <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
|
|
|
|
|
+ <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
|
|
|
|
|
+ <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
|
|
|
|
+ <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
|
|
|
|
+ <result column="version" jdbcType="VARCHAR" property="version"/>
|
|
|
|
|
|
|
|
- <result column="name" jdbcType="VARCHAR" property="name" />
|
|
|
|
|
- <result column="phone_no" jdbcType="VARCHAR" property="phoneNo" />
|
|
|
|
|
- <result column="memo" jdbcType="VARCHAR" property="memo" />
|
|
|
|
|
- </resultMap>
|
|
|
|
|
|
|
+ <result column="name" jdbcType="VARCHAR" property="name"/>
|
|
|
|
|
+ <result column="phone_no" jdbcType="VARCHAR" property="phoneNo"/>
|
|
|
|
|
+ <result column="memo" jdbcType="VARCHAR" property="memo"/>
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
|
|
|
- <select id="sumWithDay" resultType="java.math.BigDecimal">
|
|
|
|
|
- SELECT SUM(amount) AS total_amount
|
|
|
|
|
- FROM c_red_envelope
|
|
|
|
|
- WHERE user_id=#{userId}
|
|
|
|
|
- <if test="day != null">
|
|
|
|
|
- and trans_time >= #{day}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="type == 1">
|
|
|
|
|
- and status = 1
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="type == 2">
|
|
|
|
|
- and status = 2
|
|
|
|
|
- </if>
|
|
|
|
|
- </select>
|
|
|
|
|
|
|
+ <select id="sumWithDay" resultType="java.math.BigDecimal">
|
|
|
|
|
+ SELECT SUM(amount) AS total_amount
|
|
|
|
|
+ FROM c_red_envelope
|
|
|
|
|
+ WHERE user_id=#{userId}
|
|
|
|
|
+ <if test="day != null">
|
|
|
|
|
+ and trans_time >= #{day}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="type == 1">
|
|
|
|
|
+ and status = 1
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="type == 2">
|
|
|
|
|
+ and status = 2
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </select>
|
|
|
|
|
|
|
|
- <select id="top" resultType="com.txz.cif.web.bo.UserTopBo">
|
|
|
|
|
- SELECT
|
|
|
|
|
- user_id as userId,
|
|
|
|
|
- SUM(amount) AS l7DEarnings,
|
|
|
|
|
- count(id) AS groupNum
|
|
|
|
|
- FROM
|
|
|
|
|
- c_red_envelope
|
|
|
|
|
- WHERE
|
|
|
|
|
- create_time >= #{startTime}
|
|
|
|
|
- GROUP BY
|
|
|
|
|
- user_id
|
|
|
|
|
- ORDER BY
|
|
|
|
|
- l7DEarnings DESC
|
|
|
|
|
- </select>
|
|
|
|
|
|
|
+ <select id="top" resultType="com.txz.cif.web.bo.UserTopBo">
|
|
|
|
|
+ SELECT user_id AS userId, SUM(amount) AS l7DEarnings, COUNT(id) AS groupNum
|
|
|
|
|
+ FROM c_red_envelope
|
|
|
|
|
+ WHERE create_time >= #{startTime}
|
|
|
|
|
+ GROUP BY user_id
|
|
|
|
|
+ ORDER BY l7DEarnings DESC
|
|
|
|
|
+ </select>
|
|
|
|
|
|
|
|
- <select id="sumWithOrderNo" resultType="com.txz.cif.dto.EarningsDTO">
|
|
|
|
|
- SELECT SUM(amount) AS earnings, user_id as userId,order_no as orderNo
|
|
|
|
|
- FROM c_red_envelope
|
|
|
|
|
- WHERE order_no=#{orderNo}
|
|
|
|
|
- AND user_id = #{userId}
|
|
|
|
|
- group by user_id
|
|
|
|
|
- </select>
|
|
|
|
|
|
|
+ <select id="sumWithOrderNo" resultType="com.txz.cif.dto.EarningsDTO">
|
|
|
|
|
+ SELECT SUM(amount) AS earnings, user_id AS userId, order_no AS orderNo
|
|
|
|
|
+ FROM c_red_envelope
|
|
|
|
|
+ WHERE order_no = #{orderNo}
|
|
|
|
|
+ AND user_id = #{userId}
|
|
|
|
|
+ GROUP BY user_id
|
|
|
|
|
+ </select>
|
|
|
|
|
|
|
|
- <select id="sumByStatus" resultType="java.math.BigDecimal">
|
|
|
|
|
- SELECT SUM(amount)
|
|
|
|
|
- FROM c_red_envelope
|
|
|
|
|
- WHERE
|
|
|
|
|
- 1=1
|
|
|
|
|
- <if test="status == 1">
|
|
|
|
|
- and status = 1
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="status == 2">
|
|
|
|
|
- and status = 2
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="bizType != null">
|
|
|
|
|
- and biz_type = #{bizType}
|
|
|
|
|
- </if>
|
|
|
|
|
- and create_time >= #{startTime} and #{endTime} >= create_time
|
|
|
|
|
- and user_id = #{userId} <!-- 添加分片键确保查询正确路由 -->
|
|
|
|
|
- </select>
|
|
|
|
|
|
|
+ <select id="queryOrderNo" resultType="com.txz.cif.dto.EarningsDTO">
|
|
|
|
|
+ SELECT amount AS earnings, user_id AS userId, order_no AS orderNo, biz_type AS bizType
|
|
|
|
|
+ FROM c_red_envelope
|
|
|
|
|
+ WHERE order_no = #{orderNo}
|
|
|
|
|
+ AND user_id = #{userId}
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="sumByStatus" resultType="java.math.BigDecimal">
|
|
|
|
|
+ SELECT SUM(amount)
|
|
|
|
|
+ FROM c_red_envelope
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ 1=1
|
|
|
|
|
+ <if test="status == 1">
|
|
|
|
|
+ and status = 1
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="status == 2">
|
|
|
|
|
+ and status = 2
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="bizType != null">
|
|
|
|
|
+ and biz_type = #{bizType}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ and create_time >= #{startTime} and #{endTime} >= create_time
|
|
|
|
|
+ and user_id = #{userId} <!-- 添加分片键确保查询正确路由 -->
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|
|
</mapper>
|