|
|
@@ -3,6 +3,8 @@ package com.td.boss.game.complayercultivate.serivce;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ArrayUtil;
|
|
|
+import com.td.boss.common.pojo.CultivateKeys;
|
|
|
import com.td.boss.common.pojo.Result;
|
|
|
import com.td.boss.common.service.ComConfigService;
|
|
|
import com.td.boss.config.enums.ResultEnum;
|
|
|
@@ -13,7 +15,6 @@ import com.td.boss.game.comexplainland.vo.ComExplainLandVo;
|
|
|
import com.td.boss.game.complayercultivate.pojo.ComPlayerCultivate;
|
|
|
import com.td.boss.game.complayercultivate.repository.ComPlayerCultivateRepository;
|
|
|
import com.td.boss.game.complayercultivate.vo.ComPlayerCultivateSeedVo;
|
|
|
-import com.td.boss.game.complayercultivate.vo.ComPlayerCultivateVo;
|
|
|
import com.td.boss.game.complayerland.pojo.ComPlayerDisaster;
|
|
|
import com.td.boss.game.complayerland.pojo.ComPlayerLand;
|
|
|
import com.td.boss.game.complayerland.service.ComPlayerLandService;
|
|
|
@@ -29,8 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
@@ -61,6 +60,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
|
|
|
/**
|
|
|
* 解锁某个土地 【牧场养殖渔场】
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @param configLandId
|
|
|
* @return
|
|
|
@@ -75,12 +75,10 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
return Result.of(null, false, ResultEnum.LAND_DATA_ERROR.getMessage(), ResultEnum.LAND_DATA_ERROR.getCode());
|
|
|
}
|
|
|
ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
|
|
|
-
|
|
|
- String _redisKey = comPlayerLand.getPlantFlag();
|
|
|
- if (!StringUtils.hasText(_redisKey)) {
|
|
|
- //return Result.of(null, false, ResultEnum.LAND_PLANT_FLAG_IS_NULL.getMessage(), ResultEnum.LAND_PLANT_FLAG_IS_NULL.getCode());
|
|
|
- _redisKey = comPlayerLand.getUserId() + "or" + comPlayerLand.getConfigLandId();
|
|
|
+ if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType()) == false) {
|
|
|
+ return Result.of(null, false, ResultEnum.LAND_DATA_ERROR.getMessage(), ResultEnum.LAND_DATA_ERROR.getCode());
|
|
|
}
|
|
|
+ String _redisKey = "LOCK:COM_PLAYER_CULTIVATE_LAND:" + userId;
|
|
|
long landTime = System.currentTimeMillis() + RedisData.getLandTimeout();
|
|
|
if (!redisLock.lock(_redisKey, String.valueOf(landTime))) {
|
|
|
log.info("锁住key:" + _redisKey);
|
|
|
@@ -160,7 +158,7 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
if (!comPlayerLand.getIsLease().equals(1)) {
|
|
|
return Result.of(null, false, ResultEnum.LAND_NOT_LEASE.getMessage(), ResultEnum.LAND_NOT_LEASE.getCode());
|
|
|
}
|
|
|
- if (Integer.valueOf(0).equals(comPlayerLand.getMallType()) ) {
|
|
|
+ if (Integer.valueOf(0).equals(comPlayerLand.getMallType())) {
|
|
|
return Result.of(null, false, ResultEnum.FOOD_NO_TYPE_ERROR.getMessage(), ResultEnum.FOOD_NO_TYPE_ERROR.getCode());
|
|
|
}
|
|
|
Integer buyAmount = comPlayerLand.getLeaseMultiple();
|
|
|
@@ -247,12 +245,12 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
|
|
|
//实际上一共喂几次
|
|
|
long times = cultivateRepository.countComPlayerCultivateByUserIdAndLandTypeAndConfigLandId(userId, comPlayerLand.getMallType(), configLandId);
|
|
|
//从当天到现在。一共过了几天
|
|
|
- long days = DateUtil.betweenDay(new Date(), comPlayerLand.getPlantStart(), true)+1;
|
|
|
+ long days = DateUtil.betweenDay(new Date(), comPlayerLand.getPlantStart(), true) + 1;
|
|
|
//延期追加天数
|
|
|
long l = (days - times) * 2;
|
|
|
//延期后的日期=成熟期+追加天数
|
|
|
//当天也算一天。过了0点就是新的一天
|
|
|
- return Convert.toInt(l, 0) + comPlayerLand.getPlantMature()-1;
|
|
|
+ return Convert.toInt(l, 0) + comPlayerLand.getPlantMature() - 1;
|
|
|
}
|
|
|
|
|
|
private boolean exists(String userId, Integer landType, Integer configLandId, Date begin, Date end) {
|