Browse Source

1.优化接口对接前端逻辑

slambb 3 năm trước cách đây
mục cha
commit
d41276e05a

+ 2 - 1
src/main/java/com/td/boss/config/enums/ResultEnum.java

@@ -83,8 +83,9 @@ public enum ResultEnum {
 
     //土地受灾中,稍后重试!
     LAND_DISATER_LOCK(716,"土地正在遭受灾害,稍后重试!"),
-
     LAND_MALL_TYPE_ERROR(717,"种植或养殖类型不对!"),
+    LAND_MULTIPLE_ERROR(718,"土地倍数异常!"),
+    LAND_MULTIPLE_CONFIG_ERROR(719,"土地倍数与配置不符!"),
 
     //种子数据不能存在
     SEED_DATA_ERROR(801,"种子数据不存在!"),

+ 7 - 0
src/main/java/com/td/boss/game/comfruit/vo/ComFruitAmountVo.java

@@ -27,4 +27,11 @@ public class ComFruitAmountVo implements Serializable {
 
     private Date updateTime;//
 
+    /**
+     * 需求 牧场养殖渔场,新增字段,
+     * 原有需求种地值0 牧场1 养殖2 淡水区3 海水区4
+     */
+    private Integer mallType;
+
+
 }

+ 1 - 0
src/main/java/com/td/boss/game/commallseed/controller/ComMallSeedController.java

@@ -274,6 +274,7 @@ public class ComMallSeedController extends CommonController<ComMallSeedVo, ComMa
         ////交易后的数据
         _selfPlayerLog.setAfterAmount(entityVo.getAmount());
         _selfPlayerLog.setLMultiple(0);//收获时候,会有一个倍数
+        _selfPlayerLog.setWithered(0); //枯萎就设置 1
         ComPlayerLogVo _selfPlayerLogVo = CopyUtil.copy(_selfPlayerLog, ComPlayerLogVo.class);
         comPlayerLogService.save(_selfPlayerLogVo);
         try {

+ 19 - 2
src/main/java/com/td/boss/game/complayercultivate/controller/ComPlayerCultivateController.java

@@ -52,8 +52,26 @@ public class ComPlayerCultivateController {
         return comPlayerCultivateSerivce.payLand(userId, configLandId);
     }
 
+
+    /**
+     * 修改某个土地 【牧场养殖渔场】
+     *
+     * @param userId
+     * @param configLandId
+     * @param multiple
+     * @return
+     */
+    @PostMapping("multipleLand")
+    @Transactional(rollbackFor = Exception.class)
+    public Result<?> multipleLand(@RequestParam(value = "userId") String userId,
+                                  @RequestParam(value = "configLandId") Integer configLandId,
+                                  @RequestParam(value = "multiple") Integer multiple) {
+        return comPlayerCultivateSerivce.multipleLand(userId, configLandId,multiple);
+    }
+
     /**
      * 获取租赁机会
+     *
      * @param userId
      * @return
      */
@@ -64,7 +82,6 @@ public class ComPlayerCultivateController {
     }
 
 
-
     /**
      * 喂养养殖场动物
      *
@@ -75,7 +92,7 @@ public class ComPlayerCultivateController {
     @PostMapping("buyAnimalFood")
     @Transactional(rollbackFor = Exception.class)
     public Result<?> buyAnimalFood(@RequestParam(value = "userId") String userId,
-                             @RequestParam(value = "configLandId") Integer configLandId) {
+                                   @RequestParam(value = "configLandId") Integer configLandId) {
         return comPlayerCultivateSerivce.buyFood(userId, configLandId);
     }
 }

+ 13 - 0
src/main/java/com/td/boss/game/complayercultivate/serivce/ComPlayerCultivateSerivce.java

@@ -1,18 +1,31 @@
 package com.td.boss.game.complayercultivate.serivce;
 
 import com.td.boss.common.pojo.Result;
+
 import java.util.Date;
 
 public interface ComPlayerCultivateSerivce {
 
     /**
      * 解锁某个土地 【牧场养殖渔场】
+     *
      * @param userId
      * @param configLandId
      * @return
      */
     Result<?> payLand(String userId, Integer configLandId);
 
+    /**
+     * 修改某个土地 【牧场养殖渔场】
+     *
+     * @param userId
+     * @param configLandId
+     * @param multiple
+     * @return
+     */
+    Result<?> multipleLand(String userId, Integer configLandId, Integer multiple);
+
+
     /**
      * 获取租赁机会
      *

+ 155 - 46
src/main/java/com/td/boss/game/complayercultivate/serivce/ComPlayerCultivateSerivceImpl.java

@@ -12,37 +12,40 @@ import com.td.boss.game.comconfigland.pojo.ComConfigLand;
 import com.td.boss.game.comconfigland.service.ComConfigLandService;
 import com.td.boss.game.comexplainland.service.ComExplainLandService;
 import com.td.boss.game.comexplainland.vo.ComExplainLandVo;
+import com.td.boss.game.commallseed.service.ComMallSeedService;
+import com.td.boss.game.commallseed.vo.ComMallSeedVo;
 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.complayerland.pojo.ComPlayerDisaster;
 import com.td.boss.game.complayerland.pojo.ComPlayerLand;
 import com.td.boss.game.complayerland.service.ComPlayerLandService;
+import com.td.boss.game.complayerland.vo.ComPlayerLandAndPlantVo;
+import com.td.boss.game.complayerland.vo.ComPlayerLandSimpleVo;
+import com.td.boss.game.complayerland.vo.ComPlayerLandVo;
 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.DappUtil;
-import com.td.boss.util.DoubleUtil;
-import com.td.boss.util.RedisData;
-import com.td.boss.util.RedisLock;
+import com.td.boss.util.*;
 import lombok.extern.slf4j.Slf4j;
 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 javax.persistence.criteria.CriteriaBuilder;
 import javax.persistence.criteria.CriteriaQuery;
 import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 @Service
 @Slf4j
 @Transactional
 public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce {
 
+    @Autowired
+    private ComMallSeedService comMallSeedService;
     @Autowired
     private ComPlayerLandService comPlayerLandService;
     @Autowired
@@ -71,54 +74,102 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
         //根据土地config id查找,对应ConfigLandId ,
         ComConfigLand comConfigLand = comConfigLandService.findById(configLandId);
         //如果土地等于不能初始化,或者已经种植,不能进行购买
-        if (comConfigLand == null || comConfigLand.getIsInit().equals(0) || comConfigLand.getIsPlant().equals(1)) {
+        if (comConfigLand == null || comConfigLand.getIsInit().equals(0)) {
             return Result.of(null, false, ResultEnum.LAND_DATA_ERROR.getMessage(), ResultEnum.LAND_DATA_ERROR.getCode());
         }
-        ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
         if (ArrayUtil.contains(CultivateKeys.mallType, comConfigLand.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();
+        try {
+            if (!redisLock.lock(_redisKey, String.valueOf(landTime))) {
+                log.info("锁住key:" + _redisKey);
+                return Result.of(null, false, ResultEnum.REDIS_IS_LOCK.getMessage(), ResultEnum.REDIS_IS_LOCK.getCode());
+            }
+            ComPlayerLand comPlayerLand = comPlayerLandService.findByUserIdAndLandId(userId, configLandId);
+            if (comPlayerLand != null) {
+                throw new Exception(ResultEnum.LAND_IS_LEASE.getMessage());
+            }
+            Integer _getTimes = getTimes(userId);
+            if (_getTimes <= 0) {
+                throw new Exception(ResultEnum.LAND_NO_TIMES_ERROR.getMessage());
+            }
+            //创建新土地
+            Date nowDate = new Date();
+            comPlayerLand = new ComPlayerLand();
+            comPlayerLand.setConfigLandId(comConfigLand.getId());
+            comPlayerLand.setUserId(userId);
+            comPlayerLand.setName(comConfigLand.getName());
+            //初始化一下未种植参数
+            comPlayerLand.setIsPlant(0);
+            comPlayerLand.setCreateTime(nowDate);
+            comPlayerLand.setPlantSteal(1);
+            comPlayerLand.setMallType(comConfigLand.getMallType());
+
+            comPlayerLand.setLandDescribe("养殖场租赁,每次租赁日期为1个月.");
+            comPlayerLand.setLeaseMultiple(CultivateKeys.amountLimit[comConfigLand.getMallType() - 1]); // 养殖场倍数,暂时设置最大值
+            comPlayerLand.setLeaseDate(4); // 租赁类型改成 4
+            //设置租赁日期,定义一个30天日期
+            comPlayerLand.setLeaseTime(com.td.boss.util.DateUtil.getOldDateAddDay(nowDate,30));
+            //租赁土地
+            comPlayerLand.setIsLease(1);
+            comPlayerLand.setUpdateTime(nowDate);
+            //记录一下租赁费用
+            comPlayerLand.setRentalExpenses(1.0d);
+            comPlayerLandService.AddComPlayerLand(comPlayerLand);
+
+            Map map = new HashMap();
+            map.put("LandInfo", getComPlayerLandAndPlantVo(comPlayerLand));
+            map.put("times", _getTimes - 1);
+            redisLock.unlock(_redisKey, String.valueOf(landTime));
+            return Result.of(map, true, "租赁成功");
+        } catch (Exception e) {
+            redisLock.unlock(_redisKey, String.valueOf(landTime));
+            return ErrorResult(e.getMessage());
+        }
+    }
+
+    /**
+     * 修改某个土地 【牧场养殖渔场】
+     *
+     * @param userId
+     * @param configLandId
+     * @param multiple
+     * @return
+     */
+    @Transactional
+    @Override
+    public Result<?> multipleLand(String userId, Integer configLandId, Integer multiple) {
+
+        //倍数不能为零
+        if (multiple <= 0) {
+            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) {
+            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());
+        }
+        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);
             return ErrorResult("操作频繁!");
         }
         try {
-            if (getTimes(userId) <= 0) {
-                return Result.of(null, false, ResultEnum.LAND_NO_TIMES_ERROR.getMessage(), ResultEnum.LAND_NO_TIMES_ERROR.getCode());
-            }
-            if (comPlayerLand == null) {
-                //创建新土地
-                comPlayerLand = new ComPlayerLand();
-                comPlayerLand.setConfigLandId(comConfigLand.getId());
-                comPlayerLand.setUserId(userId);
-                comPlayerLand.setName(comConfigLand.getName());
-                //todo 续租问题,如果用户续租,保留之前的状态
-                //初始化一下未种植参数
-                comPlayerLand.setIsPlant(0);
-                comPlayerLand.setCreateTime(new Date());
-                comPlayerLand.setPlantSteal(1);
-                comPlayerLand.setMallType(comConfigLand.getMallType());
-
-                comPlayerLand.setLandDescribe("每次租赁1个月");
-                comPlayerLand.setLeaseMultiple(1);
-                comPlayerLand.setLeaseDate(1);
-                //设置租赁日期
-                comPlayerLand.setLeaseTime(DateUtil.offset(new Date(), DateField.MONTH, 1));
-                //租赁土地
-                comPlayerLand.setIsLease(1);
-                comPlayerLand.setUpdateTime(new Date());
-                //记录一下租赁费用
-                comPlayerLand.setRentalExpenses(1.0d);
-                comPlayerLandService.AddComPlayerLand(comPlayerLand);
-            }
-            return Result.of(comPlayerLand, true, "租赁成功");
+            //修改
+            comPlayerLand.setLeaseMultiple(multiple);
+            comPlayerLandService.AddComPlayerLand(comPlayerLand);
+            redisLock.unlock(_redisKey, String.valueOf(landTime));
+            return Result.of(CopyUtil.copy(comPlayerLand, ComPlayerLandVo.class), true, "修改养殖场成功");
         } catch (Exception e) {
-        } finally {
             redisLock.unlock(_redisKey, String.valueOf(landTime));
         }
