Преглед на файлове

新增土地级别收益

xst преди 4 години
родител
ревизия
3f654fa15d

+ 7 - 1
src/main/java/com/td/boss/common/service/ComConfigService.java

@@ -1,5 +1,11 @@
 package com.td.boss.common.service;
 
-public interface ComConfigService  {
+import com.td.boss.game.complayersattri.vo.ComPlayersLuckyLandLevelUpVo;
+
+import java.util.List;
+
+public interface ComConfigService {
     String selectByKey(String key);
+
+    List<ComPlayersLuckyLandLevelUpVo> selectLandLevel();
 }

+ 13 - 0
src/main/java/com/td/boss/common/service/ComConfigServiceImpl.java

@@ -4,10 +4,12 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.td.boss.common.pojo.ComConfig;
 import com.td.boss.common.repository.ComConfigRepository;
+import com.td.boss.game.complayersattri.vo.ComPlayersLuckyLandLevelUpVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 @Service
@@ -37,4 +39,15 @@ public class ComConfigServiceImpl implements ComConfigService {
         List<ComConfig> list = list();
         return list.stream().filter(a -> a.getConfigKey().equals(key)).map(a -> a.getConfigValue()).findFirst().orElse("");
     }
+    @Override
+    public List<ComPlayersLuckyLandLevelUpVo> selectLandLevel() {
+        String levelUp = "land_level";
+        List<ComConfig> list = list();
+        String land_tools = list.stream().filter(a -> a.getConfigKey().equals(levelUp)).map(a -> a.getConfigValue()).findFirst().orElse("");
+        if (StrUtil.isBlank(land_tools)) {
+            return new ArrayList<>();
+        } else {
+            return JSONUtil.toList(land_tools, ComPlayersLuckyLandLevelUpVo.class);
+        }
+    }
 }

+ 28 - 3
src/main/java/com/td/boss/game/complayergoods/controller/ComPlayerGoodsController.java

@@ -1,7 +1,9 @@
 package com.td.boss.game.complayergoods.controller;
 
+import cn.hutool.core.convert.Convert;
 import com.td.boss.common.controller.*;
 import com.td.boss.common.pojo.Result;
+import com.td.boss.common.service.ComConfigService;
 import com.td.boss.config.enums.ResultEnum;
 import com.td.boss.game.comexplainland.service.ComExplainLandService;
 import com.td.boss.game.comexplainland.vo.ComExplainLandVo;
@@ -35,6 +37,7 @@ import com.td.boss.game.complayers.vo.ComPlayersVo;
 import com.td.boss.game.complayersattri.service.ComPlayersAttriService;
 import com.td.boss.game.complayersattri.vo.ComPlayersAttriSimpleVo;
 import com.td.boss.game.complayersattri.vo.ComPlayersAttriVo;
+import com.td.boss.game.complayersattri.vo.ComPlayersLuckyLandLevelUpVo;
 import com.td.boss.game.comsetting.pojo.ComSetting;
 import com.td.boss.game.comsetting.service.ComSettingService;
 import com.td.boss.game.comsetting.vo.ComSettingVo;
@@ -281,8 +284,8 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             Integer _profit = _amount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
             // 配置的参数。这里先直接定义
             Double profitConfig = comSettingVo.getProfit(), stealRatioMaxConfig = comSettingVo.getStealMaxRatio(), stealRatioMinConfig = comSettingVo.getStealMinRatio(), finallyGetRatioConfig = comSettingVo.getFinalRatio();
-
-            Double _profitDouble = _profit.doubleValue();
+            Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
+            Double _profitDouble = _profit.doubleValue()+landLevelInCome;
             Double _residualProfit = DoubleUtil.mul(_profitDouble, DoubleUtil.sub(1d, profitConfig));//如果 profitConfig 0.2,剩余利润就是0.8;
             Double _stealAmount = DoubleUtil.sub(_profitDouble, _residualProfit); //可偷取的利润
 
@@ -525,7 +528,8 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
                 _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
             }
             //todo 拿出计算利润,收获量减去种子的成本(snb)后的百分之30 ,后面需要后台可调整
-            Integer _profit = _otherAmount - otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
+            Double landLevelInCome = getLandLevelInCome(otherPlayerLand, comMallSeedVo.getPriceSnb());
+            Double _profit = _otherAmount - otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb()+landLevelInCome;
             // 配置的参数。这里先直接定义
             // 需要根据 狗是否生效,小偷是否装备打狗棒来确定参数
             Double profitConfig = _dogWork ? comSettingVo.getProfitDog() : comSettingVo.getProfit(),
