yujian
2019-06-26 bb2d93ec0add746fff457c04e7995d75eb93f894
自购时 推广红包不足限制
1个文件已修改
27 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -224,12 +224,24 @@
        // 过期
        userTaoLiJinOriginService.overdueHongBao(uid);
        BigDecimal tlj = userMoneyExtra.getTlj();
        // 总推广红包
        BigDecimal totalMoney = MoneyBigDecimalUtil.mul(perface, new BigDecimal(totalNum));
        if (totalMoney.compareTo(tlj) > 0) {
        // 自购时的红包余额
        if (origin == 1) {
            BigDecimal tljSelf = userMoneyExtra.getTljSelf();
            if (tljSelf == null || tljSelf.compareTo(totalMoney) < 0) {
                throw new UserTaoLiJinRecordException(101, "红包余额不足");
            }
        }
        // 分享时的红包余额
        BigDecimal tlj = userMoneyExtra.getTlj();
        if (tlj == null || tlj.compareTo(totalMoney) < 0) {
            throw new UserTaoLiJinRecordException(101, "红包余额不足");
        }
        // 创建淘礼金红包
        TaoLiJinDTO taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, name, perface, totalNum, sendStartTime,
@@ -254,10 +266,15 @@
        record.setCreateTime(new Date());
        userTaoLiJinRecordMapper.insertSelective(record);
        // 剩余淘礼金
        BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney);
        UserMoneyExtra updateExtra = new UserMoneyExtra();
        updateExtra.setUid(uid);
        if (origin == 1) { // 剩余淘礼金-- 自购
            updateExtra.setTljSelf(MoneyBigDecimalUtil.sub(userMoneyExtra.getTljSelf(), totalMoney));
        }
        // 剩余淘礼金
        BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney);
        updateExtra.setTlj(surplusTlj);
        updateExtra.setUpdateTime(new Date());
        userMoneyExtraService.updateByPrimaryKeySelective(updateExtra);