From 36681e15e12aaa9135f69260472de65303cdcba3 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 26 四月 2022 19:10:45 +0800 Subject: [PATCH] 任务优化 --- app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java b/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java index 0d65d5e..6f5ddb1 100644 --- a/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java +++ b/app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java @@ -8,7 +8,10 @@ import com.yeshi.makemoney.app.entity.SystemEnum; import com.yeshi.makemoney.app.entity.config.SystemConfigKey; import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetType; +import com.yeshi.makemoney.app.entity.user.UserInfo; +import com.yeshi.makemoney.app.exception.goldcorn.GoldCornGetPriceException; import com.yeshi.makemoney.app.service.inter.config.SystemConfigService; +import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @@ -40,6 +43,9 @@ @Resource private SystemConfigService systemConfigService; + + @Resource + private TeamInviteRelationService teamInviteRelationService; @Override public List<GoldCornGetPrice> list(GoldCornGetPriceQuery goldCornGetPriceQuery, int page, int pageSize) { @@ -160,5 +166,61 @@ return new Gson().fromJson(value, type); } + @Override + public Integer getWatchVideoPrice(UserInfo user, Date date, int timeSeconds) throws GoldCornGetPriceException { + + //鑾峰彇浠锋牸 + GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.watchVideo, date); + if (getPrice == null) { + throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "浠锋牸淇℃伅缂哄け"); + } + + int goldCorn = (int) (timeSeconds * getPrice.getCornNum() / 60.0f); + + //鍔犱笂鍥㈤槦澧炵泭姣斾緥 + if (teamInviteRelationService.getBossUid(user.getId()) != null) { + goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); + } + + return goldCorn; + } + + @Override + public Integer getReadNovelPrice(UserInfo user, Date date, int timeSeconds) throws GoldCornGetPriceException { + + //鑾峰彇浠锋牸 + GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.readNovel, date); + if (getPrice == null) { + throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "浠锋牸淇℃伅缂哄け"); + } + + int goldCorn = (int) (timeSeconds * getPrice.getCornNum() / 60.0f); + + //鍔犱笂鍥㈤槦澧炵泭姣斾緥 + if (teamInviteRelationService.getBossUid(user.getId()) != null) { + goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); + } + + return goldCorn; + } + + @Override + public Integer getScanNewsPrice(UserInfo user, Date date, int num) throws GoldCornGetPriceException { + //鑾峰彇浠锋牸 + GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.scanNews, date); + if (getPrice == null) { + throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "浠锋牸淇℃伅缂哄け"); + } + + int goldCorn = num * getPrice.getCornNum(); + + //鍔犱笂鍥㈤槦澧炵泭姣斾緥 + if (teamInviteRelationService.getBossUid(user.getId()) != null) { + goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue(); + } + + return goldCorn; + } + } \ No newline at end of file -- Gitblit v1.8.0