yujian
2019-08-29 e1dcef9d29c8de98c603cd4880f6b272c23f1cc0
券退回
19个文件已修改
1个文件已添加
410 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderCountMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponGiveRecordMapper.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgOtherCouponActivateDTO.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgOtherDetail.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponGiveRecord.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderCountMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserOtherMsgNotificationServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/UserOtherMsgNotificationService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderCountService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/user/UserSystemCouponVO.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderCountMapper.java
@@ -52,4 +52,13 @@
     */
    BigDecimal getMoneyByOrderNo(@Param("orderNo")String orderNo);
    
    /**
     * 统计已到账返利订单
     * @param uid
     * @param dateTime
     * @return
     */
    long countValidOrderByDate(@Param("uid")Long uid, @Param("dateTime")String dateTime);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponGiveRecordMapper.java
@@ -25,4 +25,22 @@
     * @return
     */
    List<UserSystemCouponGiveRecord> overdueList(@Param("count") int count);
    /**
     * 赠送超时未领取的
     * @param count
     * @return
     */
    List<UserSystemCouponGiveRecord> overdueListByUser(@Param("uid") Long uid);
    /**
     * 领取的id
     * @param count
     * @return
     */
    UserSystemCouponGiveRecord getByReceiveId(@Param("receiveId") Long receiveId);
}
fanli/src/main/java/com/yeshi/fanli/dto/msg/MsgOtherCouponActivateDTO.java
New file
@@ -0,0 +1,65 @@
package com.yeshi.fanli.dto.msg;
/**
 * 其他消息里面的券激活
 *
 * @author Administrator
 *
 */
