| | |
| | | if(moneyCardUse.getGiftMoney() >= flow.getAmount().doubleValue()) { |
| | | double surplus = MoneyUtil.sub(moneyCardUse.getGiftMoney(), flow.getAmount().doubleValue()); |
| | | moneyCardUse.setGiftMoney(surplus); |
| | | |
| | | moneyCardUseFlow.setGiftMoney(0D - flow.getAmount().doubleValue()); |
| | | } else { |
| | | throw new GlobleException(moneyCardUse.getCardName() + "余额不足"); |
| | |
| | | if(moneyCardUse.getRealMoney() >= flow.getAmount().doubleValue()) { |
| | | double surplus = MoneyUtil.sub(moneyCardUse.getRealMoney(), flow.getAmount().doubleValue()); |
| | | moneyCardUse.setRealMoney(surplus); |
| | | |
| | | moneyCardUseFlow.setTotal(0 - flow.getAmount().doubleValue()); |
| | | } else { |
| | | throw new GlobleException(moneyCardUse.getCardName() + "余额不足"); |
| | | } |
| | | } |
| | | |
| | | if (moneyCardUse.getIsVipCar().equals(Dictionary.FLAG_NO_N)) { |
| | | //余额为0时充值卡变为无效 |
| | | if(moneyCardUse.getRealMoney().equals(0D) && moneyCardUse.getGiftMoney().equals(0D)){ |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | } |
| | | } |
| | | |
| | | ShoppingGoods shoppingGoods = shoppingGoodsService.findById(moneyCardUse.getGoodsId()); |
| | | if (shoppingGoods != null) { |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(shoppingGoods, 2, moneyCardUse.getFailTime()); |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | } |
| | | // 更新充值卡信息 |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | //设置卡项使用流水 |
| | | moneyCardUseFlow.setCarUseId(moneyCardUse.getId()); |
| | | moneyCardUseFlow.setOrderNo(sourceOrder.getOrderNo()); |
| | |
| | | moneyCardUseFlow.setOperationId(user.getSuId()); |
| | | moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney()+moneyCardUse.getRealMoney()); |
| | | moneyCardUseFlowDao.insert(moneyCardUseFlow); |
| | | |
| | | // 达到使用次数后自动清空余额 |
| | | if (!moneyCardUse.getIsVipCar().equals(Dictionary.FLAG_YES_Y) |
| | | && moneyCardUse.getLastCount() <= 0) { |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setLastCount(0); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | } |
| | | if (moneyCardUse.getRealMoney().equals(0D) && moneyCardUse.getGiftMoney().equals(0D)) { |
| | | moneyCardUse.setIsOver(Dictionary.FLAG_YES_Y); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_WX); |
| | | } |
| | | |
| | | ShoppingGoods shoppingGoods = shoppingGoodsService.findById(moneyCardUse.getGoodsId()); |
| | | if (shoppingGoods != null) { |
| | | Date invalidTime = shoppingGoodsService.calInvalidTime(shoppingGoods, 2, moneyCardUse.getFailTime()); |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | } |
| | | // 更新充值卡信息 |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | } |
| | | |
| | | /** |