From 2b71bd05caf230bf9d35e0f000cea6d0413a774e Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期五, 01 十一月 2019 11:39:45 +0800 Subject: [PATCH] 邀请奖励红包 --- fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java index b975434..227f4f7 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java @@ -32,13 +32,13 @@ @Override public BigDecimal getBalance(Long uid) { if (uid == null || uid == 0) - return null; + return new BigDecimal(0); RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid); if (redPackBalance != null) return redPackBalance.getMoney(); - return null; + return new BigDecimal(0); } @@ -67,8 +67,18 @@ throw new RedPackBalanceException(1, "鍙傛暟浼犻�掍笉瀹屾暣"); // 鍔犲叆鏄庣粏 redPackDetailService.insertSelective(detail); - // 鍑忓皯绾㈠寘 - redPackBalanceMapper.addRedPack(uid, money); + // 娣诲姞绾㈠寘 + RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid); + if (redPackBalance == null) { + redPackBalance = new RedPackBalance(); + redPackBalance.setId(uid); + redPackBalance.setMoney(money); + redPackBalance.setCreateTime(new Date()); + redPackBalance.setUpdateTime(new Date()); + redPackBalanceMapper.insertSelective(redPackBalance); + } else { + redPackBalanceMapper.addRedPack(uid, money); + } } -- Gitblit v1.8.0