Browse Source

优化可提现金币更新

dos 2 tuần trước cách đây
mục cha
commit
241f5a72fe

+ 1 - 1
game-business/src/main/java/com/game/business/controller/AppGameBettingController.java

@@ -445,7 +445,7 @@ public class AppGameBettingController extends BaseController{
 
             finTranRecord.setOrderId(gameBetting.getId());
             //finTranRecordService.insertFinTranRecord(finTranRecord);
-            appUserService.updateUserAmount(finTranRecord);
+            appUserService.updateUserAmount(finTranRecord,false);
 
             // 分佣
             if(gameBetting.getBettingType() == 0){

+ 2 - 2
game-business/src/main/java/com/game/business/controller/AppUserController.java

@@ -266,7 +266,7 @@ public class AppUserController extends BaseController
                 AppChargeChannel channel = appChargeChannelService.selectAppChargeChannelById(userChargeDto.getChannelId());
                 userChargeDto.setRate(channel.getRate());
             }*/
-            appUserService.updateUserAmount(tran);
+            appUserService.updateUserAmount(tran,false);
             BigDecimal rate = BigDecimal.ZERO;
             if(null != userChargeDto.getRate() && userChargeDto.getRate() > 0 && userChargeDto.getAmount() > 0){
                 if(userChargeDto.getRate() > 1){
@@ -315,7 +315,7 @@ public class AppUserController extends BaseController
                     giveTran.setTranType1(userChargeDto.getType() == 1 ? FinTranType1.U_Income_Coin_Balance.getType() : FinTranType1.U_Income_Coin.getType());
                     giveTran.setRemarks("充值赠送");
                     giveTran.setId(null);
-                    appUserService.updateUserAmount(giveTran);
+                    appUserService.updateUserAmount(giveTran,false);
                 }
             }
             AppUser afterUser = appUserService.selectAppUserByUserid(userChargeDto.getUserId());

+ 2 - 2
game-business/src/main/java/com/game/business/controller/AppUsersCashrecordController.java

@@ -232,7 +232,7 @@ public class AppUsersCashrecordController extends BaseController
             tran.setCurrencyType(TranCurrencyType.Balance.getType());
             tran.setTranGroupId(IdUtil.getSnowflakeNextId());
             tran.setRemarks("提现审核失败:回退金额");
-            appUserService.updateUserAmount(tran,true);
+            appUserService.updateUserAmount(tran,true,false);
         }
         int rest = appUsersCashrecordService.updateAppUsersCashrecord(update);
         logger.info("{},提现审核:{}",appUser.getUserid(),appUsersCashrecord.getStatus());
@@ -293,7 +293,7 @@ public class AppUsersCashrecordController extends BaseController
                     tran.setCurrencyType(TranCurrencyType.Balance.getType());
                     tran.setTranGroupId(IdUtil.getSnowflakeNextId());
                     tran.setRemarks("转出失败:回退金额");
-                    appUserService.updateUserAmount(tran,true);
+                    appUserService.updateUserAmount(tran,true,false);
                 }else{
                     logger.info("订单{},当前状态非转出中,停止更新失败逻辑",orderNo);
                 }

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

