yujian
2019-08-14 2e5c6b46697f7b96460ad0c356740df52bf056d2
金币兑换
28个文件已修改
5个文件已添加
1716 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/aspect/SignValidateAspect.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/InviteGetMoneyController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java 65 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/CodePublishRecordMapper.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralExchangeMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinOrigin.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/HongBaoV2.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/integral/CodePublishRecord.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/integral/IntegralExchange.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/system/SystemCoupon.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/SystemCouponMapper.xml 226 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/CodePublishRecordMapper.xml 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralExchangeMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml 313 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/CodePublishRecordServiceImpl.java 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java 238 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/CodePublishRecordService.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralExchangeService.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinOriginService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoExtraService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/integral/ExchangeTipVO.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/user/UserSystemCouponVO.java 27 ●●●●● 补丁 | 查看 | 原始文档 | 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/InviteGetMoneyController.java
@@ -23,7 +23,6 @@
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.exception.NotExistObjectException;
import com.yeshi.fanli.exception.banner.SwiperPictureException;
import com.yeshi.fanli.exception.user.UserInfoExtraException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
@@ -253,7 +252,7 @@
                return;
            }
            String newCode = userInfoExtraService.activateInviteCode(uid, inviteCode, acceptData.getPlatform(), acceptData.getVersion());
            String newCode = userInfoExtraService.activateInviteCode(uid, inviteCode);
            if (newCode == null || newCode.trim().length() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("激活失败"));
                return;
