| | |
| | | } |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | synchronized (user.getId()){ |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN",user.getId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("JP",user.getId()); |
| | | if (model.getNewCode() != null) { |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<StockSubscribe>() |
| | | .eq("newlist_id", model.getNewlistId())); |
| | |
| | | // bound = new BigDecimal(model.getApplyNums()).multiply(stockSubscribe.getPrice()); |
| | | // } |
| | | // |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.IN.getCode(), user.getId()); |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.JP.getCode(), user.getId()); |
| | | if(useEnaAmount.compareTo(bound)<0){ |
| | | return ServerResponse.createByErrorMsg("余额不足,配售失败",request); |
| | | } |
| | |
| | | UserStockSubscribe userStockSubscribe = Convert.convert(UserStockSubscribe.class, model); |
| | | userStockSubscribe.setNewStockId(stockSubscribe.getNewlistId()); |
| | | ret = userStockSubscribeMapper.insert(userStockSubscribe); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.JP.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | if (ret > 0) { |
| | | return ServerResponse.createBySuccessMsg("配售成功",request); |
| | | } else { |
| | |
| | | } |
| | | |
| | | //客户中签直接扣除客户账户可用资金 |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN", userStockSubscribe.getUserId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("JP", userStockSubscribe.getUserId()); |
| | | if (model.getStatus() == 3 && model.getApplyNumber() != null){ |
| | | if(stockSubscribe.getType() == 1){ |
| | | model.setBond((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | |
| | | } |
| | | BigDecimal cCount = new BigDecimal(model.getApplyNums()-model.getApplyNumber()); |
| | | BigDecimal tMoney = ((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice())).multiply(cCount); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(EStockType.JP.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.TOP_UP,tMoney,"",""); |
| | | model.setBond((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | | model.setDbMoney(BigDecimal.ZERO); |
| | |
| | | userStockSubscribe.setSubmitTime(DateTimeUtil.getCurrentDate()); |
| | | userStockSubscribe.setStatus(4); |
| | | BigDecimal bigDecimal = iUserAssetsServices. |
| | | getAvailableBalance(EStockType.IN.getCode(), |
| | | getAvailableBalance(EStockType.JP.getCode(), |
| | | userStockSubscribe.getUserId()); |
| | | |
| | | BigDecimal multiply = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(userStockSubscribe.getApplyNumber())); |
| | | if(bigDecimal.compareTo(multiply) <= 0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | } |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(EStockType.JP.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.BUY,multiply.negate(),"",""); |
| | | userStockSubscribe.setDbMoney(BigDecimal.ZERO); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |