dos 1 月之前
父節點
當前提交
87dcc81f42

+ 1 - 1
game-business/src/main/java/com/game/business/service/IAppUserService.java

@@ -86,7 +86,7 @@ public interface IAppUserService extends IService<AppUser> {
     /**
      * 更新用户余额、插入流水
      * */
-    int updateUserAmount(FinTranRecord finTranRecord)  throws Exception;
+    int updateUserAmount(FinTranRecord finTranRecord);
 
     ApiUserInfoVo getUserInfo(Long userId);
 

+ 3 - 2
game-business/src/main/java/com/game/business/service/impl/AppUserServiceImpl.java

@@ -18,6 +18,7 @@ import com.game.common.annotation.DataSource;
 import com.game.common.constant.finance.FinTranType3;
 import com.game.common.core.redis.RedisCache;
 import com.game.common.enums.DataSourceType;
+import com.game.common.exception.ServiceException;
 import com.game.common.utils.DateUtils;
 import com.game.common.utils.MoneyUtils;
 import com.game.common.utils.StringUtils;
@@ -174,7 +175,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
 
     @Override
     @DataSource(DataSourceType.SLAVE)
-    public int updateUserAmount(FinTranRecord finTranRecord) throws Exception{
+    public int updateUserAmount(FinTranRecord finTranRecord){
         int res = 0;
         int finRes = 0;
         RLock rLock = redisson.getLock("app_user_amount_".concat(String.valueOf(finTranRecord.getUid())));
@@ -225,7 +226,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
                     params = JSONObject.toJSONString(finTranRecord);
                 }
                 log.info("res:{},finRes:{},更新失败:{}",res,finRes,params);
-                throw new Exception("更新失败");
+                throw new ServiceException("更新失败");
             }
             rLock.unlock();
         }

+ 7 - 5
game-business/src/main/java/com/game/business/service/impl/FinTranRecordServiceImpl.java

@@ -201,13 +201,13 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
             }
         }
         //当前用户扣减余额
-        AppUser updateAppUser = new AppUser();
+        /*AppUser updateAppUser = new AppUser();
         updateAppUser.setUserid(appUser.getUserid());
         updateAppUser.setDiamondCoin(appUser.getDiamondCoin() - transfer.getMoney());
         updateAppUser.setDiamondCoinCash(appUser.getDiamondCoinCash() - transfer.getMoney());
         updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() - transfer.getMoney());
         //扣减余额
-        appUserService.updateAppUser(updateAppUser);
+        appUserService.updateAppUser(updateAppUser);*/
 
         FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
         FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.TRANSFER_TO_TEAM_DiamondCoin, FinTranType1.U_Outcome_Balance, appUser);
@@ -216,15 +216,16 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         tran.setCurrencyType(TranCurrencyType.Balance.getType());
         tran.setRemarks("团队转账");
         finTranRecordService.insertFinTranRecord(tran);
+        appUserService.updateUserAmount(tran);
 
         //受益用户增加余额
-        AppUser toUpdateAppUser = new AppUser();
+        /*AppUser toUpdateAppUser = new AppUser();
         toUpdateAppUser.setUserid(toAppUser.getUserid());
         toUpdateAppUser.setDiamondCoin(toAppUser.getDiamondCoin() + transfer.getMoney());
         toUpdateAppUser.setDiamondCoinCash(toAppUser.getDiamondCoinCash() + transfer.getMoney());
-        updateAppUser.setDiamondCoinTotal(toAppUser.getDiamondCoinTotal() + transfer.getMoney());
+        toUpdateAppUser.setDiamondCoinTotal(toAppUser.getDiamondCoinTotal() + transfer.getMoney());
         //增加余额
-        appUserService.updateAppUser(toUpdateAppUser);
+        appUserService.updateAppUser(toUpdateAppUser);*/
 
         FinTranAddedInfo toAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
         FinTranRecord toTran = FinTranRecord.initFinTranRecordSomeParams(toAddedInfo, FinTranType3.TRANSFER_TO_TEAM_DiamondCoin, FinTranType1.U_Income_Coin_Balance, toAppUser);
@@ -234,6 +235,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         toTran.setFromUid(appUser.getUserid());
         tran.setRemarks("团队转账");
         finTranRecordService.insertFinTranRecord(toTran);
+        appUserService.updateUserAmount(toTran);
         //清除用户缓存
         redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(appUser.getUserid())));
         redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(toAppUser.getUserid())));