@@ -283,7 +282,7 @@
    @RequestMapping(value = "activationInviteWX")
    public void activationInviteWX(AcceptData acceptData, Long uid, String  code, PrintWriter out) {
        try {
            userInfoExtraService.activationInviteWX(uid, code, acceptData.getPlatform(), acceptData.getVersion());
            userInfoExtraService.activationInviteWX(uid, code);
            out.print(JsonUtil.loadTrueResult("邀请码激活成功"));
        } catch (UserInfoExtraException e) {
            out.print(JsonUtil.loadFalseResult(e.getMsg()));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -1,7 +1,10 @@
package com.yeshi.fanli.controller.client.v2;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -15,10 +18,15 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserRank;
import com.yeshi.fanli.entity.integral.CodePublishRecord;
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.entity.integral.IntegralTaskClass;
import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
@@ -26,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.integral.CodePublishRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
@@ -61,6 +70,9 @@
    
    @Resource
    private IntegralExchangeRecordService integralExchangeRecordService;
    @Resource
    private CodePublishRecordService codePublishRecordService;
    
    /**
     * 获取任务列表
@@ -228,7 +240,7 @@
        Gson gson = gsonBuilder.create();
        
        JSONObject data = new JSONObject();
        data.put("goldCoin", extraVO.getGoldCoin());
        data.put("goldCoin", extraVO.getGoldCoin() + "枚");
        data.put("count", count);
        data.put("list", gson.toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
@@ -253,7 +265,7 @@
            data.put("result", gson.toJson(exchange));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (IntegralExchangeException e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    
@@ -267,7 +279,7 @@
    @RequestMapping(value = "exchange", method = RequestMethod.POST)
    public void exchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
        try {
            ExchangeTipVO exchange = integralExchangeService.verifyExchange(uid, id);
            IntegralExchange exchange = integralExchangeService.exchange(uid, id);
            
            GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
            Gson gson = gsonBuilder.create();
@@ -276,7 +288,148 @@
            data.put("result", gson.toJson(exchange));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (IntegralExchangeException e) {
            e.printStackTrace();
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    /**
     * 兑换金币检验-邀请码
     * @param acceptData
     * @param uid
     * @param id
     * @param out
     */
    @RequestMapping(value = "verifyInviteCode", method = RequestMethod.POST)
    public void verifyInviteCode(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
        try {
            ExchangeTipVO exchange = integralExchangeService.verifyInviteCode(uid, id);
            GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
            Gson gson = gsonBuilder.create();
            JSONObject data = new JSONObject();
            data.put("result", gson.toJson(exchange));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (IntegralExchangeException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    /**
     * 兑换金币-邀请码
     * @param acceptData
     * @param uid
     * @param id
     * @param out
     */
    @RequestMapping(value = "exchangeInviteCode", method = RequestMethod.POST)
    public void exchangeInviteCode(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
        try {
            integralExchangeService.exchangeInviteCode(uid, id);
            out.print(JsonUtil.loadTrueResult("邀请码激活成功"));
        } catch (IntegralExchangeException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
    /**
     * 邀请码发布列表
     * @param acceptData
     * @param page
     * @param out
     */
    @RequestMapping(value = "getPublishList", method = RequestMethod.POST)
    public void getPublishList(AcceptData acceptData, Integer page, PrintWriter out) {
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
            return;
        }
        List<CodePublishRecord> list = codePublishRecordService.listValid((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
        if (list == null) {
            list = new ArrayList<CodePublishRecord>();
        }
        long count = codePublishRecordService.countValid();
        JSONObject data = new JSONObject();
        data.put("count", count);
        data.put("list", getGson().toJson(list));
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 时间处理
     * @return
     */
    private Gson getGson() {
        GsonBuilder gb = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
        gb.excludeFieldsWithoutExposeAnnotation();
        gb.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
            @Override
            public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
                String desc = "";
                if (value != null) {
                    // 判断是否是同一天
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(value);
                    int y1 = calendar.get(Calendar.YEAR);//获取年份
                    int d1 = calendar.get(Calendar.DAY_OF_YEAR);//获取年中第几天
                    Date nowDate = new Date();
                    Calendar calendar2 = Calendar.getInstance();
                    calendar2.setTime(nowDate);
                    int y2 = calendar2.get(Calendar.YEAR);//获取年份
                    int d2 = calendar2.get(Calendar.DAY_OF_YEAR);//获取年中第几天
                    long old = value.getTime();
                    long now = nowDate.getTime();
                    if (y1 == y2) {
                        if (d1 == d2) {
                            long cha = now - old;
                            if (cha < 1000 * 60 * 2L) {
                                desc = "刚刚";
                            }else if (cha < 1000 * 60 * 60L) {
                                desc = (cha / (1000 * 60)) + "分钟前";
                            }else {
                                desc = (cha / (1000 * 60 * 60)) + "小时前";
                            }
                        } else if (d2 - d1 == 1) {
                            desc = "昨天";
                        } else {
                            desc = (d2 - d1) + "天前";
                        }
                    } else {
                        int timeDistance = 0;
                        for (int i = y1; i < y2; i++) {
                            if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
                                timeDistance += 366; // 闰年
                            } else {
                                timeDistance += 365; // 不是闰年
                            }
                        }
                        desc = timeDistance + (d2 - d1) + "天前";
                    }
                    return new JsonPrimitive(desc);
                }
                return new JsonPrimitive("");
            }
        });
        Gson gson = gb.create();
        return gson;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -121,40 +121,6 @@
        
        // 组织数据
        JSONObject resultData = organizeTeam(count, listTeam, uid, type);
        resultData.put("helpLink", configService.get("team_help_url"));
        boolean hasCode = false;
        boolean bdWeiXin = false;
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null) {
            if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
                hasCode = true;
            if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
                bdWeiXin = true;
        }
        // 未激活邀请码
        if (!hasCode) {
            resultData.put("helpLinkActivate", configService.get("team_help_url"));
            resultData.put("tipCode", "激活邀请功能后才可以邀请队员,一级队员是由你直接邀请,二级队员是由你的一级队员邀请。\r\n邀请激活功能,必须要有邀请码,邀请码可以通过金币兑换,也可以全网搜索。");
        }
        resultData.put("hasCode", hasCode);
        // 未添加微信号
        if (!bdWeiXin) {
            resultData.put("tipWeiXin", "添加微信号后,你的邀请人和一级队员可通过微信号与你建立联系;\r\n你也可以向邀请人学习或向一级队员教授赚钱技巧。");
        }
        resultData.put("bdWeiXin", bdWeiXin);
        // 安卓返回统计数据
        String platform = acceptData.getPlatform();
        if ("android".equalsIgnoreCase(platform)) {
            JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
            resultData.put("boss", bossData);
            resultData.put("firstTeam", threeSaleSerivce.countFirstTeam(uid, 1));
            resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
        }
        out.print(JsonUtil.loadTrueResult(resultData));
    }
    
@@ -267,6 +233,37 @@
        resultData.put("firstTeamTotal", threeSaleSerivce.countFirstTeam(uid, null));
        resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
        resultData.put("secondTeamTotal", threeSaleSerivce.countSecondTeam(uid, null));
        boolean hasCode = false;
        boolean bdWeiXin = false;
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null) {
            if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
                hasCode = true;
            if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
                bdWeiXin = true;
        }
        List<String> tipCode = new ArrayList<String>();
        // 未激活邀请码
        if (!hasCode) {
            resultData.put("helpLinkActivate", configService.get("team_help_url"));
            tipCode.add("激活邀请功能后才可以邀请队员,一级队员是由你直接邀请,二级队员是由你的一级队员邀请。");
            tipCode.add("邀请激活功能,必须要有邀请码,邀请码可以通过金币兑换,也可以全网搜索。");
        }
        resultData.put("hasCode", hasCode);
        resultData.put("tipCode", tipCode);
        // 未添加微信号
        List<String> tipWeiXin = new ArrayList<String>();
        if (!bdWeiXin) {
            tipWeiXin.add("添加微信号后,你的邀请人和一级队员可通过微信号与你建立联系;");
            tipWeiXin.add("你也可以向邀请人学习或向一级队员教授赚钱技巧。");
        }
        resultData.put("tipWeiXin", tipWeiXin);
        resultData.put("bdWeiXin", bdWeiXin);
        out.print(JsonUtil.loadTrueResult(resultData));
    }
    
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/CodePublishRecordMapper.java
New file
@@ -0,0 +1,24 @@
package com.yeshi.fanli.dao.mybatis.integral;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.integral.CodePublishRecord;
public interface CodePublishRecordMapper extends BaseMapper<CodePublishRecord> {
    /**
     * 查询近3天发布记录
     * @return
     */
    List<CodePublishRecord> listValid(@Param("start") long start, @Param("count") int count);
    long countValid();
    long countValidRecord(@Param("uid") long uid);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/integral/IntegralExchangeMapper.java
@@ -15,4 +15,12 @@
    List<IntegralExchange> listValid(@Param("start") long start, @Param("count") int count);
    
    Long countValid();
    /**
     * 根据类型查询有效兑换
     * @param type
     * @return
     */
    IntegralExchange getValidByType(@Param("type") String type);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinOrigin.java
@@ -16,7 +16,8 @@
public class UserTaoLiJinOrigin {
    public enum TaoLiJinOriginEnum {
        newbiesWin("新人红包"), shareWin("推广红包福利"), rankWin("账户等级福利"), inviteWin("邀请队员奖励"), refund("未领取退回");
        newbiesWin("新人红包"), shareWin("推广红包福利"), rankWin("账户等级福利"), inviteWin("邀请队员奖励"),
        refund("未领取退回"), exchange("金币兑换");
        
        private final String desc;
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/HongBaoV2.java
@@ -53,6 +53,8 @@
    // 二级分享赚分销红包
    public final static int TYPE_SHARE_ERJI = 22;
    // 使用券红包
    public final static int TYPE_EXCHANGE = 30;
    @Column(name = "hb_id")
    private Long id;
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/UserSystemCoupon.java
@@ -28,6 +28,8 @@
    public final static String SOURCE_YAOQING = "邀请奖励";
    public final static String SOURCE_SYSTEM_PUSH = "系统赠送";
    public final static String SOURCE_DAILY_REBATE = "奖励券天天抽";
    public final static String SOURCE_EXCHANGE = "金币兑换";
    public final static String SOURCE_GIVE = "好友赠送";
    
    @Expose
    @Column(name = "usc_id")
@@ -55,7 +57,12 @@
    @Expose
    @Column(name = "usc_state_activate")
    private Integer stateActivated;
    // 是否可赠送
    @Expose
    @Column(name = "usc_give")
    private Boolean give;
    // 起始时间
    @Column(name = "usc_start_time")
    private Date startTime;
@@ -163,4 +170,12 @@
    public void setStateActivated(Integer stateActivated) {
        this.stateActivated = stateActivated;
    }
    public Boolean getGive() {
        return give;
    }
    public void setGive(Boolean give) {
        this.give = give;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/integral/CodePublishRecord.java
New file
@@ -0,0 +1,101 @@
package com.yeshi.fanli.entity.integral;
import java.io.Serializable;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import com.google.gson.annotations.Expose;
/**
 * 邀请码发布记录
 *
 * @author Administrator
 *
 */
@Table("yeshi_ec_code_publish_record")
public class CodePublishRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Expose
    @Column(name = "pr_id")
    private Long id;
    @Column(name = "pr_uid")
    private Long uid;
    @Expose
    @Column(name = "pr_create_time")
    private Date createTime;
    @Expose
    private String nickName; // 昵称
    @Expose
    private String portrait; // 图片
    @Expose
    private String team; // 邀请码
    @Expose
    private String inviteCode; // 邀请码
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getUid() {
        return uid;
    }
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    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 getTeam() {
        return team;
    }
    public void setTeam(String team) {
        this.team = team;
    }
    public String getInviteCode() {
        return inviteCode;
    }
    public void setInviteCode(String inviteCode) {
        this.inviteCode = inviteCode;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/integral/IntegralExchange.java
@@ -21,7 +21,7 @@
    private static final long serialVersionUID = 1L;
    public enum ExchangeTypeEnum {
        freeCouponBuy("自购免单券"), freeCouponGive("赠送免单券"), rebateCoupon("返利奖励券"), inviteCodeActivate("邀请码激活卡"),
        freeCouponBuy("自购免单券"), freeCouponGive("赠送免单券"), rebatePercentCoupon("返利奖励券"), inviteCodeActivate("邀请码激活卡"),
        inviteCodePublish("邀请码发布卡"), taoLiJin("推广红包"), cash("现金红包");
        private final String desc;
fanli/src/main/java/com/yeshi/fanli/entity/money/UserMoneyDetail.java
@@ -28,7 +28,7 @@
    public enum UserMoneyDetailTypeEnum {
        share("分享奖金", "http://img.flqapp.com/resource/money_detail/icon_share.png", ""), invite("邀请奖金", "http://img.flqapp.com/resource/money_detail/icon_invite.png", ""), inviteAndShare("奖金收入", "http://img.flqapp.com/resource/money_detail/icon_share.png", ""), fanli("返利到账", "http://img.flqapp.com/resource/money_detail/icon_fanli.png",
                ""), fanliWeiQuan("返利扣除", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), inviteWeiQuan("邀请奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_invite.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), shareWeiQuan("分享奖金扣除", "http://img.flqapp.com/resource/money_detail/icon_share.png",
                        "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), weiQuan("售后订单扣款", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), systemEqualize("系统补齐", "http://img.flqapp.com/resource/money_detail/icon_system.png", ""), scoreConvert("积分兑换", "http://img.flqapp.com/resource/money_detail/icon_score.png",
                        "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), weiQuan("售后订单扣款", "http://img.flqapp.com/resource/money_detail/icon_fanli.png", "http://apph5.yeshitv.com/apppage/flq_whyMoneyDel.html"), systemEqualize("系统补齐", "http://img.flqapp.com/resource/money_detail/icon_system.png", ""), scoreConvert("金币兑换", "http://img.flqapp.com/resource/money_detail/icon_score.png",
                                ""), hongbao("官方红包", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png", ""), hongbaoDeduct("红包退款", "http://img.flqapp.com/resource/money_detail/icon_hongbao.png",
                                        ""), buyScore("购买积分", "http://img.flqapp.com/resource/money_detail/icon_score.png", ""), extract("提现", "http://img.flqapp.com/resource/money_detail/icon_extract.png",
                                                ""), extractVerify("提现验证", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""), extractReject("提现被拒", "http://img.flqapp.com/resource/money_detail/icon_extract.png", ""),orderReward("返利奖励","http://img.flqapp.com/resource/money_detail/icon_order_reward.png",""),repeatStatistic("重复统计返利/奖金扣除","http://img.flqapp.com/resource/money_detail/icon_fanli.png","");
fanli/src/main/java/com/yeshi/fanli/entity/system/SystemCoupon.java
@@ -22,8 +22,8 @@
    // 券类型
    public enum CouponTypeEnum {
        freeCoupon("免单"), welfareFreeCoupon("福利免单"), rebatePercentCoupon("返利比提成奖励券");
        freeCoupon("免单券"), welfareFreeCoupon("福利免单"), rebatePercentCoupon("返利比提成奖励券"),
        freeCouponBuy("自购免单券"),freeCouponGive("赠送免单券");
        private final String desc;
        private CouponTypeEnum(String desc) {
@@ -74,13 +74,14 @@
    @Column(name = "sc_rule")
    private String rule;
    // 规则
    @Column(name = "sc_rule_link")
    private String ruleLink;
    // 备注说明
    @Column(name = "sc_remark")
    private String remark;
    // 领取数量
    @Column(name = "sc_receive_count")
    private Integer receiveCount;
    // 状态 0未启用 1已启用
    @Column(name = "sc_state")
@@ -173,14 +174,6 @@
        this.remark = remark;
    }
    public Integer getReceiveCount() {
        return receiveCount;
    }
    public void setReceiveCount(Integer receiveCount) {
        this.receiveCount = receiveCount;
    }
    public Integer getState() {
        return state;
    }
@@ -220,5 +213,13 @@
    public void setPictureInvalid(String pictureInvalid) {
        this.pictureInvalid = pictureInvalid;
    }
    public String getRuleLink() {
        return ruleLink;
    }
    public void setRuleLink(String ruleLink) {
        this.ruleLink = ruleLink;
    }
    
}
fanli/src/main/java/com/yeshi/fanli/mapping/SystemCouponMapper.xml
@@ -1,113 +1,113 @@
<?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.SystemCouponMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.system.SystemCoupon">
    <id column="sc_id" property="id" jdbcType="BIGINT"/>
    <result column="sc_name" property="name" jdbcType="VARCHAR"/>
    <result column="sc_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="sc_picture_invalid" property="pictureInvalid" jdbcType="VARCHAR"/>
    <result column="sc_effect" property="effect" jdbcType="VARCHAR"/>
    <result column="sc_type" property="type"
            typeHandler="com.yeshi.fanli.util.mybatishandler.CouponTypeEnumHandler" />
    <result column="sc_percent" property="percent" jdbcType="DECIMAL"/>
    <result column="sc_amount" property="amount" jdbcType="VARCHAR"/>
    <result column="sc_expiry_day" property="expiryDay" jdbcType="INTEGER"/>
    <result column="sc_rule" property="rule" jdbcType="VARCHAR"/>
    <result column="sc_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="sc_receive_count" property="receiveCount" jdbcType="INTEGER"/>
    <result column="sc_state" property="state" jdbcType="INTEGER"/>
    <result column="sc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="sc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">sc_id,sc_name,sc_picture,sc_picture_invalid,sc_effect,sc_type,sc_percent,sc_amount,sc_expiry_day,sc_rule,sc_remark,sc_receive_count,sc_state,sc_create_time,sc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_system_coupon where sc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_system_coupon where sc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.system.SystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_system_coupon (sc_id,sc_name,sc_picture,sc_picture_invalid,sc_effect,sc_type,sc_percent,sc_amount,sc_expiry_day,sc_rule,sc_remark,sc_receive_count,sc_state,sc_create_time,sc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{pictureInvalid,jdbcType=VARCHAR},#{effect,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{percent,jdbcType=DECIMAL},#{amount,jdbcType=VARCHAR},#{expiryDay,jdbcType=INTEGER},#{rule,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{receiveCount,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.system.SystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_system_coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">sc_id,</if>
      <if test="name != null">sc_name,</if>
      <if test="picture != null">sc_picture,</if>
      <if test="pictureInvalid != null">sc_picture_invalid,</if>
      <if test="effect != null">sc_effect,</if>
      <if test="type != null">sc_type,</if>
      <if test="percent != null">sc_percent,</if>
      <if test="amount != null">sc_amount,</if>
      <if test="expiryDay != null">sc_expiry_day,</if>
      <if test="rule != null">sc_rule,</if>
      <if test="remark != null">sc_remark,</if>
      <if test="receiveCount != null">sc_receive_count,</if>
      <if test="state != null">sc_state,</if>
      <if test="createTime != null">sc_create_time,</if>
      <if test="updateTime != null">sc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="pictureInvalid != null">#{pictureInvalid,jdbcType=VARCHAR},</if>
      <if test="effect != null">#{effect,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="percent != null">#{percent,jdbcType=DECIMAL},</if>
      <if test="amount != null">#{amount,jdbcType=VARCHAR},</if>
      <if test="expiryDay != null">#{expiryDay,jdbcType=INTEGER},</if>
      <if test="rule != null">#{rule,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="receiveCount != null">#{receiveCount,jdbcType=INTEGER},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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.system.SystemCoupon">update yeshi_ec_system_coupon set sc_name = #{name,jdbcType=VARCHAR},sc_picture = #{picture,jdbcType=VARCHAR},sc_picture_invalid = #{pictureInvalid,jdbcType=VARCHAR},sc_effect = #{effect,jdbcType=VARCHAR},sc_type = #{type,jdbcType=VARCHAR},sc_percent = #{percent,jdbcType=DECIMAL},sc_amount = #{amount,jdbcType=VARCHAR},sc_expiry_day = #{expiryDay,jdbcType=INTEGER},sc_rule = #{rule,jdbcType=VARCHAR},sc_remark = #{remark,jdbcType=VARCHAR},sc_receive_count = #{receiveCount,jdbcType=INTEGER},sc_state = #{state,jdbcType=INTEGER},sc_create_time = #{createTime,jdbcType=TIMESTAMP},sc_update_time = #{updateTime,jdbcType=TIMESTAMP} where sc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.system.SystemCoupon">update yeshi_ec_system_coupon
    <set>
      <if test="name != null">sc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">sc_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="pictureInvalid != null">sc_picture_invalid=#{pictureInvalid,jdbcType=VARCHAR},</if>
      <if test="effect != null">sc_effect=#{effect,jdbcType=VARCHAR},</if>
      <if test="type != null">sc_type=#{type,jdbcType=VARCHAR},</if>
      <if test="percent != null">sc_percent=#{percent,jdbcType=DECIMAL},</if>
      <if test="amount != null">sc_amount=#{amount,jdbcType=VARCHAR},</if>
      <if test="expiryDay != null">sc_expiry_day=#{expiryDay,jdbcType=INTEGER},</if>
      <if test="rule != null">sc_rule=#{rule,jdbcType=VARCHAR},</if>
      <if test="remark != null">sc_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="receiveCount != null">sc_receive_count=#{receiveCount,jdbcType=INTEGER},</if>
      <if test="state != null">sc_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">sc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">sc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where sc_id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
    delete FROM yeshi_ec_system_coupon WHERE sc_id in
    <foreach collection="list" item="item" open="(" close=")"
        separator=",">#{item}</foreach>
  </delete>
  <select id="getCouponListByType" resultMap="BaseResultMap"  parameterType="java.util.List">
    select * FROM yeshi_ec_system_coupon
    WHERE sc_state = 1
        AND sc_type in
        <foreach collection="list" index="index" item="item" open="(" close=")"
            separator=",">'${item}'</foreach>
  </select>
  <select id="getCouponByType" resultMap="BaseResultMap" >
    select * FROM yeshi_ec_system_coupon
    WHERE sc_type = #{type}
    limit 1
  </select>
  <select id="getCouponByTypeAndPercent" resultMap="BaseResultMap" >
    select * FROM yeshi_ec_system_coupon
    WHERE sc_type = #{type} AND sc_percent = #{percent}
    limit 1
  </select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.SystemCouponMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.system.SystemCoupon">
    <id column="sc_id" property="id" jdbcType="BIGINT"/>
    <result column="sc_name" property="name" jdbcType="VARCHAR"/>
    <result column="sc_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="sc_picture_invalid" property="pictureInvalid" jdbcType="VARCHAR"/>
    <result column="sc_effect" property="effect" jdbcType="VARCHAR"/>
    <result column="sc_type" property="type"
            typeHandler="com.yeshi.fanli.util.mybatishandler.CouponTypeEnumHandler" />
    <result column="sc_percent" property="percent" jdbcType="DECIMAL"/>
    <result column="sc_amount" property="amount" jdbcType="VARCHAR"/>
    <result column="sc_expiry_day" property="expiryDay" jdbcType="INTEGER"/>
    <result column="sc_rule" property="rule" jdbcType="VARCHAR"/>
    <result column="sc_remark" property="remark" jdbcType="VARCHAR"/>
    <result column="sc_rule_link" property="ruleLink" jdbcType="VARCHAR"/>
    <result column="sc_state" property="state" jdbcType="INTEGER"/>
    <result column="sc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="sc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">sc_id,sc_name,sc_picture,sc_picture_invalid,sc_effect,sc_type,sc_percent,sc_amount,sc_expiry_day,sc_rule,sc_remark,sc_rule_link,sc_state,sc_create_time,sc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_system_coupon where sc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_system_coupon where sc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.system.SystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_system_coupon (sc_id,sc_name,sc_picture,sc_picture_invalid,sc_effect,sc_type,sc_percent,sc_amount,sc_expiry_day,sc_rule,sc_remark,sc_rule_link,sc_state,sc_create_time,sc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{pictureInvalid,jdbcType=VARCHAR},#{effect,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{percent,jdbcType=DECIMAL},#{amount,jdbcType=VARCHAR},#{expiryDay,jdbcType=INTEGER},#{rule,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{ruleLink,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.system.SystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_system_coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">sc_id,</if>
      <if test="name != null">sc_name,</if>
      <if test="picture != null">sc_picture,</if>
      <if test="pictureInvalid != null">sc_picture_invalid,</if>
      <if test="effect != null">sc_effect,</if>
      <if test="type != null">sc_type,</if>
      <if test="percent != null">sc_percent,</if>
      <if test="amount != null">sc_amount,</if>
      <if test="expiryDay != null">sc_expiry_day,</if>
      <if test="rule != null">sc_rule,</if>
      <if test="remark != null">sc_remark,</if>
      <if test="ruleLink != null">sc_rule_link,</if>
      <if test="state != null">sc_state,</if>
      <if test="createTime != null">sc_create_time,</if>
      <if test="updateTime != null">sc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="pictureInvalid != null">#{pictureInvalid,jdbcType=VARCHAR},</if>
      <if test="effect != null">#{effect,jdbcType=VARCHAR},</if>
      <if test="type != null">#{type,jdbcType=VARCHAR},</if>
      <if test="percent != null">#{percent,jdbcType=DECIMAL},</if>
      <if test="amount != null">#{amount,jdbcType=VARCHAR},</if>
      <if test="expiryDay != null">#{expiryDay,jdbcType=INTEGER},</if>
      <if test="rule != null">#{rule,jdbcType=VARCHAR},</if>
      <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
      <if test="ruleLink != null">#{ruleLink,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</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.system.SystemCoupon">update yeshi_ec_system_coupon set sc_name = #{name,jdbcType=VARCHAR},sc_picture = #{picture,jdbcType=VARCHAR},sc_picture_invalid = #{pictureInvalid,jdbcType=VARCHAR},sc_effect = #{effect,jdbcType=VARCHAR},sc_type = #{type,jdbcType=VARCHAR},sc_percent = #{percent,jdbcType=DECIMAL},sc_amount = #{amount,jdbcType=VARCHAR},sc_expiry_day = #{expiryDay,jdbcType=INTEGER},sc_rule = #{rule,jdbcType=VARCHAR},sc_remark = #{remark,jdbcType=VARCHAR},sc_rule_link = #{ruleLink,jdbcType=VARCHAR},sc_state = #{state,jdbcType=INTEGER},sc_create_time = #{createTime,jdbcType=TIMESTAMP},sc_update_time = #{updateTime,jdbcType=TIMESTAMP} where sc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.system.SystemCoupon">update yeshi_ec_system_coupon
    <set>
      <if test="name != null">sc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">sc_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="pictureInvalid != null">sc_picture_invalid=#{pictureInvalid,jdbcType=VARCHAR},</if>
      <if test="effect != null">sc_effect=#{effect,jdbcType=VARCHAR},</if>
      <if test="type != null">sc_type=#{type,jdbcType=VARCHAR},</if>
      <if test="percent != null">sc_percent=#{percent,jdbcType=DECIMAL},</if>
      <if test="amount != null">sc_amount=#{amount,jdbcType=VARCHAR},</if>
      <if test="expiryDay != null">sc_expiry_day=#{expiryDay,jdbcType=INTEGER},</if>
      <if test="rule != null">sc_rule=#{rule,jdbcType=VARCHAR},</if>
      <if test="remark != null">sc_remark=#{remark,jdbcType=VARCHAR},</if>
      <if test="ruleLink != null">sc_rule_link=#{ruleLink,jdbcType=VARCHAR},</if>
      <if test="state != null">sc_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">sc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">sc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where sc_id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteBatchByPrimaryKey"  parameterType="java.util.List">
    delete FROM yeshi_ec_system_coupon WHERE sc_id in
    <foreach collection="list" item="item" open="(" close=")"
        separator=",">#{item}</foreach>
  </delete>
  <select id="getCouponListByType" resultMap="BaseResultMap"  parameterType="java.util.List">
    select * FROM yeshi_ec_system_coupon
    WHERE sc_state = 1
        AND sc_type in
        <foreach collection="list" index="index" item="item" open="(" close=")"
            separator=",">'${item}'</foreach>
  </select>
  <select id="getCouponByType" resultMap="BaseResultMap" >
    select * FROM yeshi_ec_system_coupon
    WHERE sc_type = #{type}
    limit 1
  </select>
  <select id="getCouponByTypeAndPercent" resultMap="BaseResultMap" >
    select * FROM yeshi_ec_system_coupon
    WHERE sc_type = #{type} AND sc_percent = #{percent}
    limit 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/integral/CodePublishRecordMapper.xml
New file
@@ -0,0 +1,66 @@
<?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.integral.CodePublishRecordMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.integral.CodePublishRecord">
    <id column="pr_id" property="id" jdbcType="BIGINT"/>
    <result column="pr_uid" property="uid" jdbcType="BIGINT"/>
    <result column="pr_create_time" property="createTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <resultMap id="BaseResultVOMap" type="com.yeshi.fanli.entity.integral.CodePublishRecord">
    <id column="pr_id" property="id" jdbcType="BIGINT"/>
    <result column="pr_uid" property="uid" jdbcType="BIGINT"/>
    <result column="pr_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="nick_name" property="nickName" jdbcType="VARCHAR"/>
    <result column="portrait" property="portrait" jdbcType="VARCHAR"/>
    <result column="uie_invite_code" property="inviteCode" jdbcType="VARCHAR"/>
  </resultMap>
  <sql id="Base_Column_List">pr_id,pr_uid,pr_create_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_code_publish_record where pr_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_code_publish_record where pr_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.integral.CodePublishRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_code_publish_record (pr_id,pr_uid,pr_create_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.integral.CodePublishRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_code_publish_record
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">pr_id,</if>
      <if test="uid != null">pr_uid,</if>
      <if test="createTime != null">pr_create_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.integral.CodePublishRecord">update yeshi_ec_code_publish_record set pr_uid = #{uid,jdbcType=BIGINT},pr_create_time = #{createTime,jdbcType=TIMESTAMP} where pr_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.integral.CodePublishRecord">update yeshi_ec_code_publish_record
    <set>
      <if test="uid != null">pr_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="createTime != null">pr_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
    </set> where pr_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="listValid" resultMap="BaseResultVOMap">
      SELECT p.*,u.`nick_name`,u.`portrait`,e.`uie_invite_code`  FROM yeshi_ec_code_publish_record p
    LEFT JOIN `yeshi_ec_user` u ON u.`id` = p.`pr_uid`
    LEFT JOIN `yeshi_ec_user_info_extra` e ON e.`uie_uid` = p.`pr_uid`
    WHERE DATE_SUB(CURDATE(), INTERVAL 3 DAY) <![CDATA[<]]> DATE(p.`pr_create_time`)
    ORDER BY p.`pr_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="countValid" resultType="Long">
      SELECT IFNULL(COUNT(pr_id),0) FROM yeshi_ec_code_publish_record
    WHERE  DATE_SUB(CURDATE(), INTERVAL 3 DAY) <![CDATA[<]]> DATE(pr_create_time)
  </select>
  <select id="countValidRecord" resultType="Long">
      SELECT IFNULL(COUNT(pr_id),0) FROM yeshi_ec_code_publish_record
    WHERE  DATE_SUB(CURDATE(), INTERVAL 3 DAY) <![CDATA[<]]> DATE(pr_create_time)
           AND pr_uid = #{uid}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/integral/IntegralExchangeMapper.xml
@@ -92,4 +92,10 @@
      SELECT IFNULL(COUNT(ex_id),0) FROM yeshi_ec_integral_exchange
    WHERE ex_state = 1
  </select>
  <select id="getValidByType" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_integral_exchange
    WHERE ex_state = 1 AND ex_type = #{type}
    LIMIT 1
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserSystemCouponMapper.xml
@@ -1,154 +1,159 @@
<?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.UserSystemCouponMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCoupon">
    <id column="usc_id" property="id" jdbcType="BIGINT"/>
    <result column="usc_uid" property="uid" jdbcType="BIGINT"/>
    <result column="usc_source" property="source" jdbcType="VARCHAR"/>
    <result column="usc_state" property="state" jdbcType="INTEGER"/>
    <result column="usc_state_activate" property="stateActivated" jdbcType="INTEGER"/>
    <result column="usc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="usc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="usc_use_time" property="useTime" jdbcType="TIMESTAMP"/>
    <result column="usc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="usc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="usc_coupon_id" property="systemCoupon"
        javaType="com.yeshi.fanli.entity.system.SystemCoupon">
        <id column="usc_coupon_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
   <resultMap id="ResultVOMap" type="com.yeshi.fanli.vo.user.UserSystemCouponVO">
    <id column="usc_id" property="id" jdbcType="BIGINT"/>
    <result column="usc_uid" property="uid" jdbcType="BIGINT"/>
    <result column="usc_source" property="source" jdbcType="VARCHAR"/>
    <result column="usc_state" property="state" jdbcType="INTEGER"/>
    <result column="usc_state_activate" property="stateActivated" jdbcType="INTEGER"/>
    <result column="usc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="usc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="usc_use_time" property="useTime" jdbcType="TIMESTAMP"/>
    <result column="usc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="usc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="usc_coupon_id" property="systemCoupon"
        javaType="com.yeshi.fanli.entity.system.SystemCoupon">
        <id column="usc_coupon_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">usc_id,usc_uid,usc_coupon_id,usc_source,usc_state,usc_state_activate,usc_start_time,usc_end_time,usc_use_time,usc_create_time,usc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_system_coupon where usc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_system_coupon where usc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon (usc_id,usc_uid,usc_coupon_id,usc_source,usc_state,usc_state_activate,usc_start_time,usc_end_time,usc_use_time,usc_create_time,usc_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{systemCoupon.id,jdbcType=BIGINT},#{source,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{stateActivated,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{useTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">usc_id,</if>
      <if test="uid != null">usc_uid,</if>
      <if test="systemCoupon != null">usc_coupon_id,</if>
      <if test="source != null">usc_source,</if>
      <if test="state != null">usc_state,</if>
      <if test="stateActivated != null">usc_state_activate,</if>
      <if test="startTime != null">usc_start_time,</if>
      <if test="endTime != null">usc_end_time,</if>
      <if test="useTime != null">usc_use_time,</if>
      <if test="createTime != null">usc_create_time,</if>
      <if test="updateTime != null">usc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="systemCoupon != null">#{systemCoupon.id,jdbcType=BIGINT},</if>
      <if test="source != null">#{source,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="stateActivated != null">#{stateActivated,jdbcType=INTEGER},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="useTime != null">#{useTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon">update yeshi_ec_user_system_coupon set usc_uid = #{uid,jdbcType=BIGINT},usc_coupon_id = #{systemCoupon.id,jdbcType=BIGINT},usc_source = #{source,jdbcType=VARCHAR},usc_state = #{state,jdbcType=INTEGER},usc_state_activate = #{stateActivated,jdbcType=INTEGER},usc_start_time = #{startTime,jdbcType=TIMESTAMP},usc_end_time = #{endTime,jdbcType=TIMESTAMP},usc_use_time = #{useTime,jdbcType=TIMESTAMP},usc_create_time = #{createTime,jdbcType=TIMESTAMP},usc_update_time = #{updateTime,jdbcType=TIMESTAMP} where usc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon">update yeshi_ec_user_system_coupon
    <set>
      <if test="uid != null">usc_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="systemCoupon != null">usc_coupon_id=#{systemCoupon.id,jdbcType=BIGINT},</if>
      <if test="source != null">usc_source=#{source,jdbcType=VARCHAR},</if>
      <if test="state != null">usc_state=#{state,jdbcType=INTEGER},</if>
      <if test="stateActivated != null">usc_state_activate=#{stateActivated,jdbcType=INTEGER},</if>
      <if test="startTime != null">usc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">usc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="useTime != null">usc_use_time=#{useTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">usc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">usc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where usc_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="getUserCouponList" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid}
    ORDER BY uc.`usc_state`,uc.`usc_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="getUserCouponBySource" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid} AND usc_source = #{source}
  </select>
  <select id="countTodatyUserCouponBySource" resultType="java.lang.Integer">
    SELECT IFNULL(COUNT(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid} AND usc_source = #{source}
         AND TO_DAYS(uc.`usc_create_time`) = TO_DAYS(NOW())
  </select>
  <select id="getUserCouponVOList" resultMap="ResultVOMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid}
    ORDER BY uc.`usc_state`,uc.`usc_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="countUserCouponList" resultType="java.lang.Long">
    SELECT IFNULL(count(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid}
  </select>
  <select id="getEnableListByCouponId" resultMap="ResultVOMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid} AND uc.usc_state = 1
        AND DATE_FORMAT(CURDATE(),'%Y%m%d') <![CDATA[ >= ]]>DATE_FORMAT(uc.`usc_start_time`,'%Y%m%d')
        <if test="activated != null">AND uc.usc_state_activate = #{activated}</if>
        AND uc.usc_coupon_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    ORDER BY uc.usc_state_activate desc, uc.`usc_create_time`
  </select>
  <select id="getCounponNowInvalid" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_user_system_coupon` cp
    WHERE cp.`usc_uid` = #{uid} AND cp.`usc_state` = 1
        AND DATE_FORMAT(CURDATE(),'%Y%m%d') <![CDATA[ > ]]>DATE_FORMAT(cp.`usc_end_time`,'%Y%m%d');
  </select>
  <select id="getCouponByState" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_user_system_coupon` cp
    WHERE cp.`usc_uid` = #{uid}
        <if test="state != null">
             AND cp.`usc_state` = #{state}
        </if>
  </select>
  <select id="getCouponByTypeAndNotActivated" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_user_system_coupon
    WHERE usc_uid = #{uid} AND usc_coupon_id = #{couponId}
        AND (usc_state_activate = 0 OR usc_state_activate is null)
  </select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserSystemCoupon">
    <id column="usc_id" property="id" jdbcType="BIGINT"/>
    <result column="usc_uid" property="uid" jdbcType="BIGINT"/>
    <result column="usc_source" property="source" jdbcType="VARCHAR"/>
    <result column="usc_give" property="give" jdbcType="VARCHAR"/>
    <result column="usc_state" property="state" jdbcType="INTEGER"/>
    <result column="usc_state_activate" property="stateActivated" jdbcType="INTEGER"/>
    <result column="usc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="usc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="usc_use_time" property="useTime" jdbcType="TIMESTAMP"/>
    <result column="usc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="usc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="usc_coupon_id" property="systemCoupon"
        javaType="com.yeshi.fanli.entity.system.SystemCoupon">
        <id column="usc_coupon_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
   <resultMap id="ResultVOMap" type="com.yeshi.fanli.vo.user.UserSystemCouponVO">
    <id column="usc_id" property="id" jdbcType="BIGINT"/>
    <result column="usc_uid" property="uid" jdbcType="BIGINT"/>
    <result column="usc_source" property="source" jdbcType="VARCHAR"/>
    <result column="usc_give" property="give" jdbcType="VARCHAR"/>
    <result column="usc_state" property="state" jdbcType="INTEGER"/>
    <result column="usc_state_activate" property="stateActivated" jdbcType="INTEGER"/>
    <result column="usc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="usc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="usc_use_time" property="useTime" jdbcType="TIMESTAMP"/>
    <result column="usc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="usc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="usc_coupon_id" property="systemCoupon"
        javaType="com.yeshi.fanli.entity.system.SystemCoupon">
        <id column="usc_coupon_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">usc_id,usc_uid,usc_coupon_id,usc_source,usc_give,usc_state,usc_state_activate,usc_start_time,usc_end_time,usc_use_time,usc_create_time,usc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_system_coupon where usc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_system_coupon where usc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon (usc_id,usc_uid,usc_coupon_id,usc_source,usc_give,usc_state,usc_state_activate,usc_start_time,usc_end_time,usc_use_time,usc_create_time,usc_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{systemCoupon.id,jdbcType=BIGINT},#{source,jdbcType=VARCHAR},#{give,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{stateActivated,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{useTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_system_coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">usc_id,</if>
      <if test="uid != null">usc_uid,</if>
      <if test="systemCoupon != null">usc_coupon_id,</if>
      <if test="source != null">usc_source,</if>
      <if test="give != null">usc_give,</if>
      <if test="state != null">usc_state,</if>
      <if test="stateActivated != null">usc_state_activate,</if>
      <if test="startTime != null">usc_start_time,</if>
      <if test="endTime != null">usc_end_time,</if>
      <if test="useTime != null">usc_use_time,</if>
      <if test="createTime != null">usc_create_time,</if>
      <if test="updateTime != null">usc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="systemCoupon != null">#{systemCoupon.id,jdbcType=BIGINT},</if>
      <if test="source != null">#{source,jdbcType=VARCHAR},</if>
      <if test="give != null">#{give,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="stateActivated != null">#{stateActivated,jdbcType=INTEGER},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="useTime != null">#{useTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon">update yeshi_ec_user_system_coupon set usc_uid = #{uid,jdbcType=BIGINT},usc_coupon_id = #{systemCoupon.id,jdbcType=BIGINT},usc_source = #{source,jdbcType=VARCHAR},usc_give = #{give,jdbcType=VARCHAR},usc_state = #{state,jdbcType=INTEGER},usc_state_activate = #{stateActivated,jdbcType=INTEGER},usc_start_time = #{startTime,jdbcType=TIMESTAMP},usc_end_time = #{endTime,jdbcType=TIMESTAMP},usc_use_time = #{useTime,jdbcType=TIMESTAMP},usc_create_time = #{createTime,jdbcType=TIMESTAMP},usc_update_time = #{updateTime,jdbcType=TIMESTAMP} where usc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserSystemCoupon">update yeshi_ec_user_system_coupon
    <set>
      <if test="uid != null">usc_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="systemCoupon != null">usc_coupon_id=#{systemCoupon.id,jdbcType=BIGINT},</if>
      <if test="source != null">usc_source=#{source,jdbcType=VARCHAR},</if>
      <if test="give != null">usc_give=#{give,jdbcType=VARCHAR},</if>
      <if test="state != null">usc_state=#{state,jdbcType=INTEGER},</if>
      <if test="stateActivated != null">usc_state_activate=#{stateActivated,jdbcType=INTEGER},</if>
      <if test="startTime != null">usc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">usc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="useTime != null">usc_use_time=#{useTime,jdbcType=TIMESTAMP},</if>
      <if test="createTime != null">usc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">usc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where usc_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="getUserCouponList" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid}
    ORDER BY uc.`usc_state`,uc.`usc_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="getUserCouponBySource" resultMap="BaseResultMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid} AND usc_source = #{source}
  </select>
  <select id="countTodatyUserCouponBySource" resultType="java.lang.Integer">
    SELECT IFNULL(COUNT(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid} AND usc_source = #{source}
         AND TO_DAYS(uc.`usc_create_time`) = TO_DAYS(NOW())
  </select>
  <select id="getUserCouponVOList" resultMap="ResultVOMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid}
    ORDER BY uc.`usc_state`,uc.`usc_create_time` DESC
    LIMIT #{start},#{count}
  </select>
  <select id="countUserCouponList" resultType="java.lang.Long">
    SELECT IFNULL(count(uc.`usc_id`),0) FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid}
  </select>
  <select id="getEnableListByCouponId" resultMap="ResultVOMap">
    SELECT * FROM `yeshi_ec_user_system_coupon` uc
    WHERE uc.`usc_uid`= #{uid} AND uc.usc_state = 1
        AND DATE_FORMAT(CURDATE(),'%Y%m%d') <![CDATA[ >= ]]>DATE_FORMAT(uc.`usc_start_time`,'%Y%m%d')
        <if test="activated != null">AND uc.usc_state_activate = #{activated}</if>
        AND uc.usc_coupon_id in
        <foreach collection="list" item="item" open="(" close=")"
            separator=",">#{item}</foreach>
    ORDER BY uc.usc_state_activate desc, uc.`usc_create_time`
  </select>
  <select id="getCounponNowInvalid" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_user_system_coupon` cp
    WHERE cp.`usc_uid` = #{uid} AND cp.`usc_state` = 1
        AND DATE_FORMAT(CURDATE(),'%Y%m%d') <![CDATA[ > ]]>DATE_FORMAT(cp.`usc_end_time`,'%Y%m%d');
  </select>
  <select id="getCouponByState" resultMap="BaseResultMap">
      SELECT * FROM `yeshi_ec_user_system_coupon` cp
    WHERE cp.`usc_uid` = #{uid}
        <if test="state != null">
             AND cp.`usc_state` = #{state}
        </if>
  </select>
  <select id="getCouponByTypeAndNotActivated" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_user_system_coupon
    WHERE usc_uid = #{uid} AND usc_coupon_id = #{couponId}
        AND (usc_state_activate = 0 OR usc_state_activate is null)
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -406,13 +406,11 @@
            object.put("memoName", memoName);
            String nickName = "";
            Long  workerId= null;
            String portrait = "";
            Long lastLoginTime = null;
            UserInfo worker = threeSale.getWorker();
            if (worker != null) {
                workerId = worker.getId();
                portrait = worker.getPortrait();
                lastLoginTime = worker.getLastLoginTime();
                nickName = worker.getNickName();
@@ -505,7 +503,7 @@
    @Override
    @Transactional
    public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter, String platform, String version) throws ThreeSaleException {
    public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
        if (invitee == null || inviter == null) 
            throw new ThreeSaleException(1, "用户信息为空");
@@ -515,6 +513,8 @@
        if (threeSale != null) {
            // 有效关系--生效
            threeSale.setBoss(inviter);
            threeSale.setWorker(invitee);
            threeSale.setState(true);
            threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
            threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
@@ -590,7 +590,7 @@
    @Override
    @Transactional
    public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld, String platform, String version) throws ThreeSaleException {
    public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld) throws ThreeSaleException {
        if (invitee == null || (inviterId == null && threeSaleOld == null))
            throw new ThreeSaleException(1, "用户信息为空");
@@ -633,6 +633,7 @@
        
        UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId());
        threeSale.setBoss(boss);
        threeSale.setWorker(invitee);
        
        // 添加到队列
        ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale);
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/CodePublishRecordServiceImpl.java
New file
@@ -0,0 +1,88 @@
package com.yeshi.fanli.service.impl.integral;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.integral.CodePublishRecordMapper;
import com.yeshi.fanli.entity.integral.CodePublishRecord;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.integral.CodePublishRecordService;
import com.yeshi.fanli.util.StringUtil;
@Service
public class CodePublishRecordServiceImpl implements CodePublishRecordService {
    @Resource
    private CodePublishRecordMapper codePublishRecordMapper;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Override
    public CodePublishRecord selectByPrimaryKey(Long id) {
        return codePublishRecordMapper.selectByPrimaryKey(id);
    }
    @Override
    public void publishInviteCode(Long uid) {
        CodePublishRecord codePublishRecord = new CodePublishRecord();
        codePublishRecord.setUid(uid);
        codePublishRecord.setCreateTime(new Date());
        codePublishRecordMapper.insertSelective(codePublishRecord);
    }
    @Override
    public long countValidRecord(Long uid){
        return codePublishRecordMapper.countValidRecord(uid);
    }
    @Override
    public List<CodePublishRecord> listValid(long start, int count) {
        List<CodePublishRecord> listValid = codePublishRecordMapper.listValid(start, count);
        if (listValid == null || listValid.size() == 0) {
            return listValid;
        }
        for (CodePublishRecord codePublishRecord: listValid) {
            String inviteCode = codePublishRecord.getInviteCode();
            String index = inviteCode.substring(0, 1);
            String end = inviteCode.substring(inviteCode.length()-2, inviteCode.length()-1);
            codePublishRecord.setInviteCode("TA的邀请码:" + index + "****" + end);
            String nickName = codePublishRecord.getNickName();
            if(StringUtil.isNullOrEmpty(nickName)) {
                nickName = "K****6";
            } else if (nickName.length() == 1) {
                // 一个字
                nickName = nickName + "****8";
            } else {
                // 两个字及其以上
                String index2 = nickName.substring(0, 1);
                String end2 = nickName.substring(nickName.length()-2, nickName.length()-1);
                nickName = index2 + "****" + end2;
            }
            codePublishRecord.setNickName(nickName);
            long firstTeam = threeSaleSerivce.countFirstTeam(codePublishRecord.getUid(), 1);
            long secondTeam = threeSaleSerivce.countSecondTeam(codePublishRecord.getUid(), 1);
            codePublishRecord.setTeam("共有" + (firstTeam + secondTeam) + "个队员");
        }
        return listValid;
    }
    @Override
    public long countValid() {
        return codePublishRecordMapper.countValid();
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeRecordServiceImpl.java
@@ -6,14 +6,12 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.yeshi.utils.JsonUtil;
import com.yeshi.fanli.dao.mybatis.integral.IntegralExchangeRecordMapper;
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.vo.user.UserInfoExtraVO;
@Service
public class IntegralExchangeRecordServiceImpl implements IntegralExchangeRecordService {
fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralExchangeServiceImpl.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.service.impl.integral;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -7,12 +9,26 @@
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.mybatis.integral.IntegralExchangeMapper;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
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.integral.CodePublishRecord;
import com.yeshi.fanli.entity.integral.IntegralExchange;
import com.yeshi.fanli.entity.integral.IntegralExchange.ExchangeTypeEnum;
import com.yeshi.fanli.entity.money.UserMoneyDetail;
import com.yeshi.fanli.exception.integral.IntegralExchangeException;
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.IntegralExchangeService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
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.UserSystemCouponService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
import com.yeshi.fanli.vo.integral.ExchangeTipVO;
import com.yeshi.fanli.vo.user.UserInfoExtraVO;
@@ -24,6 +40,25 @@
    
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserSystemCouponService userSystemCouponService;
    @Resource
    private UserTaoLiJinOriginService userTaoLiJinOriginService;
    @Resource
    private HongBaoV2Service hongBaoV2Service;
    @Resource
    private UserMoneyDetailService userMoneyDetailService;
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private CodePublishRecordService codePublishRecordService;
    
    @Override
@@ -53,9 +88,18 @@
        if (exchange == null)
            throw new IntegralExchangeException(1, "兑换方式不存在");
        
        Integer goldCoin = exchange.getGoldCoin();
        
        ExchangeTipVO exchangeTip = new ExchangeTipVO();
        Integer goldCoin = exchange.getGoldCoin();
        exchangeTip.setId(id);
        ExchangeTypeEnum type = exchange.getType();
        if (ExchangeTypeEnum.inviteCodeActivate == type) {
            //exchangeTip.setTip("注:兑换成功后请到“消息-系统消息”查看");
            //exchangeTip.setGoldCoin(goldCoin + "金币");
            exchangeTip.setType(type.name());
            return exchangeTip;
        }
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue()) {
            exchangeTip.setType("notEnough");
@@ -64,16 +108,15 @@
            return exchangeTip;
        }
        
        ExchangeTypeEnum type = exchange.getType();
        if (ExchangeTypeEnum.freeCouponBuy == type) {
            exchangeTip.setTip("自购免单券仅能自己使用,且每个用户ID只能兑换一次。\r\n注:兑换成功后请到“我的-福利中心”中查看");
        } else if (ExchangeTypeEnum.freeCouponGive == type) {
            exchangeTip.setTip("赠送免单券兑换次数不限,赠送次数不限,受赠人若无“邀请人”成功领取后将成为你的一级队员。\r\n注:兑换成功后请到“我的-福利中心”中查看");
        } else if (ExchangeTypeEnum.rebateCoupon == type) {
        } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
            exchangeTip.setTip("返利奖励券兑换次数不限,赠送次数不限,受赠人若无“邀请人”成功领取后将成为你的一级队员。\r\n注:兑换成功后请到“我的-福利中心”中查看");
        } else if (ExchangeTypeEnum.inviteCodeActivate == type) {
            exchangeTip.setTip("注:兑换成功后请到“消息-系统消息”查看");
        } else if (ExchangeTypeEnum.inviteCodePublish == type) {
            if(codePublishRecordService.countValidRecord(uid) > 0)
                throw new IntegralExchangeException(1, "三天之内不可重复兑换");
            exchangeTip.setInviteCode(extraVO.getInviteCode());
            exchangeTip.setTip("兑换成功后,将发布于“激活邀请码兑换功能中”,需激活邀请的用户可用金币兑换,本次展示有效期为3天。");
        } else if (ExchangeTypeEnum.taoLiJin == type) {
@@ -91,64 +134,171 @@
        return exchangeTip;
    }
    
    @Override
    public void exchange(Long uid, Long id, Long inviteId) throws IntegralExchangeException{
        if (uid == null || uid <= 0)
    public IntegralExchange exchange(Long uid, Long id) throws IntegralExchangeException {
        if (uid == null || uid <= 0)
            throw new IntegralExchangeException(1, "用户未登录");
        if (id == null || id <= 0)
        if (id == null || id <= 0)
            throw new IntegralExchangeException(1, "兑换id不正确");
        UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid);
        UserInfoExtra extraVO = userInfoExtraService.getUserInfoExtra(uid);
        if (extraVO == null)
            throw new IntegralExchangeException(1, "用户相关信息不存在");
        IntegralExchange exchange = integralExchangeMapper.selectByPrimaryKey(id);
        if (exchange == null)
            throw new IntegralExchangeException(1, "兑换方式不存在");
        Integer goldCoin = exchange.getGoldCoin();
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue()) {
            throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!");
        }
        
        ExchangeTypeEnum type = exchange.getType();
        if (ExchangeTypeEnum.freeCouponBuy == type) {
            // 自购免单券
        try {
            ExchangeTypeEnum type = exchange.getType();
            if (ExchangeTypeEnum.freeCouponBuy == type) {
                // 自购免单券
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, false, null);
            } else if (ExchangeTypeEnum.freeCouponGive == type) {
                // 赠送免单券
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, true, null);
            } else if (ExchangeTypeEnum.rebatePercentCoupon == type) {
                // 奖励免单券
                userSystemCouponService.exchangeCoupon(uid, type.name(), UserSystemCoupon.SOURCE_EXCHANGE, true,
                        new BigDecimal(10));
            } else if (ExchangeTypeEnum.inviteCodePublish == type) {
                // 邀请码发布
                if(codePublishRecordService.countValidRecord(uid) > 0)
                    throw new IntegralExchangeException(1, "三天之内不可重复兑换");
                codePublishRecordService.publishInviteCode(uid);
            } else if (ExchangeTypeEnum.taoLiJin == type) {
                // 推广红包
                userTaoLiJinOriginService.exchangeMoney(uid, exchange.getAmount());
            } else if (ExchangeTypeEnum.cash == type) {
                // 现金红包
                BigDecimal money = exchange.getAmount();
                // 1、插入红包数据
                HongBaoV2 hongBaoV2 = new HongBaoV2();
                hongBaoV2.setMoney(money);
                hongBaoV2.setType(HongBaoV2.TYPE_EXCHANGE);
                hongBaoV2.setState(HongBaoV2.STATE_YILINGQU);
                hongBaoV2.setVersion(2);
                hongBaoV2.setCreateTime(new Date());
                hongBaoV2.setUpdateTime(new Date());
                hongBaoV2.setUserInfo(new UserInfo(uid));
                hongBaoV2.setPreGetTime(new Date());
                hongBaoV2.setGetTime(new Date());
                hongBaoV2Service.insertSelective(hongBaoV2);
                // 2.插入资金明细,用户余额
                UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createScoreConvert(money, new UserInfo(uid));
                userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
                userInfoService.addMoney(new UserInfo(uid), money);
            } else {
                throw new IntegralExchangeException(1, "兑换方式不存在");
            }
            
            String progress = exchange.getProgress();
            if (!StringUtil.isNullOrEmpty(progress))
                progress = progress.replace("{已兑换}", 1 + "").replace("{上限数}", exchange.getUpperLimit() + "");
            exchange.setProgress(progress);
            
        } else if (ExchangeTypeEnum.freeCouponGive == type) {
            // 赠送免单券
        } else if (ExchangeTypeEnum.rebateCoupon == type) {
            // 奖励免单券
        } else if (ExchangeTypeEnum.inviteCodeActivate == type) {
            if (inviteId == null || inviteId <= 0)
                throw new IntegralExchangeException(1, "传递参数不正确");
            // 激活邀请码
            UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(inviteId);
            // 更新金币
            UserInfoExtraVO extraUpdate = new UserInfoExtraVO();
            extraUpdate.setId(extraVO.getId());
            extraUpdate.setGoldCoin(goldCoinHas.intValue() - goldCoin.intValue());
            userInfoExtraService.saveUserInfoExtra(extraUpdate);
            return exchange;
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            throw new IntegralExchangeException(1, "兑换异常");
        }
    }
    @Override
    public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException{
        if (uid == null || uid <= 0)
            throw new IntegralExchangeException(1, "用户未登录");
        if (id == null || id <= 0)
            throw new IntegralExchangeException(1, "兑换id不正确");
        UserInfoExtra extraVO = userInfoExtraService.getUserInfoExtra(uid);
        if (extraVO == null)
            throw new IntegralExchangeException(1, "用户相关信息不存在");
        if (!StringUtil.isNullOrEmpty(extraVO.getInviteCode()))
            throw new IntegralExchangeException(1, "邀请码已激活,无需兑换");
        CodePublishRecord record = codePublishRecordService.selectByPrimaryKey(id);
        if (record == null)
            throw new IntegralExchangeException(1, "兑换记录不存在");
        IntegralExchange exchange = integralExchangeMapper.getValidByType(ExchangeTypeEnum.inviteCodeActivate.name());
        if (exchange == null)
            throw new IntegralExchangeException(1, "兑换方式不存在");
        ExchangeTipVO exchangeTip = new ExchangeTipVO();
        exchangeTip.setId(id);
        Integer goldCoin = exchange.getGoldCoin();
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue()) {
            exchangeTip.setType("notEnough");
            exchangeTip.setTip("当前账户中可用金币不足,无法兑换该奖品!");
            exchangeTip.setGoldCoin((goldCoin.intValue() - goldCoinHas.intValue()) + "金币");
            return exchangeTip;
        }
        exchangeTip.setTip("注:兑换成功后请到“消息-系统消息”查看");
        exchangeTip.setGoldCoin(goldCoin + "金币");
        exchangeTip.setType(ExchangeTypeEnum.inviteCodeActivate.name());
        return exchangeTip;
    }
    @Override
    public void exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException {
        if (uid == null || uid <= 0)
            throw new IntegralExchangeException(1, "用户未登录");
        if (id == null || id <= 0)
            throw new IntegralExchangeException(1, "兑换id不正确");
        UserInfoExtra extraVO = userInfoExtraService.getUserInfoExtra(uid);
        if (extraVO == null)
            throw new IntegralExchangeException(1, "用户相关信息不存在");
        if (!StringUtil.isNullOrEmpty(extraVO.getInviteCode()))
            throw new IntegralExchangeException(1, "邀请码已激活,无需兑换");
        CodePublishRecord record = codePublishRecordService.selectByPrimaryKey(id);
        if (record == null)
            throw new IntegralExchangeException(1, "兑换记录不存在");
        IntegralExchange exchange = integralExchangeMapper.getValidByType(ExchangeTypeEnum.inviteCodeActivate.name());
        if (exchange == null)
            throw new IntegralExchangeException(1, "兑换方式不存在");
        Integer goldCoin = exchange.getGoldCoin();
        Integer goldCoinHas = extraVO.getGoldCoin();
        if (goldCoin.intValue() > goldCoinHas.intValue()) {
            throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!");
        }
        try {
            UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(record.getUid());
            if (inviteExtra == null || StringUtil.isNullOrEmpty(inviteExtra.getInviteCode()))
                throw new IntegralExchangeException(1, "兑换失败,该用户邀请码不存在");
            
        } else if (ExchangeTypeEnum.inviteCodePublish == type) {
            // 邀请码发布
        } else if (ExchangeTypeEnum.taoLiJin == type) {
            // 推广红包
        } else if (ExchangeTypeEnum.cash == type) {
            // 现金红包
        } else {
            throw new IntegralExchangeException(1, "兑换方式不存在");
            userInfoExtraService.activateInviteCode(uid, inviteExtra.getInviteCode());
        } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            throw new IntegralExchangeException(1, "兑换异常");
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java
@@ -565,4 +565,18 @@
        userTaoLiJinDetailService.insertSelective(detail);
    }
    
    @Override
    @Transactional
    public void exchangeMoney(Long uid, BigDecimal money) throws UserTaoLiJinOriginException{
        if (uid == null || money == null) {
            throw new UserTaoLiJinOriginException(1, "参数不能为空");
        }
        // 添加用户红包
        userMoneyExtraService.addTaoLiJin(uid, money, false);
        // 添加新增记录
        UserTaoLiJinOrigin origin = saveOrigin(uid, 1, money, TaoLiJinOriginEnum.exchange);
        // 红包明细
        userTaoLiJinDetailService.createAddDetail(origin);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -322,7 +322,7 @@
    }
    
    @Override
    public String activateInviteCode(Long uid, String inviteCode, String platform, String version) throws UserInfoExtraException{
    public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException{
        if (uid == null || inviteCode == null) {
            throw new UserInfoExtraException(1, "用户id、邀请码不能为空");
        }
@@ -349,7 +349,7 @@
        
        // 绑定关系
        try {
            threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter, platform, version);
            threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter);
        } catch (ThreeSaleException e) {
            try {
                LogHelper.errorDetailInfo(e);
@@ -384,7 +384,7 @@
    
    
    @Override
    public void activationInviteWX(Long uid, String code, String platform, String version) throws UserInfoExtraException{
    public void activationInviteWX(Long uid, String code) throws UserInfoExtraException{
        if (uid == null || code == null) {
            throw new UserInfoExtraException(1, "激活信息不完整");
        }
@@ -465,7 +465,7 @@
        
        // 绑定关系
        try {
            threeSaleSerivce.bindRelationshipByWX(invitee, inviterId, threeSale, platform, version);
            threeSaleSerivce.bindRelationshipByWX(invitee, inviterId, threeSale);
        } catch (ThreeSaleException e) {
            try {
                LogHelper.errorDetailInfo(e);
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1633,4 +1633,184 @@
        }
    }
    
    @Override
    @Transactional
    public void exchangeCoupon(Long uid, String couponType, String source, boolean give, BigDecimal percent) throws UserSystemCouponException, Exception {
        if (couponType == null || uid == null) {
            throw new UserSystemCouponException(1, "参数不正确");
        }
        SystemCoupon coupon = null;
        if (couponType.equals(CouponTypeEnum.rebatePercentCoupon.name())) {
            coupon = systemCouponService.getCouponByTypeAndPercent(couponType, percent);
        } else {
            coupon = systemCouponService.getCouponByType(couponType);
        }
        if (coupon == null) {
            throw new UserSystemCouponException(1, "券类型不正确");
        }
        int stateActivated = 1;
        if (couponType == CouponTypeEnum.freeCoupon.name()) {
            stateActivated = 0; //
        } else if (couponType == CouponTypeEnum.welfareFreeCoupon.name() && threeSaleSerivce.countSuccessFirstTeam(uid) <= 0) {
            stateActivated = 0;  // 无下级队员 --待激活
        }
        //  计算结束日期:今天在内  减去一天
        String endDay = DateUtil.plusDay(coupon.getExpiryDay() - 1, new Date());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date endTime = format.parse(endDay);
        UserSystemCoupon userCoupon = new UserSystemCoupon();
        userCoupon.setUid(uid);
        userCoupon.setSource(source);
        userCoupon.setGive(give);
        userCoupon.setSystemCoupon(coupon);
        userCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
        userCoupon.setStateActivated(stateActivated);
        userCoupon.setStartTime(new Date());
        userCoupon.setEndTime(endTime);
        userCoupon.setCreateTime(new Date());
        userCoupon.setUpdateTime(new Date());
        insertSelective(userCoupon);
    }
    @Transactional
    @Override
    public List<UserSystemCouponVO> getCouponList(long start, int count, Long uid)throws UserSystemCouponException, Exception {
        if (uid == null) {
            return null;
        }
        // 更新过期券
        updateCounponInvalid(uid);
        // 退回券
        sendBackTimeOutCoupon(uid);
        List<UserSystemCouponVO> listVO = userSystemCouponMapper.getUserCouponVOList(start, count, uid);
        if (listVO == null || listVO.size() == 0) {
            return listVO;
        }
        // 是否激活邀请码
        String inviteCode = null;
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null) {
            inviteCode = userInfoExtra.getInviteCode();
        }
        for (UserSystemCouponVO userCouponVO : listVO) {
            SystemCoupon systemCoupon = userCouponVO.getSystemCoupon();
            if (systemCoupon != null && systemCoupon.getId() != null) {
                systemCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
            }
            if (systemCoupon == null) {
                continue; // 券信息不完整
            }
            userCouponVO.setSource("来源:" + userCouponVO.getSource());
            userCouponVO.setCouponName(systemCoupon.getName());
            userCouponVO.setCouponEffect(systemCoupon.getEffect());
            userCouponVO.setCouponRule(systemCoupon.getRule());
            userCouponVO.setCouponRuleLink(systemCoupon.getRuleLink());
            Integer state = userCouponVO.getState();
            // 券失效图片替换
            if (UserSystemCoupon.STATE_END_USE == state || UserSystemCoupon.STATE_OVERDUE == state) {
                userCouponVO.setCouponPicture(systemCoupon.getPictureInvalid());
            } else {
                userCouponVO.setCouponPicture(systemCoupon.getPicture());
            }
            Map<String, Object> jumpBtn = null;
            CouponTypeEnum type = systemCoupon.getType();
            Integer stateActivated = userCouponVO.getStateActivated();
            // 状态待激活 -且可使用
            if (UserSystemCoupon.STATE_CAN_USE == state && (stateActivated == null || stateActivated == 0)) {
                userCouponVO.setState(0);
                userCouponVO.setCouponEffect("待激活");
                if (CouponTypeEnum.freeCoupon == type) {
                    List<String> listTip = new ArrayList<String>();
                    listTip.add("本免单券由好友赠送,从获赠日起60天内需产生3笔返利订单;");
                    listTip.add("返利订单“已到账”后,方能视为订单产生成功;");
                    listTip.add("满足条件后,系统将自动激活,并在消息-其它消息中提醒。");
                } else if (CouponTypeEnum.welfareFreeCoupon == type) {
                    // 未激活规则
                    userCouponVO.setCouponRule(systemCoupon.getRemark());
                    jumpBtn = new HashMap<String, Object>();
                    if (inviteCode != null && inviteCode.trim().length() > 0) {
                        jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite_friends"));
                    } else {
                        jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite_activate"));
                    }
                }
            } else if (stateActivated == 1) {
                // 显示规则
                userCouponVO.setCouponRule(systemCoupon.getRule());
                if (UserSystemCoupon.STATE_CAN_USE == state) {
                    Map<String, Object> jumpLink = new HashMap<String, Object>();
                    if (CouponTypeEnum.freeCoupon == type || CouponTypeEnum.welfareFreeCoupon == type) {
                        // 免单券、 福利免单券
                        // 免单商品列表
                        jumpLink.put("url", configService.get("free_goods_list"));
                        jumpBtn = new HashMap<String, Object>();
                        jumpBtn.put("params", jumpLink);
                        jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("web"));
                    } else if (CouponTypeEnum.rebatePercentCoupon == type) {
                        // 返利奖励券- 跳转至订单到账界面
                        jumpLink.put("state", "2");
                        jumpBtn = new HashMap<String, Object>();
                        jumpBtn.put("params", jumpLink);
                        // 跳转订单列表
                        jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("orderList"));
                    }
                } else if (UserSystemCoupon.STATE_IN_USE == state) {
                    // 使用中
                    userCouponVO.setInUseExplain(configService.get("free_coupon_using-help"));
                }
            }
            userCouponVO.setJumpBtn(jumpBtn);
            String couponTerm = "有效期:";
            Date startTime = userCouponVO.getStartTime();
            Date endTime = userCouponVO.getEndTime();
            if (endTime != null && startTime != null) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
                couponTerm = couponTerm + sdf.format(startTime) + "-" + sdf.format(endTime);
            }
            userCouponVO.setCouponTerm(couponTerm);
            if (UserSystemCoupon.STATE_CAN_USE == state) {
                int differentDays = 0;
                if (endTime != null && startTime != null) {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    differentDays = DateUtil.daysBetween(sdf.format(new Date()), sdf.format(endTime)) + 1;
                    if (differentDays < 0) {
                        differentDays = 0;
                    }
                }
                // 剩余天数
                Map<String, Object> remainDays = new HashMap<String, Object>();
                remainDays.put("content", "还剩" + differentDays + "天过期");
                remainDays.put("fontColor", "#F14242");
                userCouponVO.setRemainDays(remainDays);
            }
        }
        return listVO;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java
@@ -219,7 +219,7 @@
     * @param inviter
     * @throws ThreeSaleException
     */
    public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter, String platform, String version) throws ThreeSaleException;
    public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException;
    /**
     * 统计邀请成功队员数量
@@ -244,7 +244,7 @@
     * @param threeSaleOld
     * @throws ThreeSaleException
     */
    public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld, String platform, String version) throws ThreeSaleException;
    public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld) throws ThreeSaleException;
    
    /**
    * 根据下级查找对象
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/CodePublishRecordService.java
New file
@@ -0,0 +1,31 @@
package com.yeshi.fanli.service.inter.integral;
import java.util.List;
import com.yeshi.fanli.entity.integral.CodePublishRecord;
public interface CodePublishRecordService {
    /**
     * 查询近3天发布记录
     * @return
     */
    public List<CodePublishRecord> listValid(long start, int count);
    public long countValid();
    public CodePublishRecord selectByPrimaryKey(Long id);
    /**
     * 发布
     * @param uid
     * @return
     */
    public void publishInviteCode(Long uid);
    public long countValidRecord(Long uid);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/integral/IntegralExchangeService.java
@@ -26,14 +26,34 @@
     * @throws IntegralExchangeException
     */
    public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException;
    /**
     * 验证内部页面
     * @param uid
     * @param id
     * @return
     * @throws IntegralExchangeException
     */
    public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException;
    /**
     * 金币兑换
     * @param uid
     * @param id
     * @param inviteId
     * @throws IntegralExchangeException
     */
    public void exchange(Long uid, Long id, Long inviteId) throws IntegralExchangeException;
    public IntegralExchange exchange(Long uid, Long id) throws IntegralExchangeException;
    /**
     * 邀请码兑换
     * @param uid
     * @param id
     * @return
     * @throws IntegralExchangeException
     */
    public void exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException;
    
}
fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinOriginService.java
@@ -131,4 +131,13 @@
    public void addInviteWinMoneyByHand(Long uid, String inviteName, Date date)
            throws UserTaoLiJinOriginException;
    /**
     * 金币兑换
     * @param uid
     * @param money
     * @param userRank
     * @throws UserTaoLiJinOriginException
     */
    public void exchangeMoney(Long uid, BigDecimal money) throws UserTaoLiJinOriginException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoExtraService.java
@@ -46,7 +46,7 @@
     * @return
     * @throws UserInfoExtraException
     */
    public String activateInviteCode(Long uid, String inviteCode, String platform, String version) throws UserInfoExtraException;
    public String activateInviteCode(Long uid, String inviteCode) throws UserInfoExtraException;
    /**
     * 获取用户附加信息
@@ -81,7 +81,7 @@
     * @param code
     * @throws UserInfoExtraException
     */
    public void activationInviteWX(Long uid, String code, String platform, String version) throws UserInfoExtraException;
    public void activationInviteWX(Long uid, String code) throws UserInfoExtraException;
    /**
     * 判断是否是新用户
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserSystemCouponService.java
@@ -205,4 +205,18 @@
     */
    public void randomRewardCoupon(int num, Long uid, String source) throws Exception;
    /**
     * 添加券
     * @param uid
     * @param couponType
     * @param source
     * @throws UserSystemCouponException
     */
    public void exchangeCoupon(Long uid, String couponType, String source, boolean give,
            BigDecimal percent) throws UserSystemCouponException, Exception;
    public List<UserSystemCouponVO> getCouponList(long start, int count, Long uid) throws UserSystemCouponException, Exception;
}
fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -497,5 +497,26 @@
        }
        return detail;
    }
    public static UserMoneyDetail createScoreConvert(BigDecimal money, UserInfo user)
            throws UserMoneyDetailException {
        if (user == null)
            throw new UserMoneyDetailException(1, "UID不能为空");
        if (money == null)
            throw new UserMoneyDetailException(1, "金额不能为空");
        UserMoneyDetail detail = new UserMoneyDetail();
        detail.setCreateTime(new Date());
        detail.setIdentifyCode(StringUtil.Md5(
                UserMoneyDetailTypeEnum.scoreConvert.name() + "-" + System.currentTimeMillis() + "-" + user.getId()));
        detail.setMoney(money);
        detail.setTitle(UserMoneyDetailTypeEnum.scoreConvert.getDesc());
        detail.setType(UserMoneyDetailTypeEnum.scoreConvert);
        detail.setUpdateTime(new Date());
        detail.setUserInfo(user);
        return detail;
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/integral/ExchangeTipVO.java
@@ -8,6 +8,9 @@
    private static final long serialVersionUID = 1L;
    // id
    @Expose
    private Long id;
    // 类型
    @Expose
    private String type;
@@ -63,4 +66,12 @@
    public void setTip(String tip) {
        this.tip = tip;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
}
fanli/src/main/java/com/yeshi/fanli/vo/user/UserSystemCouponVO.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.vo.user;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import com.google.gson.annotations.Expose;
@@ -27,9 +28,15 @@
    // 券作用
    @Expose
     private String couponEffect;
    // 券规则
    @Expose
     private String couponRule;
    // 券规则-链接
    @Expose
     private String couponRuleLink;
    // 有效期
    @Expose
     private String couponTerm;
@@ -43,6 +50,10 @@
    // 剩下天数
    @Expose
     private Map<String, Object> remainDays;
    @Expose
     private List<String> tips;
    
    public String getTopPicture() {
@@ -125,4 +136,20 @@
        this.couponPictureInvalid = couponPictureInvalid;
    }
    public String getCouponRuleLink() {
        return couponRuleLink;
    }
    public void setCouponRuleLink(String couponRuleLink) {
        this.couponRuleLink = couponRuleLink;
    }
    public List<String> getTips() {
        return tips;
    }
    public void setTips(List<String> tips) {
        this.tips = tips;
    }
}