-        return ErrorResult("租赁失败!");
+        return ErrorResult("修改养殖场失败!");
     }
 
     /**
@@ -131,11 +182,11 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
     public Integer getTimes(String userId) {
         Integer totalcount = DappUtil.getChildrenBuyLandCount(userId);
         long nowcount = comPlayerLandService.findAllByUserId(userId).stream()
-                .filter(a -> a.getMallType() != null && ArrayUtil.contains(CultivateKeys.mallType,a.getMallType())).count();
+                .filter(a -> a.getMallType() != null && ArrayUtil.contains(CultivateKeys.mallType, a.getMallType())).count();
         ComExplainLandVo comExplainLandVo = new ComExplainLandVo();
         comExplainLandVo.setUserId(userId);
         Result<List<ComExplainLandVo>> list = comExplainLandService.list(comExplainLandVo);
-        long historycount = list.getData().stream().filter(a -> a.getMallType() != null && ArrayUtil.contains(CultivateKeys.mallType,a.getMallType())).count();
+        long historycount = list.getData().stream().filter(a -> a.getMallType() != null && ArrayUtil.contains(CultivateKeys.mallType, a.getMallType())).count();
         return totalcount - Convert.toInt(nowcount) - Convert.toInt(historycount);
     }
 
@@ -218,7 +269,9 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
             comPlayerCultivate.setActivtyTime(new Date());
             comPlayerCultivate.setSnb(_needPrice);
             cultivateRepository.save(comPlayerCultivate);
-            return Result.of(null, true, "成功");
+
+
+            return Result.of(getComPlayerLandAndPlantVo(comPlayerLand), true, "成功");
         } catch (Exception e) {
         } finally {
             redisLock.unlock(_redisKey, String.valueOf(time));
@@ -250,13 +303,14 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
         long l = (days - times) * 2;
         //延期后的日期=成熟期+追加天数
         //当天也算一天。过了0点就是新的一天
-        return Convert.toInt(l, 0) + comPlayerLand.getPlantMature() - 1;
+        return comPlayerLand.getPlantMature();// Convert.toInt(l, 0) + comPlayerLand.getPlantMature() - 1;
     }
 
     /**
      * 是否已经喂养
-     * @param userId 用户编号
-     * @param landType 土地类型 具体是养殖、渔场、放养
+     *
+     * @param userId       用户编号
+     * @param landType     土地类型 具体是养殖、渔场、放养
      * @param configLandId
      * @param begin
      * @param end
@@ -281,4 +335,59 @@ public class ComPlayerCultivateSerivceImpl implements ComPlayerCultivateSerivce
     private Result<?> ErrorResult(String msg) {
         return Result.of(null, false, msg);
     }
+
+    /**
+     * 获取一个养殖的对象
+     *
+     * @param comPlayerLand
+     * @return
+     */
+    private ComPlayerLandAndPlantVo getComPlayerLandAndPlantVo(ComPlayerLand comPlayerLand) {
+
+        ComPlayerLandAndPlantVo comPlayerLandAndPlantVo = CopyUtil.copy(comPlayerLand, ComPlayerLandAndPlantVo.class);
+        Long leaseDaysMill = comPlayerLandAndPlantVo.getLeaseTime().getTime() - com.td.boss.util.DateUtil.getNowDate().getTime();
+        Long leaseAllMill = comPlayerLandAndPlantVo.getLeaseTime().getTime() - comPlayerLandAndPlantVo.getCreateTime().getTime();
+        Integer allDays = com.td.boss.util.DateUtil.getDays(leaseAllMill).intValue() <= 0 ? 0 : com.td.boss.util.DateUtil.getDays(leaseAllMill).intValue();
+        comPlayerLandAndPlantVo.setLeaseDays(allDays);
+        Integer leaseDays = com.td.boss.util.DateUtil.getDays(leaseDaysMill).intValue() <= 0 ? 0 : com.td.boss.util.DateUtil.getDays(leaseDaysMill).intValue();
+        comPlayerLandAndPlantVo.setLeaseDaysRemaining(leaseDays);
+        comPlayerLandAndPlantVo.setLeaseDaysMill(leaseDaysMill);
+        if (comPlayerLandAndPlantVo.getIsPlant().equals(1)) {
+            ComMallSeedVo comMallSeedVo = comMallSeedService.findById(comPlayerLandAndPlantVo.getPlantId());
+            //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
+            if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLandAndPlantVo.getMallType())) {
+                Integer days = getHarvestDays(comPlayerLandAndPlantVo.getUserId(), comPlayerLandAndPlantVo.getConfigLandId());
+                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(), begin, end);
+                comPlayerLandAndPlantVo.setAnimalEat(animalEat);
+            }
+            comPlayerLandAndPlantVo.setSeedInfo(comMallSeedVo);
+            Date _harvestTime = com.td.boss.util.DateUtil.getNowDateMinusDay(comMallSeedVo.getMaturity());
+            long diff = comPlayerLandAndPlantVo.getPlantStart().getTime() - _harvestTime.getTime();
+            comPlayerLandAndPlantVo.setPlantDaysMill(diff);
+            if (diff <= 0) {
+                //说明可以收获了
+                comPlayerLandAndPlantVo.setPlantDaysRemaining(0);
+                comPlayerLandAndPlantVo.setPlantHoursRemaining(0);
+                //todo [枯萎]
+                if (diff * -1 / CultivateKeys.dayLong > CultivateKeys.witheredDay) {
+                    comPlayerLandAndPlantVo.setWithered(true);
+                }
+                //这里不触发灾害
+            } else {
+                comPlayerLandAndPlantVo.setPlantDaysRemaining(com.td.boss.util.DateUtil.getDays(diff).intValue());
+                comPlayerLandAndPlantVo.setPlantHoursRemaining(com.td.boss.util.DateUtil.getHours(diff).intValue());
+            }
+        } else {
+            //未种植时候,设置为0
+            comPlayerLandAndPlantVo.setPlantDaysRemaining(0);
+            comPlayerLandAndPlantVo.setPlantHoursRemaining(0);
+        }
+
+        return comPlayerLandAndPlantVo;
+    }
 }

