dos 1 mese fa
parent
commit
1b711f5e23

+ 5 - 0
game-business/src/main/java/com/game/business/service/IFinTranRecordService.java

@@ -86,6 +86,11 @@ public interface IFinTranRecordService extends IService<FinTranRecord> {
      * */
     public HttpRet<Boolean> transfer(AppUserTeamTranserDto transfer);
 
+    /**
+     * 金币转账
+     * */
+    public HttpRet<Boolean> coinTransfer(AppUserTeamTranserDto transfer);
+
     /**
      * 代存记录
      * */

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

@@ -31,6 +31,7 @@ import com.game.common.enums.DataSourceType;
 import com.game.common.utils.DateUtils;
 import com.game.common.utils.SecurityUtils;
 import com.game.common.utils.StringUtils;
+import com.game.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.game.business.mapper.FinTranRecordMapper;
@@ -65,6 +66,9 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
     @Autowired
     private AppUserCountTask appUserCountTask;
 
+    @Autowired
+    private ISysConfigService configService;
+
     /**
      * 查询消费记录
      *
@@ -166,7 +170,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         if(null == toAppUser){
             return HttpRet.fail("受益用户不存在");
         }
-        if(appUser.getDiamondCoinCash().longValue() < transfer.getMoney().longValue()){
+        if(appUser.getDiamondCoin().longValue() < transfer.getMoney().longValue()){
             return HttpRet.fail("可转账金额不足");
         }
         if(StringUtils.isBlank(appUser.getFundPassword())){
@@ -209,7 +213,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         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);
         tran.setDiamondCoinChange(transfer.getMoney() * -1);
-        tran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
+//        tran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
         tran.setCurrencyType(TranCurrencyType.Balance.getType());
         tran.setRemarks("团队转账");
 //        finTranRecordService.insertFinTranRecord(tran);
@@ -227,7 +231,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         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);
         toTran.setDiamondCoinChange(transfer.getMoney());
-        toTran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
+//        toTran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
         toTran.setCurrencyType(TranCurrencyType.Balance.getType());
         toTran.setFromUid(appUser.getUserid());
         toTran.setRemarks("团队转账");
@@ -241,6 +245,56 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         return HttpRet.success("转账成功",true);
     }
 
+
+    @Override
+    @DSTransactional
+    @DataSource(DataSourceType.SLAVE)
+    public HttpRet<Boolean> coinTransfer(AppUserTeamTranserDto transfer) {
+        AppUser toAppUser = appUserService.selectAppUserByUserid(transfer.getToUserId());
+        AppUser appUser = appUserService.selectAppUserByUserid(SecurityUtils.getUserId());
+        if(null == toAppUser){
+            return HttpRet.fail("受益用户不存在");
+        }
+        if(appUser.getCoin().longValue() < transfer.getMoney().longValue()){
+            return HttpRet.fail("可转账金额不足");
+        }
+        if(StringUtils.isBlank(appUser.getFundPassword())){
+            return HttpRet.fail("未设置支付密码");
+        }
+        if(!Md5Utils.md5(Md5Utils.md5(transfer.getFundPassword()) + appUser.getSalt()).equals(appUser.getFundPassword())){
+            return HttpRet.fail("支付密码错误");
+        }
+
+        String userIds = configService.selectConfigByKey("system.transer.userids");
+        if(!"-1".equals(userIds)){
+            if(!Arrays.asList(userIds.split(",")).contains(appUser.getUserid())){
+                return HttpRet.fail("当前用户无权限转账");
+            }
+        }
+
+        FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
+        FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.TRANSFER_TO_Coin, FinTranType1.U_Outcome_Coin, appUser);
+        tran.setCoinChange(transfer.getMoney() * -1);
+        tran.setCurrencyType(TranCurrencyType.Coin.getType());
+        tran.setRemarks("金币转账");
+        appUserService.updateUserAmount(tran);
+
+
+        FinTranAddedInfo toAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
+        FinTranRecord toTran = FinTranRecord.initFinTranRecordSomeParams(toAddedInfo, FinTranType3.TRANSFER_TO_Coin, FinTranType1.U_Income_Coin, toAppUser);
+        toTran.setCoinChange(transfer.getMoney());
+        toTran.setCurrencyType(TranCurrencyType.Coin.getType());
+        toTran.setFromUid(appUser.getUserid());
+        toTran.setRemarks("金币转账");
+        appUserService.updateUserAmount(toTran);
+        //清除用户缓存
+        redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(appUser.getUserid())));
+        redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(toAppUser.getUserid())));
+        //更新用户可提现余额
+        appUserCountTask.updateWithdrawAble(appUser.getUserid());
+        return HttpRet.success("转账成功",true);
+    }
+
     @Override
     @DataSource(DataSourceType.SLAVE)
     public List<FinTranRecord> transferRecord(AppUserTeamTranserRecordDto transerRecordDto) {

+ 6 - 1
game-common/src/main/java/com/game/common/constant/finance/FinTranType3.java

@@ -111,7 +111,12 @@ public enum FinTranType3 {
     /**
      * 转账 - 团队余额转账
      */
-    TRANSFER_TO_TEAM_DiamondCoin(FinTranType2.USER_TRANSFER, 1601, ProjConfig.getCoinName() + MessageUtils.message("11214") + ProjConfig.getD_ticketName(),0),
+    TRANSFER_TO_TEAM_DiamondCoin(FinTranType2.USER_TRANSFER, 1601, "团队余额转账",0),
+
+    /**
+     * 转账 - 金币转账
+     */
+    TRANSFER_TO_Coin(FinTranType2.USER_TRANSFER, 1602, "金币转账",0),
 
     /**
      * 赠送礼物 - 直播房间内