yujian
2019-06-27 6ec3ab1f28bf6bc98821b5f133f41af1ef1dcf3a
淘礼金创建区分:自购、分享
4个文件已修改
68 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinRecord.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinRecordMapper.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -163,7 +163,6 @@
            count = userTaoLiJinRecordService.countRecordByUid(uid);
        }
        
        GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
        gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
            @Override
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinRecord.java
@@ -53,6 +53,10 @@
    @Column(name = "utlj_create_time")
    private Date createTime;
    // 使用类型 : 1自购 2分享
    @Column(name = "utlj_use_type")
    private Integer useType;
    // 剩余余额
    private BigDecimal surplusMoney;
@@ -170,4 +174,12 @@
    public void setSurplusMoney(BigDecimal surplusMoney) {
        this.surplusMoney = surplusMoney;
    }
    public Integer getUseType() {
        return useType;
    }
    public void setUseType(Integer useType) {
        this.useType = useType;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/tlj/UserTaoLiJinRecordMapper.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.tlj.UserTaoLiJinRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord">
    <id column="utlj_id" property="id" jdbcType="BIGINT"/>
@@ -16,6 +15,7 @@
    <result column="utlj_rights_id" property="rightsId" jdbcType="VARCHAR"/>
    <result column="utlj_send_url" property="sendUrl" jdbcType="VARCHAR"/>
    <result column="utlj_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="utlj_use_type" property="useType" jdbcType="INTEGER"/>
  </resultMap>
  
  <resultMap id="ResultVOMap" type="com.yeshi.fanli.vo.user.UserTaoLiJinRecordVO">
@@ -29,29 +29,29 @@
    <result column="utr_pre_commission_amount" property="commission" jdbcType="DECIMAL"/>
  </resultMap>
  
  <sql id="Base_Column_List">utlj_id,utlj_uid,utlj_goods_id,utlj_total_num,utlj_name,utlj_per_face,utlj_send_start_time,utlj_send_end_time,utlj_use_start_time,utlj_use_end_time,utlj_rights_id,utlj_send_url,utlj_create_time</sql>
  <sql id="Base_Column_List">utlj_id,utlj_uid,utlj_goods_id,utlj_total_num,utlj_name,utlj_per_face,utlj_send_start_time,utlj_send_end_time,utlj_use_start_time,utlj_use_end_time,utlj_rights_id,utlj_send_url,utlj_create_time,utlj_use_type</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_taolijin_record where utlj_id = #{id,jdbcType=BIGINT}
  </select>
  <select id="getRecordByUid" resultMap="ResultVOMap">
      SELECT * FROM yeshi_ec_user_taolijin_record d
    LEFT JOIN yeshi_ec_user_taolijin_report p ON d.`utlj_rights_id` = p.`utr_id`
    WHERE d.`utlj_uid` = #{uid} AND p.`utr_id` IS NOT NULL
    WHERE d.`utlj_uid` = #{uid} AND p.`utr_id` IS NOT NULL AND d.utlj_use_type = 2
    ORDER BY d.`utlj_create_time` DESC
    LIMIT ${start},${count}
  </select>
 
  <select id="countRecordByUid" resultType="Long">
      SELECT IFNULL(COUNT(d.`utlj_id`),0) FROM yeshi_ec_user_taolijin_record d
    WHERE d.`utlj_uid` = #{uid}
    WHERE d.`utlj_uid` = #{uid} AND d.utlj_use_type = 2
  </select>
 
 
  <select id="countTodayNum" resultType="Long">
      SELECT  IFNULL(count(d.utlj_id),0) FROM `yeshi_ec_user_taolijin_record` d
    WHERE   d.`utlj_uid` = #{uid} AND TO_DAYS(d.`utlj_create_time`) = TO_DAYS(NOW());
      SELECT IFNULL(count(d.utlj_id),0) FROM `yeshi_ec_user_taolijin_record` d
    WHERE d.`utlj_uid` = #{uid} AND TO_DAYS(d.`utlj_create_time`) = TO_DAYS(NOW())
            AND d.utlj_use_type = 2
  </select>
  
  <select id="getShareHongBaoByUidAndGoodsId" resultType="java.math.BigDecimal">
@@ -65,9 +65,9 @@
    WHERE d.`utlj_rights_id` =#{rightsId}  
    LIMIT 1
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_taolijin_record where utlj_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_record (utlj_id,utlj_uid,utlj_goods_id,utlj_total_num,utlj_name,utlj_per_face,utlj_send_start_time,utlj_send_end_time,utlj_use_start_time,utlj_use_end_time,utlj_rights_id,utlj_send_url,utlj_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{goodsId,jdbcType=BIGINT},#{totalNum,jdbcType=INTEGER},#{name,jdbcType=VARCHAR},#{perFace,jdbcType=DECIMAL},#{sendStartTime,jdbcType=TIMESTAMP},#{sendEndTime,jdbcType=TIMESTAMP},#{useStartTime,jdbcType=TIMESTAMP},#{useEndTime,jdbcType=TIMESTAMP},#{rightsId,jdbcType=VARCHAR},#{sendUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_record (utlj_id,utlj_uid,utlj_goods_id,utlj_total_num,utlj_name,utlj_per_face,utlj_send_start_time,utlj_send_end_time,utlj_use_start_time,utlj_use_end_time,utlj_rights_id,utlj_send_url,utlj_create_time,utlj_use_type) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{goodsId,jdbcType=BIGINT},#{totalNum,jdbcType=INTEGER},#{name,jdbcType=VARCHAR},#{perFace,jdbcType=DECIMAL},#{sendStartTime,jdbcType=TIMESTAMP},#{sendEndTime,jdbcType=TIMESTAMP},#{useStartTime,jdbcType=TIMESTAMP},#{useEndTime,jdbcType=TIMESTAMP},#{rightsId,jdbcType=VARCHAR},#{sendUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{useType,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_taolijin_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">utlj_id,</if>
@@ -83,6 +83,7 @@
      <if test="rightsId != null">utlj_rights_id,</if>
      <if test="sendUrl != null">utlj_send_url,</if>
      <if test="createTime != null">utlj_create_time,</if>
      <if test="useType != null">utlj_use_type,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
@@ -98,9 +99,10 @@
      <if test="rightsId != null">#{rightsId,jdbcType=VARCHAR},</if>
      <if test="sendUrl != null">#{sendUrl,jdbcType=VARCHAR},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="useType != null">#{useType,jdbcType=INTEGER},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord">update yeshi_ec_user_taolijin_record set utlj_uid = #{uid,jdbcType=BIGINT},utlj_goods_id = #{goodsId,jdbcType=BIGINT},utlj_total_num = #{totalNum,jdbcType=INTEGER},utlj_name = #{name,jdbcType=VARCHAR},utlj_per_face = #{perFace,jdbcType=DECIMAL},utlj_send_start_time = #{sendStartTime,jdbcType=TIMESTAMP},utlj_send_end_time = #{sendEndTime,jdbcType=TIMESTAMP},utlj_use_start_time = #{useStartTime,jdbcType=TIMESTAMP},utlj_use_end_time = #{useEndTime,jdbcType=TIMESTAMP},utlj_rights_id = #{rightsId,jdbcType=VARCHAR},utlj_send_url = #{sendUrl,jdbcType=VARCHAR},utlj_create_time = #{createTime,jdbcType=TIMESTAMP} where utlj_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord">update yeshi_ec_user_taolijin_record set utlj_uid = #{uid,jdbcType=BIGINT},utlj_goods_id = #{goodsId,jdbcType=BIGINT},utlj_total_num = #{totalNum,jdbcType=INTEGER},utlj_name = #{name,jdbcType=VARCHAR},utlj_per_face = #{perFace,jdbcType=DECIMAL},utlj_send_start_time = #{sendStartTime,jdbcType=TIMESTAMP},utlj_send_end_time = #{sendEndTime,jdbcType=TIMESTAMP},utlj_use_start_time = #{useStartTime,jdbcType=TIMESTAMP},utlj_use_end_time = #{useEndTime,jdbcType=TIMESTAMP},utlj_rights_id = #{rightsId,jdbcType=VARCHAR},utlj_send_url = #{sendUrl,jdbcType=VARCHAR},utlj_create_time = #{createTime,jdbcType=TIMESTAMP},utlj_use_type = #{useType,jdbcType=INTEGER} where utlj_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord">update yeshi_ec_user_taolijin_record
    <set>
      <if test="uid != null">utlj_uid=#{uid,jdbcType=BIGINT},</if>
@@ -115,6 +117,7 @@
      <if test="rightsId != null">utlj_rights_id=#{rightsId,jdbcType=VARCHAR},</if>
      <if test="sendUrl != null">utlj_send_url=#{sendUrl,jdbcType=VARCHAR},</if>
      <if test="createTime != null">utlj_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="useType != null">utlj_use_type=#{useType,jdbcType=INTEGER},</if>
    </set> where utlj_id = #{id,jdbcType=BIGINT}
  </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -264,17 +264,21 @@
        record.setRightsId(taoLiJinDTO.getRightsId());
        record.setSendUrl(taoLiJinDTO.getSendUrl());
        record.setCreateTime(new Date());
        if (origin == 1) { //  自购
            record.setUseType(1);
        } else { //  分享
            record.setUseType(2);
        }
        userTaoLiJinRecordMapper.insertSelective(record);
        BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney);
        
        UserMoneyExtra updateExtra = new UserMoneyExtra();
        updateExtra.setUid(uid);
        if (origin == 1) { // 剩余淘礼金-- 自购
            updateExtra.setTljSelf(MoneyBigDecimalUtil.sub(userMoneyExtra.getTljSelf(), totalMoney));
        } 
        // 剩余淘礼金
        BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney);
        updateExtra.setTlj(surplusTlj);
        updateExtra.setUpdateTime(new Date());
        userMoneyExtraService.updateByPrimaryKeySelective(updateExtra);
@@ -332,6 +336,19 @@
                    LogHelper.errorDetailInfo(e);
                }
                // 创建报告
                try {
                    userTaoLiJinReportService.insertDefault(rightsId);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
                if (origin == 1) {
                    return; //  自购不推送消息
                }
                // 使用成功消息
                try {
                    String beizhu = "未被领取/使用的部分将会退回";
@@ -344,13 +361,6 @@
                    content.setMoney(totalMoney);
                    userOtherMsgNotificationService.taoLiJinMsg(uid, beizhu, content);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
                // 创建报告
                try {
                    userTaoLiJinReportService.insertDefault(rightsId);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }