yujian
2019-10-22 22c19f1b95de5103156be5b14a20b8299bf28833
Revert "淘礼金赠送红包功能恢复"

This reverts commit 10abb8f04d3bacd4cead1758aae48726ccd29c66.
5个文件已修改
286 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java 127 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinOriginService.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -34,7 +34,6 @@
import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
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;
@@ -708,17 +707,7 @@
     */
    @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()));
        }
        out.print(JsonUtil.loadFalseResult(1, "抱歉,推广红包相关功能已下线!"));
    }
}
fanli/src/main/java/com/yeshi/fanli/job/TaoLiJinJob.java
@@ -10,7 +10,6 @@
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
import com.yeshi.fanli.entity.taobao.ShareHotGoods;
import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -170,32 +169,4 @@
        addTLJBuyGoods(list, day);
    }
    /**
     * 每2个小时 赠送退回已过期淘礼金
     */
    @Scheduled(cron = "0 0 0/2 * * ? ")
    public void giveSendBack() {
        if (!Constant.IS_TASK)
            return;
        for (int i = 0; i < 100; i++) {
            List<UserTaoLiJinGiveRecord> overdueList = userTaoLiJinGiveRecordService.overdueList(500);
            if (overdueList == null || overdueList.size() == 0) {
                break;
            }
            for (UserTaoLiJinGiveRecord record : overdueList) {
                try {
                    userTaoLiJinOriginService.giveSendBack(record.getGiveUid(), record);
                    // 更新记录
                    UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord();
                    updateRecord.setId(record.getId());
                    updateRecord.setState(UserTaoLiJinGiveRecord.STATE_OVERDUE);
                    userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinOriginServiceImpl.java
@@ -1,26 +1,15 @@
package com.yeshi.fanli.service.impl.tlj;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.tlj.UserTaoLiJinOriginMapper;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherTaoLiJinContentDTO;
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.UserTaoLiJinOrigin.TaoLiJinOriginEnum;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
@@ -31,148 +20,68 @@
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
@Service
public class UserTaoLiJinOriginServiceImpl implements UserTaoLiJinOriginService {
public class UserTaoLiJinOriginServiceImpl implements UserTaoLiJinOriginService{
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    @Resource
    private UserTaoLiJinOriginMapper userTaoLiJinOriginMapper;
    @Resource
    private UserMoneyExtraService userMoneyExtraService;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private UserTaoLiJinDetailService userTaoLiJinDetailService;
    @Resource
    private UserOtherMsgNotificationService userOtherMsgNotificationService;
    @Resource
    private ConfigTaoLiJinService configTaoLiJinService;
    @Resource
    private UserTaoLiJinRecordService userTaoLiJinRecordService;
    @Resource
    private UserTaoLiJinReportService userTaoLiJinReportService;
    @Override
    public void updateByPrimaryKeySelective(UserTaoLiJinOrigin record) {
        userTaoLiJinOriginMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    public BigDecimal countMoneyByDate(long uid, int dateType) {
        return userTaoLiJinOriginMapper.countMoneyByDate(uid, dateType);
    }
    @Override
    public long countByUidAndOrigin(long uid, String origin) {
        return userTaoLiJinOriginMapper.countByUidAndOrigin(uid, origin);
    }
    @Override
    public UserTaoLiJinOrigin getByUidAndOrigin(long uid, String origin) {
        return userTaoLiJinOriginMapper.getByUidAndOrigin(uid, origin);
    }
    @Override
    public UserTaoLiJinOrigin getRankByThisMonth(long uid, String type) {
        return userTaoLiJinOriginMapper.getRankByThisMonth(uid, type);
    }
    @Override
    public List<UserTaoLiJinOrigin> getSurplusLiJin(long uid) {
        return userTaoLiJinOriginMapper.getSurplusLiJin(uid);
    }
    @Override
    @Transactional
    public UserTaoLiJinOrigin receiveFriendsGive(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.friendsGive);
        // 红包明细
        userTaoLiJinDetailService.createAddDetail(origin);
        // 消息
        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    MsgOtherTaoLiJinContentDTO content = new MsgOtherTaoLiJinContentDTO();
                    content.setState("红包增加");
                    content.setSource("好友赠送");
                    content.setMoney(money);
                    userOtherMsgNotificationService.taoLiJinMsg(uid, "", content);
                } catch (Exception e) {
                    LogHelper.errorDetailInfo(e);
                }
            }
        });
        return origin;
    }
    @Override
    @Transactional
    public void giveSendBack(Long uid, UserTaoLiJinGiveRecord record) throws UserTaoLiJinOriginException {
        if (uid == null || record == null) {
            throw new UserTaoLiJinOriginException(1, "参数不能为空");
        }
        BigDecimal money = record.getAmount();
        // 添加红包余额
        userMoneyExtraService.addTaoLiJin(uid, money, false);
        // 添加新增记录
        saveOrigin(uid, 1, money, TaoLiJinOriginEnum.giveSendBack);
        // 红包明细
        UserTaoLiJinDetail detail = new UserTaoLiJinDetail();
        detail.setUid(uid);
        detail.setMoney(money);
        detail.setType(TaoLiJinDetailTypeEnum.giveBack);
        detail.setTitle(TaoLiJinDetailTypeEnum.giveBack.getDesc());
        detail.setCreateTime(new Date());
        userTaoLiJinDetailService.insertSelective(detail);
        executor.execute(new Runnable() {
            @Override
            public void run() {
                // 退回消息
                String beiZhu = "请到我的-推广红包查看";
                SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
                MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
                msgOther.setType(MsgOtherGiveContentDTO.TYEP_TLJ);
                msgOther.setTitle("推广红包退回");
                msgOther.setGiveType("你赠送的¥" + money + "元推广红包未被领取");
                msgOther.setGiveTime(sd.format(record.getGiveTime()));
                msgOther.setReturnTime(sd.format(new Date()));
                userOtherMsgNotificationService.tokenGiveMsg(record.getGiveUid(), beiZhu, msgOther);
            }
        });
    }
    // 添加新增记录
    public UserTaoLiJinOrigin saveOrigin(Long uid, int type, BigDecimal money, TaoLiJinOriginEnum originEnum) {
        UserTaoLiJinOrigin taoLiJinOrigin = new UserTaoLiJinOrigin();
        taoLiJinOrigin.setUid(uid);
        taoLiJinOrigin.setType(type);
        taoLiJinOrigin.setOrigin(originEnum);
        taoLiJinOrigin.setMoney(money);
        taoLiJinOrigin.setMoneySurplus(money);
        taoLiJinOrigin.setCreateTime(new Date());
        taoLiJinOrigin.setUpdateTime(new Date());
        taoLiJinOrigin.setRemark(originEnum.getDesc());
        userTaoLiJinOriginMapper.insertSelective(taoLiJinOrigin);
        return taoLiJinOrigin;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -1,6 +1,5 @@
package com.yeshi.fanli.service.impl.user;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -15,7 +14,6 @@
import com.yeshi.fanli.dao.mybatis.user.TokenRecordMapper;
import com.yeshi.fanli.dto.msg.MsgInviteContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
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;
@@ -25,14 +23,11 @@
import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
import com.yeshi.fanli.entity.system.SystemCoupon;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
import com.yeshi.fanli.exception.user.TokenRecordException;
import com.yeshi.fanli.exception.user.UserInfoExtraException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.SystemCouponService;
import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinGiveRecordService;
import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
import com.yeshi.fanli.service.inter.user.TokenRecordService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
@@ -87,13 +82,6 @@
    
    @Resource
    private UserInviteMsgNotificationService userInviteMsgNotificationService;
    @Resource
    private UserTaoLiJinGiveRecordService userTaoLiJinGiveRecordService;
    @Resource
    private UserTaoLiJinOriginService userTaoLiJinOriginService;
    
    @Override
@@ -221,34 +209,7 @@
                throw new TokenRecordException(1, "口令已失效");
            }
        } else if (tokenType == TokenTypeEnum.taoLiJin) {
            type = 12;
            UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService.selectByPrimaryKey(Long.parseLong(identify));
            if (giveRecord == null)
                throw new TokenRecordException(1, "口令已失效");
            BigDecimal amount = giveRecord.getAmount();
            num = Integer.parseInt(amount.setScale(0).toString());
            if(giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_OVERDUE) {
                tips.add("哎呀,推广红包已失效了!");
            } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_RECEIVE) {
                tips.add("哎呀,推广红包已被领取了!");
            } else if (giveRecord.getState() == UserTaoLiJinGiveRecord.STATE_INIT) {
                if (uid == null || uid <= 0)
                    throw new TokenRecordException(1001, "温馨提示,[推广红包]需要登录后领取");
                state = true;
                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, "口令失效");
            }
            throw new TokenRecordException(1, "推广红包相关功能已下线!");
        } else {
            throw new TokenRecordException(1, "无对应类型");
        }
