Browse Source

1.修复部分接口bug
2.修复获取可偷列表不同类型问题
3.修复进入农场后显示bug

slambb 3 years ago
parent
commit
25db4cc5ec

+ 7 - 0
src/main/java/com/td/boss/config/enums/ResultEnum.java

@@ -87,6 +87,8 @@ public enum ResultEnum {
     LAND_MULTIPLE_ERROR(718,"土地倍数异常!"),
     LAND_MULTIPLE_ERROR(718,"土地倍数异常!"),
     LAND_MULTIPLE_CONFIG_ERROR(719,"土地倍数与配置不符!"),
     LAND_MULTIPLE_CONFIG_ERROR(719,"土地倍数与配置不符!"),
 
 
+    LAND_CAN_STEAL_SELF(720,"不能偷取自己的土地!"),
+
     //种子数据不能存在
     //种子数据不能存在
     SEED_DATA_ERROR(801,"种子数据不存在!"),
     SEED_DATA_ERROR(801,"种子数据不存在!"),
     FRUIT_DATA_ERROR(802,"果实数据不存在!"),
     FRUIT_DATA_ERROR(802,"果实数据不存在!"),
@@ -116,6 +118,11 @@ public enum ResultEnum {
     MALL_OTHER_IS_HAVE(811,"商城装备已经存在!"),
     MALL_OTHER_IS_HAVE(811,"商城装备已经存在!"),
     PLAYER_OTHER_IS_NULL(812,"商城装备不存在!"),
     PLAYER_OTHER_IS_NULL(812,"商城装备不存在!"),
     PLAYER_OTHER_IS_HAVE(813,"商城装备已经存在!"),
     PLAYER_OTHER_IS_HAVE(813,"商城装备已经存在!"),
+    MALL_ID_LIMIT(820,"商城装备不符合购买需求!"),
+    MALL_FOOD_ID_LIMIT(821,"粮食不符合购买需求!"),
+
+    DOG_SHOW_STATE_ERROR(822,"装备狗状态错误!"),
+
 
 
     FRUIT_AMOUNT_IS_ZERO_AND_NOT_MULTIPLE(814,"请输入出售果实的数量!"),
     FRUIT_AMOUNT_IS_ZERO_AND_NOT_MULTIPLE(814,"请输入出售果实的数量!"),
     ;
     ;

+ 39 - 12
src/main/java/com/td/boss/filter/gameFilter.java

@@ -18,6 +18,7 @@ import javax.servlet.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
+import java.io.PrintWriter;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
@@ -78,8 +79,13 @@ public class gameFilter implements Filter {
             //log.info("ip2Addr:"+ ipVo.toString());
             //log.info("ip2Addr:"+ ipVo.toString());
             String limitedIp = SysSettingLimitUtil.getSysSettingLimit().getLimitedIp();
             String limitedIp = SysSettingLimitUtil.getSysSettingLimit().getLimitedIp();
             if (StringUtils.hasText(limitedIp) && !Arrays.asList(limitedIp.split(",")).contains(ipAddr)) {
             if (StringUtils.hasText(limitedIp) && !Arrays.asList(limitedIp.split(",")).contains(ipAddr)) {
-                response.setCharacterEncoding("utf-8");
-                response.getWriter().print(JsonUtils.toJson(Result.of(null, false, ResultEnum.LOGIN_IP_IS_ERROR.getMessage(), ResultEnum.LOGIN_IP_IS_ERROR.getCode())));
+                response.setCharacterEncoding("UTF-8");
+                response.setContentType("application/json; charset=utf-8");
+                PrintWriter out = response.getWriter();
+
+                out.print(JsonUtils.toJson(Result.of(null, false, ResultEnum.LOGIN_IP_IS_ERROR.getMessage(), ResultEnum.LOGIN_IP_IS_ERROR.getCode())));
+                out.flush();
+                out.close();
                 return;
                 return;
             }
             }
             filterChain.doFilter(servletRequest, response);
             filterChain.doFilter(servletRequest, response);
@@ -96,8 +102,13 @@ public class gameFilter implements Filter {
         }else{
         }else{
             int increment =  Convert.toInt(redisTemplate.opsForValue().get(redisKey));
             int increment =  Convert.toInt(redisTemplate.opsForValue().get(redisKey));
             if(increment > 10){
             if(increment > 10){
-                response.setCharacterEncoding("utf-8");
-                response.getWriter().print(JsonUtils.toJson(Result.of(null, false, ResultEnum.REDIS_IS_LOCK.getMessage(), ResultEnum.REDIS_IS_LOCK.getCode())));
+                response.setCharacterEncoding("UTF-8");
+                response.setContentType("application/json; charset=utf-8");
+                PrintWriter out = response.getWriter();
+                out.print(JsonUtils.toJson(Result.of(null, false, ResultEnum.REDIS_IS_LOCK.getMessage(), ResultEnum.REDIS_IS_LOCK.getCode())));
+                out.flush();
+                out.close();
+                return;
             } else {
             } else {
                 redisTemplate.opsForValue().set(redisKey, String.valueOf(++increment),20,TimeUnit.SECONDS);
                 redisTemplate.opsForValue().set(redisKey, String.valueOf(++increment),20,TimeUnit.SECONDS);
             }
             }
@@ -114,8 +125,12 @@ public class gameFilter implements Filter {
 
 
         if (null == token || token.isEmpty() || !token.startsWith("Bearer ")) {
         if (null == token || token.isEmpty() || !token.startsWith("Bearer ")) {
             //没有token信息
             //没有token信息
-            response.setCharacterEncoding("utf-8");
-            response.getWriter().print(JsonUtils.toJson(Result.of(null, false, ResultEnum.TOKEN_DOES_NOT_EXIST.getMessage(), ResultEnum.TOKEN_DOES_NOT_EXIST.getCode())));
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/json; charset=utf-8");
+            PrintWriter out = response.getWriter();
+            out.print(JsonUtils.toJson(Result.of(null, false, ResultEnum.TOKEN_DOES_NOT_EXIST.getMessage(), ResultEnum.TOKEN_DOES_NOT_EXIST.getCode())));
+            out.flush();
+            out.close();
             return;
             return;
         } else {
         } else {
             String authToken = token.substring(7);
             String authToken = token.substring(7);
@@ -132,17 +147,29 @@ public class gameFilter implements Filter {
                     filterChain.doFilter(new TokenRequestWrapper((HttpServletRequest) servletRequest, userId), response);
                     filterChain.doFilter(new TokenRequestWrapper((HttpServletRequest) servletRequest, userId), response);
                 } else {
                 } else {
                     //不存在用户信息
                     //不存在用户信息
-                    response.setCharacterEncoding("utf-8");
-                    response.getWriter().print(JsonUtils.toJson(Result.of(authToken, false, ResultEnum.TOKEN_DOES_NOT_HAVE_USER_ID.getMessage(), ResultEnum.TOKEN_DOES_NOT_HAVE_USER_ID.getCode())));
+                    response.setCharacterEncoding("UTF-8");
+                    response.setContentType("application/json; charset=utf-8");
+                    PrintWriter out = response.getWriter();
+                    out.print(JsonUtils.toJson(Result.of(authToken, false, ResultEnum.TOKEN_DOES_NOT_HAVE_USER_ID.getMessage(), ResultEnum.TOKEN_DOES_NOT_HAVE_USER_ID.getCode())));
+                    out.flush();
+                    out.close();
                 }
                 }
             } catch (ExpiredJwtException e) {
             } catch (ExpiredJwtException e) {
                 //token过期
                 //token过期
-                response.setCharacterEncoding("utf-8");
-                response.getWriter().print(JsonUtils.toJson(Result.of(null, false, ResultEnum.TOKEN_OUT_OF_DATE.getMessage(), ResultEnum.TOKEN_OUT_OF_DATE.getCode())));
+                response.setCharacterEncoding("UTF-8");
+                response.setContentType("application/json; charset=utf-8");
+                PrintWriter out = response.getWriter();
+                out.print(JsonUtils.toJson(Result.of(null, false, ResultEnum.TOKEN_OUT_OF_DATE.getMessage(), ResultEnum.TOKEN_OUT_OF_DATE.getCode())));
+                out.flush();
+                out.close();
             } catch (SignatureException e) {
             } catch (SignatureException e) {
                 //secret校验密钥不对
                 //secret校验密钥不对
-                response.setCharacterEncoding("utf-8");
-                response.getWriter().print(JsonUtils.toJson(Result.of(authToken, false, ResultEnum.TOKEN_IS_ILLEGAL.getMessage(), ResultEnum.TOKEN_IS_ILLEGAL.getCode())));
+                response.setCharacterEncoding("UTF-8");
+                response.setContentType("application/json; charset=utf-8");
+                PrintWriter out = response.getWriter();
+                out.print(JsonUtils.toJson(Result.of(authToken, false, ResultEnum.TOKEN_IS_ILLEGAL.getMessage(), ResultEnum.TOKEN_IS_ILLEGAL.getCode())));
+                out.flush();
+                out.close();
             }
             }
 
 
         }
         }

+ 12 - 1
src/main/java/com/td/boss/game/complayerdog/controller/ComPlayerDogController.java

@@ -61,6 +61,11 @@ public class ComPlayerDogController extends CommonController<ComPlayerDogVo, Com
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)
     public Result<Map> addEquipmentFunction(@RequestParam(value = "userId") String userId,
     public Result<Map> addEquipmentFunction(@RequestParam(value = "userId") String userId,
                                             @RequestParam(value = "mallOtherId") Integer mallOtherId) {
                                             @RequestParam(value = "mallOtherId") Integer mallOtherId) {
+
+        if(!mallOtherId.equals(1)&&!mallOtherId.equals(2)){
+            return Result.of(null, false, ResultEnum.MALL_ID_LIMIT.getMessage(), ResultEnum.MALL_ID_LIMIT.getCode());
+        }
+
         Map map = new HashMap();
         Map map = new HashMap();
         //需要redis 加锁
         //需要redis 加锁
         long time = System.currentTimeMillis() + RedisData.getSnbTimeout();
         long time = System.currentTimeMillis() + RedisData.getSnbTimeout();
@@ -196,7 +201,9 @@ public class ComPlayerDogController extends CommonController<ComPlayerDogVo, Com
                                        @RequestParam(value = "foodId") Integer foodId,
                                        @RequestParam(value = "foodId") Integer foodId,
                                        @RequestParam(value = "buyAmount", defaultValue = "1") Integer buyAmount) {
                                        @RequestParam(value = "buyAmount", defaultValue = "1") Integer buyAmount) {
 
 
-
+        if(!foodId.equals(1)&&!foodId.equals(2)){
+            return Result.of(null, false, ResultEnum.MALL_FOOD_ID_LIMIT.getMessage(), ResultEnum.MALL_FOOD_ID_LIMIT.getCode());
+        }
         //查看用户是否有狗
         //查看用户是否有狗
         ComPlayerDog comPlayerDog = comPlayerDogService.findByUserIdAndType(userId, 0);
         ComPlayerDog comPlayerDog = comPlayerDogService.findByUserIdAndType(userId, 0);
         if (comPlayerDog == null) {
         if (comPlayerDog == null) {
@@ -396,6 +403,10 @@ public class ComPlayerDogController extends CommonController<ComPlayerDogVo, Com
     public Result<Map> setDogShowStateFunction(@RequestParam(value = "userId") String userId,
     public Result<Map> setDogShowStateFunction(@RequestParam(value = "userId") String userId,
                                                @RequestParam(value = "isShow") Integer isShow) {
                                                @RequestParam(value = "isShow") Integer isShow) {
 
 
+        if(!isShow.equals(1)&&!isShow.equals(0)){
+            return Result.of(null, false, ResultEnum.DOG_SHOW_STATE_ERROR.getMessage(), ResultEnum.DOG_SHOW_STATE_ERROR.getCode());
+        }
+
         //查看用户是否有狗
         //查看用户是否有狗
         ComPlayerDog comPlayerDog = comPlayerDogService.findByUserIdAndType(userId, 0);
         ComPlayerDog comPlayerDog = comPlayerDogService.findByUserIdAndType(userId, 0);
         if (comPlayerDog == null) {
         if (comPlayerDog == null) {

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

@@ -161,6 +161,10 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             @RequestParam(value = "seedId") Integer seedId,
             @RequestParam(value = "seedId") Integer seedId,
             @RequestParam(value = "currentAmount") Integer currentAmount
             @RequestParam(value = "currentAmount") Integer currentAmount
     ) {
     ) {
+        if (currentAmount < 0) {
+            //如果背包种子是空的,说明还未添加上去
+            return Result.of(null, false, ResultEnum.SEED_AMOUNT_ERROR.getMessage(), ResultEnum.SEED_AMOUNT_ERROR.getCode());
+        }
         //查询背包种子存在的数量
         //查询背包种子存在的数量
         ComPlayerGoods comPlayerGood = comPlayerGoodsService.findByUserIdAndIndexAndType(userId, seedId, 0);
         ComPlayerGoods comPlayerGood = comPlayerGoodsService.findByUserIdAndIndexAndType(userId, seedId, 0);
         if (comPlayerGood == null) {
         if (comPlayerGood == null) {
@@ -240,7 +244,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
 
 
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
         if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType())) {
         if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType())) {
-            Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getPlantStart(),comPlayerLand.getMallType(),comPlayerLand.getConfigLandId(),comPlayerLand.getPlantFlag(),comMallSeedVo);
+            Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getPlantStart(), comPlayerLand.getMallType(), comPlayerLand.getConfigLandId(), comPlayerLand.getPlantFlag(), comMallSeedVo);
             comMallSeedVo.setMaturity(days);
             comMallSeedVo.setMaturity(days);
         }
         }
         // 收获,同时重置土地状态,先判断是否成熟
         // 收获,同时重置土地状态,先判断是否成熟
@@ -455,6 +459,11 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             @RequestParam(value = "userId") String userId,
             @RequestParam(value = "userId") String userId,
             @RequestParam(value = "otherUserId") String otherUserId,
             @RequestParam(value = "otherUserId") String otherUserId,
             @RequestParam(value = "otherLandId") Integer otherLandId) {
             @RequestParam(value = "otherLandId") Integer otherLandId) {
+
+        if(userId.equals(otherUserId)){
+            return Result.of(null, false, ResultEnum.LAND_CAN_STEAL_SELF.getMessage(), ResultEnum.LAND_CAN_STEAL_SELF.getCode());
+        }
+
         Map map = new HashMap();
         Map map = new HashMap();
 
 
         //todo 计入狗和打狗棒
         //todo 计入狗和打狗棒
@@ -556,7 +565,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
         if (otherPlayerLand == null) {
         if (otherPlayerLand == null) {
             return Result.of(null, false, ResultEnum.LAND_CAN_STEAL_IS_NULL.getMessage(), ResultEnum.LAND_CAN_STEAL_IS_NULL.getCode());
             return Result.of(null, false, ResultEnum.LAND_CAN_STEAL_IS_NULL.getMessage(), ResultEnum.LAND_CAN_STEAL_IS_NULL.getCode());
         }
         }
-        if (otherPlayerLand.getIsPlant().equals(0) && otherPlayerLand.getPlantSteal().equals(0)) {
+        if (otherPlayerLand.getIsPlant().equals(0) || otherPlayerLand.getPlantSteal().equals(0)) {
             return Result.of(null, false, ResultEnum.LAND_CAN_STEAL_IS_NULL.getMessage(), ResultEnum.LAND_CAN_STEAL_IS_NULL.getCode());
             return Result.of(null, false, ResultEnum.LAND_CAN_STEAL_IS_NULL.getMessage(), ResultEnum.LAND_CAN_STEAL_IS_NULL.getCode());
         }
         }
 
 
@@ -568,10 +577,10 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
         }
         }
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
         if (ArrayUtil.contains(CultivateKeys.mallType, otherPlayerLand.getMallType())) {
         if (ArrayUtil.contains(CultivateKeys.mallType, otherPlayerLand.getMallType())) {
-            Integer days = comPlayerCultivateSerivce.getHarvestDays(otherUserId,otherPlayerLand.getPlantStart(),otherPlayerLand.getMallType(),otherPlayerLand.getConfigLandId(),otherPlayerLand.getPlantFlag(),comMallSeedVo);
+            Integer days = comPlayerCultivateSerivce.getHarvestDays(otherUserId, otherPlayerLand.getPlantStart(), otherPlayerLand.getMallType(), otherPlayerLand.getConfigLandId(), otherPlayerLand.getPlantFlag(), comMallSeedVo);
             comMallSeedVo.setMaturity(days);
             comMallSeedVo.setMaturity(days);
         }
         }
-        Integer witheredDay = comConfigService.selectByKey( CultivateKeys.witheredDay, Integer.class);
+        Integer witheredDay = comConfigService.selectByKey(CultivateKeys.witheredDay, Integer.class);
 
 
         // 判断是否成熟
         // 判断是否成熟
         Date _harvestTime = DateUtil.getNowDateMinusDay(comMallSeedVo.getMaturity());
         Date _harvestTime = DateUtil.getNowDateMinusDay(comMallSeedVo.getMaturity());
@@ -582,7 +591,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             return Result.of(null, false, ResultEnum.SEED_DATE_ERROR.getMessage(), ResultEnum.SEED_DATE_ERROR.getCode());
             return Result.of(null, false, ResultEnum.SEED_DATE_ERROR.getMessage(), ResultEnum.SEED_DATE_ERROR.getCode());
         }
         }
         //todo [枯萎] 超过一定时间不收取 就枯萎
         //todo [枯萎] 超过一定时间不收取 就枯萎
-        else if (diff < 0 && diff * -1 / CultivateKeys.dayLong >witheredDay) {
+        else if (diff < 0 && diff * -1 / CultivateKeys.dayLong > witheredDay) {
             return Result.of(null, false, ResultEnum.SEED_LAND_WITHERED.getMessage(), ResultEnum.SEED_LAND_WITHERED.getCode());
             return Result.of(null, false, ResultEnum.SEED_LAND_WITHERED.getMessage(), ResultEnum.SEED_LAND_WITHERED.getCode());
         }
         }
 
 
@@ -616,6 +625,8 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
 
 
             }
             }
             if (!redisLock.lock(_redisKey, String.valueOf(landTime))) {
             if (!redisLock.lock(_redisKey, String.valueOf(landTime))) {
+                //如果有问题,解锁
+                redisLock.unlock(_redisSNBKey, String.valueOf(snbTime));
                 //如果有冲突锁
                 //如果有冲突锁
                 return Result.of(null, false, ResultEnum.LAND_STEAL_LOCK.getMessage(), ResultEnum.LAND_STEAL_LOCK.getCode());
                 return Result.of(null, false, ResultEnum.LAND_STEAL_LOCK.getMessage(), ResultEnum.LAND_STEAL_LOCK.getCode());
             }
             }
@@ -629,6 +640,9 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             for (int i = 0; i < comPlayerProfits.size(); i++) {
             for (int i = 0; i < comPlayerProfits.size(); i++) {
                 ComPlayerProfit temp = comPlayerProfits.get(i);
                 ComPlayerProfit temp = comPlayerProfits.get(i);
                 if (temp.getUserId().equals(userId)) {
                 if (temp.getUserId().equals(userId)) {
+                    //如果有问题,解锁
+                    redisLock.unlock(_redisKey, String.valueOf(landTime));
+                    redisLock.unlock(_redisSNBKey, String.valueOf(snbTime));
                     return Result.of(null, false, ResultEnum.LAND_HARVEST_STOLEN.getMessage(), ResultEnum.LAND_HARVEST_STOLEN.getCode());
                     return Result.of(null, false, ResultEnum.LAND_HARVEST_STOLEN.getMessage(), ResultEnum.LAND_HARVEST_STOLEN.getCode());
                 }
                 }
             }
             }
@@ -1370,170 +1384,170 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
     }
     }
 
 
 
 
-    /**
-     * 根据用户地址送果实
-     *
-     * @param userId
-     * @param address 目标用户地址
-     * @return
-     */
-    @PostMapping("grantFruit")
-    @ResponseBody
-    @Transactional(rollbackFor = Exception.class)
-    public Result<Map> grantFruitFunction(
-            @RequestParam(value = "userId") String userId,
-            @RequestParam(value = "fruitId") Integer fruitId,
-            @RequestParam(value = "amount") Integer amount,
-            @RequestParam(value = "address") String address) {
-
-        //目标用户的背包
-        ComUsersVo _targetUserVo = comUsersService.findByAddress(address);
-        if (_targetUserVo == null) {
-            return Result.of(null, false, ResultEnum.USER_NOT_ADDRESS.getMessage(), ResultEnum.USER_NOT_ADDRESS.getCode());
-        }
-
-        if (_targetUserVo.getUserId().equals(userId)) {
-            return Result.of(null, false, ResultEnum.FRUIT_SEND_SELF.getMessage(), ResultEnum.FRUIT_SEND_SELF.getCode());
-        }
-
-        ComFruitVo comFruitVo = comFruitService.findById(fruitId);
-
-        if (comFruitVo == null) {
-            return Result.of(null, false, ResultEnum.FRUIT_DATA_ERROR.getMessage(), ResultEnum.FRUIT_DATA_ERROR.getCode());
-        }
-        //果实type =1
-        ComPlayerGoods comPlayerGoodsSimpleVo = comPlayerGoodsService.findByUserIdAndIndexAndType(userId, fruitId, 1);
-
-        //销售果实数量
-        if (comPlayerGoodsSimpleVo == null) {
-            return Result.of(null, false, ResultEnum.FRUIT_DATA_ERROR.getMessage(), ResultEnum.FRUIT_DATA_ERROR.getCode());
-        }
-        //添加了 amountPart,需要加入判断整数部分
-        Integer _userFloorAmount = comPlayerGoodsSimpleVo.getAmount() + (int) Math.floor(comPlayerGoodsSimpleVo.getAmountPart());
-        if (amount > _userFloorAmount) {
-            return Result.of(null, false, ResultEnum.FRUIT_AMOUNT_ERROR.getMessage(), ResultEnum.FRUIT_AMOUNT_ERROR.getCode());
-        }
-        try {
-            Integer _selfBeforeAmount = comPlayerGoodsSimpleVo.getAmount();
-            Integer _selfAfterAmount = 0;
-            Double _selfBeforeFruitAmountPart = comPlayerGoodsSimpleVo.getAmountPart();
-            Double _selfAfterFruitAmountPart = 0d;
-            Integer _tAmount = 0;
-            Double _tAmountPart = 0d;
-
-            //if (comPlayerGoodsSimpleVo.getAmount().equals(amount)) {
-            //    //如果库存量和出售的果实数量一样,删除
-            //    comPlayerGoodsService.delete(comPlayerGoodsSimpleVo.getGoodsId());
-            //    _selfAfterAmount = 0;
-            //} else {
-            //    comPlayerGoodsSimpleVo.setAmount(comPlayerGoodsSimpleVo.getAmount() - amount);
-            //    _selfAfterAmount = comPlayerGoodsSimpleVo.getAmount();
-            //    ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
-            //    comPlayerGoodsService.save(comPlayerGoodsVo);
-            //}
-            Integer _amountDif = comPlayerGoodsSimpleVo.getAmount() - amount;
-            //优先处理背包的amount
-            if (_amountDif > 0) {
-                //当前交易值
-                _tAmount = amount;
-                //如果amount 数量足够,直接记录 他们的差值
-                comPlayerGoodsSimpleVo.setAmount(_amountDif);
-                _selfAfterAmount = comPlayerGoodsSimpleVo.getAmount();
-                _selfAfterFruitAmountPart = comPlayerGoodsSimpleVo.getAmountPart();
-                ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
-                comPlayerGoodsService.save(comPlayerGoodsVo);
-            } else {
-                _selfAfterAmount = 0;
-                //保证精度
-                BigDecimal bigDecimal1 = new BigDecimal(Double.toString(_amountDif));
-                BigDecimal bigDecimal2 = new BigDecimal(Double.toString(comPlayerGoodsSimpleVo.getAmountPart()));
-                BigDecimal _amountPart = bigDecimal1.add(bigDecimal2);
-                //当前交易值,_amountDif 小于0 说明 amount 是全全部扣除,到小数部分了。
-                _tAmount = comPlayerGoodsSimpleVo.getAmount();
-                _tAmountPart = Math.abs(bigDecimal1.doubleValue());
-                System.out.print("_amountPart{}," + _amountPart.doubleValue());
-                //前面判断了。所以 _amountPart 不会比0.0小
-                if (_amountPart.compareTo(new BigDecimal(0.0)) <= 0) {
-                    //如果库存量 amount 和 amountPart 都为零,删除
-                    comPlayerGoodsService.delete(comPlayerGoodsSimpleVo.getGoodsId());
-                    //这里记录一下,看是否会是一个负数
-                    _selfAfterFruitAmountPart = _amountPart.doubleValue();
-                } else {
-                    comPlayerGoodsSimpleVo.setAmount(0);
-                    comPlayerGoodsSimpleVo.setAmountPart(_amountPart.doubleValue());
-                    _selfAfterFruitAmountPart = comPlayerGoodsSimpleVo.getAmountPart();
-                    ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
-                    comPlayerGoodsService.save(comPlayerGoodsVo);
-                }
-            }
-
-            //todo 发送果实,记录当前用户的playerLog
-            //当前用户
-            ComPlayerLog _selfPlayerLog = new ComPlayerLog();
-            _selfPlayerLog.setUserId(userId);
-            _selfPlayerLog.setTId(comFruitVo.getId());
-            _selfPlayerLog.setTName(comFruitVo.getName());
-            _selfPlayerLog.setTType(2);//发送水果的类型:2
-            _selfPlayerLog.setTAmount(amount);
-            _selfPlayerLog.setBeforeAmount(_selfBeforeAmount);
-            ////交易后的数据
-            _selfPlayerLog.setAfterAmount(_selfAfterAmount);
-            _selfPlayerLog.setLMultiple(0);//收获时候,会有一个倍数
-            _selfPlayerLog.setWithered(0);
-            ComPlayerLogVo _selfPlayerLogVo = CopyUtil.copy(_selfPlayerLog, ComPlayerLogVo.class);
-            comPlayerLogService.save(_selfPlayerLogVo);
-
-            //接受人的背包数据
-            ComPlayerGoods _targetGoods = comPlayerGoodsService.findByUserIdAndIndexAndType(_targetUserVo.getUserId(), comFruitVo.getId(), 1);
-            Integer _targetBeforeAmount = 0;
-            Integer _targetAfterAmount = 0;
-            if (_targetGoods == null) {
-                //背包增加一个果实
-                _targetGoods = new ComPlayerGoods();
-                //目标id
-                _targetGoods.setUserId(_targetUserVo.getUserId());
-                _targetGoods.setGoodsIndex(comFruitVo.getId());
-                _targetGoods.setGoodsType(1);
-                _targetGoods.setName(comFruitVo.getName());
-                //用种子的picture
-                _targetGoods.setPictureName(comFruitVo.getPicture());
-                _targetGoods.setAmount(amount);
-                _targetGoods.setAmountPart(0d);
-                _targetAfterAmount = _targetGoods.getAmount();
-            } else {
-                _targetBeforeAmount = _targetGoods.getAmount();
-                _targetGoods.setAmount(_targetGoods.getAmount() + amount);
-                _targetAfterAmount = _targetGoods.getAmount();
-            }
-            ComPlayerGoodsVo _targetGoodsVo = CopyUtil.copy(_targetGoods, ComPlayerGoodsVo.class);
-            comPlayerGoodsService.save(_targetGoodsVo);
-            //todo 接收果实,记录目标用户的playerLog
-            ComPlayerLog _targetPlayerLog = new ComPlayerLog();
-            _targetPlayerLog.setUserId(_targetUserVo.getUserId());
-            _targetPlayerLog.setTId(comFruitVo.getId());
-            _targetPlayerLog.setTName(comFruitVo.getName());
-            _targetPlayerLog.setTType(3);//接收用户赠送水果,type设置 3
-            _targetPlayerLog.setTAmount(_tAmount);
-            _targetPlayerLog.setBeforeAmount(_targetBeforeAmount);
-            ////交易后的数据
-            _targetPlayerLog.setAfterAmount(_targetAfterAmount);
-            //增加一个小数部分记录
-            _targetPlayerLog.setTPart(_tAmountPart);
-            _targetPlayerLog.setTLoss(0d);
-            _targetPlayerLog.setBeforePart(_selfBeforeFruitAmountPart);
-            _targetPlayerLog.setAfterPart(_selfAfterFruitAmountPart);
-
-            _targetPlayerLog.setLMultiple(0);
-            _targetPlayerLog.setWithered(0);
-            ComPlayerLogVo _targetPlayerLogVo = CopyUtil.copy(_targetPlayerLog, ComPlayerLogVo.class);
-            comPlayerLogService.save(_targetPlayerLogVo);
-        } catch (Exception e) {
-            throw new RuntimeException(e.getMessage());
-        }
-
-
-        Map map = new HashMap();
-        map.put("msg", "成功发送果实!");
-        return Result.of(map);
-    }
+    ///**
+    // * 根据用户地址送果实
+    // *
+    // * @param userId
+    // * @param address 目标用户地址
+    // * @return
+    // */
+    //@PostMapping("grantFruit")
+    //@ResponseBody
+    //@Transactional(rollbackFor = Exception.class)
+    //public Result<Map> grantFruitFunction(
+    //        @RequestParam(value = "userId") String userId,
+    //        @RequestParam(value = "fruitId") Integer fruitId,
+    //        @RequestParam(value = "amount") Integer amount,
+    //        @RequestParam(value = "address") String address) {
+    //
+    //    //目标用户的背包
+    //    ComUsersVo _targetUserVo = comUsersService.findByAddress(address);
+    //    if (_targetUserVo == null) {
+    //        return Result.of(null, false, ResultEnum.USER_NOT_ADDRESS.getMessage(), ResultEnum.USER_NOT_ADDRESS.getCode());
+    //    }
+    //
+    //    if (_targetUserVo.getUserId().equals(userId)) {
+    //        return Result.of(null, false, ResultEnum.FRUIT_SEND_SELF.getMessage(), ResultEnum.FRUIT_SEND_SELF.getCode());
+    //    }
+    //
+    //    ComFruitVo comFruitVo = comFruitService.findById(fruitId);
+    //
+    //    if (comFruitVo == null) {
+    //        return Result.of(null, false, ResultEnum.FRUIT_DATA_ERROR.getMessage(), ResultEnum.FRUIT_DATA_ERROR.getCode());
+    //    }
+    //    //果实type =1
+    //    ComPlayerGoods comPlayerGoodsSimpleVo = comPlayerGoodsService.findByUserIdAndIndexAndType(userId, fruitId, 1);
+    //
+    //    //销售果实数量
+    //    if (comPlayerGoodsSimpleVo == null) {
+    //        return Result.of(null, false, ResultEnum.FRUIT_DATA_ERROR.getMessage(), ResultEnum.FRUIT_DATA_ERROR.getCode());
+    //    }
+    //    //添加了 amountPart,需要加入判断整数部分
+    //    Integer _userFloorAmount = comPlayerGoodsSimpleVo.getAmount() + (int) Math.floor(comPlayerGoodsSimpleVo.getAmountPart());
+    //    if (amount > _userFloorAmount) {
+    //        return Result.of(null, false, ResultEnum.FRUIT_AMOUNT_ERROR.getMessage(), ResultEnum.FRUIT_AMOUNT_ERROR.getCode());
+    //    }
+    //    try {
+    //        Integer _selfBeforeAmount = comPlayerGoodsSimpleVo.getAmount();
+    //        Integer _selfAfterAmount = 0;
+    //        Double _selfBeforeFruitAmountPart = comPlayerGoodsSimpleVo.getAmountPart();
+    //        Double _selfAfterFruitAmountPart = 0d;
+    //        Integer _tAmount = 0;
+    //        Double _tAmountPart = 0d;
+    //
+    //        //if (comPlayerGoodsSimpleVo.getAmount().equals(amount)) {
+    //        //    //如果库存量和出售的果实数量一样,删除
+    //        //    comPlayerGoodsService.delete(comPlayerGoodsSimpleVo.getGoodsId());
+    //        //    _selfAfterAmount = 0;
+    //        //} else {
+    //        //    comPlayerGoodsSimpleVo.setAmount(comPlayerGoodsSimpleVo.getAmount() - amount);
+    //        //    _selfAfterAmount = comPlayerGoodsSimpleVo.getAmount();
+    //        //    ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
+    //        //    comPlayerGoodsService.save(comPlayerGoodsVo);
+    //        //}
+    //        Integer _amountDif = comPlayerGoodsSimpleVo.getAmount() - amount;
+    //        //优先处理背包的amount
+    //        if (_amountDif > 0) {
+    //            //当前交易值
+    //            _tAmount = amount;
+    //            //如果amount 数量足够,直接记录 他们的差值
+    //            comPlayerGoodsSimpleVo.setAmount(_amountDif);
+    //            _selfAfterAmount = comPlayerGoodsSimpleVo.getAmount();
+    //            _selfAfterFruitAmountPart = comPlayerGoodsSimpleVo.getAmountPart();
+    //            ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
+    //            comPlayerGoodsService.save(comPlayerGoodsVo);
+    //        } else {
+    //            _selfAfterAmount = 0;
+    //            //保证精度
+    //            BigDecimal bigDecimal1 = new BigDecimal(Double.toString(_amountDif));
+    //            BigDecimal bigDecimal2 = new BigDecimal(Double.toString(comPlayerGoodsSimpleVo.getAmountPart()));
+    //            BigDecimal _amountPart = bigDecimal1.add(bigDecimal2);
+    //            //当前交易值,_amountDif 小于0 说明 amount 是全全部扣除,到小数部分了。
+    //            _tAmount = comPlayerGoodsSimpleVo.getAmount();
+    //            _tAmountPart = Math.abs(bigDecimal1.doubleValue());
+    //            System.out.print("_amountPart{}," + _amountPart.doubleValue());
+    //            //前面判断了。所以 _amountPart 不会比0.0小
+    //            if (_amountPart.compareTo(new BigDecimal(0.0)) <= 0) {
+    //                //如果库存量 amount 和 amountPart 都为零,删除
+    //                comPlayerGoodsService.delete(comPlayerGoodsSimpleVo.getGoodsId());
+    //                //这里记录一下,看是否会是一个负数
+    //                _selfAfterFruitAmountPart = _amountPart.doubleValue();
+    //            } else {
+    //                comPlayerGoodsSimpleVo.setAmount(0);
+    //                comPlayerGoodsSimpleVo.setAmountPart(_amountPart.doubleValue());
+    //                _selfAfterFruitAmountPart = comPlayerGoodsSimpleVo.getAmountPart();
+    //                ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
+    //                comPlayerGoodsService.save(comPlayerGoodsVo);
+    //            }
+    //        }
+    //
+    //        //todo 发送果实,记录当前用户的playerLog
+    //        //当前用户
+    //        ComPlayerLog _selfPlayerLog = new ComPlayerLog();
+    //        _selfPlayerLog.setUserId(userId);
+    //        _selfPlayerLog.setTId(comFruitVo.getId());
+    //        _selfPlayerLog.setTName(comFruitVo.getName());
+    //        _selfPlayerLog.setTType(2);//发送水果的类型:2
+    //        _selfPlayerLog.setTAmount(amount);
+    //        _selfPlayerLog.setBeforeAmount(_selfBeforeAmount);
+    //        ////交易后的数据
+    //        _selfPlayerLog.setAfterAmount(_selfAfterAmount);
+    //        _selfPlayerLog.setLMultiple(0);//收获时候,会有一个倍数
+    //        _selfPlayerLog.setWithered(0);
+    //        ComPlayerLogVo _selfPlayerLogVo = CopyUtil.copy(_selfPlayerLog, ComPlayerLogVo.class);
+    //        comPlayerLogService.save(_selfPlayerLogVo);
+    //
+    //        //接受人的背包数据
+    //        ComPlayerGoods _targetGoods = comPlayerGoodsService.findByUserIdAndIndexAndType(_targetUserVo.getUserId(), comFruitVo.getId(), 1);
+    //        Integer _targetBeforeAmount = 0;
+    //        Integer _targetAfterAmount = 0;
+    //        if (_targetGoods == null) {
+    //            //背包增加一个果实
+    //            _targetGoods = new ComPlayerGoods();
+    //            //目标id
+    //            _targetGoods.setUserId(_targetUserVo.getUserId());
+    //            _targetGoods.setGoodsIndex(comFruitVo.getId());
+    //            _targetGoods.setGoodsType(1);
+    //            _targetGoods.setName(comFruitVo.getName());
+    //            //用种子的picture
+    //            _targetGoods.setPictureName(comFruitVo.getPicture());
+    //            _targetGoods.setAmount(amount);
+    //            _targetGoods.setAmountPart(0d);
+    //            _targetAfterAmount = _targetGoods.getAmount();
+    //        } else {
+    //            _targetBeforeAmount = _targetGoods.getAmount();
+    //            _targetGoods.setAmount(_targetGoods.getAmount() + amount);
+    //            _targetAfterAmount = _targetGoods.getAmount();
+    //        }
+    //        ComPlayerGoodsVo _targetGoodsVo = CopyUtil.copy(_targetGoods, ComPlayerGoodsVo.class);
+    //        comPlayerGoodsService.save(_targetGoodsVo);
+    //        //todo 接收果实,记录目标用户的playerLog
+    //        ComPlayerLog _targetPlayerLog = new ComPlayerLog();
+    //        _targetPlayerLog.setUserId(_targetUserVo.getUserId());
+    //        _targetPlayerLog.setTId(comFruitVo.getId());
+    //        _targetPlayerLog.setTName(comFruitVo.getName());
+    //        _targetPlayerLog.setTType(3);//接收用户赠送水果,type设置 3
+    //        _targetPlayerLog.setTAmount(_tAmount);
+    //        _targetPlayerLog.setBeforeAmount(_targetBeforeAmount);
+    //        ////交易后的数据
+    //        _targetPlayerLog.setAfterAmount(_targetAfterAmount);
+    //        //增加一个小数部分记录
+    //        _targetPlayerLog.setTPart(_tAmountPart);
+    //        _targetPlayerLog.setTLoss(0d);
+    //        _targetPlayerLog.setBeforePart(_selfBeforeFruitAmountPart);
+    //        _targetPlayerLog.setAfterPart(_selfAfterFruitAmountPart);
+    //
+    //        _targetPlayerLog.setLMultiple(0);
+    //        _targetPlayerLog.setWithered(0);
+    //        ComPlayerLogVo _targetPlayerLogVo = CopyUtil.copy(_targetPlayerLog, ComPlayerLogVo.class);
+    //        comPlayerLogService.save(_targetPlayerLogVo);
+    //    } catch (Exception e) {
+    //        throw new RuntimeException(e.getMessage());
+    //    }
+    //
+    //
+    //    Map map = new HashMap();
+    //    map.put("msg", "成功发送果实!");
+    //    return Result.of(map);
+    //}
 }
 }

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

