|
|
@@ -161,6 +161,10 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
@RequestParam(value = "seedId") Integer seedId,
|
|
|
@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);
|
|
|
if (comPlayerGood == null) {
|
|
|
@@ -240,7 +244,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
|
|
|
//todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
|
|
|
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);
|
|
|
}
|
|
|
// 收获,同时重置土地状态,先判断是否成熟
|
|
|
@@ -455,6 +459,11 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
@RequestParam(value = "userId") String userId,
|
|
|
@RequestParam(value = "otherUserId") String otherUserId,
|
|
|
@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();
|
|
|
|
|
|
//todo 计入狗和打狗棒
|
|
|
@@ -556,7 +565,7 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
if (otherPlayerLand == null) {
|
|
|
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());
|
|
|
}
|
|
|
|
|
|
@@ -568,10 +577,10 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
}
|
|
|
//todo [牧场养殖渔场需求] 如果是养殖类的,计算延期后的成熟期
|
|
|
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);
|
|
|
}
|
|
|
- Integer witheredDay = comConfigService.selectByKey( CultivateKeys.witheredDay, Integer.class);
|
|
|
+ Integer witheredDay = comConfigService.selectByKey(CultivateKeys.witheredDay, Integer.class);
|
|
|
|
|
|
// 判断是否成熟
|
|
|
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());
|
|
|
}
|
|
|
//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());
|
|
|
}
|
|
|
|
|
|
@@ -616,6 +625,8 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
|
|
|
}
|
|
|
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());
|
|
|
}
|
|
|
@@ -629,6 +640,9 @@ public class ComPlayerGoodsController extends CommonController<ComPlayerGoodsVo,
|
|
|
for (int i = 0; i < comPlayerProfits.size(); i++) {
|
|
|
ComPlayerProfit temp = comPlayerProfits.get(i);
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
@@ -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);
|
|
|
+ //}
|
|
|
}
|