|
|
@@ -111,7 +111,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
comPlayerLand.setLeaseMultiple(getMaxAmount(comConfigLand.getMallType())); // 养殖场倍数,暂时设置最大值
|
|
|
comPlayerLand.setLeaseDate(4); // 租赁类型改成 4
|
|
|
//设置租赁日期,定义一个30天日期
|
|
|
- comPlayerLand.setLeaseTime(com.td.boss.util.DateUtil.getOldDateAddDay(nowDate,30));
|
|
|
+ comPlayerLand.setLeaseTime(com.td.boss.util.DateUtil.getOldDateAddDay(nowDate, 30));
|
|
|
//租赁土地
|
|
|
comPlayerLand.setIsLease(1);
|
|
|
comPlayerLand.setUpdateTime(nowDate);
|
|
|
@@ -230,7 +230,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
//判断今天是否已经喂过
|
|
|
Date begin = DateUtil.beginOfDay(new Date());
|
|
|
Date end = DateUtil.endOfDay(new Date());
|
|
|
- if (isAnimalEat(userId, comPlayerLand.getMallType(), configLandId,comPlayerLand.getPlantFlag(), begin, end)) {
|
|
|
+ if (isAnimalEat(userId, comPlayerLand.getMallType(), configLandId, comPlayerLand.getPlantFlag(), begin, end)) {
|
|
|
return Result.of(null, false, ResultEnum.FOOD_REPEAT_ERROR.getMessage(), ResultEnum.FOOD_REPEAT_ERROR.getCode());
|
|
|
}
|
|
|
long time = System.currentTimeMillis() + RedisData.getPlayerCultivateBuyFoodTimeout();
|
|
|
@@ -281,32 +281,40 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
return ErrorResult("喂养失败!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取成熟时间(计算延期天数),2022年4月7日15:55:11-2022年4月8日15:55:11为一天
|
|
|
+ * @param userId
|
|
|
+ * @param configLandId
|
|
|
+ * @param plantFlag
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
- public Integer getHarvestDays(String userId, Integer configLandId,String plantFlag) {
|
|
|
+ public Integer getHarvestDays(String userId, Integer configLandId, String plantFlag) {
|
|
|
ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
|
|
|
//实际上一共喂几次
|
|
|
- long times = cultivateRepository.countComPlayerCultivateByUserIdAndLandTypeAndConfigLandIdAndPlantFlag(userId, comPlayerLand.getMallType(), configLandId,plantFlag);
|
|
|
+ long times = cultivateRepository.countComPlayerCultivateByUserIdAndLandTypeAndConfigLandIdAndPlantFlag(userId, comPlayerLand.getMallType(), configLandId, plantFlag);
|
|
|
//从当天到现在。一共过了几天
|
|
|
- long days = DateUtil.betweenDay(new Date(), comPlayerLand.getPlantStart(), true) + 1;
|
|
|
- //延期追加天数
|
|
|
- long l = (days - times) * 2;
|
|
|
- //延期后的日期=成熟期+追加天数
|
|
|
- //当天也算一天。过了0点就是新的一天
|
|
|
- return comPlayerLand.getPlantMature();// Convert.toInt(l, 0) + comPlayerLand.getPlantMature() - 1;
|
|
|
+ long days = DateUtil.betweenDay(comPlayerLand.getPlantStart(), new Date(), false);
|
|
|
+ long l = 0;
|
|
|
+ if (times < days) {
|
|
|
+ l = (days - times) * 2;
|
|
|
+ }
|
|
|
+ return Convert.toInt(l, 0) + comPlayerLand.getPlantMature();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 是否已经喂养
|
|
|
- * @param userId 用户编号
|
|
|
- * @param landType 土地类型 具体是养殖、渔场、放养
|
|
|
+ *
|
|
|
+ * @param userId 用户编号
|
|
|
+ * @param landType 土地类型 具体是养殖、渔场、放养
|
|
|
* @param configLandId 土地配置表id
|
|
|
- * @param plantFlag 种植唯一标识
|
|
|
- * @param begin 查询开始时间
|
|
|
- * @param end 查询截止时间
|
|
|
+ * @param plantFlag 种植唯一标识
|
|
|
+ * @param begin 查询开始时间
|
|
|
+ * @param end 查询截止时间
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean isAnimalEat(String userId, Integer landType, Integer configLandId,String plantFlag, Date begin, Date end) {
|
|
|
+ public boolean isAnimalEat(String userId, Integer landType, Integer configLandId, String plantFlag, Date begin, Date end) {
|
|
|
Specification specification = new Specification<ComPlayerDisaster>() {
|
|
|
@Override
|
|
|
public Predicate toPredicate(Root<ComPlayerDisaster> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
|
|
|
@@ -346,13 +354,13 @@ 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(),comPlayerLandAndPlantVo.getPlantFlag());
|
|
|
+ Integer days = getHarvestDays(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getConfigLandId(), comPlayerLandAndPlantVo.getPlantFlag());
|
|
|
comMallSeedVo.setMaturity(days);
|
|
|
|
|
|
//获取并设置今日喂养状态
|
|
|
Date begin = cn.hutool.core.date.DateUtil.beginOfDay(new Date());
|
|
|
Date end = cn.hutool.core.date.DateUtil.endOfDay(new Date());
|
|
|
- boolean animalEat = isAnimalEat(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getMallType(), comPlayerLandAndPlantVo.getConfigLandId(),comPlayerLandAndPlantVo.getPlantFlag(), begin, end);
|
|
|
+ boolean animalEat = isAnimalEat(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getMallType(), comPlayerLandAndPlantVo.getConfigLandId(), comPlayerLandAndPlantVo.getPlantFlag(), begin, end);
|
|
|
comPlayerLandAndPlantVo.setAnimalEat(animalEat);
|
|
|
}
|
|
|
comPlayerLandAndPlantVo.setSeedInfo(comMallSeedVo);
|
|
|
@@ -384,12 +392,13 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
|
|
|
/**
|
|
|
* 获取最大种植数量
|
|
|
+ *
|
|
|
* @param mallType
|
|
|
* @return
|
|
|
*/
|
|
|
- private Integer getMaxAmount(Integer mallType){
|
|
|
+ private Integer getMaxAmount(Integer mallType) {
|
|
|
//获取配置 土堆分别最大种植数量,对应类型mallType:1、2、3、4的值
|
|
|
List<Map> maps = comConfigService.selectListByKey(CultivateKeys.maxAmount, Map.class);
|
|
|
- return maps.stream().filter(a->a.get("key").equals(mallType)).map(a-> Convert.toInt(a.get("value"),0)).findFirst().orElse(10000);
|
|
|
+ return maps.stream().filter(a -> a.get("key").equals(mallType)).map(a -> Convert.toInt(a.get("value"), 0)).findFirst().orElse(10000);
|
|
|
}
|
|
|
}
|