@@ -972,6 +976,27 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
 //
 //        return Result.of(map);
 //    }
+    @Autowired
+    private ComConfigService comConfigService;
+    /**
+     * 获得土地级别收益,普通土地最后结果为0
+     * @param comPlayerLand
+     * @param priceSnb
+     * @return
+     */
+    private Double getLandLevelInCome(ComPlayerLand comPlayerLand, Integer priceSnb) {
+        List<ComPlayersLuckyLandLevelUpVo> comPlayersLuckyLandLevelUpVos = comConfigService.selectLandLevel();
+        ComPlayersLuckyLandLevelUpVo first = comPlayersLuckyLandLevelUpVos.stream()
+                .filter(a -> a.getId().equals(comPlayerLand.getLandLevel()))
+                .findFirst().orElse(null);
+        //土地级别不存在
+        if (first == null) {
+            first = new ComPlayersLuckyLandLevelUpVo();
+            first.setProduct(0);
+        }
+        Integer all = comPlayerLand.getLeaseMultiple() * priceSnb;
+        return Convert.toDouble(all * first.getProduct() * 0.01);
+    }
 
 
     /**

+ 28 - 2
src/main/java/com/td/boss/game/complayerprofit/service/ComPlayerProfitServiceImpl.java

@@ -1,5 +1,6 @@
 package com.td.boss.game.complayerprofit.service;
 
+import cn.hutool.core.convert.Convert;
 import com.td.boss.common.service.*;
 import com.td.boss.game.commallseed.pojo.ComMallSeed;
 import com.td.boss.game.commallseed.vo.ComMallSeedVo;
@@ -7,6 +8,7 @@ import com.td.boss.game.complayerland.pojo.ComPlayerLand;
 import com.td.boss.game.complayerprofit.pojo.ComPlayerProfit;
 import com.td.boss.game.complayerprofit.vo.ComPlayerProfitVo;
 import com.td.boss.game.complayerprofit.repository.ComPlayerProfitRepository;
+import com.td.boss.game.complayersattri.vo.ComPlayersLuckyLandLevelUpVo;
 import com.td.boss.util.CopyUtil;
 import com.td.boss.util.DoubleUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -78,7 +80,8 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
             _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
         }
         //todo 拿出全部利润
-        Integer _profit = _otherAmount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
+        Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
+        Double _profit = _otherAmount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb()+landLevelInCome;
         //todo 计算减产,第一次灾难按利润的 50% 减产,两次就是减到 0 了。
 
         //必然发生的灾难,减产50%
@@ -133,7 +136,8 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
             _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
         }
         //todo 拿出全部利润
-        Integer _profit = _otherAmount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
+        Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
+        Double _profit = _otherAmount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb()+landLevelInCome;
         //todo 计算减产,第一次灾难按利润的 50% 减产,两次就是减到 0 了。
 
         //额外发生的灾难,按照次数计算减产 50% 发生已经发生1次计算后当次等于 25%,
@@ -173,4 +177,26 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
 
         return comPlayerProfitVo;
     }
+    @Autowired
+    private ComConfigService comConfigService;
+
+    /**
+     * 获得土地级别收益,普通土地最后结果为0
+     * @param comPlayerLand
+     * @param priceSnb
+     * @return
+     */
+    private Double getLandLevelInCome( ComPlayerLand comPlayerLand, Integer priceSnb) {
+        List<ComPlayersLuckyLandLevelUpVo> comPlayersLuckyLandLevelUpVos = comConfigService.selectLandLevel();
+        ComPlayersLuckyLandLevelUpVo first = comPlayersLuckyLandLevelUpVos.stream()
+                .filter(a -> a.getId().equals(comPlayerLand.getLandLevel()))
+                .findFirst().orElse(null);
+        //土地级别不存在
+        if (first == null) {
+            first = new ComPlayersLuckyLandLevelUpVo();
+            first.setProduct(0);
+        }
+        Integer all = comPlayerLand.getLeaseMultiple() * priceSnb;
+        return Convert.toDouble(all * first.getProduct() * 0.01);
+    }
 }

+ 1 - 2
src/main/java/com/td/boss/game/complayersattri/service/ComPlayersLuckyServiceImpl.java

@@ -314,7 +314,6 @@ public class ComPlayersLuckyServiceImpl extends CommonServiceImpl<ComPlayersLuck
      */
     @Override
     public List<ComPlayersLuckyLandLevelUpVo> getLandLevelUp() {
-        String land_tools = comConfigService.selectByKey(levelUp);
-        return JSONUtil.toList(land_tools, ComPlayersLuckyLandLevelUpVo.class);
+        return comConfigService.selectLandLevel();
     }
 }