| | |
| | | package com.nq.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.StockDzMapper; |
| | | import com.nq.dao.StockMapper; |
| | | import com.nq.dao.UserPositionMapper; |
| | | import com.nq.pojo.Stock; |
| | | import com.nq.pojo.StockDz; |
| | | import com.nq.pojo.UserPosition; |
| | | import com.nq.pojo.reponse.RPageInfo; |
| | | import com.nq.service.StockDzService; |
| | | import com.nq.utils.stock.sina.StockApi; |
| | |
| | | private SiteSettingServiceImpl siteSettingService; |
| | | @Autowired |
| | | private StockMapper stockMapper; |
| | | @Autowired |
| | | private UserPositionMapper userPositionMapper; |
| | | |
| | | @Override |
| | | public ServerResponse getDzList(int pageNum, int pageSize, String orderBy, String keyWords, HttpServletRequest request) { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<StockDz> stockTypeDz = stockMapper.findStockTypeDz(orderBy, keyWords); |
| | | if (keyWords == null || keyWords.trim().isEmpty()) { |
| | | // 如果 keyWords 为空,则直接返回空分页结果 |
| | | return ServerResponse.createBySuccess(new RPageInfo()); |
| | | } |
| | | String formatDate = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN); |
| | | List<StockDz> stockTypeDz = stockMapper.findStockTypeDz(orderBy, keyWords,formatDate); |
| | | RPageInfo pageInfo = new RPageInfo(); |
| | | pageInfo.setList(stockTypeDz); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | |
| | | public ServerResponse addByAdmin(String stockCode, String stockNum, String password, String startTime, String endTime, String discount,Integer period,String nowPrice,Integer switchType) { |
| | | if (stockCode == null || stockCode.equals("")||stockNum == null || stockNum.equals("")|| startTime == null || startTime.equals("")||endTime == null || endTime.equals("") || period == null || nowPrice == null){ |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | | } |
| | | |
| | | Long count = stockDzMapper.selectCount(new LambdaQueryWrapper<StockDz>() |
| | | .eq(StockDz::getStockCode,stockCode)); |
| | | if(count > 0){ |
| | | return ServerResponse.createByErrorMsg("股票代码已存在"); |
| | | } |
| | | |
| | | QueryWrapper queryWrapper = new QueryWrapper(); |
| | |
| | | |
| | | @Override |
| | | public ServerResponse deleteByAdmin(String id) { |
| | | List<UserPosition> userPositions = userPositionMapper.selectList(new LambdaQueryWrapper<>(UserPosition.class).eq(UserPosition::getDzId, id).isNull(UserPosition::getSellOrderId)); |
| | | if(CollectionUtil.isNotEmpty(userPositions)){ |
| | | return ServerResponse.createByErrorMsg("删除失败,当前大宗还有用户持有仓位"); |
| | | } |
| | | int res = stockDzMapper.deleteById(id); |
| | | if (res > 0) { |
| | | return ServerResponse.createBySuccess("删除成功"); |