yujian
2019-08-16 1db61f9479d537ecf2c030d8b9cb45b1e0bf0eec
口令
12个文件已修改
524 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinGiveRecordMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinDetail.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinGiveRecord.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java 207 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinRecordService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/TokenRecordService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/msg/TokenVO.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -367,12 +367,13 @@
        }
        
        try {
            List<String> listIOS = new ArrayList<String>();
            List<String> listAndroid = new ArrayList<String>();
            pushService.pushZNX(remindId, "", "", listIOS, listAndroid);
            // TODO版本区分
            userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.question,
                    "", "", UserSystemMsg.TIME_TAG_EMERGENT, null);
//            List<String> listIOS = new ArrayList<String>();
//            List<String> listAndroid = new ArrayList<String>();
//            pushService.pushZNX(remindId, "", "", listIOS, listAndroid);
//            userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.question,
//                    "", "", UserSystemMsg.TIME_TAG_EMERGENT, null);
            
            JSONObject data = new JSONObject();
            data.put("weiXinState", 2);
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -34,6 +34,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.user.TokenRecordException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -45,11 +46,13 @@
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.service.inter.user.HistorySearchService;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -62,6 +65,7 @@
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.msg.TokenVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -106,6 +110,9 @@
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private TokenRecordService tokenRecordService;
    /**
     * 粘贴板信息推荐
     * 
@@ -115,7 +122,7 @@
     * @param out
     */
    @RequestMapping(value = "getRecommendInfo", method = RequestMethod.POST)
    public void getRecommendInfo(AcceptData acceptData, String text, PrintWriter out) {
    public void getRecommendInfo(AcceptData acceptData, String text, Long uid, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(text)) {
            out.print(JsonUtil.loadFalseResult("值为空"));
            return;
@@ -123,6 +130,16 @@
        // 去除前后空格
        text = text.trim();
        try {
            TokenVO tokenVO = tokenRecordService.discernToken(text, uid);
            out.print(JsonUtil.loadTrueResult(tokenVO));
            return;
        } catch (TokenRecordException e) {
            if (e.getCode() == 1001) { // 需要用户登录
                out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
                return;
            }
        }
    
        TaoBaoGoodsBrief tb = null;
@@ -228,6 +245,18 @@
        }
        JSONObject data = new JSONObject();
        if(VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
            BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
            BigDecimal shareRate = hongBaoManageService.getShareRate();
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                    .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            data.put("type", 3);
            data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods, null, fanLiRate, shareRate)));
            out.print(JsonUtil.loadTrueResult(data));
            return;
        }
        JSONObject taoBaoGoodsJSON = new JSONObject();
        taoBaoGoodsJSON.put("title", commonGoods.getTitle());
        taoBaoGoodsJSON.put("zkPrice", commonGoods.getPrice() + "");
@@ -247,7 +276,6 @@
        JSONObject root = new JSONObject();
        root.put("type", 1);
        root.put("data", data);
        out.print(JsonUtil.loadTrueResult(root));
    }
