|
@@ -109,9 +109,20 @@ public class UserCoinServiceImpl extends ServiceImpl<UserCoinMapper, UserCoin> i
|
|
Assert.isTrue(rtn1, "扣除转赠方盲豆失败, userId:" + coinTransferParamDTO.getFromUserId());
|
|
Assert.isTrue(rtn1, "扣除转赠方盲豆失败, userId:" + coinTransferParamDTO.getFromUserId());
|
|
// 增加受赠方盲豆
|
|
// 增加受赠方盲豆
|
|
UserCoin toUserCoin = getById(coinTransferParamDTO.getToUserId());
|
|
UserCoin toUserCoin = getById(coinTransferParamDTO.getToUserId());
|
|
- boolean rtn2 = update(new LambdaUpdateWrapper<UserCoin>().set(UserCoin::getCoin, toUserCoin.getCoin() + coinTransferParamDTO.getRealTransferCoin())
|
|
|
|
- .eq(UserCoin::getUserId, coinTransferParamDTO.getToUserId()));
|
|
|
|
- Assert.isTrue(rtn2, "增加受赠方盲豆失败,userId:" + coinTransferParamDTO.getToUserId());
|
|
|
|
|
|
+ if (toUserCoin == null) {
|
|
|
|
+ // 受赠方从未获得过盲豆
|
|
|
|
+ UserCoin toUserNoCoin = new UserCoin();
|
|
|
|
+ toUserNoCoin.setCoin(coinTransferParamDTO.getRealTransferCoin());
|
|
|
|
+ toUserNoCoin.setUserId(coinTransferParamDTO.getToUserId());
|
|
|
|
+ toUserNoCoin.setCreatedTime(new Date());
|
|
|
|
+ toUserNoCoin.setUpdatedTime(new Date());
|
|
|
|
+ boolean rtn2 = save(toUserNoCoin);
|
|
|
|
+ Assert.isTrue(rtn2, "从未获得过盲豆的用户转赠盲豆失败, userId:" + coinTransferParamDTO.getToUserId());
|
|
|
|
+ } else {
|
|
|
|
+ boolean rtn3 = update(new LambdaUpdateWrapper<UserCoin>().set(UserCoin::getCoin, toUserCoin.getCoin() + coinTransferParamDTO.getRealTransferCoin())
|
|
|
|
+ .eq(UserCoin::getUserId, coinTransferParamDTO.getToUserId()));
|
|
|
|
+ Assert.isTrue(rtn3, "增加受赠方盲豆失败,userId:" + coinTransferParamDTO.getToUserId());
|
|
|
|
+ }
|
|
|
|
|
|
// 盲豆转赠日志
|
|
// 盲豆转赠日志
|
|
List<UserCoinLog> userCoinLogList = new ArrayList<>();
|
|
List<UserCoinLog> userCoinLogList = new ArrayList<>();
|