From de00eeb45e3aee0cbb5f62210c05ef32bb7478b4 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 30 Nov 2021 14:22:49 +0800 Subject: [PATCH] fix --- src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java | 48 ++++++++++++++++++++++++++++++++++++------------ 1 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java b/src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java index ea0460d..d0671f2 100644 --- a/src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java @@ -10,13 +10,11 @@ import com.xcong.excoin.common.enumerates.CoinTypeEnum; import com.xcong.excoin.common.response.Result; import com.xcong.excoin.modules.coin.service.CoinService; -import com.xcong.excoin.modules.fish.dao.CannonAccountMoneyChangeDao; -import com.xcong.excoin.modules.fish.dao.CannonOwnRecordDao; -import com.xcong.excoin.modules.fish.dao.CannonSettingDao; -import com.xcong.excoin.modules.fish.dao.MemberAccountGoldDao; +import com.xcong.excoin.modules.fish.dao.*; import com.xcong.excoin.modules.fish.dto.*; import com.xcong.excoin.modules.fish.entity.*; import com.xcong.excoin.modules.fish.service.MemberCannonService; +import com.xcong.excoin.modules.fish.vo.AccountAvaBanlaceVo; import com.xcong.excoin.modules.fish.vo.CannonSettingVo; import com.xcong.excoin.modules.fish.vo.GoldAccountVo; import com.xcong.excoin.modules.fish.vo.OwnCannonVo; @@ -33,21 +31,23 @@ public class MemberCannonServiceImpl extends ServiceImpl<CannonOwnRecordDao, CannonOwnRecord> implements MemberCannonService { @Resource - CannonSettingDao cannonSettingDao; - @Resource MemberAccountGoldDao memberAccountGoldDao; - @Resource - CannonAccountMoneyChangeDao cannonAccountMoneyChangeDao; @Resource MemberWalletCoinDao memberWalletCoinDao; @Resource + private MemberCannonService memberCannonService; + @Resource + CannonAccountMoneyChangeDao cannonAccountMoneyChangeDao; + @Resource CannonOwnRecordDao cannonOwnRecordDao; + @Resource + CannonSettingDao cannonSettingDao; + @Resource + CannonGameRecordDao cannonGameRecordDao; @Resource RedisUtils redisUtils; @Resource private CoinService coinService; - @Resource - private MemberCannonService memberCannonService; @Override public Result coinGoldExchange(CoinGoldExchangeDto coinGoldExchangeDto) { @@ -66,7 +66,7 @@ //1:金币兑换1代币 2:1代币兑换金币 if(type == 1){ MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); - MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); + MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); if(balance.compareTo(memberAccountGold.getAvailableBalance()) > 0){ return Result.fail("金币不足"); } @@ -88,7 +88,7 @@ cannonAccountMoneyChangeDao.insert(cannonAccountMoneyChange); }else if(type == 2){ MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); - MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCT.name()); + MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); if(balance.compareTo(memberWalletCoinEntity.getAvailableBalance()) > 0){ return Result.fail("代币不足"); } @@ -252,9 +252,33 @@ BigDecimal goldConsume = cannonSetting.getGoldConsume().subtract(new BigDecimal(goldWin)).setScale(0,BigDecimal.ROUND_DOWN); MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); memberCannonService.updateTotalBalanceAndAvailableBalance(memberAccountGold.getId(),goldConsume.negate(),goldConsume.negate(),null); + //增加一条游戏记录 + CannonGameRecord cannonGameRecord = new CannonGameRecord(); + cannonGameRecord.setMemberId(memberId); + cannonGameRecord.setCannonOwnId(cannonOwnRecord.getId()); + cannonGameRecord.setCannonName(cannonOwnRecord.getCannonName()); + cannonGameRecord.setCannonCode(cannonOwnRecord.getCannonCode()); + cannonGameRecord.setGoldConsume(cannonSetting.getGoldConsume()); + cannonGameRecord.setGoldReward(new BigDecimal(goldWin)); + cannonGameRecordDao.insert(cannonGameRecord); + return Result.ok("success"); } + @Override + public Result getAccountAvaBanlace() { + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + MemberAccountGold memberAccountGold = memberAccountGoldDao.selectAccountGoldByMemberId(memberId); + MemberWalletCoinEntity memberWalletCoinEntityXCC = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.XCC.name()); + MemberWalletCoinEntity memberWalletCoinEntityUSDT = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, CoinTypeEnum.USDT.name()); + AccountAvaBanlaceVo accountAvaBanlaceVo = new AccountAvaBanlaceVo(); +// accountAvaBanlaceVo.setMemberId(memberId); + accountAvaBanlaceVo.setGoldAvailableBalance(memberAccountGold.getAvailableBalance() == null?BigDecimal.ZERO:memberAccountGold.getAvailableBalance()); + accountAvaBanlaceVo.setCoinAvailableBalance(memberWalletCoinEntityXCC.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityXCC.getAvailableBalance()); + accountAvaBanlaceVo.setUsdtAvailableBalance(memberWalletCoinEntityUSDT.getAvailableBalance() == null?BigDecimal.ZERO:memberWalletCoinEntityUSDT.getAvailableBalance()); + return Result.ok(accountAvaBanlaceVo); + } + public static void main(String[] args) { System.out.println(UUID.randomUUID().toString()); } -- Gitblit v1.9.1