+ 40 - 22
src/main/java/com/td/boss/game/complayergoods/controller/ComPlayerGoodsController.java

@@ -136,6 +136,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
                 ComFruitAmountVo comFruitAmountVo = CopyUtil.copy(comFruitVo, ComFruitAmountVo.class);
                 comFruitAmountVo.setAmount(e.getAmount());
                 comFruitAmountVo.setAmountPart(e.getAmountPart());
+                comFruitAmountVo.setMallType(e.getMallType());
                 fruitList.add(comFruitAmountVo);
             }
             return e;
@@ -238,7 +239,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
         }
 
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
-        if (ArrayUtil.contains(CultivateKeys.mallType,comPlayerLand.getMallType())) {
+        if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType())) {
             Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, comPlayerLand.getConfigLandId());
             comMallSeedVo.setMaturity(days);
         }
@@ -248,14 +249,13 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
         // 两个时间差, 逻辑是_harvestTime 时间慢慢接近种植时间
         long diff = comPlayerLand.getPlantStart().getTime() - _harvestTime.getTime();
         //if (DateUtil.getNowDateMinusDay(comMallSeedVo.getMaturity()).getTime() < comPlayerLand.getPlantStart().getTime())
-        boolean isWithered=false;
+        boolean isWithered = false;
         if (diff > 0) {
             //如果当前时间减去种子的成熟期,还是小于种植日期,则判断未成熟
             return Result.of(null, false, ResultEnum.SEED_DATE_ERROR.getMessage(), ResultEnum.SEED_DATE_ERROR.getCode());
-        }
-        else {
+        } else {
             //判断是否枯萎
-            isWithered= diff*-1/CultivateKeys.dayLong>CultivateKeys.witheredDay;
+            isWithered = diff * -1 / CultivateKeys.dayLong > CultivateKeys.witheredDay;
         }
         //获取数据库相关配置
         ComSettingVo comSettingVo = comSettingService.get("1").getData();
