From 6cc97918a5a42e37a3c3867cc5b78a0b9fd43a24 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 29 四月 2022 19:55:41 +0800
Subject: [PATCH] 功能完善

---
 app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornGetPriceServiceImpl.java |   71 +++++++++++++++--------------------
 1 files changed, 31 insertions(+), 40 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 6f5ddb1..2478b0f 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,6 +8,7 @@
 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.goldcorn.GoldCornPriceCountType;
 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;
@@ -17,14 +18,11 @@
 
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Date;
+import java.util.*;
 
 import org.yeshi.utils.StringUtil;
 import org.yeshi.utils.TimeUtil;
 import org.yeshi.utils.bean.BeanUtil;
-
-import java.util.List;
 
 import com.yeshi.makemoney.app.dao.goldcorn.GoldCornGetPriceDao;
 import com.yeshi.makemoney.app.entity.goldcorn.GoldCornGetPrice;
@@ -167,59 +165,52 @@
     }
 
     @Override
-    public Integer getWatchVideoPrice(UserInfo user, Date date, int timeSeconds) throws GoldCornGetPriceException {
-
-        //鑾峰彇浠锋牸
-        GoldCornGetPrice getPrice = getPrice(user.getSystem(), GoldCornGetType.watchVideo, date);
+    public Integer getCountPrice(GoldCornGetType type, UserInfo user, SystemEnum system, Date date, long eventCount) throws GoldCornGetPriceException {
+        GoldCornGetPrice getPrice = getPrice(system, type, date);
         if (getPrice == null) {
             throw new GoldCornGetPriceException(GoldCornGetPriceException.CODE_NOT_EXIST, "浠锋牸淇℃伅缂哄け");
         }
 
-        int goldCorn = (int) (timeSeconds * getPrice.getCornNum() / 60.0f);
+        int goldCorn;
+        if (getPrice.getCountType() == GoldCornPriceCountType.time) {
+            goldCorn = (int) (eventCount * getPrice.getCornNum() / 60.0f);
 
-        //鍔犱笂鍥㈤槦澧炵泭姣斾緥
-        if (teamInviteRelationService.getBossUid(user.getId()) != null) {
-            goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue();
+        } else {
+            goldCorn = (int) (eventCount * getPrice.getCornNum());
         }
 
+        //鍔犱笂鍥㈤槦澧炵泭姣斾緥
+        if (user != null && 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, "浠锋牸淇℃伅缂哄け");
+    public Map<GoldCornGetType, GoldCornGetPrice> getCountPrice(List<GoldCornGetType> typeList, UserInfo user, SystemEnum system, Date date) {
+        Map<GoldCornGetType, GoldCornGetPrice> map = new HashMap();
+        for (GoldCornGetType type : typeList) {
+            GoldCornGetPrice getPrice = getPrice(system, type, date);
+            if (getPrice == null) {
+                continue;
+            }
+            int goldCorn = getPrice.getCornNum();
+            //鍔犱笂鍥㈤槦澧炵泭姣斾緥
+            if (user != null && teamInviteRelationService.getBossUid(user.getId()) != null) {
+                goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue();
+            }
+            getPrice.setCornNum(goldCorn);
+            map.put(type, getPrice);
         }
-
-        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;
+        return map;
     }
 
     @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, "浠锋牸淇℃伅缂哄け");
-        }
+    public GoldCornGetPrice getCountPrice(GoldCornGetType type, UserInfo user, SystemEnum system, Date date) {
 
-        int goldCorn = num * getPrice.getCornNum();
+        Map<GoldCornGetType, GoldCornGetPrice> map = getCountPrice(Arrays.asList(new GoldCornGetType[]{type}), user, system, date);
 
-        //鍔犱笂鍥㈤槦澧炵泭姣斾緥
-        if (teamInviteRelationService.getBossUid(user.getId()) != null) {
-            goldCorn = new BigDecimal(goldCorn).multiply(new BigDecimal(1).add(getPrice.getTeamGainRate())).intValue();
-        }
-
-        return goldCorn;
+        return map.get(type);
     }
 
 

--
Gitblit v1.8.0