@@ -94,7 +94,7 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
         if (StringUtils.hasText(otherUserId)) {
         if (StringUtils.hasText(otherUserId)) {
             _currentUserId = otherUserId;
             _currentUserId = otherUserId;
         }
         }
-        log.info("获取土地时候的userId:" + _currentUserId);
+        //log.info("获取土地时候的userId:" + _currentUserId);
         List<ComPlayerLand> comPlayerLands = comPlayerLandService.findAllByUserId(_currentUserId);
         List<ComPlayerLand> comPlayerLands = comPlayerLandService.findAllByUserId(_currentUserId);
         List<ComPlayerLandAndPlantVo> _simpleVoList = CopyUtil.copyList(comPlayerLands, ComPlayerLandAndPlantVo.class);
         List<ComPlayerLandAndPlantVo> _simpleVoList = CopyUtil.copyList(comPlayerLands, ComPlayerLandAndPlantVo.class);
         List<ComPlayerLandAndPlantVo> _list = new ArrayList<>();
         List<ComPlayerLandAndPlantVo> _list = new ArrayList<>();
@@ -142,13 +142,13 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
                     ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
                     ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
                     //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
                     //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
                     if (ArrayUtil.contains(CultivateKeys.mallType,e.getMallType())) {
                     if (ArrayUtil.contains(CultivateKeys.mallType,e.getMallType())) {
-                        Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, e.getPlantStart(),e.getMallType(),e.getConfigLandId(),e.getPlantFlag(),comMallSeedVo);
+                        Integer days = comPlayerCultivateSerivce.getHarvestDays(e.getUserId(), e.getPlantStart(),e.getMallType(),e.getConfigLandId(),e.getPlantFlag(),comMallSeedVo);
                         comMallSeedVo.setMaturity(days);
                         comMallSeedVo.setMaturity(days);
 
 
                         //获取并设置今日喂养状态
                         //获取并设置今日喂养状态
                         Date begin = cn.hutool.core.date.DateUtil.beginOfDay(new Date());
                         Date begin = cn.hutool.core.date.DateUtil.beginOfDay(new Date());
                         Date end = cn.hutool.core.date.DateUtil.endOfDay(new Date());
                         Date end = cn.hutool.core.date.DateUtil.endOfDay(new Date());
-                        boolean animalEat = comPlayerCultivateSerivce.isAnimalEat(userId, e.getMallType(), e.getConfigLandId(),e.getPlantFlag(), begin, end);
+                        boolean animalEat = comPlayerCultivateSerivce.isAnimalEat(e.getUserId(), e.getMallType(), e.getConfigLandId(),e.getPlantFlag(), begin, end);
                         comPlayerLandAndPlantVo.setAnimalEat(animalEat);
                         comPlayerLandAndPlantVo.setAnimalEat(animalEat);
 
 
                         //养殖场部分价格信息
                         //养殖场部分价格信息
@@ -238,10 +238,16 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
                 // 如果种植了,返回一个种植数据
                 // 如果种植了,返回一个种植数据
                 if (comPlayerLandAndPlantVo.getIsPlant().equals(1)) {
                 if (comPlayerLandAndPlantVo.getIsPlant().equals(1)) {
                     ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
                     ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
-                    //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
+                    //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期 otherUserId
                     if (ArrayUtil.contains(CultivateKeys.mallType,e.getMallType())) {
                     if (ArrayUtil.contains(CultivateKeys.mallType,e.getMallType())) {
-                        Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, e.getPlantStart(),e.getMallType(),e.getConfigLandId(),e.getPlantFlag(),comMallSeedVo);
+                        Integer days = comPlayerCultivateSerivce.getHarvestDays(e.getUserId(), e.getPlantStart(),e.getMallType(),e.getConfigLandId(),e.getPlantFlag(),comMallSeedVo);
                         comMallSeedVo.setMaturity(days);
                         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 = comPlayerCultivateSerivce.isAnimalEat(e.getUserId(), e.getMallType(), e.getConfigLandId(),e.getPlantFlag(), begin, end);
+                        comPlayerLandAndPlantVo.setAnimalEat(animalEat);
                     }
                     }
                     comPlayerLandAndPlantVo.setSeedInfo(comMallSeedVo);
                     comPlayerLandAndPlantVo.setSeedInfo(comMallSeedVo);
                     //种子时间
                     //种子时间
@@ -550,8 +556,8 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
             @RequestParam(value = "page", defaultValue = "0") Integer page,
             @RequestParam(value = "page", defaultValue = "0") Integer page,
             @RequestParam(value = "limit", defaultValue = "10") Integer limit
             @RequestParam(value = "limit", defaultValue = "10") Integer limit
     ) {
     ) {
-
-        PageRequest pageable = PageRequest.of(page, limit, Sort.by(Sort.Direction.DESC, "plant_start"));
+        // Sort.by(Sort.Direction.DESC, "plant_start")
+        PageRequest pageable = PageRequest.of(page, limit);
 
 
         List<ComPlayerLandAndUserInfoVo> comPlayerLands = comPlayerLandService.findAllByCanStealNotSelf(userId, pageable);
         List<ComPlayerLandAndUserInfoVo> comPlayerLands = comPlayerLandService.findAllByCanStealNotSelf(userId, pageable);
 
 
@@ -627,7 +633,7 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
                     }
                     }
                 }
                 }
             }
             }
-            log.info("用户编号:{},防护历史记录:{}", comPlayerLandAndPlantVo.getUserId(), JSONUtil.toJsonStr(protectList));
+            //log.info("用户编号:{},防护历史记录:{}", comPlayerLandAndPlantVo.getUserId(), JSONUtil.toJsonStr(protectList));
             //获得对应灾难类型的防护记录    并得到这个 防护到期时间. 自然灾害类型
             //获得对应灾难类型的防护记录    并得到这个 防护到期时间. 自然灾害类型
             //如果没有防护或者防护到期。则直接发生灾难进行减产
             //如果没有防护或者防护到期。则直接发生灾难进行减产
 
 

+ 4 - 0
src/main/java/com/td/boss/game/complayerland/pojo/ComPlayerLandAndCanSteal.java

@@ -53,4 +53,8 @@ public class ComPlayerLandAndCanSteal implements Serializable {
     private Date updateTime;
     private Date updateTime;
 
 
     private Integer canSteal; //这个是当前用户的偷取状态
     private Integer canSteal; //这个是当前用户的偷取状态
+
+    private Integer landLevel;//土地级别
+
+    private Integer mallType;
 }
 }

+ 25 - 7
src/main/java/com/td/boss/game/complayerland/repository/ComPlayerLandRepository.java

@@ -16,20 +16,38 @@ public interface ComPlayerLandRepository extends CommonRepository<ComPlayerLand,
     List<ComPlayerLand> findAllByUserId(String userId);
     List<ComPlayerLand> findAllByUserId(String userId);
 
 
 
 
+    //@Query(value = "SELECT\n" +
+    //        "a.user_id,\n" +
+    //        "a.is_plant,\n" +
+    //        "a.plant_start,\n" +
+    //        "a.plant_mature,\n" +
+    //        "DATE_ADD(a.plant_start,INTERVAL a.plant_mature DAY) AS mature_date,\n" +
+    //        "b.address,\n" +
+    //        "(CASE WHEN c.id IS NULL AND a.plant_steal = 1  THEN 1 ELSE 0 END) AS can_steal\n" +
+    //        "FROM\n" +
+    //        "com_player_land AS a \n" +
+    //        "LEFT JOIN com_users AS b ON a.user_id = b.user_id\n" +
+    //        "LEFT JOIN com_player_profit AS c ON c.user_id = :userId AND c.target_id = a.user_id AND a.config_land_id = c.land_id AND (  ( ISNULL(a.plant_flag) = 1 AND c.plant_flag = CONCAT(a.user_id,'or',a.config_land_id)) OR a.plant_flag = c.plant_flag )\n" +
+    //        "WHERE NOT(a.user_id = :userId) AND is_lease = 1 AND is_plant = 1 AND a.plant_steal = 1 AND DATE_ADD(a.plant_start,INTERVAL a.plant_mature DAY) <= NOW()\n" +
+    //        "AND DATE(a.lease_time) > DATE(NOW()) GROUP BY a.user_id,can_steal HAVING can_steal = 1  ", nativeQuery = true)
+    //List<Object> findAllIsStealComPlayerLandAndUserInfo(String userId,Pageable pageable);
     @Query(value = "SELECT\n" +
     @Query(value = "SELECT\n" +
             "a.user_id,\n" +
             "a.user_id,\n" +
             "a.is_plant,\n" +
             "a.is_plant,\n" +
             "a.plant_start,\n" +
             "a.plant_start,\n" +
             "a.plant_mature,\n" +
             "a.plant_mature,\n" +
-            "DATE_ADD(a.plant_start,INTERVAL a.plant_mature DAY) AS mature_date,\n" +
+            "@times \\:= (SELECT count(*) FROM com_player_cultivate AS d WHERE d.user_id = a.user_id AND d.plant_flag = a.plant_flag) AS times,\n" +
+            "@endMature \\:= IF(@times < DATEDIFF(NOW(),a.plant_start) AND a.mall_type != 0,(DATEDIFF(NOW(),a.plant_start)- @times)*2,0) + a.plant_mature AS days,\n" +
+            "DATE_ADD(a.plant_start,INTERVAL @endMature DAY) as mature_date,\n" +
             "b.address,\n" +
             "b.address,\n" +
-            "(CASE WHEN c.id IS NULL AND a.plant_steal = 1  THEN 1 ELSE 0 END) AS can_steal\n" +
-            "FROM\n" +
-            "com_player_land AS a \n" +
+            "(CASE WHEN c.id IS NULL AND a.plant_steal = 1 AND DATE_ADD(a.plant_start,INTERVAL @endMature DAY) <= NOW()  THEN 1 ELSE 0 END) AS can_steal,\n" +
+            "a.mall_type,\n" +
+            "a.plant_flag\n" +
+            "FROM com_player_land  AS a\n" +
             "LEFT JOIN com_users AS b ON a.user_id = b.user_id\n" +
             "LEFT JOIN com_users AS b ON a.user_id = b.user_id\n" +
-            "LEFT JOIN com_player_profit AS c ON c.user_id = :userId AND c.target_id = a.user_id AND a.config_land_id = c.land_id AND (  ( ISNULL(a.plant_flag) = 1 AND c.plant_flag = CONCAT(a.user_id,'or',a.config_land_id)) OR a.plant_flag = c.plant_flag )\n" +
-            "WHERE NOT(a.user_id = :userId) AND is_lease = 1 AND is_plant = 1 AND a.plant_steal = 1 AND DATE_ADD(a.plant_start,INTERVAL a.plant_mature DAY) <= NOW()\n" +
-            "AND DATE(a.lease_time) > DATE(NOW()) GROUP BY a.user_id,can_steal HAVING can_steal = 1  ", nativeQuery = true)
+            "LEFT JOIN com_player_profit AS c ON c.user_id = :userId AND c.target_id = a.user_id AND a.config_land_id = c.land_id AND (( ISNULL(a.plant_flag) = 1 AND c.plant_flag = CONCAT(a.user_id,'or',a.config_land_id)) OR a.plant_flag = c.plant_flag )\n" +
+            "WHERE a.lease_time > NOW() AND NOT(a.user_id = :userId)  AND a.is_lease = 1 AND a.is_plant = 1 AND a.plant_steal = 1\n" +
+            "GROUP BY a.user_id ,can_steal HAVING can_steal = 1 ORDER BY plant_start DESC", nativeQuery = true)
     List<Object> findAllIsStealComPlayerLandAndUserInfo(String userId,Pageable pageable);
     List<Object> findAllIsStealComPlayerLandAndUserInfo(String userId,Pageable pageable);
 
 
 
 