@@ -301,21 +301,29 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             //计算一个收获量, 租赁倍数* 租赁日期下的产量
             Integer _amount = 0;
             Double _amountPart = 0d;
-            if (comPlayerLand.getLeaseDate().equals(1)) {
-                _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
-            } else if (comPlayerLand.getLeaseDate().equals(2)) {
-                _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
-            } else if (comPlayerLand.getLeaseDate().equals(3)) {
-                _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+
+            //种植的收获量
+            if (comPlayerLand.getMallType().equals(0)) {
+                if (comPlayerLand.getLeaseDate().equals(1)) {
+                    _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest1();
+                } else if (comPlayerLand.getLeaseDate().equals(2)) {
+                    _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest2();
+                } else if (comPlayerLand.getLeaseDate().equals(3)) {
+                    _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvest3();
+                }
+            } else {
+                //养殖的收获计算,这里直接用租赁时候消耗倍数 和 harvestQuantity 来计算
+                _amount = comPlayerLand.getLeaseMultiple() * comMallSeedVo.getHarvestQuantity();
             }
+
             //todo 收获果实时候,需要减去一个被偷取的利润,然后判断一个是否大于设置的利润,超出了报异常,并且收取的数量不能为小于0
             //     拿出计算利润,收获量减去种子的成本(snb)后的百分之20 ,后面需要后台可调整
             Integer _profit = _amount - comPlayerLand.getLeaseMultiple() * comMallSeedVo.getPriceSnb();
             // 配置的参数。这里先直接定义
-            Double profitConfig = comSettingVo.getProfit(), stealRatioMaxConfig = comSettingVo.getStealMaxRatio(), stealRatioMinConfig = comSettingVo.getStealMinRatio(), finallyGetRatioConfig = comSettingVo.getFinalRatio();
+            // Double profitConfig = comSettingVo.getProfit(), stealRatioMaxConfig = comSettingVo.getStealMaxRatio(), stealRatioMinConfig = comSettingVo.getStealMinRatio(), finallyGetRatioConfig = comSettingVo.getFinalRatio();
             Double landLevelInCome = getLandLevelInCome(comPlayerLand, comMallSeedVo.getPriceSnb());
             Double _profitDouble = DoubleUtil.add(_profit.doubleValue(), landLevelInCome);
-            Double _residualProfit = DoubleUtil.mul(_profitDouble, DoubleUtil.sub(1d, profitConfig));//如果 profitConfig 0.2,剩余利润就是0.8;
+            //Double _residualProfit = DoubleUtil.mul(_profitDouble, DoubleUtil.sub(1d, profitConfig));//如果 profitConfig 0.2,剩余利润就是0.8;
             //Double _stealAmount = DoubleUtil.sub(_profitDouble, _residualProfit); //可偷取的利润
 
             //todo 计算总共损失的数量
@@ -349,9 +357,9 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             _amountPart = _userHarvestPart;// DoubleUtil.add(_residualProfit, _userHarvestPart);
 
             //todo [枯萎] 没枯萎才有利润
-            if(isWithered) {
-                _amount=0;
-                _amountPart=0d;
+            if (isWithered) {
+                _amount = 0;
+                _amountPart = 0d;
             }
             //果实 Type =1
             ComPlayerGoods comPlayerGoodsSimpleVo = comPlayerGoodsService.findByUserIdAndIndexAndType(userId, comMallSeedVo.getHarvestId(), 1);
@@ -383,7 +391,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
 
                 _afterProfitPart = comPlayerGoodsSimpleVo.getAmountPart();
             }
-            if(isWithered==false) {
+            if (isWithered == false) {
                 ComPlayerGoodsVo comPlayerGoodsVo = CopyUtil.copy(comPlayerGoodsSimpleVo, ComPlayerGoodsVo.class);
                 comPlayerGoodsService.save(comPlayerGoodsVo);
             }
@@ -393,7 +401,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             _playerLog.setUserId(userId);
             _playerLog.setTId(comMallSeedVo.getHarvestId());
             _playerLog.setTName(comMallSeedVo.getHarvestName());
-            _playerLog.setTType(0);//设置一个默认水果id
+            _playerLog.setTType(0);//设置一个 收成,比如果实,养殖后收成等
             _playerLog.setTAmount(_amount);
             _playerLog.setBeforeAmount(_beforeAmount);
             ////交易后的数据
@@ -404,6 +412,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             _playerLog.setBeforePart(_beforeProfitPart);
             _playerLog.setAfterPart(_afterProfitPart);
             _playerLog.setLMultiple(comPlayerLand.getLeaseMultiple());
+            _playerLog.setWithered(isWithered ? 1 : 0); //枯萎就设置 1
             ComPlayerLogVo _playerLogVo = CopyUtil.copy(_playerLog, ComPlayerLogVo.class);
             comPlayerLogService.save(_playerLogVo);
 
@@ -415,7 +424,12 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             } catch (Exception e) {
                 System.err.println("断电损耗异常:" + e.getMessage());
             }
-            map.put("msg",isWithered?"果实已枯萎": "成功收取果实!");
+            if (ArrayUtil.contains(CultivateKeys.mallType, comPlayerLand.getMallType())) {
+                map.put("msg", isWithered ? "养殖动物已死亡!" : "成功收获动物!");
+            } else {
+                map.put("msg", isWithered ? "种植果实已枯萎" : "成功收取果实!");
+            }
+            map.put("isWithered", isWithered);
             //redisLock.unlock(_disasterKey, String.valueOf(_disasterTime));
         } catch (Exception e) {
             //对应的,存在plantFlag则解锁
@@ -557,8 +571,8 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             return Result.of(null, false, ResultEnum.SEED_DATA_ERROR.getMessage(), ResultEnum.SEED_DATA_ERROR.getCode());
         }
         //todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
-        if (ArrayUtil.contains(CultivateKeys.mallType,otherPlayerLand.getMallType())) {
-            Integer days = comPlayerCultivateSerivce.getHarvestDays(userId, otherPlayerLand.getConfigLandId());
+        if (ArrayUtil.contains(CultivateKeys.mallType, otherPlayerLand.getMallType())) {
+            Integer days = comPlayerCultivateSerivce.getHarvestDays(otherUserId, otherPlayerLand.getConfigLandId());
             comMallSeedVo.setMaturity(days);
         }
         // 判断是否成熟
@@ -570,7 +584,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             return Result.of(null, false, ResultEnum.SEED_DATE_ERROR.getMessage(), ResultEnum.SEED_DATE_ERROR.getCode());
         }
         //todo [枯萎] 超过一定时间不收取 就枯萎
-        else if(diff <0&&diff*-1/CultivateKeys.dayLong>CultivateKeys.witheredDay) {
+        else if (diff < 0 && diff * -1 / CultivateKeys.dayLong > CultivateKeys.witheredDay) {
             return Result.of(null, false, ResultEnum.SEED_LAND_WITHERED.getMessage(), ResultEnum.SEED_LAND_WITHERED.getCode());
         }
 
@@ -790,6 +804,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             _playerLog.setTLoss(_lostStealAmount); //损失的部分
             _playerLog.setAfterPart(comPlayerGoods.getAmountPart());
             _playerLog.setLMultiple(otherPlayerLand.getLeaseMultiple());
+            _playerLog.setWithered(0);
             ComPlayerLogVo _playerLogVo = CopyUtil.copy(_playerLog, ComPlayerLogVo.class);
             comPlayerLogService.save(_playerLogVo);
 
@@ -1341,6 +1356,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             _saleFruitPlayerLog.setBeforePart(_selfBeforeFruitAmountPart);
             _saleFruitPlayerLog.setAfterPart(_selfAfterFruitAmountPart);
             _saleFruitPlayerLog.setLMultiple(0);//收获时候,会有一个倍数
+            _saleFruitPlayerLog.setWithered(0); //枯萎就设置 1
             ComPlayerLogVo _saleFruitPlayerLogVo = CopyUtil.copy(_saleFruitPlayerLog, ComPlayerLogVo.class);
             comPlayerLogService.save(_saleFruitPlayerLogVo);
 
@@ -1467,6 +1483,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             ////交易后的数据
             _selfPlayerLog.setAfterAmount(_selfAfterAmount);
             _selfPlayerLog.setLMultiple(0);//收获时候,会有一个倍数
+            _selfPlayerLog.setWithered(0);
             ComPlayerLogVo _selfPlayerLogVo = CopyUtil.copy(_selfPlayerLog, ComPlayerLogVo.class);
             comPlayerLogService.save(_selfPlayerLogVo);
 
@@ -1511,6 +1528,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
             _targetPlayerLog.setAfterPart(_selfAfterFruitAmountPart);
 
             _targetPlayerLog.setLMultiple(0);
+            _targetPlayerLog.setWithered(0);
             ComPlayerLogVo _targetPlayerLogVo = CopyUtil.copy(_targetPlayerLog, ComPlayerLogVo.class);
             comPlayerLogService.save(_targetPlayerLogVo);
         } catch (Exception e) {

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

@@ -397,11 +397,11 @@ public class ComPlayerLandController extends CommonController<ComPlayerLandVo, C
                     return Result.of(null, false, "剩余租赁时间不足!");
                 }
                 //验证该土地最大种植数量
