yujian
2019-11-20 64d96fd02c487ff70b6d342534b2fb79089d35ba
红包领取加入唯一标识
7个文件已修改
64 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackWinInvite.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
@@ -177,7 +177,7 @@
     * @param endTime 结束时间
     * @return
     */
    BigDecimal getShareRewardByTeamUid(@Param("uid") Long uid, @Param("teamUid") Long teamUid, @Param("endTime") Date endTime);
    BigDecimal getOrderRewardByTeamUid(@Param("uid") Long uid, @Param("teamUid") Long teamUid, @Param("endTime") Date endTime);
    /**
     * 统计下级上个有效订单
@@ -186,6 +186,6 @@
     * @param endTime 结束时间
     * @return
     */
    BigDecimal getShareRewardByTeamUidLastMonth(@Param("uid") Long uid, @Param("teamUid") Long teamUid);
    BigDecimal getOrderRewardByTeamUidTheMonth(@Param("uid") Long uid, @Param("teamUid") Long teamUid);
}
fanli/src/main/java/com/yeshi/fanli/entity/redpack/RedPackWinInvite.java
@@ -53,6 +53,10 @@
    @Column(name = "rwr_source")
    private Integer source;
    
    // 唯一标识
    @Column(name = "rwr_identify_code")
    private String identifyCode;
    // 订单号
    @Column(name = "rwr_order_no")
    private String orderNo;