+ 26 - 6
src/main/java/com/td/boss/game/complayerland/service/ComPlayerLandServiceImpl.java

@@ -56,21 +56,41 @@ public class ComPlayerLandServiceImpl extends CommonServiceImpl<ComPlayerLandVo,
         List<ComPlayerLandAndUserInfoVo> landAndUserInfoVos = new ArrayList<>();
         List<ComPlayerLandAndUserInfoVo> landAndUserInfoVos = new ArrayList<>();
         for (int i = 0; i < objects.size(); i++) {
         for (int i = 0; i < objects.size(); i++) {
             Object[] tempObj = (Object[]) objects.get(i);
             Object[] tempObj = (Object[]) objects.get(i);
-            landAndUserInfoVos.add(new ComPlayerLandAndUserInfoVo((String) tempObj[0], (Boolean) tempObj[1], (Date) tempObj[2], (Integer) tempObj[3], (Date) tempObj[4], (String) tempObj[5]));
+            landAndUserInfoVos.add(new ComPlayerLandAndUserInfoVo(
+                    (String) tempObj[0],  //0:userId
+                    (Boolean) tempObj[1], //1:isPlant
+                    (Date) tempObj[2],    //2:plantStart
+                    (Integer) tempObj[3], //3:plantMature, 4:times,5:days
+                    (Date) tempObj[6],    //6:matureDate
+                    (String) tempObj[7],  //7:address,8:canSteal,9:mallType
+                    (String) tempObj[10]) //10:plantFlag
+            );
         }
         }
         return landAndUserInfoVos;
         return landAndUserInfoVos;
     }
     }
 
 
     @Override
     @Override
     public List<ComPlayerLandAndCanSteal> findCanStealByUserIdAndOtherUserId(String userId, String otherUserId) {
     public List<ComPlayerLandAndCanSteal> findCanStealByUserIdAndOtherUserId(String userId, String otherUserId) {
+        //String sql = "SELECT\n" +
+        //        "a.*,\n" +
+        //        "(CASE WHEN c.id IS NULL THEN 1 ELSE 0 END ) AS can_steal\n" +
+        //        "FROM\n" +
+        //        "com_player_land AS a \n" +
+        //        "LEFT JOIN com_player_profit AS c ON a.user_id = c.target_id AND c.user_id = " + userId + " AND a.config_land_id = c.land_id AND (( ISNULL(a.plant_flag) = 1 AND c.plant_flag = CONCAT(a.user_id,'or',a.config_land_id)) OR a.plant_flag = c.plant_flag )\n" +
+        //        "WHERE a.lease_time > NOW() AND a.user_id = " + otherUserId + " AND is_lease = 1 AND is_plant = 1 AND \n" +
+        //        "(CASE WHEN a.mall_type=0 \n" +
+        //        "THEN DATE_ADD(a.plant_start,INTERVAL a.plant_mature DAY)  \n" +
+        //        "ELSE DATE_ADD(a.plant_start,INTERVAL (a.plant_mature+ (DATEDIFF(NOW(),a.plant_start) - (SELECT count(*) FROM com_player_cultivate WHERE user_id = a.user_id AND plant_flag = a.plant_flag))*2) DAY) END \n" +
+        //        ") <= NOW()";
         String sql = "SELECT\n" +
         String sql = "SELECT\n" +
                 "a.*,\n" +
                 "a.*,\n" +
-                "(CASE WHEN c.id IS NULL THEN 1 ELSE 0 END ) AS can_steal\n" +
+                "@times \\:= (SELECT count(*) FROM com_player_cultivate AS d WHERE d.user_id = a.user_id AND d.plant_flag = a.plant_flag) AS times,\n" +
+                "@endMature \\:= IF(@times < DATEDIFF(NOW(),a.plant_start) AND a.mall_type != 0,(DATEDIFF(NOW(),a.plant_start)- @times)*2,0) + a.plant_mature AS days,\n" +
+                "(CASE WHEN c.id IS NULL AND a.plant_steal = 1 AND DATE_ADD(a.plant_start,INTERVAL @endMature DAY) <= NOW()  THEN 1 ELSE 0 END) AS can_steal\n" +
                 "FROM\n" +
                 "FROM\n" +
-                "com_player_land AS a \n" +
-                "LEFT JOIN com_player_profit AS c ON a.user_id = c.target_id AND c.user_id = " + userId + " AND a.config_land_id = c.land_id AND (( ISNULL(a.plant_flag) = 1 AND c.plant_flag = CONCAT(a.user_id,'or',a.config_land_id)) OR a.plant_flag = c.plant_flag )\n" +
-                "WHERE a.user_id = " + otherUserId + " AND is_lease = 1 AND is_plant = 1 AND DATE_ADD(a.plant_start,INTERVAL a.plant_mature DAY) <= NOW()\n" +
-                "AND a.lease_time > NOW()";
+                "com_player_land AS a\n" +
+                "LEFT JOIN com_player_profit AS c ON a.user_id = c.target_id AND c.user_id = " + userId + "  AND a.config_land_id = c.land_id AND (  ( ISNULL(a.plant_flag) = 1 AND c.plant_flag = CONCAT(a.user_id,'or',a.config_land_id)) OR a.plant_flag = c.plant_flag )\n" +
+                "WHERE a.lease_time > NOW() AND a.user_id = " + otherUserId + "  AND a.is_lease = 1 AND a.is_plant = 1";
         Query nativeQuery = em.createNativeQuery(sql, ComPlayerLandAndCanSteal.class);
         Query nativeQuery = em.createNativeQuery(sql, ComPlayerLandAndCanSteal.class);
         List list = nativeQuery.getResultList();
         List list = nativeQuery.getResultList();
         return list;
         return list;

+ 3 - 1
src/main/java/com/td/boss/game/complayerland/vo/ComPlayerLandAndUserInfoVo.java

@@ -20,14 +20,16 @@ public class ComPlayerLandAndUserInfoVo {
     private Integer plantMature;
     private Integer plantMature;
     private Date matureDate;
     private Date matureDate;
     private String address;
     private String address;
+    private String plantFlag;
 
 
-    public ComPlayerLandAndUserInfoVo(String userId, Boolean isPlant, Date plantStart, Integer plantMature, Date matureDate, String address) {
+    public ComPlayerLandAndUserInfoVo(String userId, Boolean isPlant, Date plantStart, Integer plantMature, Date matureDate, String address,String plantFlag) {
         this.userId = userId;
         this.userId = userId;
         this.isPlant = isPlant;
         this.isPlant = isPlant;
         this.plantStart = plantStart;
         this.plantStart = plantStart;
         this.plantMature = plantMature;
         this.plantMature = plantMature;
         this.matureDate = matureDate;
         this.matureDate = matureDate;
         this.address = address;
         this.address = address;
+        this.plantFlag = plantFlag;
     }
     }
 
 
 }
 }

+ 7 - 2
src/main/java/com/td/boss/game/complayersattri/service/ComPlayersLuckyServiceImpl.java

@@ -4,9 +4,11 @@ import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import cn.hutool.json.JSONUtil;
+import com.td.boss.common.pojo.CultivateKeys;
 import com.td.boss.common.pojo.Result;
 import com.td.boss.common.pojo.Result;
 import com.td.boss.common.service.ComConfigService;
 import com.td.boss.common.service.ComConfigService;
 import com.td.boss.common.service.CommonServiceImpl;
 import com.td.boss.common.service.CommonServiceImpl;
@@ -80,11 +82,11 @@ public class ComPlayersLuckyServiceImpl extends CommonServiceImpl<ComPlayersLuck
         //验证土地是否存在
         //验证土地是否存在
         ComPlayerLand comPlayerLand = comPlayerLandRepository.findById(landId).orElse(null);
         ComPlayerLand comPlayerLand = comPlayerLandRepository.findById(landId).orElse(null);
         if (comPlayerLand == null || comPlayerLand.getUserId().equals(userId) == false) {
         if (comPlayerLand == null || comPlayerLand.getUserId().equals(userId) == false) {
-            return Result.of(null, false, "升级失败,无效土地!");
+            return Result.of(null, false, "使用工具失败,无效土地!");
         }
         }
         //土地租赁到期了,不能使用工具
         //土地租赁到期了,不能使用工具
         if (comPlayerLand.getLeaseTime().before(new Date())) {
         if (comPlayerLand.getLeaseTime().before(new Date())) {
-            return Result.of(null, false, "升级失败,土地已到期!");
+            return Result.of(null, false, "使用工具失败,土地已到期!");
         }
         }
         //验证用户是否存在
         //验证用户是否存在
         ComPlayersAttri playersAttri = comPlayersAttriRepository.findByUserId(userId).orElse(null);
         ComPlayersAttri playersAttri = comPlayersAttriRepository.findByUserId(userId).orElse(null);
@@ -152,6 +154,9 @@ public class ComPlayersLuckyServiceImpl extends CommonServiceImpl<ComPlayersLuck
         if (comPlayerLand == null || comPlayerLand.getUserId().equals(userId) == false) {
         if (comPlayerLand == null || comPlayerLand.getUserId().equals(userId) == false) {
             return Result.of(null, false, "升级失败,无效土地!");
             return Result.of(null, false, "升级失败,无效土地!");
         }
         }
+        if(ArrayUtil.contains(CultivateKeys.mallType,comPlayerLand.getMallType())){
+            return Result.of(null, false, "升级失败,无效土地类型!");
+        }
         //土地租赁到期了,不能升级
         //土地租赁到期了,不能升级
         if (comPlayerLand.getLeaseTime().before(new Date())) {
         if (comPlayerLand.getLeaseTime().before(new Date())) {
             return Result.of(null, false, "升级失败,土地已到期!");
             return Result.of(null, false, "升级失败,土地已到期!");

+ 3 - 3
src/main/java/com/td/boss/game/comsnbfreeze/controller/ComSnbFreezeController.java

@@ -142,9 +142,9 @@ public class ComSnbFreezeController extends CommonController<ComSnbFreezeVo, Com
         //todo 新增一个判断当前交易是否存在对应snb通过审核的
         //todo 新增一个判断当前交易是否存在对应snb通过审核的
         ComSnbApply comSnbApply = comSnbApplyService.findByUserIdAndSnbAndIsState(id.toString(), snbAmount, 1);
         ComSnbApply comSnbApply = comSnbApplyService.findByUserIdAndSnbAndIsState(id.toString(), snbAmount, 1);
         if (comSnbApply == null) {
         if (comSnbApply == null) {
-            comSnbApply.setIsState(2);
-            comSnbApplyService.save(CopyUtil.copy(comSnbApply, ComSnbApplyVo.class));
-            map.put("msg", "此交易未通过审核,返回给用户账户待用户提交审核");
+            //comSnbApply.setIsState(2);
+            //comSnbApplyService.save(CopyUtil.copy(comSnbApply, ComSnbApplyVo.class));
+            map.put("msg", "交易异常:此交易未通过审核");
             return Result.of(map);
             return Result.of(map);
         }
         }