@@ -87,12 +87,14 @@ public interface IAppUserService extends IService<AppUser> {
     /**
      * 更新用户余额、插入流水
      * */
-    int updateUserAmount(FinTranRecord finTranRecord);
+    int updateUserAmount(FinTranRecord finTranRecord,boolean coinCashFlag);
 
     /**
      * 更新用户余额、插入流水(更新可提现)
+     * @param withdrawAble 是否更新可提现金额
+     * @param coinCashFlag 是否更新可提现金币
      * */
-    int updateUserAmount(FinTranRecord finTranRecord,boolean withdrawAble);
+    int updateUserAmount(FinTranRecord finTranRecord,boolean withdrawAble,boolean coinCashFlag);
 
     ApiUserInfoVo getUserInfo(Long userId);
 

+ 4 - 4
game-business/src/main/java/com/game/business/service/impl/AppUserCountDividendServiceImpl.java

@@ -236,7 +236,7 @@ public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDiv
                         curTran.setRemarks(countDividend.getDateNo() + " 发放团队分红奖励");
                         curTran.setFromUid(sendUserId);
 //                        tranRecordList.add(curTran);
-                        appUserService.updateUserAmount(curTran);
+                        appUserService.updateUserAmount(curTran,true);
 
                         //受益用户
                         /*updateAppUser.setDiamondCoin(appUser.getDiamondCoin() + e.getDiamondCoin());
@@ -251,7 +251,7 @@ public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDiv
                         tran.setRemarks(countDividend.getDateNo() + " 团队周分红奖励");
                         tran.setFromUid(sendUserId);
                         //                    tranRecordList.add(tran);
-                        appUserService.updateUserAmount(tran,true);
+                        appUserService.updateUserAmount(tran,true,true);
                     }
                     if (null != countDividend.getCoin() && countDividend.getCoin() > 0) {
                         if(null != countDividend.getCoin() && curUser.getCoin() < countDividend.getCoin()){
@@ -272,7 +272,7 @@ public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDiv
                         curTran.setRemarks(countDividend.getDateNo() + " 发放团队分红奖励");
                         curTran.setFromUid(sendUserId);
 //                        tranRecordList.add(curTran);
-                        appUserService.updateUserAmount(curTran);
+                        appUserService.updateUserAmount(curTran,true);
 
                         //                    updateAppUser.setCoin(appUser.getDiamondCoin() + e.getDiamondCoin());
                         //流水 余额
@@ -283,7 +283,7 @@ public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDiv
                         tran.setCurrencyType(TranCurrencyType.Coin.getType());
                         tran.setRemarks(countDividend.getDateNo() + " 团队周分红奖励");
                         tran.setFromUid(sendUserId);
-                        appUserService.updateUserAmount(tran);
+                        appUserService.updateUserAmount(tran,true);
                         //                    tranRecordList.add(tran);
                     }
                     /*appUserService.updateAppUser(updateAppUser);

+ 6 - 4
game-business/src/main/java/com/game/business/service/impl/AppUserServiceImpl.java

@@ -178,7 +178,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
 
     @Override
     @DataSource(DataSourceType.SLAVE)
-    public int updateUserAmount(FinTranRecord finTranRecord,boolean withdrawAble){
+    public int updateUserAmount(FinTranRecord finTranRecord,boolean withdrawAble,boolean coinCashFlag){
         int res = 0;
         int finRes = 0;
         RLock rLock = redisson.getLock("app_user_amount_".concat(String.valueOf(finTranRecord.getUid())));
@@ -193,7 +193,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
                     if(2 == finTranRecord.getCurrencyType().intValue()){
                         //金币
                         updateAppUser.setCoin(finTranRecord.getCoinChange());
-                        updateAppUser.setCoinCash(MoneyUtils.consumeCash(appUser.getCoin(),appUser.getCoinCash(),finTranRecord.getCoinChange()));
+                        if(coinCashFlag || finTranRecord.getCoinChange() < 0) {
+                            updateAppUser.setCoinCash(MoneyUtils.consumeCash(appUser.getCoin(), appUser.getCoinCash(), finTranRecord.getCoinChange()));
+                        }
                     }else if(4 == finTranRecord.getCurrencyType().intValue()){
                         //余额
                         updateAppUser.setDiamondCoin(finTranRecord.getDiamondCoinChange());
@@ -241,8 +243,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
 
     @Override
     @DataSource(DataSourceType.SLAVE)
-    public int updateUserAmount(FinTranRecord finTranRecord){
-        return updateUserAmount(finTranRecord,false);
+    public int updateUserAmount(FinTranRecord finTranRecord,boolean coinCashFlag){
+        return updateUserAmount(finTranRecord,false,coinCashFlag);
     }
 
     @Override

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

@@ -217,7 +217,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         tran.setCurrencyType(TranCurrencyType.Balance.getType());
         tran.setRemarks("团队转账");
 //        finTranRecordService.insertFinTranRecord(tran);
-        appUserService.updateUserAmount(tran);
+        appUserService.updateUserAmount(tran,true);
 
         //受益用户增加余额
         /*AppUser toUpdateAppUser = new AppUser();
@@ -236,7 +236,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         toTran.setFromUid(appUser.getUserid());
         toTran.setRemarks("团队转账");
 //        finTranRecordService.insertFinTranRecord(toTran);
-        appUserService.updateUserAmount(toTran);
+        appUserService.updateUserAmount(toTran,false);
         //清除用户缓存
         redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(appUser.getUserid())));
         redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(toAppUser.getUserid())));
@@ -277,7 +277,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         tran.setCoinChange(transfer.getMoney() * -1);
         tran.setCurrencyType(TranCurrencyType.Coin.getType());
         tran.setRemarks("金币转账:转给" + toAppUser.getUserid());
-        appUserService.updateUserAmount(tran);
+        appUserService.updateUserAmount(tran,true);
 
 
         FinTranAddedInfo toAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
@@ -286,7 +286,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         toTran.setCurrencyType(TranCurrencyType.Coin.getType());
         toTran.setFromUid(appUser.getUserid());
         toTran.setRemarks("金币转账: 收到来自" + appUser.getUserid() + "的转账");
-        appUserService.updateUserAmount(toTran);
+        appUserService.updateUserAmount(toTran,false);
         //清除用户缓存
         redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(appUser.getUserid())));
         redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(toAppUser.getUserid())));

+ 2 - 2
game-business/src/main/java/com/game/business/task/AppAgentGameBettingTask.java

@@ -256,7 +256,7 @@ public class AppAgentGameBettingTask {
 
             finTranRecord.setOrderId(appGameBetting.getId());
             //finTranRecordService.insertFinTranRecord(finTranRecord);
-            appUserService.updateUserAmount(finTranRecord,true);
+            appUserService.updateUserAmount(finTranRecord,true,false);
         }
     }
 
@@ -363,7 +363,7 @@ public class AppAgentGameBettingTask {
 
         finTranRecord.setOrderId(appGameBetting.getId());
         //finTranRecordService.insertFinTranRecord(finTranRecord);
-        appUserService.updateUserAmount(finTranRecord);
+        appUserService.updateUserAmount(finTranRecord,false);
 
     }
 

+ 1 - 1
game-business/src/main/java/com/game/business/task/AppGameBettingTask.java

@@ -604,7 +604,7 @@ public class AppGameBettingTask {
 
             finTranRecord.setOrderId(appGameBetting.getId());
             //finTranRecordService.insertFinTranRecord(finTranRecord);
-            appUserService.updateUserAmount(finTranRecord);
+            appUserService.updateUserAmount(finTranRecord,false);
         }
         return userIds;
     }

+ 1 - 1
game-business/src/main/java/com/game/business/task/AppGameLotteryTask.java

@@ -235,7 +235,7 @@ public class AppGameLotteryTask {
 
             finTranRecord.setOrderId(appGameBetting.getId());
             //finTranRecordService.insertFinTranRecord(finTranRecord);
-            appUserService.updateUserAmount(finTranRecord);
+            appUserService.updateUserAmount(finTranRecord,false);
         }
         return userIds;
     }

+ 1 - 1
game-business/src/main/java/com/game/business/task/AppUserLiveDividedTask.java

@@ -226,7 +226,7 @@ public class AppUserLiveDividedTask {
             //finTranRecordService.insertFinTranRecord(finTranRecord);
             //本人已在直播系统分成过 停止流水生成以及金额更新
             if(!item.getUserId().equals(appUser.getUserid())){
-                appUserService.updateUserAmount(finTranRecord);
+                appUserService.updateUserAmount(finTranRecord,true);
                 // 插入分佣记录
                 AppUserLiveDividedRecord appUserLiveDividedRecord = new AppUserLiveDividedRecord();
                 appUserLiveDividedRecord.setRate(userLiveRate);