From 25d595acbb1da6e564d470b0edf62935239ea4d6 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Wed, 24 Nov 2021 16:58:32 +0800 Subject: [PATCH] Merge branch 'fish' of http://120.27.238.55:7000/r/exchange into fish --- src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java | 55 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 41 insertions(+), 14 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 ee974e7..f8e636c 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,14 +10,8 @@ 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.dto.CannonExchangeDto; -import com.xcong.excoin.modules.fish.dto.CoinGoldExchangeDto; -import com.xcong.excoin.modules.fish.dto.GetCannonsDto; -import com.xcong.excoin.modules.fish.dto.GoldExchangeDto; +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.CannonSettingVo; @@ -36,21 +30,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) { @@ -237,6 +233,37 @@ return Result.ok(cannonOwnRecords); } + @Override + public Result fishing(FishingDto fishingDto) { + Long memberId = LoginUserUtils.getAppLoginUser().getId(); + Integer goldWin = fishingDto.getGoldWin() == null?0:fishingDto.getGoldWin(); + if(goldWin < 0){ + return Result.fail("请求异常,请刷新页面"); + } + Long cannonOwnId = fishingDto.getCannonOwnId(); + List<CannonOwnRecord> cannonOwnRecords = cannonOwnRecordDao.selectCannonOwnRecordsByIdAndMemberId(cannonOwnId,memberId); + if(CollUtil.isEmpty(cannonOwnRecords)){ + Result.fail("请求异常,请刷新页面"); + } + //消耗金币 = 每发炮弹的消耗 - 获得金币; + CannonOwnRecord cannonOwnRecord = cannonOwnRecords.get(0); + CannonSetting cannonSetting = cannonSettingDao.selectCannonSettingByCannonCode(cannonOwnRecord.getCannonCode()); + 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"); + } + public static void main(String[] args) { System.out.println(UUID.randomUUID().toString()); } -- Gitblit v1.9.1