|
@@ -58,18 +58,18 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@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
|
|
@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
|
|
@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();
|
|
ComPlayerProfit comPlayerProfit = new ComPlayerProfit();
|
|
@@ -77,17 +77,32 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
|
|
|
Double _endReduceProfit = 0d;
|
|
Double _endReduceProfit = 0d;
|
|
|
//计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
|
|
//计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
|
|
|
Integer _otherAmount = 0;
|
|
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 拿出全部利润
|
|
//todo 拿出全部利润
|
|
|
Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
|
|
Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
|
|
|
Integer _profitInt = _otherAmount - comPlayerLand.getLeaseMultiple() * 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 了。
|
|
//todo 计算减产,第一次灾难按利润的 50% 减产,两次就是减到 0 了。
|
|
|
|
|
|
|
|
//必然发生的灾难,减产40%
|
|
//必然发生的灾难,减产40%
|
|
@@ -131,7 +146,7 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@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();
|
|
ComPlayerProfit comPlayerProfit = new ComPlayerProfit();
|
|
@@ -139,29 +154,43 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
|
|
|
Double _endReduceProfit = 0d;
|
|
Double _endReduceProfit = 0d;
|
|
|
//计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
|
|
//计算一个偷取的收获量, 租赁倍数* 租赁日期下的产量
|
|
|
Integer _otherAmount = 0;
|
|
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 拿出全部利润
|
|
//todo 拿出全部利润
|
|
|
Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
|
|
Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
|
|
|
Integer _profitInt = _otherAmount - comPlayerLand.getLeaseMultiple() * 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。
|
|
//todo 计算减产,第一次灾难按利润的 100 减产 50,两次就是 50 减到 25。
|
|
|
|
|
|
|
|
//额外发生的灾难,按照次数计算减产 50% 发生已经发生1次计算后当次等于 25%,
|
|
//额外发生的灾难,按照次数计算减产 50% 发生已经发生1次计算后当次等于 25%,
|
|
|
double _startRatio = 0.5;
|
|
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);
|
|
Double _reduceProfit = DoubleUtil.mul(_profit, _startRatio);
|
|
|
// 100 - 80 = 20
|
|
// 100 - 80 = 20
|
|
|
Double _residualProfit = DoubleUtil.sub(_profit, allLossProfit);
|
|
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);
|
|
Double _tempProfit = DoubleUtil.sub(_residualProfit, _reduceProfit);
|
|
@@ -173,7 +202,7 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
|
|
|
comPlayerLand.setPlantSteal(0);
|
|
comPlayerLand.setPlantSteal(0);
|
|
|
comPlayerLandService.save(CopyUtil.copy(comPlayerLand, ComPlayerLandVo.class));
|
|
comPlayerLandService.save(CopyUtil.copy(comPlayerLand, ComPlayerLandVo.class));
|
|
|
|
|
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
_endReduceProfit = _reduceProfit;
|
|
_endReduceProfit = _reduceProfit;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -208,16 +237,18 @@ public class ComPlayerProfitServiceImpl extends CommonServiceImpl<ComPlayerProfi
|
|
|
|
|
|
|
|
return comPlayerProfitVo;
|
|
return comPlayerProfitVo;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ComConfigService comConfigService;
|
|
private ComConfigService comConfigService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获得土地级别收益,普通土地最后结果为0
|
|
* 获得土地级别收益,普通土地最后结果为0
|
|
|
|
|
+ *
|
|
|
* @param comPlayerLand
|
|
* @param comPlayerLand
|
|
|
* @param priceSnb
|
|
* @param priceSnb
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private Double getLandLevelInCome( ComPlayerLand comPlayerLand, Integer priceSnb) {
|
|
|
|
|
|
|
+ private Double getLandLevelInCome(ComPlayerLand comPlayerLand, Integer priceSnb) {
|
|
|
List<ComPlayersLuckyLandLevelUpVo> comPlayersLuckyLandLevelUpVos = comConfigService.selectLandLevel();
|
|
List<ComPlayersLuckyLandLevelUpVo> comPlayersLuckyLandLevelUpVos = comConfigService.selectLandLevel();
|
|
|
ComPlayersLuckyLandLevelUpVo first = comPlayersLuckyLandLevelUpVos.stream()
|
|
ComPlayersLuckyLandLevelUpVo first = comPlayersLuckyLandLevelUpVos.stream()
|
|
|
.filter(a -> a.getId().equals(comPlayerLand.getLandLevel()))
|
|
.filter(a -> a.getId().equals(comPlayerLand.getLandLevel()))
|