| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ResponseCode; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.EChoMapper; |
| | | import com.nq.dao.OrderEchoMapper; |
| | | import com.nq.dao.UserAssetsMapper; |
| | | import com.nq.dao.UserPositionMapper; |
| | | import com.nq.enums.EStockAIStatus; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.*; |
| | | import com.nq.pojo.reponse.OrderEChoReponse; |
| | | import com.nq.service.IEchoServices; |
| | | import com.nq.service.IUserService; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.vo.subscribe.UserStockSubscribeVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Override |
| | | public List<EChoBean> queryList() { |
| | | return eChoMapper.selectList(new LambdaQueryWrapper<EChoBean>()); |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse queryListPage(int pageNum, int pageSize) { |
| | | try { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<EChoBean> eChoBeans = eChoMapper.selectList(null); |
| | | PageInfo<EChoBean> pageInfo = new PageInfo<>(eChoBeans); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } catch (Exception ex) { |
| | | log.error("echoService queryListPage error", ex); |
| | | } |
| | | return ServerResponse.createByError(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse queryOrderEchoPage(int pageNum, int pageSize, HttpServletRequest request) { |
| | | try { |
| | | User user = iUserService.getCurrentRefreshUser(request); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorCodeMsg(ResponseCode.NEED_LOGIN.getCode(),"请先登录"); |
| | | } |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<OrderEchoOut> orderEchoOutList = orderEchoMapper.queryByUserId(user.getId()); |
| | | PageInfo<OrderEchoOut> pageInfo = new PageInfo<>(orderEchoOutList); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } catch (Exception ex) { |
| | | log.error("echoService queryOrderEchoPage error", ex); |
| | | } |
| | | return ServerResponse.createByError(); |
| | | } |
| | | |
| | | @Override |
| | | public List<OrderEChoReponse> queryALLOrderEcho() { |
| | | return orderEchoMapper.queryAll(); |
| | | } |
| | |
| | | // 创建固定大小的线程池,根据需求调整线程数量 |
| | | ExecutorService executor = Executors.newFixedThreadPool(2); |
| | | try { |
| | | executor.submit(() -> sendMoney(EStockType.US.getCode())); |
| | | executor.submit(() -> sendMoney(EStockType.MX.getCode())); |
| | | executor.submit(() -> sendMoney(EStockType.getDefault().getCode())); |
| | | } finally { |
| | | // 关闭线程池 |
| | | executor.shutdown(); |
| | |
| | | } else { |
| | | userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(aml)); |
| | | } |
| | | UserPosition userPosition = userPositionMapper.selectOne(new LambdaQueryWrapper<UserPosition>().gt(UserPosition::getAmountToBeCovered, BigDecimal.ZERO).eq(UserPosition::getUserId,userAssets.getUserId())); |
| | | /*UserPosition userPosition = userPositionMapper.selectOne(new LambdaQueryWrapper<UserPosition>().gt(UserPosition::getAmountToBeCovered, BigDecimal.ZERO).eq(UserPosition::getUserId,userAssets.getUserId())); |
| | | if(null != userPosition){ |
| | | userPosition.setAmountToBeCovered(userAssets.getAmountToBeCovered()); |
| | | userPositionMapper.updateById(userPosition); |
| | | } |
| | | }*/ |
| | | userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(money)); |
| | | userAssetsMapper.updateById(userAssets); |
| | | orderEchoBean.setState("2"); |