yujian
2019-08-15 01e773cf27e572b8fb83538d85f31130930d93d1
券赠送
16个文件已修改
9个文件已添加
732 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCouponControllerV2.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralExchangeRecordMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinGiveRecordMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/TokenRecordMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponGiveRecordMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinGiveRecord.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/TokenRecord.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponGiveRecord.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/user/TokenRecordException.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralExchangeRecordMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/TokenRecordMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralExchangeRecordService.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/TokenRecordService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/msg/TokenVO.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java
@@ -41,7 +41,7 @@
        KEY = Constant.systemCommonConfig.getSignKey();
    }
//    @Around(EDP)
    @Around(EDP)
    public Object testAround(ProceedingJoinPoint joinPoint) throws IOException {
        Object[] args = joinPoint.getArgs();
        PrintWriter out = null;
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
@@ -2136,7 +2136,7 @@
            }
            // 1.6.5 之后返回 微信号提示
            if(VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion()))
                userInfo.setWeiXinTip(configService.get("添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。"));
                userInfo.setWeiXinTip("添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。");
            
            data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
            data.put("invitCode", invitCode); // 邀请码
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -34,6 +34,7 @@
import com.yeshi.fanli.exception.integral.IntegralExchangeException;
import com.yeshi.fanli.exception.integral.IntegralTaskRecordException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
@@ -52,6 +53,9 @@
@Controller
@RequestMapping("api/v2/integral")
public class IntegralControllerV2 {
    @Resource
    private ConfigService configService;
    @Resource
    private UserInfoService userInfoService;
@@ -359,6 +363,7 @@
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("list", getGson().toJson(list));
        data.put("helpLink", configService.get("publish_list_help_link"));
        out.print(JsonUtil.loadTrueResult(data));
    }
    
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -122,6 +122,18 @@
        
        // 组织数据
        JSONObject resultData = organizeTeam(count, listTeam, uid, type);
        // 第一页判断是否激活 是否有队员
        if (type == 1 && page == 1) {
            boolean hasCode = false;
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra != null) {
                if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
                    hasCode = true;
            }
            resultData.put("hasCode", hasCode);
            resultData.put("hasTeam", count > 0? true:false);
        }
        out.print(JsonUtil.loadTrueResult(resultData));
    }
    
@@ -272,6 +284,7 @@
            tipWeiXin.add("你也可以向邀请人学习或向一级队员教授赚钱技巧。");
        }
        resultData.put("tipWeiXin", tipWeiXin);
        resultData.put("tipWeiXinAdd", "添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。");
        resultData.put("bdWeiXin", bdWeiXin);
        
        out.print(JsonUtil.loadTrueResult(resultData));
