Bladeren bron

解决养殖成熟后,重新放养后,成熟时间的bug

xst 3 jaren geleden
bovenliggende
commit
c0bced37dc

+ 1 - 1
src/main/java/com/td/boss/game/complayercultivate/repository/ComPlayerCultivateRepository.java

@@ -7,5 +7,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface ComPlayerCultivateRepository extends CommonRepository<ComPlayerCultivate, Integer> {
 
-    long countComPlayerCultivateByUserIdAndLandTypeAndConfigLandId(String userId,Integer landType,Integer configLandId);
+    long countComPlayerCultivateByUserIdAndLandTypeAndConfigLandIdAndPlantFlag(String userId,Integer landType,Integer configLandId,String plantFlag);
 }

+ 1 - 9
src/main/java/com/td/boss/game/complayercultivate/serivce/ComPlayerCultivateSerivce.java

@@ -43,15 +43,7 @@ public interface ComPlayerCultivateSerivce {
      */
     Result<?> buyFood(String userId, Integer configLandId);
 
-    /**
-     * 获得养殖类种子实际成熟日期:正常成熟天数+延期天数(一次不喂延迟2天)
-     * 成熟时间的具体值 (取时间差(今天-种植当天)-喂的次数)*2
-     *
-     * @return 延期后的成熟期
-     */
-    Date getHarvestTime(String userId, Integer configLandId);
-
-    Integer getHarvestDays(String userId, Integer configLandId);
+    Integer getHarvestDays(String userId, Integer configLandId,String plantFlag);
 
     /**
      * 是否已经喂养

+ 3 - 16
src/main/java/com/td/boss/game/complayercultivate/serivce/ComPlayerCultivateSerivceImpl.java

@@ -281,24 +281,11 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
         return ErrorResult("喂养失败!");
     }
 
-    /**
-     * 获得养殖类种子实际成熟日期:正常成熟天数+延期天数(一次不喂延迟2天)
-     * 成熟时间的具体值 (取时间差(今天-种植当天)-喂的次数)*2
-     *
-     * @return 延期后的成熟期
-     */
-    @Override
-    public Date getHarvestTime(String userId, Integer configLandId) {
-        ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
-        Integer harvestDays = getHarvestDays(userId, configLandId);
-        return DateUtil.offset(comPlayerLand.getPlantStart(), DateField.DAY_OF_YEAR, harvestDays);
-    }
-
     @Override
-    public Integer getHarvestDays(String userId, Integer configLandId) {
+    public Integer getHarvestDays(String userId, Integer configLandId,String plantFlag) {
         ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
         //实际上一共喂几次
-        long times = cultivateRepository.countComPlayerCultivateByUserIdAndLandTypeAndConfigLandId(userId, comPlayerLand.getMallType(), configLandId);
+        long times = cultivateRepository.countComPlayerCultivateByUserIdAndLandTypeAndConfigLandIdAndPlantFlag(userId, comPlayerLand.getMallType(), configLandId,plantFlag);
         //从当天到现在。一共过了几天
         long days = DateUtil.betweenDay(new Date(), comPlayerLand.getPlantStart(), true) + 1;
         //延期追加天数
@@ -359,7 +346,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
             ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
             //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
             if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLandAndPlantVo.getMallType())) {
-                Integer days = getHarvestDays(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getConfigLandId());
+                Integer days = getHarvestDays(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getConfigLandId(),comPlayerLandAndPlantVo.getPlantFlag());
                 comMallSeedVo.setMaturity(days);
 
                 //获取并设置今日喂养状态

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

@@ -240,7 +240,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
 
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
         if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType())) {
-            Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getConfigLandId());
+            Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getConfigLandId(),comPlayerLand.getPlantFlag());
             comMallSeedVo.setMaturity(days);
         }
         // 收获,同时重置土地状态,先判断是否成熟
@@ -573,7 +573,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
         }
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
         if (ArrayUtil.contains(CultivateKeys.mallType, otherPlayerLand.getMallType())) {
-            Integer days = comPlayerCultivateSerivce.getHarvestDays(otherUserId, otherPlayerLand.getConfigLandId());
+            Integer days = comPlayerCultivateSerivce.getHarvestDays(otherUserId, otherPlayerLand.getConfigLandId(),otherPlayerLand.getPlantFlag());
             comMallSeedVo.setMaturity(days);
         }
         Integer witheredDay = comConfigService.selectByKey( CultivateKeys.witheredDay, Integer.class);

+ 3 - 3
src/main/java/com/td/boss/game/complayerland/controller/ComPlayerLandController.java

@@ -139,7 +139,7 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
                     ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
                     //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
                     if (ArrayUtil.contains(CultivateKeys.mallType,e.getMallType())) {
-                        Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, e.getConfigLandId());
+                        Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, e.getConfigLandId(),e.getPlantFlag());
                         comMallSeedVo.setMaturity(days);
 
                         //获取并设置今日喂养状态
@@ -234,7 +234,7 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
                     ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
                     //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
                     if (ArrayUtil.contains(CultivateKeys.mallType,e.getMallType())) {
-                        Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, e.getConfigLandId());
+                        Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, e.getConfigLandId(),e.getPlantFlag());
                         comMallSeedVo.setMaturity(days);
                     }
                     comPlayerLandAndPlantVo.setSeedInfo(comMallSeedVo);
@@ -493,7 +493,7 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
 
             //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
             if (ArrayUtil.contains(CultivateKeys.mallType,comPlayerLand.getMallType())) {
-                Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getConfigLandId());
+                Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getConfigLandId(),comPlayerLand.getPlantFlag());
                 comMallSeedVo.setMaturity(days);
             }
             //种子时间