@@ -289,6 +317,26 @@
        return false;
    }
    /**
     *
     * @param acceptData
     * @param kw
     * @param goodsType
     * @param out
     */
    @RequestMapping(value = "tokenReceive", method = RequestMethod.POST)
    public void tokenReceive(AcceptData acceptData, Long uid, String token, PrintWriter out) {
        try {
            tokenRecordService.receiveToken(token, uid);
            out.print(JsonUtil.loadTrueResult("领取成功"));
        } catch (TokenRecordException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
    /**
     * 搜索候选词
     * 
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -39,6 +39,7 @@
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
@@ -253,13 +254,13 @@
            lastMonthUse = zero;
        }
        
        // 问号链接
        String helpLink = configTaoLiJinService.getValueByKey("hongbao_help_link");
        String giveMin = configTaoLiJinService.getValueByKey("give_min_amount");
        JSONObject data = new JSONObject();
        data.put("tlj", tlj.setScale(2).toString());
        data.put("helpLink", helpLink);
        data.put("giveMin", giveMin);
        data.put("giveTip", "注:赠送推广红包金额至少"+ giveMin +"元");
        data.put("helpLink", configTaoLiJinService.getValueByKey("hongbao_help_link"));
        data.put("countShare", countShare);
        data.put("todayWin", todayWin.setScale(2).toString());
        data.put("yesterdayWin", yesterdayWin.setScale(2).toString());
@@ -839,4 +840,27 @@
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 赠送淘礼金
     * @param acceptData
     * @param uid
     * @param amount
     * @param out
     */
    @RequestMapping(value = "giveTLJ", method = RequestMethod.POST)
    public void giveTLJ(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) {
        if (uid == null || uid <= 0) {
            out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
            return;
        }
        try {
            String tips = userTaoLiJinRecordService.giveTaolijin(uid, amount);
            out.print(JsonUtil.loadTrueResult(tips));
        } catch (UserTaoLiJinRecordException e) {
            out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/tlj/UserTaoLiJinGiveRecordMapper.java
@@ -5,4 +5,5 @@
public interface UserTaoLiJinGiveRecordMapper extends BaseMapper<UserTaoLiJinGiveRecord> {
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinDetail.java
@@ -21,7 +21,9 @@
        add("红包增加", "http://img.flqapp.com/img/tlj/icon_tlj.png"), 
        reduce("成功使用扣除", "http://img.flqapp.com/img/tlj/icon_tlj.png"), 
        sendBack("长期未使用收回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        refund("未使用成功退回", "http://img.flqapp.com/img/tlj/icon_tlj.png");
        refund("未使用成功退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        give("红包赠送", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
        giveBack("赠送退回 ", "http://img.flqapp.com/img/tlj/icon_tlj.png");
        
        private final String desc;
        private final String picture;
fanli/src/main/java/com/yeshi/fanli/entity/bus/tlj/UserTaoLiJinGiveRecord.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.entity.bus.tlj;
import java.math.BigDecimal;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
@@ -12,8 +13,19 @@
@Table("yeshi_ec_user_taolijin_give_record")
public class UserTaoLiJinGiveRecord {
    // 未领取
    public final static int STATE_INIT = 0;
    // 已领取
    public final static int STATE_RECEIVE =1;
    // 已过期 退回
    public final static int STATE_OVERDUE = 2;
    @Column(name = "tgr_id")
    private Long id;
    // 面额
    @Column(name = "tgr_amount")
    private BigDecimal amount;
    // 赠送uid
    @Column(name = "tgr_give_uid")
    private Long giveUid;
@@ -80,4 +92,11 @@
        this.state = state;
    }
    public BigDecimal getAmount() {
        return amount;
    }
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -13,14 +13,18 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.BigDecimalUtil;
import org.yeshi.utils.DateUtil;
import com.yeshi.fanli.dao.mybatis.tlj.UserTaoLiJinRecordMapper;
import com.yeshi.fanli.dto.msg.MsgOtherTaoLiJinContentDTO;
import com.yeshi.fanli.dto.taobao.TaoLiJinDTO;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -28,6 +32,7 @@
import com.yeshi.fanli.exception.taobao.TaoKeApiException;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
@@ -35,9 +40,11 @@
import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserMoneyExtraService;
@@ -46,6 +53,7 @@
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
@@ -60,6 +68,9 @@
    @Resource
    private RedisManager redisManager;
    @Resource
    private ConfigService configService;
    @Resource
    private UserTaoLiJinRecordMapper userTaoLiJinRecordMapper;
@@ -99,6 +110,13 @@
    @Resource
    private ShareHotGoodsService shareHotGoodsService;
    @Resource
    private TokenRecordService tokenRecordService;
    @Resource
    private UserTaoLiJinGiveRecordService userTaoLiJinGiveRecordService;
    
    @Override
    public UserTaoLiJinRecord selectByPrimaryKey(Long id) {
@@ -497,4 +515,129 @@
        return userTaoLiJinRecordMapper.getByRightsId(rightsId);
    }
    @Override
    public String giveTaolijin(Long uid, BigDecimal amount) throws UserTaoLiJinRecordException{
        if (uid == null || amount == null)
            throw new UserTaoLiJinRecordException(1,"参数不正确");
        String giveMin = configTaoLiJinService.getValueByKey("give_min_amount");
        if (amount.compareTo(new BigDecimal(giveMin)) < 0)
            throw new UserTaoLiJinRecordException(1,"赠送推广红包金额至少" + giveMin + "元");
        // 用户剩余可以淘礼金验证
        UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
        if (userMoneyExtra == null || userMoneyExtra.getTlj() == null)
            throw new UserTaoLiJinRecordException(1, "红包余额不足");
        BigDecimal tlj = userMoneyExtra.getTlj();
        if (amount.compareTo(tlj) > 0)
            throw new UserTaoLiJinRecordException(1, "红包余额不足");
        Date nowDate = new Date();
        // 赠送记录
        UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
        giveRecord.setAmount(amount);
        giveRecord.setGiveUid(uid);
        giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
        giveRecord.setGiveTime(nowDate);
        userTaoLiJinGiveRecordService.insertSelective(giveRecord);
        String token = null;
        for (int i = 0; i < 5; i++) {
            try {
                // TODO 口令生成规则待定
                long num = 10000 + (long) (Math.random() * 10000);
                token = UserUtil.getInviteCode(num);
                TokenRecord tokenRecord = new TokenRecord();
                tokenRecord.setUid(uid);
                tokenRecord.setIdentify(giveRecord.getId()+""); // 记录id
                tokenRecord.setType(TokenTypeEnum.taoLiJin);
                tokenRecord.setStartTime(nowDate);
                tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
                tokenRecord.setToken(token);
                tokenRecord.setState(0);
                tokenRecordService.insertSelective(tokenRecord);
            } catch (Exception e) {
                LogHelper.errorDetailInfo(e);
                token = null;
            }
            if(!StringUtil.isNullOrEmpty(token)) {
                break;
            }
        }
        if(StringUtil.isNullOrEmpty(token))
            throw new UserTaoLiJinRecordException(1, "口令生成失败");
        UserMoneyExtra updateExtra = new UserMoneyExtra();
        updateExtra.setUid(uid);
        updateExtra.setTlj(MoneyBigDecimalUtil.sub(tlj, amount));
        updateExtra.setUpdateTime(new Date());
        userMoneyExtraService.updateByPrimaryKeySelective(updateExtra);
        String tips = "送给你[%s]元推广红包快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,用推广分享爆款商品,成单率更高哦。\r\n"
                 + "----------------------------\r\n"
                 + "下载[返利券]App链接:%s\r\n"
                 + "PS:口令将会24小时内失效,请及时领取。";
        tips = String.format(tips, amount, token, configService.get("app_down_link"));
        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    // 插入明细
                    UserTaoLiJinDetail detail = new UserTaoLiJinDetail();
                    detail.setUid(uid);
                    detail.setMoney(new BigDecimal("-" + amount));
                    detail.setTitle(TaoLiJinDetailTypeEnum.give.getDesc());
                    detail.setType(TaoLiJinDetailTypeEnum.give);
                    detail.setCreateTime(new Date());
                    userTaoLiJinDetailService.insertSelective(detail);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
                // 成功使用红包
                try {
                    BigDecimal total = amount;
                    BigDecimal lastMoney = null;
                    BigDecimal zero = new BigDecimal(0);
                    // 修改余额
                    List<UserTaoLiJinOrigin> list = userTaoLiJinOriginService.getSurplusLiJin(uid);
                    if (list != null && list.size() > 0) {
                        for (UserTaoLiJinOrigin taoLiJinOrigin : list) {
                            if (total.compareTo(zero) < 1) {
                                break;
                            }
                            BigDecimal moneySurplus = taoLiJinOrigin.getMoneySurplus();
                            lastMoney = total;
                            total = MoneyBigDecimalUtil.sub(total, moneySurplus);
                            if (total.compareTo(zero) >= 0) {
                                moneySurplus = zero;
                            } else {
                                moneySurplus = MoneyBigDecimalUtil.sub(moneySurplus, lastMoney);
                            }
                            UserTaoLiJinOrigin usertlj = new UserTaoLiJinOrigin();
                            usertlj.setId(taoLiJinOrigin.getId());
                            usertlj.setMoneySurplus(moneySurplus);
                            usertlj.setUpdateTime(new Date());
                            userTaoLiJinOriginService.updateByPrimaryKeySelective(usertlj);
                        }
                    }
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        });
        return tips;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -7,16 +7,24 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.yeshi.utils.JsonUtil;
import com.yeshi.fanli.dao.mybatis.user.TokenRecordMapper;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.exception.user.TokenRecordException;
import com.yeshi.fanli.exception.user.UserSystemCouponException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
@@ -38,7 +46,11 @@
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    
    @Resource
    private UserTaoLiJinGiveRecordService userTaoLiJinGiveRecordService;
    
    @Resource
    private UserInfoExtraService userInfoExtraService;
    
    @Override
    public void insertSelective(TokenRecord record) {
@@ -52,8 +64,8 @@
        return tokenRecordMapper.getNearByTypeAndIdentify(type, identify);
    }
    public void discernToken(String token, Long uid) throws TokenRecordException {
    @Override
    public TokenVO discernToken(String token, Long uid) throws TokenRecordException {
        
        // TODO token 验证
        
@@ -94,76 +106,99 @@
        if (StringUtil.isNullOrEmpty(identify)) 
            throw new TokenRecordException(1, "口令标识不存在");
        
        Integer type = 0;
        boolean state = false;
        List<String> tips = new ArrayList<String>();
        TokenTypeEnum tokenType = rokenRecord.getType();
        if (tokenType == TokenTypeEnum.freeCoupon) {
            type = 10;
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null || userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
            if (userCoupon == null) {
                tips.add("哎呀,这张免单券已失效了!");
            } else {
                Boolean give = userCoupon.getGive();
                if (give == null)
                    give = false;
                if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
                tips.add("哎呀,这张免单券已失效了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
                tips.add("哎呀,这张免单券已被领取了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) {
                throw new TokenRecordException(1, "口令已失效");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                } else if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "用户未登录");
                        throw new TokenRecordException(1001, "温馨提示,[免单券]需要登录后领取");
                
                state = true;
                ThreeSale boss = threeSaleSerivce.getMyBoss(uid);
                if (boss != null) {
                    tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
                    tips.add("成功领取后,请到“我的-福利中心”查看。");
                } else {
                    UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                    if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
                    tips.add("成功领取后,请到“我的-福利中心”查看。");
                    } else {
                        tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
                        tips.add("成功领取后,请到“我的-福利中心”查看。");
                    }
                } else {
                    throw new TokenRecordException(1, "口令已失效");
                }
            }
        } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) {
            type = 11;
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null || userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
            if (userCoupon == null) {
            } else {
                Boolean give = userCoupon.getGive();
                if (give == null)
                    give = false;
                if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
                tips.add("哎呀,这张返利奖励券已失效了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
                tips.add("哎呀,这张返利奖励券已被领取了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) {
                throw new TokenRecordException(1, "口令已失效");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                } else if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "用户未登录");
                        throw new TokenRecordException(1001, "温馨提示,[返利奖励券]需要登录后领取");
                
                state = true;
                ThreeSale boss = threeSaleSerivce.getMyBoss(uid);
                if (boss != null) {
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                } else {
                    UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                    if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                    } else {
                        tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                        tips.add("成功领取后,请到“我的-福利中心”中查看。");
                    }
                } else {
                    throw new TokenRecordException(1, "口令已失效");
                }
            }
        } else if (tokenType == TokenTypeEnum.taoLiJin) {
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null || userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE) {
                tips.add("哎呀,这张返利奖励券已失效了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
                tips.add("哎呀,这张返利奖励券已被领取了!");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE) {
                throw new TokenRecordException(1, "口令已失效");
            } else if (userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
            type = 12;
            UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService
                    .selectByPrimaryKey(Long.parseLong(identify));
            if (giveRecord == null || giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE) {
                tips.add("哎呀,推广红包已失效了!");
            } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) {
                tips.add("哎呀,推广红包已被领取了!");
            } else {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "用户未登录");
                    throw new TokenRecordException(1001, "温馨提示,[推广红包]需要登录后领取");
                
                state = true;
                ThreeSale boss = threeSaleSerivce.getMyBoss(uid);
                if (boss != null) {
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                } else {
                UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
                if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                    tips.add("确认领取后,你将成为赠送者的一级队员;");
                    tips.add("返利券奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
                    tips.add("成功领取后,请到“我的-福利中心”中查看。");
                    tips.add("推广红包,可分享爆款商品,让分享订单成单率更高;");
                    tips.add("成功领取后,请到“我的-推广红包”中查看。");
                } else {
                    tips.add("推广红包,可分享爆款商品,让分享订单成单率更高;");
                    tips.add("成功领取后,请到“我的-推广红包”中查看。");
                }
            }
        } else {
@@ -172,8 +207,108 @@
        
        tokenVO.setTips(tips);
        tokenVO.setState(state);
        tokenVO.setType(tokenType.name());
        tokenVO.setType(type);
        return tokenVO;
    }
    
    @Override
    public void receiveToken(String token, Long uid) throws TokenRecordException {
        if (uid == null || uid <= 0)
            throw new TokenRecordException(1, "用户未登录");
        if (StringUtil.isNullOrEmpty(token))
            throw new TokenRecordException(1, "口令不能为空");
        TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
        if (rokenRecord == null || rokenRecord.getState() == 1)
            throw new TokenRecordException(1, "口令已失效");
        String identify = rokenRecord.getIdentify();
        if (StringUtil.isNullOrEmpty(identify))
            throw new TokenRecordException(1, "口令标识不存在");
        boolean receive = false;
        TokenTypeEnum tokenType = rokenRecord.getType();
        if (tokenType == TokenTypeEnum.freeCoupon) {
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null)
                throw new TokenRecordException(1, "该券不存在");
            Boolean give = userCoupon.getGive();
            if (give == null)
                give = false;
            if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE)
                throw new TokenRecordException(1, "哎呀,这张免单券已失效了!");
            if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE)
                throw new TokenRecordException(1, "哎呀,这张免单券已被领取了!");
            if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE)
                throw new TokenRecordException(1, "口令已失效");
            if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                try {
                    userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(), UserSystemCoupon.SOURCE_GIVE);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
                // 领取成功
                receive = true;
            } else {
                throw new TokenRecordException(1, "口令已失效");
            }
        } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) {
            UserSystemCoupon userCoupon = userSystemCouponService.selectByPrimaryKey(Long.parseLong(identify));
            if (userCoupon == null)
                throw new TokenRecordException(1, "该券不存在");
            Boolean give = userCoupon.getGive();
            if (give == null)
                give = false;
            if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE)
                throw new TokenRecordException(1, "哎呀,这张返利奖励券已失效了!");
            if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE)
                throw new TokenRecordException(1, "哎呀,这张返利奖励券已被领取了!");
            if (userCoupon.getState() == UserSystemCoupon.STATE_CAN_USE)
                throw new TokenRecordException(1, "口令已失效");
            if (give && userCoupon.getState() == UserSystemCoupon.STATE_IN_USE) {
                try {
                    userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_GIVE);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
                // 领取成功
                receive = true;
            } else {
                throw new TokenRecordException(1, "口令已失效");
            }
        } else if (tokenType == TokenTypeEnum.taoLiJin) {
            UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService
                    .selectByPrimaryKey(Long.parseLong(identify));
            if (giveRecord == null || giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE) {
                throw new TokenRecordException(1, "哎呀,哎呀,推广红包已失效了!");
            } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) {
                throw new TokenRecordException(1, "哎呀,推广红包已被领取了!");
            } else {
            }
        } else {
            throw new TokenRecordException(1, "无对应类型");
        }
        if (receive)
            throw new TokenRecordException(1, "领取失败啦");
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1899,7 +1899,7 @@
                    tokenRecord.setStartTime(nowDate);
                    tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
                    tokenRecord.setToken(token);
                    tokenRecord.setState(state);
                    tokenRecord.setState(0);
                    tokenRecordService.insertSelective(tokenRecord);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
