| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.Repository.ExchangeRateRepository; |
| | | import com.nq.common.ResponseCode; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.StockSubscribeMapper; |
| | | import com.nq.dao.UserAssetsMapper; |
| | |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.utils.KeyUtils; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.utils.redis.JsonUtil; |
| | | import com.nq.utils.redis.RedisShardedPoolUtils; |
| | | import com.nq.utils.stock.BuyAndSellUtils; |
| | | import com.nq.vo.stock.UserStockSubscribeAddIn; |
| | | import com.sun.org.apache.bcel.internal.generic.RETURN; |
| | | import com.nq.vo.subscribe.UserStockSubscribeVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | UserAssetsMapper userAssetsMapper; |
| | | |
| | | @Autowired |
| | | ExchangeRateRepository exchangeRateRepository; |
| | | |
| | | /** |
| | | * 用户新股申购 |
| | | * @param model |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ServerResponse insert(UserStockSubscribeAddIn model, HttpServletRequest request) throws Exception { |
| | | int ret = 0; |
| | | if (model == null) { |
| | |
| | | if (siteProduct.getRealNameDisplay() && user.getIsActive() != 2) { |
| | | return ServerResponse.createByErrorMsg("订单失败,请先实名认证",request); |
| | | } |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stockSubscribe.getStockType(), user.getId()); |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stockSubscribe.getStockType(), user.getId()); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("请先缴清待补资金", request); |
| | | } |
| | |
| | | }else{ |
| | | bound = new BigDecimal(model.getApplyNums()).multiply(stockSubscribe.getPrice()); |
| | | } |
| | | |
| | | if(stockSubscribe.getType() == 1){ |
| | | model.setUserId(user.getId()); |
| | | model.setNewName(stockSubscribe.getName()); |
| | |
| | | userStockSubscribe.setNewStockId(stockSubscribe.getNewlistId()); |
| | | ret = userStockSubscribeMapper.insert(userStockSubscribe); |
| | | |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.MX.getCode())) { |
| | | bound = iUserAssetsServices.exchangeAmountByRate(stockSubscribe.getStockType(), bound); |
| | | } |
| | | BigDecimal subtract = userAssets.getAvailableBalance().subtract(bound); |
| | | if(subtract.compareTo(BigDecimal.ZERO) >= 0){ |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().add(bound)); |
| | |
| | | UserStockSubscribe userStockSubscribe = Convert.convert(UserStockSubscribe.class, model); |
| | | userStockSubscribe.setNewStockId(stockSubscribe.getNewlistId()); |
| | | ret = userStockSubscribeMapper.insert(userStockSubscribe); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(stockSubscribe.getStockType(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | if (ret > 0) { |
| | | return ServerResponse.createBySuccessMsg("配售成功",request); |
| | | } else { |
| | |
| | | * admin 新股申购-添加和修改 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public ServerResponse save(UserStockSubscribe model, HttpServletRequest request) throws Exception { |
| | | int ret = 0; |
| | | if( model.getId() != null ){ |
| | | if (model.getStatus() == 3||model.getStatus() == 2) { |
| | | model.setEndTime(DateTimeUtil.getCurrentDate()); |
| | | } |
| | | UserStockSubscribe userStockSubscribe = userStockSubscribeMapper.load(model.getId()); |
| | | if (userStockSubscribe.getStatus() == 5) { |
| | | return ServerResponse.createByErrorMsg("It's been converted"); |
| | | } |
| | | if(userStockSubscribe.getStatus() == 3){ |
| | | return ServerResponse.createByErrorMsg("不能更改申购状态"); |
| | | } |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<>(new StockSubscribe()) |
| | | .eq("newlist_id", userStockSubscribe.getNewStockId())); |
| | | if((model.getStatus() == 3 && model.getApplyNumber() == null) || (model.getStatus() == 3 && model.getApplyNumber() == 0) ){ |
| | | return ServerResponse.createByErrorMsg("中签数量不能小于0"); |
| | | } |
| | | if(model.getStatus() == 3 && model.getApplyNumber()>userStockSubscribe.getApplyNums()){ |
| | | return ServerResponse.createByErrorMsg("配置中签数量不能超过申请数量",request); |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ServerResponse save(UserStockSubscribe model, HttpServletRequest request){ |
| | | try { |
| | | int ret = 0; |
| | | if( model.getId() != null){ |
| | | if (model.getStatus() == 3||model.getStatus() == 2) { |
| | | model.setEndTime(DateTimeUtil.getCurrentDate()); |
| | | } |
| | | UserStockSubscribe userStockSubscribe = userStockSubscribeMapper.load(model.getId()); |
| | | if (userStockSubscribe.getStatus() == 5) { |
| | | return ServerResponse.createByErrorMsg("It's been converted"); |
| | | } |
| | | if(userStockSubscribe.getStatus() == 3){ |
| | | return ServerResponse.createByErrorMsg("不能更改申购状态"); |
| | | } |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<>(new StockSubscribe()) |
| | | .eq("newlist_id", userStockSubscribe.getNewStockId())); |
| | | if((model.getStatus() == 3 && model.getApplyNumber() == null) || (model.getStatus() == 3 && model.getApplyNumber() == 0) ){ |
| | | return ServerResponse.createByErrorMsg("中签数量不能小于0"); |
| | | } |
| | | if(model.getStatus() == 3 && model.getApplyNumber()>userStockSubscribe.getApplyNums()){ |
| | | return ServerResponse.createByErrorMsg("配置中签数量不能超过申请数量",request); |
| | | } |
| | | |
| | | //客户中签直接扣除客户账户可用资金 |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stockSubscribe.getStockType(), 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()))); |
| | | model.setDbMoney(model.getDbMoney()); |
| | | //客户中签直接扣除客户账户可用资金 |
| | | UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stockSubscribe.getStockType(), 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()))); |
| | | model.setDbMoney(model.getDbMoney()); |
| | | |
| | | if(null == userAssets){ |
| | | return ServerResponse.createByErrorMsg("客户资金账户不存在"); |
| | | } |
| | | int applyNumber = userStockSubscribe.getApplyNums() - model.getApplyNumber(); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) <= 0){ |
| | | if(applyNumber > 0){ |
| | | //需要退回的资金 |
| | | BigDecimal refundPrice = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(applyNumber)); |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(refundPrice)); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(refundPrice)); |
| | | if(null == userAssets){ |
| | | return ServerResponse.createByErrorMsg("客户资金账户不存在"); |
| | | } |
| | | }else{ |
| | | if(applyNumber > 0){ |
| | | BigDecimal refundPrice = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(applyNumber)); |
| | | BigDecimal subtract = refundPrice.subtract(userAssets.getAmountToBeCovered()); |
| | | if(subtract.compareTo(BigDecimal.ZERO) <= 0){//如果退回的资金不足补足待补则直接减 |
| | | userAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().subtract(refundPrice)); |
| | | }else{//如果退回的资金足够填补待补资金还有剩余,则返回余额 |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(refundPrice).add(userAssets.getAmountToBeCovered())); |
| | | userAssets.setAmountToBeCovered(BigDecimal.ZERO); |
| | | userAssets.setAvailableBalance(subtract); |
| | | int applyNumber = userStockSubscribe.getApplyNums() - model.getApplyNumber(); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) <= 0){ |
| | | if(applyNumber > 0){ |
| | | //需要退回的资金 |
| | | BigDecimal refundPrice = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(applyNumber)); |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.MX.getCode())) { |
| | | refundPrice = iUserAssetsServices.exchangeAmountByRate(stockSubscribe.getStockType(), refundPrice); |
| | | } |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(refundPrice)); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(refundPrice)); |
| | | } |
| | | }else{ |
| | | if(applyNumber > 0){ |
| | | BigDecimal refundPrice = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(applyNumber)); |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stockSubscribe.getStockType().equals(EStockType.MX.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)); |
| | | }else{//如果退回的资金足够填补待补资金还有剩余,则返回余额 |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(refundPrice).add(userAssets.getAmountToBeCovered())); |
| | | userAssets.setAmountToBeCovered(BigDecimal.ZERO); |
| | | userAssets.setAvailableBalance(subtract); |
| | | } |
| | | } |
| | | } |
| | | ret = userStockSubscribeMapper.update1(model); |
| | | userAssetsMapper.updateById(userAssets); |
| | | iUserPositionService.newStockToPosition(model.getId(),userAssets.getAmountToBeCovered());//转持仓 |
| | | model.setStatus(5); |
| | | }else{ |
| | | if(model.getApplyNumber()>model.getApplyNums()){ |
| | | return ServerResponse.createByErrorMsg("配置中签数量不能超过申请数量",request); |
| | | } |
| | | BigDecimal cCount = new BigDecimal(model.getApplyNums()-model.getApplyNumber()); |
| | | BigDecimal tMoney = ((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice())).multiply(cCount); |
| | | iUserAssetsServices.availablebalanceChange(stockSubscribe.getStockType(),userStockSubscribe.getUserId(), |
| | | EUserAssets.TOP_UP,tMoney,"",""); |
| | | model.setBond((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | | model.setDbMoney(BigDecimal.ZERO); |
| | | model.setStatus(4); |
| | | ret = userStockSubscribeMapper.update1(model); |
| | | } |
| | | ret = userStockSubscribeMapper.update1(model); |
| | | }else if (model.getStatus() == 2){ |
| | | BigDecimal bond = (stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNums())); |
| | | BigDecimal subtractMoney = bond.subtract(userAssets.getAmountToBeCovered());//需要退回的钱 |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(subtractMoney.abs())); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(subtractMoney)); |
| | | userAssets.setAmountToBeCovered(BigDecimal.ZERO); |
| | | userAssetsMapper.updateById(userAssets); |
| | | iUserPositionService.newStockToPosition(model.getId(),userAssets.getAmountToBeCovered());//转持仓 |
| | | model.setStatus(5); |
| | | }else{ |
| | | if(model.getApplyNumber()>model.getApplyNums()){ |
| | | return ServerResponse.createByErrorMsg("配置中签数量不能超过申请数量",request); |
| | | } |
| | | BigDecimal cCount = new BigDecimal(model.getApplyNums()-model.getApplyNumber()); |
| | | BigDecimal tMoney = ((stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice())).multiply(cCount); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.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); |
| | | model.setStatus(4); |
| | | ret = userStockSubscribeMapper.update1(model); |
| | | } |
| | | }else if (model.getStatus() == 2){ |
| | | BigDecimal bond = (stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()).multiply(BigDecimal.valueOf(model.getApplyNums())); |
| | | BigDecimal subtractMoney = bond.subtract(userAssets.getAmountToBeCovered());//需要退回的钱 |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(subtractMoney.abs())); |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(subtractMoney)); |
| | | userAssets.setAmountToBeCovered(BigDecimal.ZERO); |
| | | userAssetsMapper.updateById(userAssets); |
| | | ret = userStockSubscribeMapper.update1(model); |
| | | }else if (model.getStatus() == 5){ |
| | | }else if (model.getStatus() == 5){ |
| | | return iUserPositionService.newStockToPosition(model.getId(),BigDecimal.ZERO); |
| | | |
| | | } |
| | | } |
| | | if(ret>0 && model.getStatus() == 3 ){ |
| | | //给用户推送消息 |
| | | SiteMessage siteMessage = new SiteMessage(); |
| | |
| | | } |
| | | |
| | | } |
| | | } else{ |
| | | if(model.getPhone() != null&&model.getId()==null) { |
| | | User user = userMapper.findByPhone(model.getPhone()); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("User does not exist"); |
| | | } |
| | | model.setRealName(user.getRealName()); |
| | | model.setUserId(user.getId()); |
| | | model.setAgentId(user.getAgentId()); |
| | | model.setAgentName(user.getAgentName()); |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<>(new StockSubscribe()) |
| | | .eq("newlist_id", model.getNewStockId())); |
| | | if (stockSubscribe == null) { |
| | | return ServerResponse.createByErrorMsg("Failed. Ipo information does not exist"); |
| | | } |
| | | } else{ |
| | | if(model.getPhone() != null&&model.getId()==null) { |
| | | User user = userMapper.findByPhone(model.getPhone()); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("User does not exist"); |
| | | } |
| | | model.setRealName(user.getRealName()); |
| | | model.setUserId(user.getId()); |
| | | model.setAgentId(user.getAgentId()); |
| | | model.setAgentName(user.getAgentName()); |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<>(new StockSubscribe()) |
| | | .eq("newlist_id", model.getNewStockId())); |
| | | if (stockSubscribe == null) { |
| | | return ServerResponse.createByErrorMsg("Failed. Ipo information does not exist"); |
| | | } |
| | | |
| | | model.setNewName(stockSubscribe.getName()); |
| | | model.setBuyPrice(stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()); |
| | | if (model.getApplyNums() > stockSubscribe.getOrderNumber() || model.getApplyNumber() > stockSubscribe.getOrderNumber()) { |
| | | return ServerResponse.createByErrorMsg("The number of applications or the number of wins is the maximum" + stockSubscribe.getOrderNumber()); |
| | | model.setNewName(stockSubscribe.getName()); |
| | | model.setBuyPrice(stockSubscribe.getMinPrice() != null ? stockSubscribe.getMinPrice() : stockSubscribe.getPrice()); |
| | | if (model.getApplyNums() > stockSubscribe.getOrderNumber() || model.getApplyNumber() > stockSubscribe.getOrderNumber()) { |
| | | return ServerResponse.createByErrorMsg("The number of applications or the number of wins is the maximum" + stockSubscribe.getOrderNumber()); |
| | | } |
| | | model.setBond(model.getBuyPrice().multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | | model.setAddTime(DateTimeUtil.getCurrentDate()); |
| | | model.setOrderNo(KeyUtils.getUniqueKey()); |
| | | model.setType(stockSubscribe.getType()); |
| | | UserStockSubscribeAddIn convert = Convert.convert(UserStockSubscribeAddIn.class, model); |
| | | return insert(convert,request); |
| | | } |
| | | model.setBond(model.getBuyPrice().multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | | model.setAddTime(DateTimeUtil.getCurrentDate()); |
| | | model.setOrderNo(KeyUtils.getUniqueKey()); |
| | | model.setType(stockSubscribe.getType()); |
| | | UserStockSubscribeAddIn convert = Convert.convert(UserStockSubscribeAddIn.class, model); |
| | | return insert(convert,request); |
| | | } |
| | | if(ret>0){ |
| | | return ServerResponse.createBySuccessMsg("Successful operation"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(),e); |
| | | } |
| | | if(ret>0){ |
| | | return ServerResponse.createBySuccessMsg("Successful operation"); |
| | | } |
| | | |
| | | return ServerResponse.createByErrorMsg("Operation failure"); |
| | | } |
| | | /** |
| | |
| | | public ServerResponse<PageInfo> getList(int pageNum, int pageSize, String keyword, String agentId,HttpServletRequest request){ |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<UserStockSubscribe> listData = this.userStockSubscribeMapper.pageList(pageNum, pageSize, keyword,agentId); |
| | | PageInfo pageInfo = new PageInfo(listData); |
| | | pageInfo.setList(listData); |
| | | PageInfo<UserStockSubscribe> pageInfo = new PageInfo<>(listData); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | | |
| | |
| | | |
| | | /*新股申购-查询用户最新新股申购数据*/ |
| | | @Override |
| | | public ServerResponse getOneSubscribeByUserId(String type,HttpServletRequest request) { |
| | | public ServerResponse getOneSubscribeByUserId(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); |
| | | List<UserStockSubscribe> userStockSubscribe = null; |
| | | if (type==null||type.equals("")){ |
| | | |
| | | 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<UserStockSubscribe> list = new ArrayList<>(); |
| | | for (UserStockSubscribe userStockSubscribe1 : userStockSubscribe) { |
| | | 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) { |
| | |
| | | } |
| | | return ServerResponse.createBySuccess(list); |
| | | } |
| | | return ServerResponse.createByErrorMsg("请先登录",request); |
| | | return ServerResponse.createByErrorCodeMsg(ResponseCode.NEED_LOGIN.getCode(),"请先登录"); |
| | | } |
| | | /** |
| | | * 新股申购-用户提交金额 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ServerResponse userSubmit(Integer id,HttpServletRequest request) { |
| | | int ret = 0; |
| | | String property = PropertiesUtil.getProperty("user.cookie.name"); |
| | | String header = request.getHeader(property); |
| | | if (header != null) { |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | if(id == null){ |
| | | return ServerResponse.createByErrorMsg("参数错误",request); |
| | | } |
| | | UserStockSubscribe userStockSubscribe = userStockSubscribeMapper.load(id); |
| | | if (userStockSubscribe != null && userStockSubscribe.getUserId().equals(user.getId())) { |
| | | if(userStockSubscribe.getType()== 2 ){ |
| | | return ServerResponse.createByErrorMsg("未中签,无需支付",request); |
| | | try { |
| | | int ret = 0; |
| | | String property = PropertiesUtil.getProperty("user.cookie.name"); |
| | | String header = request.getHeader(property); |
| | | if (header != null) { |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | if(id == null){ |
| | | return ServerResponse.createByErrorMsg("参数错误",request); |
| | | } |
| | | if (userStockSubscribe.getStatus() == 3) { |
| | | userStockSubscribe.setSubmitTime(DateTimeUtil.getCurrentDate()); |
| | | userStockSubscribe.setStatus(4); |
| | | BigDecimal bigDecimal = iUserAssetsServices. |
| | | getAvailableBalance(EStockType.US.getCode(), |
| | | userStockSubscribe.getUserId()); |
| | | |
| | | BigDecimal multiply = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(userStockSubscribe.getApplyNumber())); |
| | | if(bigDecimal.compareTo(multiply) <= 0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | UserStockSubscribe userStockSubscribe = userStockSubscribeMapper.load(id); |
| | | if (userStockSubscribe != null && userStockSubscribe.getUserId().equals(user.getId())) { |
| | | if(userStockSubscribe.getType()== 2 ){ |
| | | return ServerResponse.createByErrorMsg("未中签,无需支付",request); |
| | | } |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.BUY,multiply.negate(),"",""); |
| | | userStockSubscribe.setDbMoney(BigDecimal.ZERO); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |
| | | return ServerResponse.createBySuccess(); |
| | | if (userStockSubscribe.getStatus() == 3) { |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<>(new StockSubscribe()) |
| | | .eq("newlist_id", userStockSubscribe.getNewStockId())); |
| | | if (stockSubscribe == null) { |
| | | return ServerResponse.createByErrorMsg("新股不存在",request); |
| | | } |
| | | userStockSubscribe.setSubmitTime(DateTimeUtil.getCurrentDate()); |
| | | userStockSubscribe.setStatus(4); |
| | | BigDecimal bigDecimal = iUserAssetsServices. |
| | | getAvailableBalance(EStockType.US.getCode(), |
| | | userStockSubscribe.getUserId()); |
| | | |
| | | BigDecimal multiply = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(userStockSubscribe.getApplyNumber())); |
| | | if(bigDecimal.compareTo(multiply) <= 0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | } |
| | | iUserAssetsServices.availablebalanceChange(stockSubscribe.getStockType(), userStockSubscribe.getUserId(), |
| | | EUserAssets.BUY,multiply.negate(),"",""); |
| | | userStockSubscribe.setDbMoney(BigDecimal.ZERO); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |
| | | return ServerResponse.createBySuccess(); |
| | | } else { |
| | | return ServerResponse.createByErrorMsg("不成功的申请者不收取任何费用",request); |
| | | } |
| | | } else { |
| | | return ServerResponse.createByErrorMsg("不成功的申请者不收取任何费用",request); |
| | | return ServerResponse.createByErrorMsg("新股认购订单不存在!",request); |
| | | } |
| | | } else { |
| | | return ServerResponse.createByErrorMsg("新股认购订单不存在!",request); |
| | | } |
| | | return ServerResponse.createByErrorCodeMsg(ResponseCode.NEED_LOGIN.getCode(),"请先登录"); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg(e.getMessage()); |
| | | } |
| | | return ServerResponse.createByErrorMsg("请先登录",request); |
| | | } |
| | | /** |
| | | * 新股申购-删除 |
| | |
| | | } |
| | | return ServerResponse.createByErrorMsg("Operation failure"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |