| | |
| | | }else{ |
| | | bound = new BigDecimal(model.getApplyNums()).multiply(stockSubscribe.getPrice()); |
| | | } |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.MX.getCode())) { |
| | | /*//如果不是默认货币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.getDefault().getCode())) { |
| | | bound = iUserAssetsServices.exchangeAmountByRate(stockSubscribe.getStockType(), bound); |
| | | } |
| | | }*/ |
| | | if(userAssets.getAvailableBalance().compareTo(bound) < 0){ |
| | | return ServerResponse.createByErrorMsg("账户余额不足", request); |
| | | } |
| | |
| | | userAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().add(subtract.abs())); |
| | | } |
| | | userAssetsMapper.updateById(userAssets); |
| | | //交易记录MEX |
| | | //交易记录 |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | EUserAssets eUserAssets = EUserAssets.BUY; |
| | | moneyLog.setDescs(eUserAssets.getDesc()); |
| | | moneyLog.setBeFore(before); |
| | | moneyLog.setAfter(userAssets.getAvailableBalance().toString()); |
| | | moneyLog.setAmount(bound.negate().toString()); |
| | | moneyLog.setAccectType(EStockType.MX.getCode()); |
| | | moneyLog.setAccectType(stockSubscribe.getStockType()); |
| | | moneyLog.setType(eUserAssets.getCode()); |
| | | moneyLog.setUserId(user.getId()+""); |
| | | moneyLog.setSymbol(EStockType.MX.getSymbol()); |
| | | moneyLog.setSymbol(EStockType.getEStockTypeByCode(stockSubscribe.getStockType()).getSymbol()); |
| | | moneyLog.setCreateTime(new Date()); |
| | | moneyLogMapper.insert(moneyLog); |
| | | if (ret > 0) { |
| | |
| | | if(applyNumber > 0){ |
| | | //需要退回的资金 |
| | | refundPrice = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(applyNumber)); |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.MX.getCode())) { |
| | | /*//如果不是默认货币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.getDefault().getCode())) { |
| | | refundPrice = iUserAssetsServices.exchangeAmountByRate(stockSubscribe.getStockType(), refundPrice); |
| | | } |
| | | }*/ |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(refundPrice)); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(refundPrice)); |
| | | } |
| | | }else{ |
| | | if(applyNumber > 0){ |
| | | refundPrice = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(applyNumber)); |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.MX.getCode())) { |
| | | /*//如果不是默认货币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.getDefault().getCode())) { |
| | | refundPrice = iUserAssetsServices.exchangeAmountByRate(stockSubscribe.getStockType(), refundPrice); |
| | | } |
| | | }*/ |
| | | BigDecimal subtract = refundPrice.subtract(userAssets.getAmountToBeCovered()); |
| | | if(subtract.compareTo(BigDecimal.ZERO) <= 0){//如果退回的资金不足补足待补则直接减 |
| | | userAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().subtract(refundPrice)); |
| | |
| | | } |
| | | } |
| | | } |
| | | //退回资金 交易记录MEX |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | EUserAssets eUserAssets = EUserAssets.BUY_RT; |
| | | moneyLog.setDescs(eUserAssets.getDesc()); |
| | | moneyLog.setBeFore(before); |
| | | moneyLog.setAfter(userAssets.getAvailableBalance().toString()); |
| | | moneyLog.setAmount(refundPrice.toString()); |
| | | moneyLog.setAccectType(EStockType.MX.getCode()); |
| | | moneyLog.setType(eUserAssets.getCode()); |
| | | moneyLog.setUserId(userAssets.getUserId()+""); |
| | | moneyLog.setSymbol(EStockType.MX.getSymbol()); |
| | | moneyLog.setCreateTime(new Date()); |
| | | moneyLogMapper.insert(moneyLog); |
| | | //如果退回资金 add交易记录MEX |
| | | if (refundPrice.compareTo(BigDecimal.ZERO) > 0) { |
| | | MoneyLog moneyLog = new MoneyLog(); |
| | | EUserAssets eUserAssets = EUserAssets.BUY_RT; |
| | | moneyLog.setDescs(eUserAssets.getDesc()); |
| | | moneyLog.setBeFore(before); |
| | | moneyLog.setAfter(userAssets.getAvailableBalance().toString()); |
| | | moneyLog.setAmount(refundPrice.toString()); |
| | | moneyLog.setAccectType(stockSubscribe.getStockType()); |
| | | moneyLog.setType(eUserAssets.getCode()); |
| | | moneyLog.setUserId(userAssets.getUserId()+""); |
| | | moneyLog.setSymbol(EStockType.getEStockTypeByCode(stockSubscribe.getStockType()).getSymbol()); |
| | | moneyLog.setCreateTime(new Date()); |
| | | moneyLogMapper.insert(moneyLog); |
| | | } |
| | | ret = userStockSubscribeMapper.update1(model); |
| | | userAssetsMapper.updateById(userAssets); |
| | | iUserPositionService.newStockToPosition(model.getId(),userAssets.getAmountToBeCovered());//转持仓 |
| | |
| | | String header = request.getHeader(property); |
| | | if (header != null) { |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | |
| | | List<UserStockSubscribeVo> userStockSubscribe = this.userStockSubscribeMapper.getListByParam(user.getId(), type, status); |
| | | /*if (type==null||type.equals("")){ |
| | | userStockSubscribe = this.userStockSubscribeMapper.selectList(new QueryWrapper<>(new UserStockSubscribe()).eq("user_id", user.getId()).orderByDesc("add_time")); |
| | | }else{ |
| | | userStockSubscribe = this.userStockSubscribeMapper.selectList(new QueryWrapper<>(new UserStockSubscribe()).eq("user_id", user.getId()).eq("type", type).orderByDesc("add_time")); |
| | | }*/ |
| | | |
| | | List<UserStockSubscribeVo> list = new ArrayList<>(); |
| | | for (UserStockSubscribeVo userStockSubscribe1 : userStockSubscribe) { |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<>(new StockSubscribe()) |
| | | .eq("newlist_id", userStockSubscribe1.getNewStockId())); |
| | | if (stockSubscribe != null) { |
| | | list.add(userStockSubscribe1); |
| | | } |
| | | } |
| | | return ServerResponse.createBySuccess(list); |
| | | return ServerResponse.createBySuccess(userStockSubscribe); |
| | | } |
| | | return ServerResponse.createByErrorCodeMsg(ResponseCode.NEED_LOGIN.getCode(),"请先登录"); |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse getOneSubscribeByUserIdPage(int pageNum,int pageSize,String type, Integer status, HttpServletRequest request) { |
| | | String property = PropertiesUtil.getProperty("user.cookie.name"); |
| | | String header = request.getHeader(property); |
| | | if (header != null) { |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<UserStockSubscribeVo> userStockSubscribe = this.userStockSubscribeMapper.getListByParam(user.getId(), type, status); |
| | | PageInfo<UserStockSubscribeVo> pageInfo = new PageInfo<>(userStockSubscribe); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | | return ServerResponse.createByErrorCodeMsg(ResponseCode.NEED_LOGIN.getCode(),"请先登录"); |
| | | } |
| | | |
| | | /** |
| | | * 新股申购-用户提交金额 |
| | | */ |