@@ -505,64 +466,7 @@
                }
            });
        } else if (tokenType == TokenTypeEnum.taoLiJin) {
            UserTaoLiJinGiveRecord giveRecord = userTaoLiJinGiveRecordService
                    .selectByPrimaryKey(Long.parseLong(identify));
            if (giveRecord == null || giveRecord.getState() != UserTaoLiJinGiveRecord.STATE_INIT)
                throw new TokenRecordException(1, "赠送记录失效或已被领取");
            Date endTime = giveRecord.getEndTime();
            if (endTime != null && endTime.getTime() < now.getTime())
                throw new TokenRecordException(1, "推广红包已失效了");
            BigDecimal amount = giveRecord.getAmount();
            try {
                // 领取
                userTaoLiJinOriginService.receiveFriendsGive(uid, amount);
                // 更新记录
                UserTaoLiJinGiveRecord updateRecord = new UserTaoLiJinGiveRecord();
                updateRecord.setId(Long.parseLong(identify));
                updateRecord.setReceiveTime(new Date());
                updateRecord.setReceiveUid(uid);
                updateRecord.setState(UserTaoLiJinGiveRecord.STATE_RECEIVE);
                userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
                integralGetService.addGiveTaoLiJin(giveUid);
                msg = "领取成功[推广红包]成功,请到[我的-推广红包]中查看";
                // 消息 + 队员
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
                        boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
                        String beiZhu = "无";
                        if (addTeam)
                            beiZhu = "领取人已经成为你的一级队员";
                        String userName = "无";
                        UserInfo user = userInfoService.selectByPKey(uid);
                        if (user != null && !StringUtil.isNullOrEmpty(user.getNickName()))
                            userName = user.getNickName();
                        MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
                        msgOther.setType(MsgOtherGiveContentDTO.TYEP_TLJ);
                        msgOther.setTitle("赠送推广红包");
                        msgOther.setGiveType("你赠送的推广红包被成功领取");
                        msgOther.setReceiveInfo("昵称:" + userName + " ID:" + uid);
                        msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
                        msgOther.setReceiveTime(sd.format(new Date()));
                        userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
                        // 激活邀请信息
                        if (addTeam)
                            addInviteMsg(uid, giveUid, amount.setScale(2) + "元推广红包");
                    }
                });
            } catch (UserTaoLiJinOriginException e) {
                e.printStackTrace();
            }
            throw new TokenRecordException(1, "推广红包相关功能已下线!");
        } else {
            throw new TokenRecordException(1, "无对应类型");
        }
fanli/src/main/java/com/yeshi/fanli/service/inter/tlj/UserTaoLiJinOriginService.java
@@ -3,9 +3,7 @@
import java.math.BigDecimal;
import java.util.List;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin;
import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
public interface UserTaoLiJinOriginService {
@@ -58,21 +56,6 @@
    /**
     * 领取淘礼金-好友赠送
     * @param uid
     * @param money
     * @return
     * @throws UserTaoLiJinOriginException
     */
    public UserTaoLiJinOrigin receiveFriendsGive(Long uid, BigDecimal money) throws UserTaoLiJinOriginException;
    /**
     * 红包赠送退回
     * @param uid
     * @param UserTaoLiJinGiveRecord record
     * @throws UserTaoLiJinOriginException
     */
    public void giveSendBack(Long uid, UserTaoLiJinGiveRecord record) throws UserTaoLiJinOriginException;
    
}