|
|
@@ -108,7 +108,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
comPlayerLand.setMallType(comConfigLand.getMallType());
|
|
|
|
|
|
comPlayerLand.setLandDescribe("养殖场租赁,每次租赁日期为1个月.");
|
|
|
- comPlayerLand.setLeaseMultiple(CultivateKeys.amountLimit[comConfigLand.getMallType() - 1]); // 养殖场倍数,暂时设置最大值
|
|
|
+ comPlayerLand.setLeaseMultiple(getMaxAmount(comConfigLand.getMallType())); // 养殖场倍数,暂时设置最大值
|
|
|
comPlayerLand.setLeaseDate(4); // 租赁类型改成 4
|
|
|
//设置租赁日期,定义一个30天日期
|
|
|
comPlayerLand.setLeaseTime(com.td.boss.util.DateUtil.getOldDateAddDay(nowDate,30));
|
|
|
@@ -151,8 +151,8 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
return Result.of(null, false, ResultEnum.LAND_DATA_ERROR.getMessage(), ResultEnum.LAND_DATA_ERROR.getCode());
|
|
|
}
|
|
|
//不能超过最大值,倍数
|
|
|
- if (CultivateKeys.amountLimit[comPlayerLand.getMallType() - 1] < multiple) {
|
|
|
- return Result.of(null, false, "最大养殖量:" + CultivateKeys.amountLimit[comPlayerLand.getMallType() - 1], ResultEnum.LAND_MULTIPLE_CONFIG_ERROR.getCode());
|
|
|
+ if (getMaxAmount(comPlayerLand.getMallType()) < multiple) {
|
|
|
+ return Result.of(null, false, "最大养殖量:" + getMaxAmount(comPlayerLand.getMallType()), ResultEnum.LAND_MULTIPLE_CONFIG_ERROR.getCode());
|
|
|
}
|
|
|
String _redisKey = "LOCK:COM_PLAYER_CULTIVATE_LAND:" + userId;
|
|
|
long landTime = System.currentTimeMillis() + RedisData.getLandTimeout();
|
|
|
@@ -222,7 +222,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
return Result.of(null, false, ResultEnum.LAND_NO_PLANT_ERROR.getMessage(), ResultEnum.LAND_NO_PLANT_ERROR.getCode());
|
|
|
}
|
|
|
//通过判断土地类型,获取喂粮饲料
|
|
|
- List<ComPlayerCultivateSeedVo> SeedList = comConfigService.selectByKey("cultivate_food", ComPlayerCultivateSeedVo.class);
|
|
|
+ List<ComPlayerCultivateSeedVo> SeedList = comConfigService.selectListByKey(CultivateKeys.cultivateFood, ComPlayerCultivateSeedVo.class);
|
|
|
ComPlayerCultivateSeedVo seedVo = SeedList.stream().filter(a -> a.getSeedId().equals(comPlayerLand.getMallType())).findFirst().orElse(null);
|
|
|
if (seedVo == null) {
|
|
|
return Result.of(null, false, ResultEnum.FOOD_NO_ERROR.getMessage(), ResultEnum.FOOD_NO_ERROR.getCode());
|
|
|
@@ -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, 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();
|
|
|
@@ -259,6 +259,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
//记录修改的数据
|
|
|
comUsersService.save(comUsersVo);
|
|
|
|
|
|
+ //持久化喂养记录
|
|
|
ComPlayerCultivate comPlayerCultivate = new ComPlayerCultivate();
|
|
|
comPlayerCultivate.setLandId(comPlayerLand.getId());
|
|
|
comPlayerCultivate.setLandType(comPlayerLand.getMallType());
|
|
|
@@ -268,6 +269,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
comPlayerCultivate.setAmount(buyAmount);
|
|
|
comPlayerCultivate.setActivtyTime(new Date());
|
|
|
comPlayerCultivate.setSnb(_needPrice);
|
|
|
+ comPlayerCultivate.setPlantFlag(comPlayerLand.getPlantFlag());
|
|
|
cultivateRepository.save(comPlayerCultivate);
|
|
|
|
|
|
|
|
|
@@ -308,16 +310,16 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
|
|
|
/**
|
|
|
* 是否已经喂养
|
|
|
- *
|
|
|
- * @param userId 用户编号
|
|
|
- * @param landType 土地类型 具体是养殖、渔场、放养
|
|
|
- * @param configLandId
|
|
|
- * @param begin
|
|
|
- * @param end
|
|
|
+ * @param userId 用户编号
|
|
|
+ * @param landType 土地类型 具体是养殖、渔场、放养
|
|
|
+ * @param configLandId 土地配置表id
|
|
|
+ * @param plantFlag 种植唯一标识
|
|
|
+ * @param begin 查询开始时间
|
|
|
+ * @param end 查询截止时间
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean isAnimalEat(String userId, Integer landType, Integer configLandId, 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) {
|
|
|
@@ -326,6 +328,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
predicates.add(criteriaBuilder.equal(root.get("userId"), userId));
|
|
|
predicates.add(criteriaBuilder.equal(root.get("landType"), landType));
|
|
|
predicates.add(criteriaBuilder.equal(root.get("configLandId"), configLandId));
|
|
|
+ predicates.add(criteriaBuilder.equal(root.get("plantFlag"), plantFlag));
|
|
|
return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
}
|
|
|
};
|
|
|
@@ -362,7 +365,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
//获取并设置今日喂养状态
|
|
|
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(), begin, end);
|
|
|
+ boolean animalEat = isAnimalEat(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getMallType(), comPlayerLandAndPlantVo.getConfigLandId(),comPlayerLandAndPlantVo.getPlantFlag(), begin, end);
|
|
|
comPlayerLandAndPlantVo.setAnimalEat(animalEat);
|
|
|
}
|
|
|
comPlayerLandAndPlantVo.setSeedInfo(comMallSeedVo);
|
|
|
@@ -374,7 +377,8 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
comPlayerLandAndPlantVo.setPlantDaysRemaining(0);
|
|
|
comPlayerLandAndPlantVo.setPlantHoursRemaining(0);
|
|
|
//todo [枯萎]
|
|
|
- if (diff * -1 / CultivateKeys.dayLong > CultivateKeys.witheredDay) {
|
|
|
+ Integer witheredDay = comConfigService.selectByKey(CultivateKeys.witheredDay, Integer.class);
|
|
|
+ if (diff * -1 / CultivateKeys.dayLong > witheredDay) {
|
|
|
comPlayerLandAndPlantVo.setWithered(true);
|
|
|
}
|
|
|
//这里不触发灾害
|
|
|
@@ -390,4 +394,15 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
|
|
|
return comPlayerLandAndPlantVo;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取最大种植数量
|
|
|
+ * @param mallType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|