<?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.money.UserMoneyDetailMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.money.UserMoneyDetail">
|
<id column="umd_id" property="id" jdbcType="BIGINT" />
|
<result column="umd_money" property="money" jdbcType="DECIMAL" />
|
<result column="umd_type" property="type"
|
typeHandler="com.yeshi.fanli.util.mybatishandler.UserMoneyDetailTypeEnumHandler" />
|
<result column="umd_title" property="title" jdbcType="VARCHAR" />
|
<result column="umd_sub_title" property="subTitle" jdbcType="VARCHAR" />
|
<result column="umd_desc_info" property="descInfo" jdbcType="VARCHAR" />
|
<result column="umd_source_identify_id" property="sourceIdentifyId"
|
jdbcType="BIGINT" />
|
<result column="umd_identify_code" property="identifyCode"
|
jdbcType="VARCHAR" />
|
<result column="umd_beizhu" property="beiZhu" jdbcType="VARCHAR" />
|
<result column="umd_createtime" property="createTime" jdbcType="TIMESTAMP" />
|
<result column="umd_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
|
<!-- 老版明细适用该字段 -->
|
<result column="state" property="state" jdbcType="INTEGER" />
|
<result column="umd_order_type" property="orderType" jdbcType="INTEGER" />
|
<result column="umd_show" property="show" jdbcType="BOOLEAN" />
|
<association property="userInfo" column="umd_uid"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="umd_uid" property="id" jdbcType="BIGINT" />
|
</association>
|
|
</resultMap>
|
<resultMap id="UserMonthMoneyMap" type="com.yeshi.fanli.vo.money.UserMonthMoneyVO">
|
<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">umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type,umd_show
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user_money_detail where umd_id = #{id,jdbcType=BIGINT}
|
</select>
|
<select id="selectByUidWithIndexId" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM yeshi_ec_user_money_detail d WHERE d.`umd_createtime` <![CDATA[
|
<=
|
]]>
|
(SELECT d.`umd_createtime` FROM yeshi_ec_user_money_detail d WHERE
|
d.`umd_id`=#{id}) and d.umd_uid=#{uid} and d.umd_show=1
|
<if test="type == 1">and d.umd_money<![CDATA[>]]>0</if>
|
<if test="type == 2">and d.umd_money<![CDATA[<=]]>0</if>
|
order by d.`umd_createtime`
|
desc,d.umd_id desc limit #{count}
|
</select>
|
<select id="selectCountByUid" resultType="java.lang.Long"
|
parameterType="java.lang.Long">SELECT count(umd_id) FROM yeshi_ec_user_money_detail
|
where umd_uid=#{uid} and umd_show=1
|
<if test="type == 1">and umd_money<![CDATA[>]]>0</if>
|
<if test="type == 2">and umd_money<![CDATA[<=]]>0</if>
|
</select>
|
<select id="selectByMaxCreateTime" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM yeshi_ec_user_money_detail d WHERE d.umd_uid=#{uid} and d.umd_show=1 and d.`umd_createtime`<![CDATA[<=]]>#{date}
|
<if test="type == 1">and d.umd_money<![CDATA[>]]>0</if>
|
<if test="type == 2">and d.umd_money<![CDATA[<=]]>0</if>
|
order by d.`umd_createtime` desc,d.umd_id desc limit ${count}
|
</select>
|
<select id="selectCountByUidAndMaxCreateTime" resultType="java.lang.Long">SELECT
|
count(umd_id) FROM yeshi_ec_user_money_detail where umd_uid=#{uid} and umd_show=1 and
|
`umd_createtime`<![CDATA[<=]]>#{date}
|
<if test="type == 1">and umd_money<![CDATA[>]]>0</if>
|
<if test="type == 2">and umd_money<![CDATA[<=]]>0</if>
|
</select>
|
<select id="selectMonthCountByUid" resultType="java.lang.Integer">SELECT
|
COUNT(*) FROM (SELECT * FROM yeshi_ec_user_money_detail d WHERE
|
d.`umd_uid`=#{uid} and d.umd_show=1 and d.`umd_createtime` <![CDATA[<=]]>
|
#{date}
|
<if test="type == 1">and d.umd_money<![CDATA[>]]>0</if>
|
<if test="type == 2">and d.umd_money<![CDATA[<=]]>0</if>
|
group by DATE_FORMAT(d.`umd_createtime`,'%y-%m')) a
|
</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.`umd_createtime`,'%Y-%m') AS `time`,SUM(d.`umd_money`) AS money
|
FROM `yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} and d.umd_show=1 AND
|
d.`umd_money`>=0 AND DATE_FORMAT(
|
d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY DATE_FORMAT(
|
d.`umd_createtime`,'%Y-%m') ) a on a.time=c.time LEFT JOIN ( SELECT
|
DATE_FORMAT( d.`umd_createtime`,'%Y-%m') AS
|
`time`,SUM(d.`umd_money`) AS money FROM `yeshi_ec_user_money_detail`
|
d WHERE d.`umd_uid`=#{uid} and d.umd_show=1 AND d.`umd_money`<![CDATA[<0]]>
|
AND DATE_FORMAT( d.`umd_createtime`,'%Y-%m')=#{item} GROUP BY
|
DATE_FORMAT( d.`umd_createtime`,'%Y-%m') ) b ON c.time=b.time
|
</trim>
|
</foreach>
|
</select>
|
<select id="selectByUidWithState" resultMap="BaseResultMap">SELECT a.* FROM
|
((SELECT d.*,-1 AS state FROM `yeshi_ec_user_money_detail` d WHERE
|
d.`umd_uid`=#{uid} AND (d.`umd_type`!='extract' AND
|
d.`umd_type`!='extractReject') ) UNION ALL( SELECT d.*,-1 AS state
|
FROM `yeshi_ec_user_money_detail` d LEFT JOIN `yeshi_ec_extract` e ON
|
e.`id`=d.umd_source_identify_id WHERE d.`umd_uid`=#{uid} AND
|
d.umd_type='extractReject' ) UNION ALL( SELECT d.*,e.state FROM
|
`yeshi_ec_user_money_detail` d LEFT JOIN `yeshi_ec_extract` e ON
|
e.`id`=d.`umd_source_identify_id` WHERE d.`umd_uid`=#{uid} AND
|
d.umd_type='extract' )) a ORDER BY a.umd_createtime DESC LIMIT
|
#{start},#{count}</select>
|
<select id="selectCountByUidWithState" resultType="java.lang.Long">SELECT
|
count(*) FROM ((SELECT d.*,-1 AS state FROM
|
`yeshi_ec_user_money_detail` d WHERE d.`umd_uid`=#{uid} AND
|
(d.`umd_type`!='extract' AND d.`umd_type`!='extractReject') ) UNION
|
ALL( SELECT d.*,-1 AS state FROM `yeshi_ec_user_money_detail` d LEFT
|
JOIN `yeshi_ec_extract` e ON e.`id`=d.umd_source_identify_id WHERE
|
d.`umd_uid`=#{uid} AND d.umd_type='extractReject' ) UNION ALL( SELECT
|
d.*,e.state FROM `yeshi_ec_user_money_detail` d LEFT JOIN
|
`yeshi_ec_extract` e ON e.`id`=d.`umd_source_identify_id` WHERE
|
d.`umd_uid`=#{uid} AND d.umd_type='extract' )) a</select>
|
<select id="getTotalMoneyByTypeAndUidWithDate" resultType="java.math.BigDecimal">select
|
sum(umd_money) from yeshi_ec_user_money_detail where umd_uid=#{uid}
|
<if test="show != null"> AND umd_show = #{show}</if>
|
and umd_createtime>=#{minDate} and umd_createtime<![CDATA[<]]>#{maxDate}
|
<foreach collection="typeList" item="item" open=" and ("
|
separator=" or " close=")">umd_type=#{item}</foreach>
|
</select>
|
<select id="selectByTypeAndUidAndIdentifyCode" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_user_money_detail where umd_uid=#{uid} and
|
umd_type=#{type} and umd_source_identify_id=#{sourceIdentifyId}
|
</select>
|
|
<select id="listQuery" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" /> from yeshi_ec_user_money_detail
|
<if test="key != null and key !=''">
|
<if test="keyType == 1"> where umd_uid = #{key}</if>
|
<if test="keyType == 2"> where umd_uid like '${key}%'</if>
|
</if>
|
order by umd_id DESC
|
LIMIT #{start},#{count}
|
</select>
|
|
<select id="countQuery" resultType ="Long">
|
select count(umd_id) from yeshi_ec_user_money_detail
|
<if test="key != null and key !=''">
|
<if test="keyType == 1"> where umd_uid = #{key}</if>
|
<if test="keyType == 2"> where umd_uid like '${key}%'</if>
|
</if>
|
</select>
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_user_money_detail where umd_id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"
|
useGeneratedKeys="true" keyProperty="id">insert into
|
yeshi_ec_user_money_detail
|
(umd_id,umd_uid,umd_money,umd_type,umd_title,umd_sub_title,umd_desc_info,umd_source_identify_id,umd_identify_code,umd_beizhu,umd_createtime,umd_updatetime,umd_order_type,umd_show)
|
values
|
(#{id,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{title,jdbcType=VARCHAR},#{subTitle,jdbcType=VARCHAR},#{descInfo,jdbcType=VARCHAR},#{sourceIdentifyId,jdbcType=BIGINT},#{identifyCode,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{orderType,jdbcType=INTEGER},#{show,jdbcType=BOOLEAN})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_user_money_detail
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">umd_id,</if>
|
<if test="userInfo != null">umd_uid,</if>
|
<if test="money != null">umd_money,</if>
|
<if test="type != null">umd_type,</if>
|
<if test="title != null">umd_title,</if>
|
<if test="subTitle != null">umd_sub_title,</if>
|
<if test="descInfo != null">umd_desc_info,</if>
|
<if test="sourceIdentifyId != null">umd_source_identify_id,</if>
|
<if test="identifyCode != null">umd_identify_code,</if>
|
<if test="beiZhu != null">umd_beizhu,</if>
|
<if test="createTime != null">umd_createtime,</if>
|
<if test="updateTime != null">umd_updatetime,</if>
|
<if test="orderType != null">umd_order_type,</if>
|
<if test="show != null">umd_show,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
<if test="type != null">#{type,jdbcType=VARCHAR},</if>
|
<if test="title != null">#{title,jdbcType=VARCHAR},</if>
|
<if test="subTitle != null">#{subTitle,jdbcType=VARCHAR},</if>
|
<if test="descInfo != null">#{descInfo,jdbcType=VARCHAR},</if>
|
<if test="sourceIdentifyId != null">#{sourceIdentifyId,jdbcType=BIGINT},</if>
|
<if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if>
|
<if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
<if test="orderType != null">#{orderType,jdbcType=INTEGER},</if>
|
<if test="show != null">#{show,jdbcType=BOOLEAN}</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">update
|
yeshi_ec_user_money_detail set umd_uid =
|
#{userInfo.id,jdbcType=BIGINT},umd_money =
|
#{money,jdbcType=DECIMAL},umd_type =
|
#{type,jdbcType=VARCHAR},umd_title =
|
#{title,jdbcType=VARCHAR},umd_sub_title =
|
#{subTitle,jdbcType=VARCHAR},umd_desc_info =
|
#{descInfo,jdbcType=VARCHAR},umd_source_identify_id =
|
#{sourceIdentifyId,jdbcType=BIGINT},umd_identify_code =
|
#{identifyCode,jdbcType=VARCHAR},umd_beizhu =
|
#{beiZhu,jdbcType=VARCHAR},umd_createtime =
|
#{createTime,jdbcType=TIMESTAMP},umd_updatetime =
|
#{updateTime,jdbcType=TIMESTAMP} ,umd_order_type
|
=#{orderType,jdbcType=INTEGER},umd_show
|
=#{show,jdbcType=BOOLEAN} where umd_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.money.UserMoneyDetail">
|
update yeshi_ec_user_money_detail
|
<set>
|
<if test="userInfo != null">umd_uid=#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="money != null">umd_money=#{money,jdbcType=DECIMAL},</if>
|
<if test="type != null">umd_type=#{type,jdbcType=VARCHAR},</if>
|
<if test="title != null">umd_title=#{title,jdbcType=VARCHAR},</if>
|
<if test="subTitle != null">umd_sub_title=#{subTitle,jdbcType=VARCHAR},</if>
|
<if test="descInfo != null">umd_desc_info=#{descInfo,jdbcType=VARCHAR},</if>
|
<if test="sourceIdentifyId != null">umd_source_identify_id=#{sourceIdentifyId,jdbcType=BIGINT},
|
</if>
|
<if test="identifyCode != null">umd_identify_code=#{identifyCode,jdbcType=VARCHAR},</if>
|
<if test="beiZhu != null">umd_beizhu=#{beiZhu,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">umd_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">umd_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
|
<if test="orderType !=null">umd_order_type =#{orderType,jdbcType=INTEGER},</if>
|
<if test="show !=null">umd_show =#{show,jdbcType=BOOLEAN},</if>
|
</set>
|
where umd_id = #{id,jdbcType=BIGINT}
|
</update>
|
</mapper>
|