账户等级福利-收回时间改为30天收回;红包扣除消息模板改备注:未被领取或领取后未使用部分退回
4个文件已修改
531 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinOriginMapper.java 196 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinOriginMapper.xml 273 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinOriginMapper.java
@@ -1,95 +1,103 @@
package com.yeshi.fanli.dao.mybatis.tlj;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin;
public interface UserTaoLiJinOriginMapper extends BaseMapper<UserTaoLiJinOrigin> {
    /**
     * 根据日期类型统计金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    BigDecimal countMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType);
    /**
     * 根据用户、来源统计
     * @param uid
     * @param origin
     * @return
     */
    long countByUidAndOrigin(@Param("uid")long uid, @Param("origin")String origin);
    /**
     * 根据用户、来源统计
     * @param uid
     * @param origin
     * @return
     */
    UserTaoLiJinOrigin getByUidAndOrigin(@Param("uid")long uid, @Param("origin")String origin);
    /**
     *  统计本月等级红包
     * @param uid
     * @param origin
     * @return
     */
    long countRankByThisMonth(@Param("uid")long uid);
    /**
     *  统计本月等级红包
     * @param uid
     * @param origin
     * @return
     */
    UserTaoLiJinOrigin  getRankByThisMonth(@Param("uid")long uid, @Param("type")String type);
    /**
     * 查询过期的红包
     * @param date
     * @return
     */
    List<UserTaoLiJinOrigin> getOverdueTaoLiJin(@Param("uid")long uid, @Param("date")Date date);
    /**
     * 查询剩余淘礼金
     * @param uid
     * @return
     */
    List<UserTaoLiJinOrigin> getSurplusLiJin(@Param("uid")long uid);
    /**
     * 统计用户红包记录
     * @param uid
     * @return
     */
    long countByUidAndType(@Param("uid")long uid, @Param("type")String type);
    /**
     * 统计金额
     * @param rightsId
     * @param origin
     * @return
     */
    BigDecimal countMoneyByOrigin(@Param("rightsId")String rightsId, @Param("origin")String origin);
    /**
     * 根据淘礼金id查询
     * @param rightsId
     * @return
     */
    UserTaoLiJinOrigin getOriginByRightsId(@Param("rightsId")String rightsId);
package com.yeshi.fanli.dao.mybatis.tlj;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin;
public interface UserTaoLiJinOriginMapper extends BaseMapper<UserTaoLiJinOrigin> {
    /**
     * 根据日期类型统计金额
     * @param uid
     * @param dateType 1今日 、2昨日、3本月、4上月
     * @return
     */
    BigDecimal countMoneyByDate(@Param("uid")long uid, @Param("dateType")int dateType);
    /**
     * 根据用户、来源统计
     * @param uid
     * @param origin
     * @return
     */
    long countByUidAndOrigin(@Param("uid")long uid, @Param("origin")String origin);
    /**
     * 根据用户、来源统计
     * @param uid
     * @param origin
     * @return
     */
    UserTaoLiJinOrigin getByUidAndOrigin(@Param("uid")long uid, @Param("origin")String origin);
    /**
     *  统计本月等级红包
     * @param uid
     * @param origin
     * @return
     */
    long countRankByThisMonth(@Param("uid")long uid);
    /**
     *  统计本月等级红包
     * @param uid
     * @param origin
     * @return
     */
    UserTaoLiJinOrigin  getRankByThisMonth(@Param("uid")long uid, @Param("type")String type);
    /**
     * 查询过期的红包 排除等级
     * @param date
     * @return
     */
    List<UserTaoLiJinOrigin> getOverdueTaoLiJin(@Param("uid")long uid, @Param("date")Date date);
    /**
     * 查询过期的红包-等级
     * @param date
     * @return
     */
    List<UserTaoLiJinOrigin> getOverdueTaoLiJinByRank(@Param("uid")long uid, @Param("date")Date date);
    /**
     * 查询剩余淘礼金
     * @param uid
     * @return
     */
    List<UserTaoLiJinOrigin> getSurplusLiJin(@Param("uid")long uid);
    /**
     * 统计用户红包记录
     * @param uid
     * @return
     */
    long countByUidAndType(@Param("uid")long uid, @Param("type")String type);
    /**
     * 统计金额
     * @param rightsId
     * @param origin
     * @return
     */
    BigDecimal countMoneyByOrigin(@Param("rightsId")String rightsId, @Param("origin")String origin);
    /**
     * 根据淘礼金id查询
     * @param rightsId
     * @return
     */
    UserTaoLiJinOrigin getOriginByRightsId(@Param("rightsId")String rightsId);
}
fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinOriginMapper.xml
@@ -1,134 +1,139 @@
<?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.tlj.UserTaoLiJinOriginMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">
    <id column="uto_id" property="id" jdbcType="BIGINT"/>
    <result column="uto_uid" property="uid" jdbcType="BIGINT"/>
    <result column="uto_rights_id" property="rightsId" jdbcType="VARCHAR"/>
    <result column="uto_money" property="money" jdbcType="DECIMAL"/>
    <result column="uto_money_surplus" property="moneySurplus" jdbcType="DECIMAL"/>
    <result column="uto_type" property="type" jdbcType="INTEGER"/>
    <result column="uto_origin" property="origin" typeHandler="com.yeshi.fanli.util.mybatishandler.tlj.TaoLiJinOriginEnumHandler"/>
    <result column="uto_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="uto_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="uto_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">uto_id,uto_uid,uto_rights_id,uto_money,uto_money_surplus,uto_type,uto_origin,uto_remark,uto_create_time,uto_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_taolijin_origin where uto_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_taolijin_origin where uto_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_origin (uto_id,uto_uid,uto_rights_id,uto_money,uto_money_surplus,uto_type,uto_origin,uto_remark,uto_create_time,uto_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{rightsId,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{moneySurplus,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{origin,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_origin
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">uto_id,</if>
      <if test="uid != null">uto_uid,</if>
      <if test="rightsId != null">uto_rights_id,</if>
      <if test="money != null">uto_money,</if>
      <if test="moneySurplus != null">uto_money_surplus,</if>
      <if test="type != null">uto_type,</if>
      <if test="origin != null">uto_origin,</if>
      <if test="remark != null">uto_remark,</if>
      <if test="createTime != null">uto_create_time,</if>
      <if test="updateTime != null">uto_update_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="rightsId != null">#{rightsId,jdbcType=VARCHAR},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="moneySurplus != null">#{moneySurplus,jdbcType=DECIMAL},</if>
      <if test="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="origin != null">#{origin,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">update yeshi_ec_user_taolijin_origin set uto_uid = #{uid,jdbcType=BIGINT},uto_rights_id = #{rightsId,jdbcType=VARCHAR},uto_money = #{money,jdbcType=DECIMAL},uto_money_surplus = #{moneySurplus,jdbcType=DECIMAL},uto_type = #{type,jdbcType=INTEGER},uto_origin = #{origin,jdbcType=VARCHAR},uto_remark = #{remark,jdbcType=VARCHAR},uto_create_time = #{createTime,jdbcType=TIMESTAMP},uto_update_time = #{updateTime,jdbcType=TIMESTAMP} where uto_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">update yeshi_ec_user_taolijin_origin
    <set>
      <if test="uid != null">uto_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="rightsId != null">uto_rights_id=#{rightsId,jdbcType=VARCHAR},</if>
      <if test="money != null">uto_money=#{money,jdbcType=DECIMAL},</if>
      <if test="moneySurplus != null">uto_money_surplus=#{moneySurplus,jdbcType=DECIMAL},</if>
      <if test="type != null">uto_type=#{type,jdbcType=INTEGER},</if>
      <if test="origin != null">uto_origin=#{origin,jdbcType=VARCHAR},</if>
      <if test="remark != null">uto_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">uto_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">uto_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where uto_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="countMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`uto_money`),0) FROM `yeshi_ec_user_taolijin_origin` t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` <![CDATA[<>]]>'refund'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`uto_create_time`) =  TO_DAYS(NOW());
        </if>
        <if test="dateType == 2"> <!-- 昨日  -->
          AND TO_DAYS(NOW()) - TO_DAYS(t.`uto_create_time`) = 1
        </if>
           <if test="dateType == 3"> <!-- 本月  -->
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
        </if>
        <if test="dateType == 4"> <!--上月  -->
          AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`uto_create_time`, '%Y%m')) = 1
        </if>
  </select>
  <select id="countByUidAndOrigin" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{origin}
  </select>
   <select id="getByUidAndOrigin" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{origin}
    LIMIT 1
  </select>
  <select id="countRankByThisMonth" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = 'rankWin'
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
  </select>
   <select id="getRankByThisMonth" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{type}
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
    LIMIT 1
  </select>
  <select id="getOverdueTaoLiJin" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_create_time`<![CDATA[<=]]> #{date}
          AND t.`uto_money_surplus`<![CDATA[>]]> 0
  </select>
  <select id="getSurplusLiJin" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_money_surplus`<![CDATA[>]]> 0
    ORDER BY t.`uto_create_time`
  </select>
  <select id="countByUidAndType" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{type}
  </select>
  <select id="countMoneyByOrigin" resultType="java.math.BigDecimal">
     SELECT IFNULL(SUM(t.`uto_money`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_rights_id` = #{rightsId}  AND t.`uto_origin` = #{origin}
  </select>
  <select id="getOriginByRightsId" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_rights_id` = #{rightsId}
    LIMIT 1
  </select>
</mapper>
<?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.tlj.UserTaoLiJinOriginMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">
    <id column="uto_id" property="id" jdbcType="BIGINT"/>
    <result column="uto_uid" property="uid" jdbcType="BIGINT"/>
    <result column="uto_rights_id" property="rightsId" jdbcType="VARCHAR"/>
    <result column="uto_money" property="money" jdbcType="DECIMAL"/>
    <result column="uto_money_surplus" property="moneySurplus" jdbcType="DECIMAL"/>
    <result column="uto_type" property="type" jdbcType="INTEGER"/>
    <result column="uto_origin" property="origin" typeHandler="com.yeshi.fanli.util.mybatishandler.tlj.TaoLiJinOriginEnumHandler"/>
    <result column="uto_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="uto_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="uto_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">uto_id,uto_uid,uto_rights_id,uto_money,uto_money_surplus,uto_type,uto_origin,uto_remark,uto_create_time,uto_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_taolijin_origin where uto_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_taolijin_origin where uto_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_origin (uto_id,uto_uid,uto_rights_id,uto_money,uto_money_surplus,uto_type,uto_origin,uto_remark,uto_create_time,uto_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{rightsId,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{moneySurplus,jdbcType=DECIMAL},#{type,jdbcType=INTEGER},#{origin,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_origin
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">uto_id,</if>
      <if test="uid != null">uto_uid,</if>
      <if test="rightsId != null">uto_rights_id,</if>
      <if test="money != null">uto_money,</if>
      <if test="moneySurplus != null">uto_money_surplus,</if>
      <if test="type != null">uto_type,</if>
      <if test="origin != null">uto_origin,</if>
      <if test="remark != null">uto_remark,</if>
      <if test="createTime != null">uto_create_time,</if>
      <if test="updateTime != null">uto_update_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="rightsId != null">#{rightsId,jdbcType=VARCHAR},</if>
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="moneySurplus != null">#{moneySurplus,jdbcType=DECIMAL},</if>
      <if test="type != null">#{type,jdbcType=INTEGER},</if>
      <if test="origin != null">#{origin,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">update yeshi_ec_user_taolijin_origin set uto_uid = #{uid,jdbcType=BIGINT},uto_rights_id = #{rightsId,jdbcType=VARCHAR},uto_money = #{money,jdbcType=DECIMAL},uto_money_surplus = #{moneySurplus,jdbcType=DECIMAL},uto_type = #{type,jdbcType=INTEGER},uto_origin = #{origin,jdbcType=VARCHAR},uto_remark = #{remark,jdbcType=VARCHAR},uto_create_time = #{createTime,jdbcType=TIMESTAMP},uto_update_time = #{updateTime,jdbcType=TIMESTAMP} where uto_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin">update yeshi_ec_user_taolijin_origin
    <set>
      <if test="uid != null">uto_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="rightsId != null">uto_rights_id=#{rightsId,jdbcType=VARCHAR},</if>
      <if test="money != null">uto_money=#{money,jdbcType=DECIMAL},</if>
      <if test="moneySurplus != null">uto_money_surplus=#{moneySurplus,jdbcType=DECIMAL},</if>
      <if test="type != null">uto_type=#{type,jdbcType=INTEGER},</if>
      <if test="origin != null">uto_origin=#{origin,jdbcType=VARCHAR},</if>
      <if test="remark != null">uto_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="createTime != null">uto_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">uto_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where uto_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="countMoneyByDate" resultType="java.math.BigDecimal">
      SELECT IFNULL(SUM(t.`uto_money`),0) FROM `yeshi_ec_user_taolijin_origin` t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` <![CDATA[<>]]>'refund'
        <if test="dateType == 1"> <!-- 今日  -->
            AND TO_DAYS(t.`uto_create_time`) =  TO_DAYS(NOW());
        </if>
        <if test="dateType == 2"> <!-- 昨日  -->
          AND TO_DAYS(NOW()) - TO_DAYS(t.`uto_create_time`) = 1
        </if>
           <if test="dateType == 3"> <!-- 本月  -->
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
        </if>
        <if test="dateType == 4"> <!--上月  -->
          AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'),DATE_FORMAT(t.`uto_create_time`, '%Y%m')) = 1
        </if>
  </select>
  <select id="countByUidAndOrigin" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{origin}
  </select>
   <select id="getByUidAndOrigin" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{origin}
    LIMIT 1
  </select>
  <select id="countRankByThisMonth" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = 'rankWin'
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
  </select>
   <select id="getRankByThisMonth" resultMap="BaseResultMap">
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{type}
          AND DATE_FORMAT(t.`uto_create_time`, '%Y%m') =DATE_FORMAT(CURDATE(), '%Y%m')
    LIMIT 1
  </select>
  <select id="getOverdueTaoLiJin" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_create_time`<![CDATA[<=]]> #{date}
          AND t.`uto_money_surplus`<![CDATA[>]]> 0 AND t.`uto_origin`<![CDATA[<>]]>'rankWin'
  </select>
  <select id="getOverdueTaoLiJinByRank" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_create_time`<![CDATA[<=]]> #{date}
          AND t.`uto_money_surplus`<![CDATA[>]]> 0 AND t.`uto_origin`= 'rankWin'
  </select>
  <select id="getSurplusLiJin" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_money_surplus`<![CDATA[>]]> 0
    ORDER BY t.`uto_create_time`
  </select>
  <select id="countByUidAndType" resultType="Long">
     SELECT IFNULL(COUNT(t.`uto_id`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_uid` = #{uid} AND t.`uto_origin` = #{type}
  </select>
  <select id="countMoneyByOrigin" resultType="java.math.BigDecimal">
     SELECT IFNULL(SUM(t.`uto_money`),0) FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_rights_id` = #{rightsId}  AND t.`uto_origin` = #{origin}
  </select>
  <select id="getOriginByRightsId" resultMap="BaseResultMap" >
     SELECT * FROM yeshi_ec_user_taolijin_origin t
    WHERE t.`uto_rights_id` = #{rightsId}
    LIMIT 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java
@@ -404,31 +404,43 @@
    @Override
    public void overdueHongBao(Long uid) {
        // 15天前过期
        Date date = null;
        if (uid == null) {
            return;
        }
        // 15天前过期- 非等级红包
        try {
            date = DateUtil.reduceDay(14, new Date());
            Date date = DateUtil.reduceDay(14, new Date());
            List<UserTaoLiJinOrigin> list = userTaoLiJinOriginMapper.getOverdueTaoLiJin(uid, date);
            executeOverdueHongBao(uid, date, list);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        
        if (date == null) {
            return;
        // 30天前过期 - 等级红包
        try {
            Date date = DateUtil.reduceDay(29, new Date());
            List<UserTaoLiJinOrigin> list = userTaoLiJinOriginMapper.getOverdueTaoLiJinByRank(uid, date);
            executeOverdueHongBao(uid, date, list);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        List<UserTaoLiJinOrigin> list = userTaoLiJinOriginMapper.getOverdueTaoLiJin(uid, date);
    }
    public void executeOverdueHongBao(Long uid, Date date, List<UserTaoLiJinOrigin> list) {
        if (list == null || list.size() == 0) {
            return;
        }
        BigDecimal total = new BigDecimal(0);
        for (UserTaoLiJinOrigin userTaoLiJinOrigin: list) {
        for (UserTaoLiJinOrigin userTaoLiJinOrigin : list) {
            SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
            String time = sd.format(userTaoLiJinOrigin.getCreateTime());
            String time = sd.format(userTaoLiJinOrigin.getCreateTime());
            BigDecimal moneySurplus = userTaoLiJinOrigin.getMoneySurplus();
            total = MoneyBigDecimalUtil.add(total, moneySurplus);
            String rightsId = null;
            boolean refund = false;
            TaoLiJinOriginEnum originEnum = userTaoLiJinOrigin.getOrigin();
@@ -436,13 +448,13 @@
                refund = true;
                rightsId = userTaoLiJinOrigin.getRightsId();
            }
            UserTaoLiJinOrigin origin = new UserTaoLiJinOrigin();
            origin.setId(userTaoLiJinOrigin.getId());
            origin.setMoneySurplus(new BigDecimal(0));
            origin.setUpdateTime(new Date());
            userTaoLiJinOriginMapper.updateByPrimaryKeySelective(origin);
            if (refund) {
                UserTaoLiJinReport report = userTaoLiJinReportService.selectByPrimaryKey(rightsId);
                Date shareTime = null;
@@ -451,17 +463,17 @@
                } else {
                    shareTime = report.getCreateTime();
                }
                // 消息
                MsgOtherTaoLiJinContentDTO content = new MsgOtherTaoLiJinContentDTO();
                content.setState("红包收回");
                content.setSource("于["+ sd.format(shareTime) + "]创建的分享未被领取部分");
                content.setSource("于[" + sd.format(shareTime) + "]创建的分享未被领取部分");
                content.setTimeDesc("退回于" + time);
                content.setMoney(moneySurplus);
                content.setReason("本笔退回推广红包从退回日起至今并未产生分享记录");
                content.setResult("长期未使用收回");
                userOtherMsgNotificationService.taoLiJinMsg(uid, "如有疑问请联系人工客服", content);
            } else {
                // 消息
                MsgOtherTaoLiJinContentDTO content = new MsgOtherTaoLiJinContentDTO();
@@ -474,16 +486,16 @@
                userOtherMsgNotificationService.taoLiJinMsg(uid, "如有疑问请联系人工客服", content);
            }
        }
        // 用户剩余淘礼金
        UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
        if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) {
            return;
        }
        UserMoneyExtra updateExtra = new UserMoneyExtra();
        updateExtra.setUid(uid);
        BigDecimal tljSelf = userMoneyExtra.getTljSelf();
        if (tljSelf != null && tljSelf.compareTo(new BigDecimal(0)) > 0) { // 剩余淘礼金-- 自购
            BigDecimal sub = MoneyBigDecimalUtil.sub(tljSelf, total);
@@ -492,12 +504,11 @@
            } else {
                updateExtra.setTljSelf(new BigDecimal(0));
            }
        }
        }
        updateExtra.setTlj(MoneyBigDecimalUtil.sub(userMoneyExtra.getTlj(), total));
        updateExtra.setUpdateTime(new Date());
        userMoneyExtraService.updateByPrimaryKeySelective(updateExtra);
        // 插入明细
        UserTaoLiJinDetail detail = new UserTaoLiJinDetail();
        detail.setUid(uid);
@@ -507,7 +518,8 @@
        detail.setCreateTime(new Date());
        userTaoLiJinDetailService.insertSelective(detail);
    }
    @Override
    public List<UserTaoLiJinOrigin> getSurplusLiJin(long uid) {
        return userTaoLiJinOriginMapper.getSurplusLiJin(uid);
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -374,7 +374,7 @@
                
                // 使用成功消息
                try {
                    String beizhu = "未被领取/使用的部分将会退回";
                    String beizhu = "未被领取或领取后未使用部分退回";
                    SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
                    String time = sd.format(new Date());
                    MsgOtherTaoLiJinContentDTO content = new MsgOtherTaoLiJinContentDTO();