Эх сурвалжийг харах

1.兑换种子diamond修改。接口暂未使用
2.修复修改土地倍数类型限制bug

slambb 3 жил өмнө
parent
commit
d8e941d1c9

+ 12 - 5
src/main/java/com/td/boss/game/commallseed/controller/ComMallSeedController.java

@@ -23,6 +23,7 @@ import com.td.boss.game.comsnbtran.vo.ComSnbTranVo;
 import com.td.boss.game.comusers.service.ComUsersService;
 import com.td.boss.game.comusers.vo.ComUsersVo;
 import com.td.boss.util.CopyUtil;
+import com.td.boss.util.DoubleUtil;
 import com.td.boss.util.RedisData;
 import com.td.boss.util.RedisLock;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -209,6 +210,9 @@ public class ComMallSeedController extends CommonController<ComMallSeedVo, ComMa
             @RequestParam(value = "diamondAmount") Integer diamondAmount,
             @RequestParam(value = "seedId") Integer seedId
     ) {
+        if(diamondAmount< 30000){
+            return Result.of(null, false, ResultEnum.SEED_PLAY_ERROR.getMessage(), ResultEnum.SEED_PLAY_ERROR.getCode());
+        }
         // 处理itemType,种子id ,获取种子类型,设置种子不同的数据
         Integer itemType = seedId;
         ComMallSeedVo seedVo = comMallSeedService.findById(seedId);
@@ -225,16 +229,19 @@ public class ComMallSeedController extends CommonController<ComMallSeedVo, ComMa
             return Result.of(map, false, ResultEnum.SEED_IS_EXCHANGE.getMessage(), ResultEnum.SEED_IS_EXCHANGE.getCode());
         }
 
-        JSONObject jsonObject = JSONObject.parseObject(player.getData());
-        Integer _diamond = Integer.parseInt(jsonObject.getString("Diamond"));
-        if(_diamond<diamondAmount){
+        //JSONObject jsonObject = JSONObject.parseObject(player.getData());
+        //Integer _diamond = Integer.parseInt(jsonObject.getString("Diamond"));
+        Double _diamond = player.getDiamond();
+        if(DoubleUtil.compare(_diamond,diamondAmount.doubleValue()).equals(-1)){
             return Result.of(map, false, ResultEnum.SEED_PLAY_DIAMOND_ERROR.getMessage(), ResultEnum.SEED_PLAY_DIAMOND_ERROR.getCode());
         }
-        jsonObject.put("Diamond",_diamond - diamondAmount);
+        //jsonObject.put("Diamond",_diamond - diamondAmount);
+        Double _endDiamond = DoubleUtil.sub(_diamond , diamondAmount.doubleValue());
         //设置已经兑换的状态
         player.setIsExchange(1);
         //更新游戏状态
-        player.setData(jsonObject.toString());
+        //player.setData(jsonObject.toString());
+        player.setDiamond(_endDiamond);
         comPlayersService.addComPlayers(player);
         //合法操作记录到仓库中
         //todo 添加一个辣椒种子

+ 2 - 1
src/main/java/com/td/boss/game/complayercultivate/serivce/ComPlayerCultivateSerivceImpl.java

@@ -153,7 +153,8 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
             return Result.of(null, false, ResultEnum.LAND_MULTIPLE_ERROR.getMessage(), ResultEnum.LAND_MULTIPLE_ERROR.getCode());
         }
         ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
-        if (comPlayerLand == null && ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType()) == false) {
+        //只能修改养殖场类型
+        if (comPlayerLand == null || ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType()) == false) {
             return Result.of(null, false, ResultEnum.LAND_DATA_ERROR.getMessage(), ResultEnum.LAND_DATA_ERROR.getCode());
         }
         //不能超过最大值,倍数