@@ -134,4 +138,12 @@
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getIdentifyCode() {
        return identifyCode;
    }
    public void setIdentifyCode(String identifyCode) {
        this.identifyCode = identifyCode;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
@@ -359,20 +359,20 @@
                AND (`hb_type` =5 OR `hb_type` =6 OR `hb_type` =7 OR `hb_type` =20 OR `hb_type`=21 OR `hb_type` =22 )
    </select>
     <select id="getShareRewardByTeamUid" resultType="BigDecimal">
     <select id="getOrderRewardByTeamUid" resultType="BigDecimal">
        SELECT SUM(v2.`hb_money`) FROM yeshi_ec_hongbao_v2 v2 
        LEFT JOIN yeshi_ec_hongbao_v2 p ON p.`hb_id` = v2.`hb_pid`
        WHERE v2.`hb_type` = 21 AND v2.`hb_state` = 3
        WHERE v2.`hb_state` = 3 AND (v2.`hb_type` = 6 OR v2.`hb_type` = 21)
            AND v2.`hb_uid` = #{uid} AND p.`hb_uid` = #{teamUid}
            AND v2.`hb_create_time`<![CDATA[<=]]> #{endTime}
    </select>
    
    <select id="getShareRewardByTeamUidLastMonth" resultType="BigDecimal">
    <select id="getOrderRewardByTeamUidTheMonth" resultType="BigDecimal">
        SELECT SUM(v2.`hb_money`) FROM yeshi_ec_hongbao_v2 v2 
        LEFT JOIN yeshi_ec_hongbao_v2 p ON p.`hb_id` = v2.`hb_pid`
        WHERE v2.`hb_type` = 21 AND v2.`hb_state` = 3
        WHERE  v2.`hb_state` = 3 AND (v2.`hb_type` = 6 OR v2.`hb_type` = 21)
            AND v2.`hb_uid` = #{uid} AND p.`hb_uid` = #{teamUid}
            AND PERIOD_DIFF(DATE_FORMAT(NOW(), '%Y%m'), DATE_FORMAT(v2.`hb_create_time`, '%Y%m')) = 1
            AND DATE_FORMAT(CURDATE(), '%Y%m') = DATE_FORMAT(v2.`hb_get_time`, '%Y%m')
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/redpack/RedPackWinInviteMapper.xml
@@ -1,6 +1,5 @@
<?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.redpack.RedPackWinInviteMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.redpack.RedPackWinInvite">
    <id column="rwr_id" property="id" jdbcType="BIGINT"/>
@@ -8,17 +7,18 @@
    <result column="rwr_team_uid" property="teamUid" jdbcType="BIGINT"/>
    <result column="rwr_money" property="money" jdbcType="DECIMAL"/>
    <result column="rwr_source" property="source" jdbcType="INTEGER"/>
    <result column="rwr_identify_code" property="identifyCode" jdbcType="VARCHAR"/>
    <result column="rwr_order_no" property="orderNo" jdbcType="VARCHAR"/>
    <result column="rwr_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="rwr_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <result column="rwr_type" property="type" typeHandler="com.yeshi.fanli.util.mybatishandler.redpack.RedPackWinInviteTypeEnumHandler"/>
  </resultMap>
  <sql id="Base_Column_List">rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_order_no,rwr_create_time,rwr_update_time</sql>
  <sql id="Base_Column_List">rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_identify_code,rwr_order_no,rwr_create_time,rwr_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_red_pack_win_invite where rwr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_red_pack_win_invite where rwr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_win_invite (rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_order_no,rwr_create_time,rwr_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{teamUid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{source,jdbcType=INTEGER},#{orderNo,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_win_invite (rwr_id,rwr_uid,rwr_team_uid,rwr_money,rwr_type,rwr_source,rwr_identify_code,rwr_order_no,rwr_create_time,rwr_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{teamUid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{source,jdbcType=INTEGER},#{identifyCode,jdbcType=VARCHAR},#{orderNo,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_red_pack_win_invite
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">rwr_id,</if>
@@ -27,6 +27,7 @@
      <if test="money != null">rwr_money,</if>
      <if test="type != null">rwr_type,</if>
      <if test="source != null">rwr_source,</if>
      <if test="identifyCode != null">rwr_identify_code,</if>
      <if test="orderNo != null">rwr_order_no,</if>
      <if test="createTime != null">rwr_create_time,</if>
      <if test="updateTime != null">rwr_update_time,</if>
@@ -38,12 +39,13 @@
      <if test="money != null">#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="source != null">#{source,jdbcType=INTEGER},</if>
      <if test="identifyCode != null">#{identifyCode,jdbcType=VARCHAR},</if>
      <if test="orderNo != null">#{orderNo,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.redpack.RedPackWinInvite">update yeshi_ec_red_pack_win_invite set rwr_uid = #{uid,jdbcType=BIGINT},rwr_team_uid = #{teamUid,jdbcType=BIGINT},rwr_money = #{money,jdbcType=DECIMAL},rwr_type = #{type,jdbcType=VARCHAR},rwr_source = #{source,jdbcType=INTEGER},rwr_order_no = #{orderNo,jdbcType=VARCHAR},rwr_create_time = #{createTime,jdbcType=TIMESTAMP},rwr_update_time = #{updateTime,jdbcType=TIMESTAMP} where rwr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite">update yeshi_ec_red_pack_win_invite set rwr_uid = #{uid,jdbcType=BIGINT},rwr_team_uid = #{teamUid,jdbcType=BIGINT},rwr_money = #{money,jdbcType=DECIMAL},rwr_type = #{type,jdbcType=VARCHAR},rwr_source = #{source,jdbcType=INTEGER},rwr_identify_code = #{identifyCode,jdbcType=VARCHAR},rwr_order_no = #{orderNo,jdbcType=VARCHAR},rwr_create_time = #{createTime,jdbcType=TIMESTAMP},rwr_update_time = #{updateTime,jdbcType=TIMESTAMP} where rwr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.redpack.RedPackWinInvite">update yeshi_ec_red_pack_win_invite
    <set>
      <if test="uid != null">rwr_uid=#{uid,jdbcType=BIGINT},</if>
@@ -51,6 +53,7 @@
      <if test="money != null">rwr_money=#{money,jdbcType=DECIMAL},</if>
      <if test="type != null">rwr_type=#{type,jdbcType=VARCHAR},</if>
      <if test="source != null">rwr_source=#{source,jdbcType=INTEGER},</if>
      <if test="identifyCode != null">rwr_identify_code=#{identifyCode,jdbcType=VARCHAR},</if>
      <if test="orderNo != null">rwr_order_no=#{orderNo,jdbcType=VARCHAR},</if>
      <if test="createTime != null">rwr_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">rwr_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
@@ -96,5 +99,4 @@
      SELECT IFNULL(SUM(d.`rwr_money`),0) FROM yeshi_ec_red_pack_win_invite d
    WHERE d.`rwr_uid` = #{uid}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java
@@ -298,12 +298,12 @@
    }
    @Override
    public BigDecimal getShareRewardByTeamUid(Long uid, Long teamUid, Date endTime) {
        return hongBaoV2CountMapper.getShareRewardByTeamUid(uid, teamUid, endTime);
    public BigDecimal getOrderRewardByTeamUid(Long uid, Long teamUid, Date endTime) {
        return hongBaoV2CountMapper.getOrderRewardByTeamUid(uid, teamUid, endTime);
    }
    
    @Override
    public BigDecimal getShareRewardByTeamUidLastMonth(Long uid, Long teamUid) {
        return hongBaoV2CountMapper.getShareRewardByTeamUidLastMonth(uid, teamUid);
    public BigDecimal getOrderRewardByTeamUidTheMonth(Long uid, Long teamUid) {
        return hongBaoV2CountMapper.getOrderRewardByTeamUidTheMonth(uid, teamUid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -150,6 +150,7 @@
        winInvite.setUid(bossId);
        winInvite.setTeamUid(teamUid);
        winInvite.setMoney(money);
        winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.oneStageReward.name() + ":" + teamUid));
        redPackWinInviteMapper.insertSelective(winInvite);
        
        // 增加红包
@@ -219,7 +220,8 @@
    private void twoStageRewardToBoss(Long bossId, Long teamUid, Date oneStageTime, Integer source, String orderNo) throws Exception{
        // 第一阶段完成之后的90天内 ; 队友产生的订单中(自购+分享),邀请人累计产生≥1 元奖金  
        Date endDate = DateUtil.plusDayDate(Constant.TWO_STAGE_LIMIT_DAYS, oneStageTime);
        BigDecimal rewardMoney = hongBaoV2CountService.getShareRewardByTeamUid(bossId, teamUid, endDate);
        // 统计订单奖金 (“好友自购”和“好友分享”)
        BigDecimal rewardMoney = hongBaoV2CountService.getOrderRewardByTeamUid(bossId, teamUid, endDate);
        if (rewardMoney == null || rewardMoney.compareTo(Constant.TWO_STAGE_ORDER_REWARD_MIN) < 0)
            return;
        
@@ -241,6 +243,7 @@
        winInvite.setCreateTime(new Date());
        winInvite.setUpdateTime(new Date());
        winInvite.setType(RedPackWinInviteTypeEnum.twoStageReward);
        winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.twoStageReward.name() + ":" + teamUid));
        redPackWinInviteMapper.insertSelective(winInvite);
        
        // 4、增加红包
@@ -284,8 +287,8 @@
        if (monthSpace !=  totalNum + 1)
            return;
        
        // 每月给你累计产生≥2 元
        BigDecimal rewardMoney = hongBaoV2CountService.getShareRewardByTeamUidLastMonth(bossId, teamUid);
        // 统计本月获得奖金 (“好友自购”和“好友分享”)
        BigDecimal rewardMoney = hongBaoV2CountService.getOrderRewardByTeamUidTheMonth(bossId, teamUid);
        if (rewardMoney == null || rewardMoney.compareTo(Constant.THREE_STAGE_ORDER_REWARD_MIN) < 0)
            return;
        
@@ -304,6 +307,7 @@
        winInvite.setMoney(money);
        winInvite.setSource(source);
        winInvite.setOrderNo(orderNo);
        winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.threeStageReward.name() + ":" + teamUid + "-" + monthSpace));
        redPackWinInviteMapper.insertSelective(winInvite);
        
        // 4、增加红包
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
@@ -185,20 +185,20 @@
    public long countAlreadyGetMoneyByUid(Long uid, List<Integer> typeList, Date minGetTime, Date maxGetTime);
    /**
     * 查询来源该下级成功分享奖金活动
     * 查询来源该下级成功分享 + 自购订单
     * @param uid
     * @param teamUid
     * @param endTime
     * @return
     */
    public BigDecimal getShareRewardByTeamUid(Long uid, Long teamUid, Date endTime);
    public BigDecimal getOrderRewardByTeamUid(Long uid, Long teamUid, Date endTime);
    /**
     * 统计下级上个有效订单
     * 统计该下级成功分享 + 自购订单
     * @param uid
     * @param teamUid 下级id
     * @return
     */
    public BigDecimal getShareRewardByTeamUidLastMonth(Long uid, Long teamUid);
    public BigDecimal getOrderRewardByTeamUidTheMonth(Long uid, Long teamUid);
}