public class MsgOtherCouponActivateDTO {
    private String title; // 标题
    private String type; // 类别
    private String explain; // 说明
    private String giveUser; // 赠送时间
    private String receiveTime;// 领取时间
    private String validityTime;// 有效期
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getExplain() {
        return explain;
    }
    public void setExplain(String explain) {
        this.explain = explain;
    }
    public String getGiveUser() {
        return giveUser;
    }
    public void setGiveUser(String giveUser) {
        this.giveUser = giveUser;
    }
    public String getReceiveTime() {
        return receiveTime;
    }
    public void setReceiveTime(String receiveTime) {
        this.receiveTime = receiveTime;
    }
    public String getValidityTime() {
        return validityTime;
    }
    public void setValidityTime(String validityTime) {
        this.validityTime = validityTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgOtherDetail.java
@@ -21,7 +21,8 @@
public class MsgOtherDetail {
    public enum MsgTypeOtherTypeEnum {
        couponMianDan("免单券"), couponWelfareMianDan("福利免单券"), freeCouponBuy("自购免单券"), 
        freeCouponGive("赠送免单券"), couponReward("奖励券"), taoLiJin("推广红包"), give("赠送"), exchange("金币兑换");
        freeCouponGive("赠送免单券"), couponReward("奖励券"), taoLiJin("推广红包"), give("赠送"), exchange("金币兑换")
        , couponActivate("免单券激活");
        
        private final String desc;
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponGiveRecord.java
@@ -36,6 +36,9 @@
    // 领取uid
    @Column(name = "cgr_receive_uid")
    private Long receiveUid;
    // 领取成功的券id
    @Column(name = "cgr_receive_id")
    private Long receiveId;
    // 领取时间
    @Column(name = "cgr_receive_time")
    private Date receiveTime;
@@ -107,4 +110,12 @@
    public void setState(Integer state) {
        this.state = state;
    }
    public Long getReceiveId() {
        return receiveId;
    }
    public void setReceiveId(Long receiveId) {
        this.receiveId = receiveId;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderCountMapper.xml
@@ -169,4 +169,11 @@
        WHERE co.`co_order_no` = #{orderNo}
    </select>
    
    <select id="countValidOrderByDate" resultType="Long">
        SELECT IFNULL(COUNT(co.`co_id`),0) FROM yeshi_ec_common_order co
        LEFT JOIN  yeshi_ec_hongbao_order ho ON co.`co_id`=ho.`ho_order_id`
        LEFT JOIN yeshi_ec_hongbao_v2 v2 ON  v2.hb_id=ho.`ho_hongbao_id`
        WHERE co.`co_uid` = #{uid} AND v2.`hb_type` = 1 AND v2.`hb_state` = 3
              AND co.`co_third_create_time` > #{dateTime}
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml
@@ -9,15 +9,16 @@
    <result column="cgr_give_time" property="giveTime" jdbcType="TIMESTAMP"/>
    <result column="cgr_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="cgr_receive_uid" property="receiveUid" jdbcType="BIGINT"/>
    <result column="cgr_receive_id" property="receiveId" jdbcType="BIGINT"/>
    <result column="cgr_receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
    <result column="cgr_state" property="state" jdbcType="INTEGER"/>
  </resultMap>
  <sql id="Base_Column_List">cgr_id,cgr_coupon_id,cgr_give_uid,cgr_give_time,cgr_end_time,cgr_receive_uid,cgr_receive_time,cgr_state</sql>
  <sql id="Base_Column_List">cgr_id,cgr_coupon_id,cgr_give_uid,cgr_give_time,cgr_end_time,cgr_receive_uid,cgr_receive_id,cgr_receive_time,cgr_state</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_system_coupon_give_record where cgr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_system_coupon_give_record where cgr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon_give_record (cgr_id,cgr_coupon_id,cgr_give_uid,cgr_give_time,cgr_end_time,cgr_receive_uid,cgr_receive_time,cgr_state) values (#{id,jdbcType=BIGINT},#{couponId,jdbcType=BIGINT},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon_give_record (cgr_id,cgr_coupon_id,cgr_give_uid,cgr_give_time,cgr_end_time,cgr_receive_uid,cgr_receive_id,cgr_receive_time,cgr_state) values (#{id,jdbcType=BIGINT},#{couponId,jdbcType=BIGINT},#{giveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{receiveUid,jdbcType=BIGINT},#{receiveId,jdbcType=BIGINT},#{receiveTime,jdbcType=TIMESTAMP},#{state,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon_give_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">cgr_id,</if>
@@ -26,6 +27,7 @@
      <if test="giveTime != null">cgr_give_time,</if>
      <if test="endTime != null">cgr_end_time,</if>
      <if test="receiveUid != null">cgr_receive_uid,</if>
      <if test="receiveId != null">cgr_receive_id,</if>
      <if test="receiveTime != null">cgr_receive_time,</if>
      <if test="state != null">cgr_state,</if>
    </trim>values
@@ -36,11 +38,12 @@
      <if test="giveTime != null">#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveUid != null">#{receiveUid,jdbcType=BIGINT},</if>
      <if test="receiveId != null">#{receiveId,jdbcType=BIGINT},</if>
      <if test="receiveTime != null">#{receiveTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord">update yeshi_ec_user_system_coupon_give_record set cgr_coupon_id = #{couponId,jdbcType=BIGINT},cgr_give_uid = #{giveUid,jdbcType=BIGINT},cgr_give_time = #{giveTime,jdbcType=TIMESTAMP},cgr_end_time = #{endTime,jdbcType=TIMESTAMP},cgr_receive_uid = #{receiveUid,jdbcType=BIGINT},cgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},cgr_state = #{state,jdbcType=INTEGER} where cgr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord">update yeshi_ec_user_system_coupon_give_record set cgr_coupon_id = #{couponId,jdbcType=BIGINT},cgr_give_uid = #{giveUid,jdbcType=BIGINT},cgr_give_time = #{giveTime,jdbcType=TIMESTAMP},cgr_end_time = #{endTime,jdbcType=TIMESTAMP},cgr_receive_uid = #{receiveUid,jdbcType=BIGINT},cgr_receive_id = #{receiveId,jdbcType=BIGINT},cgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP},cgr_state = #{state,jdbcType=INTEGER} where cgr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord">update yeshi_ec_user_system_coupon_give_record
    <set>
      <if test="couponId != null">cgr_coupon_id=#{couponId,jdbcType=BIGINT},</if>
@@ -48,6 +51,7 @@
      <if test="giveTime != null">cgr_give_time=#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">cgr_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveUid != null">cgr_receive_uid=#{receiveUid,jdbcType=BIGINT},</if>
      <if test="receiveId != null">cgr_receive_id=#{receiveId,jdbcType=BIGINT},</if>
      <if test="receiveTime != null">cgr_receive_time=#{receiveTime,jdbcType=TIMESTAMP},</if>
      <if test="state != null">cgr_state=#{state,jdbcType=INTEGER},</if>
    </set> where cgr_id = #{id,jdbcType=BIGINT}
@@ -65,4 +69,16 @@
    WHERE d.`cgr_state` = 0 AND d.`cgr_end_time` IS NOT NULL AND d.`cgr_end_time` <![CDATA[<]]> CURDATE()
    LIMIT #{count}
  </select>
  <select id="overdueListByUser" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_system_coupon_give_record d
    WHERE d.cgr_give_uid = #{uid} AND d.`cgr_state` = 0 AND d.`cgr_end_time` IS NOT NULL
          AND d.`cgr_end_time` <![CDATA[<]]> CURDATE()
  </select>
   <select id="getByReceiveId" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_system_coupon_give_record d
    WHERE d.cgr_receive_id = #{receiveId}
    LIMIT 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java
@@ -260,4 +260,9 @@
        return commonOrderCountMapper.getMoneyByOrderNo(orderNo);
    }
    @Override
    public long countValidOrderByDate(Long uid, String dateTime) {
        return commonOrderCountMapper.countValidOrderByDate(uid, dateTime);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -232,7 +232,7 @@
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, null);
                couponNews = 1;
            } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
                thing = "奖励免单券";
                thing = "返利奖励券";
                thingNum = "3天";
                String percent = configService.get("exchange_rebate_percent");
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent));
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/MsgOtherDetailServiceImpl.java
@@ -46,6 +46,9 @@
        } else if (detail.getType() == MsgTypeOtherTypeEnum.exchange) {
            msgOtherDetailMapper.insertSelective(detail);
            userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
        } else if (detail.getType() == MsgTypeOtherTypeEnum.couponActivate) {
            msgOtherDetailMapper.insertSelective(detail);
            userMsgReadStateService.addOtherMsgUnReadCount(detail.getUser().getId(), 1);
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/msg/UserOtherMsgNotificationServiceImpl.java
@@ -8,6 +8,7 @@
import org.springframework.stereotype.Service;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.msg.MsgOtherCouponActivateDTO;
import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherExchangeContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
@@ -347,6 +348,24 @@
        }
    }
    
    @Override
    public void giveCouponActivateMsg(Long uid, String beiZhu, MsgOtherCouponActivateDTO content) {
        try {
            MsgOtherDetail detail = new MsgOtherDetail();
            detail.setBeiZhu(beiZhu);
            detail.setCreateTime(new Date());
            detail.setRead(false);
            detail.setUser(new UserInfo(uid));
            detail.setContent(new Gson().toJson(content));
            detail.setType(MsgTypeOtherTypeEnum.couponActivate);
            msgOtherDetailService.addMsgOtherDetail(detail);
        } catch (MsgOtherDetailException e) {
            e.printStackTrace();
        }
    }
    @Override
    public void taoLiJinMsg(Long uid, String beiZhu, MsgOtherTaoLiJinContentDTO content) {
        try {
@@ -381,6 +400,7 @@
    }
    
    
    @Override
    public void exchangeMsg(Long uid, String beiZhu,  MsgOtherExchangeContentDTO content) {
        try {
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -332,10 +332,9 @@
                    || userCoupon.getState() != UserSystemCoupon.STATE_IN_USE)
                throw new TokenRecordException(1, "该券不存在或非赠送");
            UserSystemCoupon userSystemCoupon= null;
            try {
                userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(),
                userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(),
                        UserSystemCoupon.SOURCE_GIVE, null);
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
@@ -362,9 +361,13 @@
            // 更新赠送记录
            UserSystemCouponGiveRecord updateGiveRecord = new UserSystemCouponGiveRecord();
            updateGiveRecord.setId(giveRecord.getId());
            updateGiveRecord.setReceiveUid(uid);
            updateGiveRecord.setReceiveTime(new Date());
            updateGiveRecord.setState(UserSystemCouponGiveRecord.STATE_RECEIVE);
            if (userSystemCoupon != null) {
                updateGiveRecord.setReceiveId(userSystemCoupon.getId());
            }
            userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord);
            integralGetService.addGiveFreeCoupon(giveUid);
@@ -419,8 +422,9 @@
            if (systemCoupon == null)
                throw new TokenRecordException(1, "该券不存在");
            
            UserSystemCoupon userSystemCoupon= null;
            try {
                userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
                userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
                        UserSystemCoupon.SOURCE_GIVE, systemCoupon.getPercent());
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
@@ -447,9 +451,13 @@
            // 更新赠送记录
            UserSystemCouponGiveRecord updateGiveRecord = new UserSystemCouponGiveRecord();
            updateGiveRecord.setId(giveRecord.getId());
            updateGiveRecord.setReceiveUid(uid);
            updateGiveRecord.setReceiveTime(new Date());
            updateGiveRecord.setState(UserSystemCouponGiveRecord.STATE_RECEIVE);
            if (userSystemCoupon != null) {
                updateGiveRecord.setReceiveId(userSystemCoupon.getId());
            }
            userSystemCouponGiveRecordService.updateByPrimaryKeySelective(updateGiveRecord);
            integralGetService.addGiveRebateCoupon(giveUid);
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java
@@ -41,4 +41,14 @@
    public List<UserSystemCouponGiveRecord> overdueList(int count) {
        return userSystemCouponGiveRecordMapper.overdueList(count);
    }
    @Override
    public List<UserSystemCouponGiveRecord> overdueListByUser(Long uid) {
        return userSystemCouponGiveRecordMapper.overdueListByUser(uid);
    }
    @Override
    public UserSystemCouponGiveRecord getByReceiveId(Long receiveId) {
        return userSystemCouponGiveRecordMapper.getByReceiveId(receiveId);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -16,6 +16,7 @@
import org.yeshi.utils.DateUtil;
import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper;
import com.yeshi.fanli.dto.msg.MsgOtherCouponActivateDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail.MsgTypeOtherTypeEnum;
import com.yeshi.fanli.entity.bus.user.DeviceLotteryRecord;
@@ -196,7 +197,7 @@
    @Override
    @Transactional
    public void insertUserCoupon(Long uid, String couponType, String source, BigDecimal percent)
    public UserSystemCoupon insertUserCoupon(Long uid, String couponType, String source, BigDecimal percent)
            throws UserSystemCouponException, Exception {
        if (couponType == null || uid == null) {
@@ -212,7 +213,7 @@
            // 随机奖励券
            if (percent == null || percent.compareTo(new BigDecimal(0)) < 1) {
                randomRewardCoupon(1, uid, source);
                return;
                return null;
            }  else {
                coupon = systemCouponService.getCouponByTypeAndPercent(couponType, percent);
            }
@@ -299,6 +300,8 @@
                e1.printStackTrace();
            }
        }
        return userCoupon;
    }
    @Transactional
@@ -1613,6 +1616,9 @@
        // 退回券
        sendBackTimeOutCoupon(uid);
        // 赠送的退回
        sendBackGiveUser(uid);
        
        List<UserSystemCouponVO> listVO = userSystemCouponMapper.getUserCouponVOList(start, count, uid);
        if (listVO == null || listVO.size() == 0) {
@@ -1697,6 +1703,15 @@
                        listTip.add("满足条件后,系统将自动激活,并在消息-其它消息中提醒。");
                        userCouponVO.setTips(listTip);
                        userCouponVO.setPopup(true);
                        // 验证是否已累计3单
                        executor.execute(new Runnable() {
                            @Override
                            public void run() {
                                freeCouponActivate(userCouponVO.getId(), uid, userCouponVO.getCreateTime());
                            }
                        });
                    } else if (CouponTypeEnum.welfareFreeCoupon == type) {
                        jumpBtn = new HashMap<String, Object>();
                        if (inviteCode != null && inviteCode.trim().length() > 0) {
@@ -1710,7 +1725,11 @@
            if (UserSystemCoupon.STATE_IN_USE == state && (CouponTypeEnum.freeCouponBuy == type
                    || CouponTypeEnum.freeCoupon == type || CouponTypeEnum.welfareFreeCoupon == type)) {
                userCouponVO.setInUseExplain(configService.get("free_coupon_using-help"));
                List<String> listTip = new ArrayList<String>();
                listTip.add("系统正在判断是否符合免单需求;");
                listTip.add("系统正在同步淘宝订单;");
                listTip.add("未使用成功的免单券会原路退回。");
                userCouponVO.setTipsUsing(listTip);
            }
            // 是否已赠送
@@ -1965,6 +1984,80 @@
    }
    
    /**
     * 免单券激活
     * @param uid
     */
    public void freeCouponActivate(Long id,Long uid, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long count = commonOrderCountService.countValidOrderByDate(uid, sdf.format(date));
        String activateNum = configService.get("free_coupon_activate_num");
        int num = Integer.parseInt(activateNum);
        if (count >= num) {
            UserSystemCoupon coupon = userSystemCouponMapper.selectByPrimaryKey(id);
            if (coupon == null || coupon.getState() != UserSystemCoupon.STATE_CAN_USE
                    || coupon.getStateActivated() != 0)
                return;
            Date nowDate = new Date();
            Date endTime2 = coupon.getEndTime();
            if (endTime2 != null && endTime2.getTime() <= nowDate.getTime())
                return;
            SystemCoupon systemCoupon = coupon.getSystemCoupon();
            if (systemCoupon == null)
                return;
            systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
            if (systemCoupon == null || systemCoupon.getType() != CouponTypeEnum.freeCoupon)
                return;
            try {
                Integer expiryDay =  systemCoupon.getExpiryDay();
                String endDay = DateUtil.plusDay(expiryDay - 1, nowDate);
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                Date endTime = format.parse(endDay);
                UserSystemCoupon userCoupon = new UserSystemCoupon();
                userCoupon.setId(coupon.getId());
                userCoupon.setStateActivated(1);
                userCoupon.setEndTime(endTime);
                userCoupon.setStartTime(nowDate);
                userCoupon.setUpdateTime(new Date());
                userSystemCouponMapper.updateByPrimaryKeySelective(userCoupon);
                // 赠送记录
                UserSystemCouponGiveRecord giveRecord = userSystemCouponGiveRecordService.getByReceiveId(id);
                if (giveRecord == null)
                    return;
                Long giveUid = giveRecord.getGiveUid();
                UserInfo userInfo = userInfoService.selectByPKey(giveUid);
                if (userInfo == null)
                    return;
                String beiZhu = "请到我的-福利中心中查看";
                SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
                MsgOtherCouponActivateDTO msgOther = new MsgOtherCouponActivateDTO();
                msgOther.setTitle("免单券激活");
                msgOther.setType("免单券系统已自动激活");
                msgOther.setExplain("满足"+ systemCoupon.getActivateDay() +"天内产生"+ num +"笔已到账返利订单");
                msgOther.setGiveUser("昵称:"+ userInfo.getNickName() +" ID:" + giveUid);
                msgOther.setReceiveTime(sd.format(giveRecord.getReceiveTime()));
                msgOther.setValidityTime(expiryDay + "天");
                userOtherMsgNotificationService.giveCouponActivateMsg(uid, beiZhu, msgOther);
            } catch (Exception e) {
                e.printStackTrace();
                LogHelper.errorDetailInfo(e);
            }
        }
    }
    @Transactional
    @Override
    public void updateInvalidSate(Long uid) {
@@ -2098,6 +2191,16 @@
    }
    
    @Transactional
    @Override
    public void sendBackGiveUser(Long uid) {
        List<UserSystemCouponGiveRecord> list =userSystemCouponGiveRecordService.overdueListByUser(uid);
        if (list == null || list.size() == 0) {
            return;
        }
        sendBackGiveCoupon(list);
    }
    @Override
    public void sendBackGiveCoupon(List<UserSystemCouponGiveRecord> overdueList) {
        for (UserSystemCouponGiveRecord record: overdueList) {
@@ -2160,14 +2263,17 @@
            
            // 退回消息
            String couponName = systemCoupon.getName();
            if (CouponTypeEnum.freeCouponGive == systemCoupon.getType())
            if (CouponTypeEnum.freeCouponGive == systemCoupon.getType()) {
                couponName = "免单券";
            } else if (CouponTypeEnum.rebatePercentCoupon == systemCoupon.getType()) {
                couponName = "奖励券";
            }
            
            String beiZhu = "请到我的-福利中心查看";
            SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
            MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
            msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
            msgOther.setTitle("赠送" + couponName + "退回");
            msgOther.setTitle(couponName + "退回");
            msgOther.setGiveType("你赠送的"+ couponName + "未被成功领取");
            msgOther.setGiveTime(sd.format(record.getGiveTime()));
            msgOther.setReturnTime(sd.format(new Date()));
fanli/src/main/java/com/yeshi/fanli/service/inter/msg/UserOtherMsgNotificationService.java
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import com.yeshi.fanli.dto.msg.MsgOtherCouponActivateDTO;
import com.yeshi.fanli.dto.msg.MsgOtherExchangeContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherTaoLiJinContentDTO;
@@ -224,4 +225,13 @@
    
    public void couponUsedFreeSheet(UserSystemCoupon coupon, String orderId, MsgTypeOtherTypeEnum type);
    /**
     * 赠送的免单券激活
     * @param uid
     * @param beiZhu
     * @param content
     */
    public void giveCouponActivateMsg(Long uid, String beiZhu, MsgOtherCouponActivateDTO content);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderCountService.java
@@ -69,5 +69,14 @@
     * @return
     */
    BigDecimal getMoneyByOrderNo(String orderNo);
    /**
     * 统计已到账返利订单
     * @param uid
     * @param dateTime
     * @return
     */
    public long countValidOrderByDate(Long uid, String dateTime);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java
@@ -41,4 +41,19 @@
     */
    public UserSystemCouponGiveRecord selectByPrimaryKey(Long id);
    /**
     * 赠送需退回
     * @param uid
     * @return
     */
    public List<UserSystemCouponGiveRecord> overdueListByUser(Long uid);
    /**
     * 领取的id
     * @param count
     * @return
     */
    UserSystemCouponGiveRecord getByReceiveId(Long receiveId);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -134,7 +134,7 @@
     * @throws UserSystemCouponException
     * @throws Exception
     */
    public void insertUserCoupon(Long uid, String couponType, String source, BigDecimal percent) throws UserSystemCouponException, Exception;
    public UserSystemCoupon insertUserCoupon(Long uid, String couponType, String source, BigDecimal percent) throws UserSystemCouponException, Exception;
    /**
@@ -282,4 +282,9 @@
     */
    public void updateInvalidSate(Long uid);
    /*
     * 赠送券
     */
    public void sendBackGiveUser(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -6,6 +6,7 @@
import java.util.List;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.msg.MsgOtherCouponActivateDTO;
import com.yeshi.fanli.dto.msg.MsgOtherCouponContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherExchangeContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
@@ -794,6 +795,55 @@
            contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
        } else if (msg.getType() == MsgTypeOtherTypeEnum.couponActivate) {
            if (StringUtil.isNullOrEmpty(msg.getContent()))
                return null;
            MsgOtherCouponActivateDTO dto = new Gson().fromJson(msg.getContent(), MsgOtherCouponActivateDTO.class);
            if (dto == null)
                return null;
            icon = "http://img.flqapp.com/resource/msg/icon_msg_other_coupon.png";
            List<ClientTextStyleVO> contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(dto.getType(), COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("类别", COLOR_TITLE), contentList));
            if (!StringUtil.isNullOrEmpty(dto.getExplain())) {
                contentList = new ArrayList<>();
                contentList.add(new ClientTextStyleVO(dto.getExplain() + "", COLOR_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("说明", COLOR_TITLE), contentList));
            }
            if (!StringUtil.isNullOrEmpty(dto.getGiveUser())) {
                contentList = new ArrayList<>();
                contentList.add(new ClientTextStyleVO(dto.getGiveUser() + "", COLOR_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送人", COLOR_TITLE), contentList));
            }
            if (!StringUtil.isNullOrEmpty(dto.getReceiveTime())) {
                contentList = new ArrayList<>();
                contentList.add(new ClientTextStyleVO(dto.getReceiveTime() + "", COLOR_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("获赠时间", COLOR_TITLE), contentList));
            }
            if (!StringUtil.isNullOrEmpty(dto.getValidityTime())) {
                contentList = new ArrayList<>();
                contentList.add(new ClientTextStyleVO(dto.getValidityTime() + "", COLOR_CONTENT));
                items.add(new CommonMsgItemVO(new ClientTextStyleVO("有效期", COLOR_TITLE), contentList));
            }
            contentList = new ArrayList<>();
            contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
                    COLOR_CONTENT));
            items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
            UserMsgVO userMsgVO = new UserMsgVO();
            userMsgVO.setIcon(icon);
            userMsgVO.setTitle(dto.getTitle());
            userMsgVO.setTime(msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime());
            userMsgVO.setContentItems(items);
            return userMsgVO;
        }
        return new UserMsgVO(icon, msg.getType().getDesc(),
fanli/src/main/java/com/yeshi/fanli/vo/user/UserSystemCouponVO.java
@@ -58,6 +58,10 @@
    @Expose
     private List<String> tips;
    
    // 使用中说明1.6.5
    @Expose
     private List<String> tipsUsing;
    // 赠送中-分享口令
    @Expose
     private String giveTips;
@@ -175,4 +179,12 @@
    public void setGiveTips(String giveTips) {
        this.giveTips = giveTips;
    }
    public List<String> getTipsUsing() {
        return tipsUsing;
    }
    public void setTipsUsing(List<String> tipsUsing) {
        this.tipsUsing = tipsUsing;
    }
}