xiaoyong931011
2021-11-24 54d2e6cccbcc8ecb176d807f80f5f64cf104018f
src/main/java/com/xcong/excoin/modules/fish/service/impl/MemberCannonServiceImpl.java
@@ -14,10 +14,7 @@
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.dto.*;
import com.xcong.excoin.modules.fish.entity.*;
import com.xcong.excoin.modules.fish.service.MemberCannonService;
import com.xcong.excoin.modules.fish.vo.CannonSettingVo;
@@ -237,6 +234,27 @@
        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);
        return Result.ok("success");
    }
    public static void main(String[] args) {
        System.out.println(UUID.randomUUID().toString());
    }