<?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.yeshi.fanli.dao.mybatis.integral.IntegralDetailMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.integral.IntegralDetail">
|
<id column="td_id" property="id" jdbcType="BIGINT"/>
|
<result column="td_uid" property="uid" jdbcType="BIGINT"/>
|
<result column="td_money" property="money" jdbcType="INTEGER"/>
|
<result column="td_title" property="title" jdbcType="VARCHAR"/>
|
<result column="td_desc_info" property="descInfo" jdbcType="VARCHAR"/>
|
<result column="td_remark" property="remark" jdbcType="VARCHAR"/>
|
<result column="td_unique_key" property="uniqueKey" jdbcType="VARCHAR"/>
|
<result column="td_create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
</resultMap>
|
|
<resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.integral.IntegralMonthVO">
|
<result column="expend" property="expend" jdbcType="DECIMAL" />
|
<result column="income" property="income" jdbcType="DECIMAL" />
|
<result column="dateFormate" property="dateFormate" jdbcType="VARCHAR" />
|
</resultMap>
|
|
<sql id="Base_Column_List">td_id,td_uid,td_money,td_title,td_desc_info,td_remark,td_unique_key,td_create_time</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
|
<include refid="Base_Column_List"/>from yeshi_ec_integral_detail where td_id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_integral_detail where td_id = #{id,jdbcType=BIGINT}</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_detail (td_id,td_uid,td_money,td_title,td_desc_info,td_remark,td_unique_key,td_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=INTEGER},#{title,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{uniqueKey,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_integral_detail
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">td_id,</if>
|
<if test="uid != null">td_uid,</if>
|
<if test="money != null">td_money,</if>
|
<if test="title != null">td_title,</if>
|
<if test="descInfo != null">td_desc_info,</if>
|
<if test="remark != null">td_remark,</if>
|
<if test="uniqueKey != null">td_unique_key,</if>
|
<if test="createTime != null">td_create_time,</if>
|
</trim>values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="uid != null">#{uid,jdbcType=BIGINT},</if>
|
<if test="money != null">#{money,jdbcType=INTEGER},</if>
|
<if test="title != null">#{title,jdbcType=VARCHAR},</if>
|
<if test="descInfo != null">#{descInfo,jdbcType=VARCHAR},</if>
|
<if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
|
<if test="uniqueKey != null">#{uniqueKey,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail">update yeshi_ec_integral_detail set td_uid = #{uid,jdbcType=BIGINT},td_money = #{money,jdbcType=INTEGER},td_title = #{title,jdbcType=VARCHAR},td_desc_info = #{descInfo,jdbcType=VARCHAR},td_remark = #{remark,jdbcType=VARCHAR},td_unique_key = #{uniqueKey,jdbcType=VARCHAR},td_create_time = #{createTime,jdbcType=TIMESTAMP} where td_id = #{id,jdbcType=BIGINT}</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.IntegralDetail">update yeshi_ec_integral_detail
|
<set>
|
<if test="uid != null">td_uid=#{uid,jdbcType=BIGINT},</if>
|
<if test="money != null">td_money=#{money,jdbcType=INTEGER},</if>
|
<if test="title != null">td_title=#{title,jdbcType=VARCHAR},</if>
|
<if test="descInfo != null">td_desc_info=#{descInfo,jdbcType=VARCHAR},</if>
|
<if test="remark != null">td_remark=#{remark,jdbcType=VARCHAR},</if>
|
<if test="uniqueKey != null">td_unique_key=#{uniqueKey,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">td_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
</set> where td_id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<select id="getDetailByUniqueKey" resultMap="BaseResultMap">
|
SELECT * FROM yeshi_ec_integral_detail
|
WHERE td_unique_key = #{uniqueKey}
|
</select>
|
|
|
<select id="selectCountByUid" resultType="java.lang.Long" parameterType="java.lang.Long">
|
SELECT count(td_id) FROM yeshi_ec_integral_detail
|
WHERE td_uid = #{uid}
|
<if test="type == 1">AND td_money <![CDATA[>]]> 0</if>
|
<if test="type == 2">AND td_money <![CDATA[<]]> 0</if>
|
</select>
|
|
<select id="selectMonthCountByUid" resultType="java.lang.Integer">
|
SELECT COUNT(*) FROM
|
(SELECT * FROM yeshi_ec_integral_detail d
|
WHERE d.`td_uid`=#{uid} AND d.`td_create_time` <![CDATA[<=]]> #{date}
|
<if test="type == 1">AND d.td_money <![CDATA[>]]> 0</if>
|
<if test="type == 2">AND d.td_money <![CDATA[<]]> 0</if>
|
GROUP BY DATE_FORMAT(d.`td_create_time`,'%y-%m')
|
) a
|
</select>
|
|
|
<select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">
|
SELECT count(td_id) FROM yeshi_ec_integral_detail
|
WHERE td_uid=#{uid} and `td_create_time`<![CDATA[<=]]>#{date}
|
<if test="type == 1">AND td_money <![CDATA[>]]> 0</if>
|
<if test="type == 2">AND td_money <![CDATA[<]]> 0</if>
|
</select>
|
|
<select id="selectByMaxCreateTime" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_integral_detail t
|
WHERE t.`td_uid`=#{uid} AND t.`td_create_time`<![CDATA[<=]]> #{date}
|
<if test="type == 1">AND t.td_money <![CDATA[>]]> 0</if>
|
<if test="type == 2">AND t.td_money <![CDATA[<]]> 0</if>
|
ORDER BY t.`td_create_time` DESC,t.td_id DESC
|
LIMIT #{count}
|
</select>
|
|
<select id="selectByUidWithIndexId" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_integral_detail t
|
WHERE t.`td_uid`=#{uid}
|
AND t.`td_create_time`<![CDATA[<=]]>(SELECT td_create_time FROM yeshi_ec_integral_detail WHERE td_id =#{id})
|
<if test="type == 1">AND t.td_money <![CDATA[>]]> 0</if>
|
<if test="type == 2">AND t.td_money <![CDATA[<]]> 0</if>
|
ORDER BY t.`td_create_time` DESC,t.td_id DESC
|
LIMIT #{count}
|
</select>
|
|
<select id="selectMonthMoneyByUid" resultMap="UserMonthMoneyMap">
|
<foreach collection="dateFormat" index="index" item="item"
|
separator="UNION ALL">
|
<trim prefix="(" suffix=")">
|
SELECT c.time AS dateFormate , IF(a.money IS NULL,0,a.money) AS income ,IF(b.money IS NULL,0,b.money) AS expend
|
FROM (SELECT #{item} AS `time`) c
|
LEFT JOIN (SELECT DATE_FORMAT(d.`td_create_time`,'%Y-%m') AS `time`,SUM(d.`td_money`)AS money
|
FROM `yeshi_ec_integral_detail` d
|
WHERE d.`td_uid`=#{uid} AND d.`td_money`<![CDATA[>=]]>0 AND DATE_FORMAT(d.`td_create_time`,'%Y-%m')=#{item}
|
GROUP BY DATE_FORMAT(d.`td_create_time`,'%Y-%m')
|
) a ON a.time=c.time
|
|
LEFT JOIN(SELECT DATE_FORMAT(d.`td_create_time`,'%Y-%m') AS `time`,SUM(d.`td_money`) AS money
|
FROM `yeshi_ec_integral_detail` d
|
WHERE d.`td_uid`=#{uid} AND d.`td_money` <![CDATA[<]]>0 AND DATE_FORMAT(d.`td_create_time`,'%Y-%m')=#{item}
|
GROUP BY DATE_FORMAT(d.`td_create_time`,'%Y-%m')
|
) b ON c.time=b.time
|
</trim>
|
</foreach>
|
</select>
|
|
<select id="getCumulativeMoney" resultType="BigDecimal">
|
SELECT IFNULL(SUM(d.`td_money`),0) FROM `yeshi_ec_integral_detail` d
|
WHERE d.`td_uid` = #{uid} AND d.`td_money` > 0;
|
</select>
|
|
|
<select id="countNewAddByDate" resultType = "Long">
|
SELECT SUM(d.`td_money`) FROM `yeshi_ec_integral_detail` d
|
WHERE d.`td_money` > 0 AND TO_DAYS(d.`td_create_time`) = TO_DAYS(#{preDay})
|
</select>
|
|
|
<select id="listQuery" resultMap="BaseResultMap">
|
SELECT * FROM `yeshi_ec_integral_detail` d
|
<if test="key != null and key != ''">WHERE d.`td_uid` LIKE '%${key}%'</if>
|
ORDER BY d.`td_id` DESC
|
LIMIT #{start},#{count}
|
</select>
|
|
<select id="countQuery" resultType = "Long">
|
SELECT COUNT(d.`td_id`) FROM `yeshi_ec_integral_detail` d
|
<if test="key != null and key != ''">WHERE d.`td_uid` LIKE '%${key}%'</if>
|
</select>
|
</mapper>
|