-                if (amount > CultivateKeys.amountLimit[comPlayerLand.getMallType() - 1]) {
+                if (comPlayerLand.getLeaseMultiple() > CultivateKeys.amountLimit[comPlayerLand.getMallType() - 1]) {
                     return Result.of(null, false, "超出最大养殖数量!");
                 }
                 //lease_multiple租赁倍数 填入实际养殖数量
-                comPlayerLand.setLeaseMultiple(amount);
+                //comPlayerLand.setLeaseMultiple(amount);
             }
 
             //todo 背包种子减去 土地当前的倍数,需要多倍播种,即消耗多个种子

+ 6 - 0
src/main/java/com/td/boss/game/complayerland/vo/ComPlayerLandSimpleVo.java

@@ -59,4 +59,10 @@ public class ComPlayerLandSimpleVo implements Serializable {
     private Date updateTime;
 
     private Integer landLevel;//土地级别
+
+    /**
+     * 需求 牧场养殖渔场,新增字段,
+     * 原有需求种地值0 牧场1 养殖2 淡水区3 海水区4
+     */
+    private Integer mallType;
 }

+ 2 - 0
src/main/java/com/td/boss/game/complayerlog/pojo/ComPlayerLog.java

@@ -37,6 +37,8 @@ public class ComPlayerLog implements Serializable {
 
     private Integer lMultiple;//如果是操作土地相关,land 数据,记录一下倍数
 
+    private Integer withered;//添加一个枯萎记录 , 0 没有,1 枯萎或者动物死亡,2断损耗
+
     private Date createTime;//
 
     private Date updateTime;//

+ 1 - 0
src/main/java/com/td/boss/game/complayerlog/service/ComPlayerLogServiceImpl.java

@@ -109,6 +109,7 @@ public class ComPlayerLogServiceImpl extends CommonServiceImpl<ComPlayerLogVo, C
             playerLog.setAfterPart(goods.getAmountPart());
             // 收获时候,会有一个倍数
             playerLog.setLMultiple(0);
+            playerLog.setWithered(2); //断电损耗
             // 损失
             playerLog.setTLoss((goodsBeforeAmount + goodsBeforePart) * NumberUtil.div(dayDiff, 100));
             playerLog.setCreateTime(serverDate);

+ 2 - 0
src/main/java/com/td/boss/game/complayerlog/vo/ComPlayerLogVo.java

@@ -36,6 +36,8 @@ public class ComPlayerLogVo extends PageCondition implements Serializable {
 
     private Double afterPart;//收取交易后的数量
 
+    private Integer withered;//添加一个枯萎记录 , 0 没有,1 枯萎或者动物死亡,2断损耗
+
     private Date createTime;//
 
     private Date updateTime;//

+ 2 - 2
src/main/java/com/td/boss/util/DappUtil.java

@@ -154,7 +154,7 @@ public class DappUtil {
             HttpEntity<MultiValueMap<String, Object>> files = new HttpEntity<>(form, headers);
             Map response = restTemplate.postForObject(DAppUrl, files, Map.class);
             log.info("response={}", response);
-            return (Integer) response.get("data");
+            return 100;// (Integer) response.get("data");
         } catch (Exception e) {
             log.error(e.getMessage());
             return 0;
@@ -192,7 +192,7 @@ public class DappUtil {
             HttpEntity<MultiValueMap<String, Object>> files = new HttpEntity<>(form, headers);
             Map response = restTemplate.postForObject(DAppUrl, files, Map.class);
             log.info("response={}", response);
-            return (Integer) response.get("data");
+            return 10000;// (Integer) response.get("data");
         } catch (Exception e) {
             log.error(e.getMessage());
             return 0;