| | |
| | | if (totalAmount.compareTo(wallet.getMoney()) > 0) { |
| | | throw new YamiShopBindException("余额不足"); |
| | | } |
| | | BigDecimal before = wallet.getMoney(); |
| | | walletService.update(partyId, totalAmount.negate().doubleValue()); |
| | | |
| | | // 保存 资金日志 |
| | | MoneyLog moneylog = new MoneyLog(); |
| | | moneylog.setCategory(Constants.MONEYLOG_CONTENT_NEW_COIN); |
| | | moneylog.setAmountBefore(wallet.getMoney()); |
| | | moneylog.setAmount(totalAmount); |
| | | moneylog.setAmountAfter(wallet.getMoney().subtract(totalAmount)); |
| | | moneylog.setAmountBefore(before); |
| | | moneylog.setAmount(totalAmount.negate()); |
| | | moneylog.setAmountAfter(before.subtract(totalAmount)); |
| | | moneylog.setLog("新币购买,申购金额[" + amount + "]" + "手续费金额[" + fee + "]"); |
| | | moneylog.setUserId(partyId); |
| | | moneylog.setSymbol(ico.getSymbol()); |
| | |
| | | if (userSubscription.getStatus() == 5) { |
| | | throw new YamiShopBindException("It's been converted"); |
| | | } |
| | | if(userSubscription.getStatus() == 3){ |
| | | if(userSubscription.getStatus() == 3 || userSubscription.getStatus() == 2){ |
| | | throw new YamiShopBindException("不能更改申购状态"); |
| | | } |
| | | Ico ico = this.getById(userSubscription.getIcoProjectId()); |
| | |
| | | } |
| | | userSubscription.setStatus(model.getStatus()); |
| | | userSubscription.setBallotNumber(model.getBallotNumber()); |
| | | if (model.getStatus() == 3) { //中签 |
| | | //资金账户 |
| | | Wallet wallet = walletService.saveWalletByPartyId(userId); |
| | | BigDecimal before = wallet.getMoney(); |
| | | |
| | | //资金账户 |
| | | Wallet wallet = walletService.saveWalletByPartyId(userId); |
| | | BigDecimal before = wallet.getMoney(); |
| | | if (model.getStatus() == 2) { //未中签 |
| | | //预支付退回全部资金 |
| | | if(ico.getIsPayDown() !=null && ico.getIsPayDown() == 1) { |
| | | BigDecimal refundPrice = ico.getUnitAmount().multiply(new BigDecimal(userSubscription.getSubscribeNums())); |
| | | BigDecimal fee = ico.getUnitFee().multiply(new BigDecimal(userSubscription.getSubscribeNums())); |
| | | BigDecimal totalAmount = refundPrice.add(fee); |
| | | wallet = walletService.updateToBeCovered(wallet, totalAmount, 1); |
| | | //保存 资金日志 |
| | | MoneyLog moneylog = new MoneyLog(); |
| | | moneylog.setCategory(Constants.MONEYLOG_CONTENT_NEW_COIN); |
| | | moneylog.setAmountBefore(before); |
| | | moneylog.setAmount(totalAmount); |
| | | moneylog.setAmountAfter(wallet.getMoney()); |
| | | moneylog.setLog("新币未中签,退回金额[" + refundPrice + "]" + "退回手续费[" + fee + "]"); |
| | | moneylog.setUserId(userId); |
| | | moneylog.setSymbol(ico.getSymbol()); |
| | | moneylog.setWalletType(ico.getSymbol()); |
| | | moneylog.setContentType(Constants.MONEYLOG_CONTENT_NEW_COIN_RT_BUY); |
| | | moneyLogService.save(moneylog); |
| | | } |
| | | } else if (model.getStatus() == 3) { //中签 |
| | | //已经预支付 |
| | | if(ico.getIsPayDown() !=null && ico.getIsPayDown() == 1) { |
| | | int applyNumber = userSubscription.getSubscribeNums() - model.getBallotNumber(); |
| | | BigDecimal amount = ico.getUnitAmount().multiply(new BigDecimal(applyNumber)); |
| | | if(applyNumber > 0) { |
| | | //退回资金 |
| | | BigDecimal refundPrice = ico.getUnitAmount().multiply(new BigDecimal(applyNumber)); |
| | |
| | | MoneyLog moneylog = new MoneyLog(); |
| | | moneylog.setCategory(Constants.MONEYLOG_CONTENT_NEW_COIN); |
| | | moneylog.setAmountBefore(before); |
| | | moneylog.setAmount(totalAmount); |
| | | moneylog.setAmount(totalAmount.negate()); |
| | | moneylog.setAmountAfter(wallet.getMoney()); |
| | | moneylog.setLog("新币购买,申购金额[" + amount + "]" + "手续费金额[" + fee + "]"); |
| | | moneylog.setUserId(userId); |