@@ -311,7 +324,6 @@
                }
            }
            bossData.put("inviteTime", "你于 " + sdf.format(inviteTime) + "接受了TA的邀请");
        } else {
            bossData.put("hasBoss", false);
            bossData.put("helpLink", configService.get("invite_code_hlep_link"));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCouponControllerV2.java
@@ -121,29 +121,29 @@
    }
    
    /**
     * 赠送券口令生成
     * @param acceptData
     * @param uid
     * @param id
     * @param out
     */
    @RequestMapping(value = "giveCoupon", method = RequestMethod.POST)
    public void giveCoupon(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        if (id == null || id <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "传递参数不正确"));
            return;
        }
        try {
            String tips = UserSystemCouponService.giveCoupon(uid, id);
            out.print(JsonUtil.loadTrueResult(tips));
        } catch (UserSystemCouponException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralExchangeRecordMapper.java
@@ -1,7 +1,5 @@
package com.yeshi.fanli.dao.mybatis.integral;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
@@ -9,11 +7,12 @@
public interface IntegralExchangeRecordMapper extends BaseMapper<IntegralExchangeRecord> {
    
    /**
     * 查询今日兑换情况
     *  统计今日兑换情况
     * @param list
     * @return
     */
    List<Long> listRecordByExchangeIds(@Param("list") List<Long> list);
    long countRecordByUid(@Param("exchangeId") Long exchangeId, @Param("uid") Long uid);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinGiveRecordMapper.java
New file
@@ -0,0 +1,8 @@
package com.yeshi.fanli.dao.mybatis.tlj;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
public interface UserTaoLiJinGiveRecordMapper extends BaseMapper<UserTaoLiJinGiveRecord> {
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/TokenRecordMapper.java
@@ -1,8 +1,25 @@
package com.yeshi.fanli.dao.mybatis.user;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
public interface TokenRecordMapper extends BaseMapper<TokenRecord> {
    /**
     * 根据口令查询
     * @param token
     * @return
     */
    TokenRecord getByToken(@Param("token")String token);
    /**
     * 查询该类型最近生成口令
     * @param identify
     * @param type
     * @return
     */
    TokenRecord getNearByTypeAndIdentify(@Param("type")String type, @Param("identify")String identify);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserSystemCouponGiveRecordMapper.java
New file
@@ -0,0 +1,8 @@
package com.yeshi.fanli.dao.mybatis.user;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
public interface UserSystemCouponGiveRecordMapper extends BaseMapper<UserSystemCouponGiveRecord> {
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinGiveRecord.java
New file
@@ -0,0 +1,83 @@
package com.yeshi.fanli.entity.bus.tlj;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 淘礼金赠送记录
 *
 */
@Table("yeshi_ec_user_taolijin_give_record")
public class UserTaoLiJinGiveRecord {
    @Column(name = "tgr_id")
    private Long id;
    // 赠送uid
    @Column(name = "tgr_give_uid")
    private Long giveUid;
    // 领取uid
    @Column(name = "tgr_receive_uid")
    private Long receiveUid;
    // 赠送时间
    @Column(name = "tgr_give_time")
    private Date giveTime;
    // 领取时间
    @Column(name = "tgr_receive_time")
    private Date receiveTime;
    // 状态:0初始 1已领取 2已退回
    @Column(name = "tgr_state")
    private Integer state;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getGiveUid() {
        return giveUid;
    }
    public void setGiveUid(Long giveUid) {
        this.giveUid = giveUid;
    }
    public Long getReceiveUid() {
        return receiveUid;
    }
    public void setReceiveUid(Long receiveUid) {
        this.receiveUid = receiveUid;
    }
    public Date getGiveTime() {
        return giveTime;
    }
    public void setGiveTime(Date giveTime) {
        this.giveTime = giveTime;
    }
    public Date getReceiveTime() {
        return receiveTime;
    }
    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/TokenRecord.java
@@ -16,7 +16,7 @@
    
    // 口令类型
    public enum TokenTypeEnum {
        coupon("福利中心券");
        freeCoupon("免单券"), rebatePercentCoupon("返利比提成奖励券"),taoLiJin("推广红包"), ;
        private final String desc;
        private TokenTypeEnum(String desc) {
@@ -53,7 +53,7 @@
    @Column(name = "tr_end_time")
    private Date endTime;
    
    // 状态:0失效 1有效
    // 状态:0有效 1失效
    @Column(name = "tr_state")
    private Integer state;
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCouponGiveRecord.java
New file
@@ -0,0 +1,83 @@
package com.yeshi.fanli.entity.bus.user;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 券赠送记录
 *
 */
@Table("yeshi_ec_user_system_coupon_give_record")
public class UserSystemCouponGiveRecord {
    @Column(name = "cgr_id")
    private Long id;
    // 券id
    @Column(name = "cgr_coupon_id")
    private Long couponId;
    // 赠送uid
    @Column(name = "cgr_give_uid")
    private Long giveUid;
    // 领取uid
    @Column(name = "cgr_receive_uid")
    private Long receiveUid;
    // 赠送时间
    @Column(name = "cgr_give_time")
    private Date giveTime;
    // 领取时间
    @Column(name = "cgr_receive_time")
    private Date receiveTime;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getCouponId() {
        return couponId;
    }
    public void setCouponId(Long couponId) {
        this.couponId = couponId;
    }
    public Long getGiveUid() {
        return giveUid;
    }
    public void setGiveUid(Long giveUid) {
        this.giveUid = giveUid;
    }
    public Long getReceiveUid() {
        return receiveUid;
    }
    public void setReceiveUid(Long receiveUid) {
        this.receiveUid = receiveUid;
    }
    public Date getGiveTime() {
        return giveTime;
    }
    public void setGiveTime(Date giveTime) {
        this.giveTime = giveTime;
    }
    public Date getReceiveTime() {
        return receiveTime;
    }
    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/user/TokenRecordException.java
New file
@@ -0,0 +1,32 @@
package com.yeshi.fanli.exception.user;
public class TokenRecordException extends Exception {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public TokenRecordException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public TokenRecordException() {
    }
    @Override
    public String getMessage() {
        return this.msg;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralExchangeRecordMapper.xml
@@ -37,9 +37,8 @@
    </set> where er_id = #{id,jdbcType=BIGINT}
  </update>
  
  <select id="listRecordByExchangeIds" resultType="Long">
      SELECT er_exchange_id FROM yeshi_ec_integral_exchange_record
    WHERE er_uid = 1 AND TO_DAYS(er_create_time) = TO_DAYS(NOW())
         AND er_exchange_id in <foreach collection="list" item="item" open="(" separator="," close=")">#{item}</foreach>
  <select id="countRecordByUid" resultType="Long">
      SELECT IFNULL(COUNT(er_id),0) FROM yeshi_ec_integral_exchange_record
    WHERE er_uid = #{uid} AND er_exchange_id = #{exchangeId} AND TO_DAYS(er_create_time) = TO_DAYS(NOW())
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/TokenRecordMapper.xml
@@ -60,4 +60,18 @@
      <if test="updateTime != null">tr_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where tr_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="getByToken" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_token_record
    WHERE tr_token = #{token}
    LIMIT 1
  </select>
  <select id="getNearByTypeAndIdentify" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_token_record
    WHERE tr_identify = #{identify} AND tr_type = #{type}
    ORDER BY tr_create_time DESC
    LIMIT 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponGiveRecordMapper.xml
New file
@@ -0,0 +1,47 @@
<?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.user.UserSystemCouponGiveRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord">
    <id column="cgr_id" property="id" jdbcType="BIGINT"/>
    <result column="cgr_coupon_id" property="couponId" jdbcType="BIGINT"/>
    <result column="cgr_give_uid" property="giveUid" jdbcType="BIGINT"/>
    <result column="cgr_receive_uid" property="receiveUid" jdbcType="BIGINT"/>
    <result column="cgr_give_time" property="giveTime" jdbcType="TIMESTAMP"/>
    <result column="cgr_receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">cgr_id,cgr_coupon_id,cgr_give_uid,cgr_receive_uid,cgr_give_time,cgr_receive_time</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_receive_uid,cgr_give_time,cgr_receive_time) values (#{id,jdbcType=BIGINT},#{couponId,jdbcType=BIGINT},#{giveUid,jdbcType=BIGINT},#{receiveUid,jdbcType=BIGINT},#{giveTime,jdbcType=TIMESTAMP},#{receiveTime,jdbcType=TIMESTAMP})</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>
      <if test="couponId != null">cgr_coupon_id,</if>
      <if test="giveUid != null">cgr_give_uid,</if>
      <if test="receiveUid != null">cgr_receive_uid,</if>
      <if test="giveTime != null">cgr_give_time,</if>
      <if test="receiveTime != null">cgr_receive_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="couponId != null">#{couponId,jdbcType=BIGINT},</if>
      <if test="giveUid != null">#{giveUid,jdbcType=BIGINT},</if>
      <if test="receiveUid != null">#{receiveUid,jdbcType=BIGINT},</if>
      <if test="giveTime != null">#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveTime != null">#{receiveTime,jdbcType=TIMESTAMP},</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_receive_uid = #{receiveUid,jdbcType=BIGINT},cgr_give_time = #{giveTime,jdbcType=TIMESTAMP},cgr_receive_time = #{receiveTime,jdbcType=TIMESTAMP} 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>
      <if test="giveUid != null">cgr_give_uid=#{giveUid,jdbcType=BIGINT},</if>
      <if test="receiveUid != null">cgr_receive_uid=#{receiveUid,jdbcType=BIGINT},</if>
      <if test="giveTime != null">cgr_give_time=#{giveTime,jdbcType=TIMESTAMP},</if>
      <if test="receiveTime != null">cgr_receive_time=#{receiveTime,jdbcType=TIMESTAMP},</if>
    </set> where cgr_id = #{id,jdbcType=BIGINT}
  </update>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java
@@ -1,6 +1,5 @@
package com.yeshi.fanli.service.impl.integral;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
@@ -29,24 +28,22 @@
            return listValid;
        }
        
        List<Long> listId = new ArrayList<Long>();
        for(IntegralExchange integralExchange: listValid) {
            listId.add(integralExchange.getId());
        }
        List<Long> listRecord = integralExchangeRecordMapper.listRecordByExchangeIds(listId);
        for(IntegralExchange integralExchange: listValid) {
            String progress = integralExchange.getProgress();
            if (StringUtil.isNullOrEmpty(progress))
                continue;
            
            int exchange = 0;
            if (listRecord != null && listRecord.size() >0 && listRecord.contains(integralExchange.getId()))
                exchange = 1;
            // 今日兑换情况
            long exchange = integralExchangeRecordMapper.countRecordByUid(integralExchange.getId(), uid);
            
            progress = progress.replace("{已兑换}", exchange + "").replace("{上限数}", integralExchange.getUpperLimit() + "");
            integralExchange.setProgress(progress);
        }
        return listValid;
    }
    @Override
    public long countRecordByUid(long exchangeid, Long uid){
        return integralExchangeRecordMapper.countRecordByUid(exchangeid, uid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -21,6 +21,7 @@
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
@@ -58,6 +59,9 @@
    
    @Resource
    private CodePublishRecordService codePublishRecordService;
    @Resource
    private IntegralExchangeRecordService integralExchangeRecordService;
    
    
@@ -99,6 +103,14 @@
            exchangeTip.setType(type.name());
            return exchangeTip;
        }
        int upperLimit = exchange.getUpperLimit();
        // 今日兑换情况
        long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
        if (exchangeCount >= upperLimit) {
            throw new IntegralExchangeException(1, "今日兑换已达上限");
        }
        
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue()) {
@@ -150,6 +162,13 @@
        if (exchange == null)
            throw new IntegralExchangeException(1, "兑换方式不存在");
        int upperLimit = exchange.getUpperLimit();
        // 今日兑换情况
        long exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid);
        if (exchangeCount >= upperLimit) {
            throw new IntegralExchangeException(1, "今日兑换已达上限");
        }
        Integer goldCoin = exchange.getGoldCoin();
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue()) {
@@ -197,9 +216,10 @@
                throw new IntegralExchangeException(1, "兑换方式不存在");
            }
            
            exchangeCount ++;
            String progress = exchange.getProgress();
            if (!StringUtil.isNullOrEmpty(progress))
                progress = progress.replace("{已兑换}", 1 + "").replace("{上限数}", exchange.getUpperLimit() + "");
                progress = progress.replace("{已兑换}",exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + "");
            exchange.setProgress(progress);
            
            // 更新金币
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -1,14 +1,27 @@
package com.yeshi.fanli.service.impl.user;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.user.TokenRecordMapper;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
import com.yeshi.fanli.exception.user.TokenRecordException;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.vo.msg.TokenVO;
@Service
public class TokenRecordServiceImpl implements TokenRecordService{
@@ -16,10 +29,151 @@
    @Resource
    private TokenRecordMapper tokenRecordMapper;
    
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Override
    public void insertSelective(TokenRecord record) {
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        tokenRecordMapper.insertSelective(record);
    }
    @Override
    public TokenRecord getNearByTypeAndIdentify(String type, String identify) {
        return tokenRecordMapper.getNearByTypeAndIdentify(type, identify);
    }
    public void discernToken(String token, Long uid) throws TokenRecordException {
        // TODO token 验证
        TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
        if (rokenRecord == null)
            throw new TokenRecordException(1, "口令不存在");
        String nickName = null;
        String portrait = null;
        Long inviteId = rokenRecord.getUid();
        if (inviteId != null) {
            UserInfo inviteUser = userInfoService.selectByPKey(inviteId);
            if (inviteUser !=null) {
                nickName = inviteUser.getNickName();
                portrait = inviteUser.getPortrait();
            }
        }
        if (StringUtil.isNullOrEmpty(nickName))
            nickName = Constant.systemCommonConfig.getDefaultNickName();
        if (StringUtil.isNullOrEmpty(portrait))
            portrait = Constant.systemCommonConfig.getDefaultPortrait();
        if (nickName.length() > 6) {
            nickName = nickName.substring(0, 6) + "...";
        }
        Integer stateTtoken = rokenRecord.getState();
        if (stateTtoken == 1)
            throw new TokenRecordException(1, "口令已失效");
        TokenVO tokenVO = new TokenVO();
        tokenVO.setNickName(nickName);
        tokenVO.setPortrait(portrait);
        String identify = rokenRecord.getIdentify();
        if (StringUtil.isNullOrEmpty(identify))
            throw new TokenRecordException(1, "口令标识不存在");
        boolean state = false;
        List<String> tips = new ArrayList<String>();
        TokenTypeEnum tokenType = rokenRecord.getType();
        if (tokenType == TokenTypeEnum.freeCoupon) {
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null || userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
                tips.add("哎呀,这张免单券已失效了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
                tips.add("哎呀,这张免单券已被领取了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) {
                throw new TokenRecordException(1, "口令已失效");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "用户未登录");
                state = true;
                ThreeSale boss = threeSaleSerivce.getMyBoss(uid);
                if (boss != null) {
                    tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
                    tips.add("成功领取后,请到“我的-福利中心”查看。");
                } else {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
                    tips.add("成功领取后,请到“我的-福利中心”查看。");
                }
            }
        } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) {
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null || userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
                tips.add("哎呀,这张返利奖励券已失效了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
                tips.add("哎呀,这张返利奖励券已被领取了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) {
                throw new TokenRecordException(1, "口令已失效");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "用户未登录");
                state = true;
                ThreeSale boss = threeSaleSerivce.getMyBoss(uid);
                if (boss != null) {
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                } else {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                }
            }
        } else if (tokenType == TokenTypeEnum.taoLiJin) {
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null || userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
                tips.add("哎呀,这张返利奖励券已失效了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
                tips.add("哎呀,这张返利奖励券已被领取了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) {
                throw new TokenRecordException(1, "口令已失效");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "用户未登录");
                state = true;
                ThreeSale boss = threeSaleSerivce.getMyBoss(uid);
                if (boss != null) {
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                } else {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                }
            }
        } else {
            throw new TokenRecordException(1, "无对应类型");
        }
        tokenVO.setTips(tips);
        tokenVO.setState(state);
        tokenVO.setType(tokenType.name());
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponGiveRecordServiceImpl.java
New file
@@ -0,0 +1,23 @@
package com.yeshi.fanli.service.impl.user;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponGiveRecordMapper;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
@Service
public class UserSystemCouponGiveRecordServiceImpl implements UserSystemCouponGiveRecordService{
    @Resource
    private UserSystemCouponGiveRecordMapper userSystemCouponGiveRecordMapper;
    @Override
    public void insertSelective(UserSystemCouponGiveRecord record) {
        userSystemCouponGiveRecordMapper.insertSelective(record);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -25,6 +25,7 @@
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
@@ -54,11 +55,13 @@
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
@@ -80,6 +83,9 @@
    @Resource
    private UserSystemCouponMapper userSystemCouponMapper;
    @Resource
    private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
    @Resource
    private ConfigService configService;
@@ -1865,23 +1871,59 @@
        if (type != CouponTypeEnum.freeCouponGive && type != CouponTypeEnum.rebatePercentCoupon )
            throw new UserSystemCouponException(1, "该券不支持赠送");
        
        TokenTypeEnum tokenTypeEnum = null;
        if (type == CouponTypeEnum.freeCouponGive) {
            tokenTypeEnum = TokenTypeEnum.freeCoupon;
        } else if (type == CouponTypeEnum.rebatePercentCoupon){
            tokenTypeEnum = TokenTypeEnum.rebatePercentCoupon;
        } else {
            throw new UserSystemCouponException(1, "该券不支持赠送");
        }
        
        Date startTime = new Date();
        Date endTime = DateUtil.plusDayDate(3, new Date());
        String token = null;
        Date nowDate = new Date();
        TokenRecord record = tokenRecordService.getNearByTypeAndIdentify(tokenTypeEnum.name(), id+"");
        if (record != null && record.getEndTime().getTime() > nowDate.getTime()) {
            token = record.getToken();
        } else {
            for (int i = 0; i < 5; i++) {
                try {
                    // TODO 口令生成规则待定
        long num = 10000 + (long) (Math.random() * 10000);
        String token = UserUtil.getInviteCode(num);
                    token = UserUtil.getInviteCode(num);
        
        TokenRecord tokenRecord = new TokenRecord();
        tokenRecord.setUid(uid);
        tokenRecord.setIdentify(id+"");
        tokenRecord.setType(TokenTypeEnum.coupon);
        tokenRecord.setEndTime(endTime);
        tokenRecord.setStartTime(startTime);
                    tokenRecord.setType(tokenTypeEnum);
                    tokenRecord.setStartTime(nowDate);
                    tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
        tokenRecord.setToken(token);
        tokenRecord.setState(state);
        tokenRecordService.insertSelective(tokenRecord);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                    token = null;
                }
        
                if(!StringUtil.isNullOrEmpty(token)) {
                    break;
                }
            }
            if(StringUtil.isNullOrEmpty(token))
                throw new UserSystemCouponException(1, "口令生成失败");
            // 插入赠送记录
            UserSystemCouponGiveRecord giveRecord = new UserSystemCouponGiveRecord();
            giveRecord.setCouponId(id);
            giveRecord.setGiveUid(uid);
            giveRecord.setGiveTime(nowDate);
            userSystemCouponGiveRecordService.insertSelective(giveRecord);
        }
        if(StringUtil.isNullOrEmpty(token))
            throw new UserSystemCouponException(1, "口令生成失败");
        String tips = "送给你一张返利奖励券快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,使用后可让返利加倍。\r\n" 
                +"----------------------------\r\n" 
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralExchangeRecordService.java
@@ -15,6 +15,11 @@
     */
    public List<IntegralExchange> listExchange(long start, int count, Long uid);
    /**
     * 今日任务统计
     * @param exchangeid
     * @param uid
     * @return
     */
    public long countRecordByUid(long exchangeid, Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/TokenRecordService.java
@@ -6,4 +6,12 @@
    public void insertSelective(TokenRecord record);
    /**
     * 查询最近发布口令
     * @param type
     * @param identify
     * @return
     */
    public TokenRecord getNearByTypeAndIdentify(String type, String identify);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponGiveRecordService.java
New file
@@ -0,0 +1,10 @@
package com.yeshi.fanli.service.inter.user;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
public interface UserSystemCouponGiveRecordService {
    public void insertSelective(UserSystemCouponGiveRecord record);
}
fanli/src/main/java/com/yeshi/fanli/vo/msg/TokenVO.java
New file
@@ -0,0 +1,86 @@
package com.yeshi.fanli.vo.msg;
import java.util.List;
import com.google.gson.annotations.Expose;
public class TokenVO {
    @Expose // id
    private Long id;
    @Expose // 昵称
    private String nickName;
    @Expose // 头像
    private String portrait;
    @Expose // 类型
    private String type;
    @Expose // 数量、面额
    private Integer amount;
    @Expose // 提示语
    private List<String> tips;
    @Expose // 是否有效
    private Boolean state;
    public String getNickName() {
        return nickName;
    }
    public void setNickName(String nickName) {
        this.nickName = nickName;
    }
    public String getPortrait() {
        return portrait;
    }
    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Integer getAmount() {
        return amount;
    }
    public void setAmount(Integer amount) {
        this.amount = amount;
    }
    public List<String> getTips() {
        return tips;
    }
    public void setTips(List<String> tips) {
        this.tips = tips;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Boolean getState() {
        return state;
    }
    public void setState(Boolean state) {
        this.state = state;
    }
}