Selaa lähdekoodia

1.修改计算利润部分bug。区分malltype类型

slambb 3 vuotta sitten
vanhempi
sitoutus
8970d13912

+ 14 - 6
src/main/java/com/td/boss/game/complayergoods/controller/ComPlayerGoodsController.java

@@ -643,13 +643,21 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             //todo 如果当前人员偷窃水果。记录一个信息,存储当前玩家已偷过的水果的信息
             //计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
             Integer _otherAmount = 0;
-            if (otherPlayerLand.getLeaseDate().equals(1)) {
-                _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
-            } else if (otherPlayerLand.getLeaseDate().equals(2)) {
-                _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
-            } else if (otherPlayerLand.getLeaseDate().equals(3)) {
-                _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+
+            //种植的收获量
+            if (otherPlayerLand.getMallType().equals(0)) {
+                if (otherPlayerLand.getLeaseDate().equals(1)) {
+                    _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
+                } else if (otherPlayerLand.getLeaseDate().equals(2)) {
+                    _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
+                } else if (otherPlayerLand.getLeaseDate().equals(3)) {
+                    _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+                }
+            } else {
+                //养殖的收获计算,这里直接用租赁时候消耗倍数 和 harvestQuantity 来计算
+                _otherAmount = otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvestQuantity();
             }
+
             //todo 拿出计算利润,收获量减去种子的成本(snb)后的百分之30 ,后面需要后台可调整
             Double landLevelInCome = getLandLevelInCome(otherPlayerLand, comMallSeedVo.getPriceSnb());
             Integer _profitInt = _otherAmount - otherPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();

+ 56 - 25
src/main/java/com/td/boss/game/complayerprofit/service/ComPlayerProfitServiceImpl.java

@@ -58,18 +58,18 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
     }
 
     @Override
-    public ComPlayerProfit findByPlantFlagAndLossTypeAndDsasterId(String plantFlag, Integer lossType,long dsaterId) {
-        return comPlayerProfitRepository.findByPlantFlagAndLossTypeAndDsasterId(plantFlag, lossType,dsaterId).orElse(null);
+    public ComPlayerProfit findByPlantFlagAndLossTypeAndDsasterId(String plantFlag, Integer lossType, long dsaterId) {
+        return comPlayerProfitRepository.findByPlantFlagAndLossTypeAndDsasterId(plantFlag, lossType, dsaterId).orElse(null);
     }
 
     @Override
-    public Double getStolenSumByOtherUserIdAndPlantFlagAndLossType(String otherUserId, String plantFlag,Integer lossType) {
-        return comPlayerProfitRepository.getStolenSumByTargetIdAndPlantFlagAndLossType(otherUserId, plantFlag,lossType);
+    public Double getStolenSumByOtherUserIdAndPlantFlagAndLossType(String otherUserId, String plantFlag, Integer lossType) {
+        return comPlayerProfitRepository.getStolenSumByTargetIdAndPlantFlagAndLossType(otherUserId, plantFlag, lossType);
     }
 
 
     @Override
-    public ComPlayerProfitVo addFirstDisasterAndLoss(ComPlayerLand comPlayerLand, ComMallSeedVo comMallSeedVo, Integer lossType, Double allLossProfit ,long _dsasterId) {
+    public ComPlayerProfitVo addFirstDisasterAndLoss(ComPlayerLand comPlayerLand, ComMallSeedVo comMallSeedVo, Integer lossType, Double allLossProfit, long _dsasterId) {
 
         //对应土地灾害损失
         ComPlayerProfit comPlayerProfit = new ComPlayerProfit();
@@ -77,17 +77,32 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
         Double _endReduceProfit = 0d;
         //计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
         Integer _otherAmount = 0;
-        if (comPlayerLand.getLeaseDate().equals(1)) {
-            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
-        } else if (comPlayerLand.getLeaseDate().equals(2)) {
-            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
-        } else if (comPlayerLand.getLeaseDate().equals(3)) {
-            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+//        if (comPlayerLand.getLeaseDate().equals(1)) {
+//            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
+//        } else if (comPlayerLand.getLeaseDate().equals(2)) {
+//            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
+//        } else if (comPlayerLand.getLeaseDate().equals(3)) {
+//            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+//        }
+
+        //种植的收获量
+        if (comPlayerLand.getMallType().equals(0)) {
+            if (comPlayerLand.getLeaseDate().equals(1)) {
+                _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
+            } else if (comPlayerLand.getLeaseDate().equals(2)) {
+                _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
+            } else if (comPlayerLand.getLeaseDate().equals(3)) {
+                _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+            }
+        } else {
+            //养殖的收获计算,这里直接用租赁时候消耗倍数 和 harvestQuantity 来计算
+            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvestQuantity();
         }
+
         //todo 拿出全部利润
         Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
         Integer _profitInt = _otherAmount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
-        Double _profit =  DoubleUtil.add(_profitInt.doubleValue(),landLevelInCome);
+        Double _profit = DoubleUtil.add(_profitInt.doubleValue(), landLevelInCome);
         //todo 计算减产,第一次灾难按利润的 50% 减产,两次就是减到 0 了。
 
         //必然发生的灾难,减产40%
@@ -131,7 +146,7 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
 
 
     @Override
-    public ComPlayerProfitVo addOtherDisasterAndLoss(ComPlayerLand comPlayerLand, ComMallSeedVo comMallSeedVo, Integer lossType, Double allLossProfit, Integer disasterCount,long _dsasterId) {
+    public ComPlayerProfitVo addOtherDisasterAndLoss(ComPlayerLand comPlayerLand, ComMallSeedVo comMallSeedVo, Integer lossType, Double allLossProfit, Integer disasterCount, long _dsasterId) {
 
         //对应土地灾害损失
         ComPlayerProfit comPlayerProfit = new ComPlayerProfit();
@@ -139,29 +154,43 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
         Double _endReduceProfit = 0d;
         //计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
         Integer _otherAmount = 0;
-        if (comPlayerLand.getLeaseDate().equals(1)) {
-            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
-        } else if (comPlayerLand.getLeaseDate().equals(2)) {
-            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
-        } else if (comPlayerLand.getLeaseDate().equals(3)) {
-            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+//        if (comPlayerLand.getLeaseDate().equals(1)) {
+//            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
+//        } else if (comPlayerLand.getLeaseDate().equals(2)) {
+//            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
+//        } else if (comPlayerLand.getLeaseDate().equals(3)) {
+//            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+//        }
+        //种植的收获量
+        if (comPlayerLand.getMallType().equals(0)) {
+            if (comPlayerLand.getLeaseDate().equals(1)) {
+                _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
+            } else if (comPlayerLand.getLeaseDate().equals(2)) {
+                _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
+            } else if (comPlayerLand.getLeaseDate().equals(3)) {
+                _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+            }
+        } else {
+            //养殖的收获计算,这里直接用租赁时候消耗倍数 和 harvestQuantity 来计算
+            _otherAmount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvestQuantity();
         }
+
         //todo 拿出全部利润
         Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
         Integer _profitInt = _otherAmount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
-        Double _profit =  DoubleUtil.add(_profitInt.doubleValue(),landLevelInCome);
+        Double _profit = DoubleUtil.add(_profitInt.doubleValue(), landLevelInCome);
         //todo 计算减产,第一次灾难按利润的 100 减产 50,两次就是 50 减到 25。
 
         //额外发生的灾难,按照次数计算减产 50% 发生已经发生1次计算后当次等于 25%,
         double _startRatio = 0.5;
-        for(int i = disasterCount;i>0;i--){
-            _startRatio =  DoubleUtil.mul(_startRatio,0.5);
+        for (int i = disasterCount; i > 0; i--) {
+            _startRatio = DoubleUtil.mul(_startRatio, 0.5);
         }
         Double _reduceProfit = DoubleUtil.mul(_profit, _startRatio);
         // 100 - 80 = 20
         Double _residualProfit = DoubleUtil.sub(_profit, allLossProfit);
         //判断当前是否还存在可减去的利润
-        if(DoubleUtil.compare(_residualProfit,0.0).equals(1)){
+        if (DoubleUtil.compare(_residualProfit, 0.0).equals(1)) {
             //存在
             //剩余利润减去当前需要减产的利润值
             Double _tempProfit = DoubleUtil.sub(_residualProfit, _reduceProfit);
@@ -173,7 +202,7 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
                 comPlayerLand.setPlantSteal(0);
                 comPlayerLandService.save(CopyUtil.copy(comPlayerLand, ComPlayerLandVo.class));
 
-            }else{
+            } else {
                 _endReduceProfit = _reduceProfit;
             }
         }
@@ -208,16 +237,18 @@ 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) {
+    private Double getLandLevelInCome(ComPlayerLand comPlayerLand, Integer priceSnb) {
         List<ComPlayersLuckyLandLevelUpVo> comPlayersLuckyLandLevelUpVos = comConfigService.selectLandLevel();
         ComPlayersLuckyLandLevelUpVo first = comPlayersLuckyLandLevelUpVos.stream()
                 .filter(a -> a.getId().equals(comPlayerLand.getLandLevel()))

+ 2 - 0
src/main/java/com/td/boss/game/comsnbfreeze/controller/ComSnbFreezeController.java

@@ -417,6 +417,8 @@ public class ComSnbFreezeController extends CommonController<ComSnbFreezeVo, Com
                     comPlayerLand.setIsPlant(0);
                     comPlayerLand.setCreateTime(new Date());
                     comPlayerLand.setPlantSteal(1);
+                    //记录mallType类型
+                    comPlayerLand.setMallType(comConfigLand.getMallType());
                     isNewPlant = true;
                 }
                 //todo 可能续租