@@ -1927,10 +1927,10 @@
        String tips = "送给你一张返利奖励券快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,使用后可让返利加倍。\r\n" 
                +"----------------------------\r\n" 
                + "下载[返利券]App链接:http://t.cn/2H7AXAH\r\n"
                + "下载[返利券]App链接:%s\r\n"
                + "PS:口令将会24小时内失效,请及时领取。";
        
        tips = String.format(tips, token);
        tips = String.format(tips, token, configService.get("app_down_link"));
        
        return tips;
    }
fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinRecordService.java
@@ -96,6 +96,16 @@
     */
    public UserTaoLiJinRecord createShareTaoLiJin(Long uid, int totalNum, TaoBaoGoodsBrief goods)
            throws UserTaoLiJinRecordException;
    /**
     * 赠送推广红包
     * @param uid
     * @param amount
     * @return
     * @throws UserTaoLiJinRecordException
     */
    public String giveTaolijin(Long uid, BigDecimal amount) throws UserTaoLiJinRecordException;
    
    
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/TokenRecordService.java
@@ -1,6 +1,8 @@
package com.yeshi.fanli.service.inter.user;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
import com.yeshi.fanli.exception.user.TokenRecordException;
import com.yeshi.fanli.vo.msg.TokenVO;
public interface TokenRecordService {
@@ -14,4 +16,22 @@
     */
    public TokenRecord getNearByTypeAndIdentify(String type, String identify);
    /**
     * 赠送口令解析
     * @param token
     * @param uid
     * @return
     * @throws TokenRecordException
     */
    public TokenVO discernToken(String token, Long uid) throws TokenRecordException;
    /**
     * 口令领取
     * @param token
     * @param uid
     * @throws TokenRecordException
     */
    public void receiveToken(String token, Long uid) throws TokenRecordException;
}
fanli/src/main/java/com/yeshi/fanli/vo/msg/TokenVO.java
@@ -7,7 +7,7 @@
public class TokenVO {
    
    @Expose // id
    private Long id;
    private String token;
    
    @Expose // 昵称
    private String nickName;
@@ -15,8 +15,8 @@
    @Expose // 头像
    private String portrait;
    
    @Expose // 类型
    private String type;
    @Expose // 类型  1标题搜索  2链接搜索
    private Integer type;
    
    @Expose // 数量、面额
    private Integer amount;
@@ -44,11 +44,12 @@
        this.portrait = portrait;
    }
    public String getType() {
    public Integer getType() {
        return type;
    }
    public void setType(String type) {
    public void setType(Integer type) {
        this.type = type;
    }
@@ -68,12 +69,12 @@
        this.tips = tips;
    }
    public Long getId() {
        return id;
    public String getToken() {
        return token;
    }
    public void setId(Long id) {
        this.id = id;
    public void setToken(String token) {
        this.token = token;
    }
    public Boolean getState() {