| | |
| | | package com.nq.service.impl; |
| | | |
| | | 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.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.StockMapper; |
| | | import com.nq.dao.UserStockSubscribeMapper; |
| | | import com.nq.pojo.Stock; |
| | | import com.nq.pojo.StockSubscribe; |
| | | import com.nq.pojo.UserStockSubscribe; |
| | | import com.nq.service.IStockSubscribeService; |
| | | import com.nq.dao.StockSubscribeMapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | StockSubscribeMapper stockSubscribeMapper; |
| | | |
| | | @Autowired |
| | | UserStockSubscribeMapper userStockSubscribeMapper; |
| | | |
| | | @Autowired |
| | | StockMapper stockMapper; |
| | | |
| | | /** |
| | | * @Description: 用户新股列表 |
| | | * @Param: |
| | |
| | | * @Date: 2022/10/25 |
| | | */ |
| | | @Override |
| | | public ServerResponse list(String name, String code, Integer zt, Integer isLock, Integer type, HttpServletRequest request) { |
| | | public ServerResponse list(String name, String code, Integer zt,Integer getType, Integer isLock, Integer type, HttpServletRequest request) { |
| | | |
| | | //name和code模糊查询 |
| | | QueryWrapper<StockSubscribe> queryWrapper = new QueryWrapper(); |
| | |
| | | } |
| | | if (type != null && !type.equals("")) { |
| | | queryWrapper.eq("type", type); |
| | | } |
| | | if(getType == 1){ |
| | | queryWrapper.gt("list_date", new Date()); |
| | | } |
| | | queryWrapper.orderByDesc("newlist_id"); |
| | | List<StockSubscribe> stockSubscribeList = this.stockSubscribeMapper.selectList(queryWrapper); |
| | |
| | | public ServerResponse add(StockSubscribe model, HttpServletRequest request) { |
| | | //判断是否已经存在 |
| | | log.info("model:{}", model); |
| | | Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, model.getCode()).last(" limit 1")); |
| | | if(null == stock){ |
| | | return ServerResponse.createByErrorMsg("新股代码不存在"); |
| | | } |
| | | Long count = stockSubscribeMapper.selectCount(new LambdaQueryWrapper<StockSubscribe>() |
| | | .eq(StockSubscribe::getCode, model.getCode()) |
| | | .eq(StockSubscribe::getType, model.getType())); |
| | | if(count > 0){ |
| | | return ServerResponse.createByErrorMsg("新股已存在"); |
| | | } |
| | | int resultCount = this.stockSubscribeMapper.insert(model); |
| | | if (resultCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("添加新股成功"); |
| | |
| | | if (stockSubscribe == null) { |
| | | return ServerResponse.createByErrorMsg("新股不存在"); |
| | | } |
| | | Long count = stockSubscribeMapper.selectCount(new LambdaQueryWrapper<StockSubscribe>() |
| | | .eq(StockSubscribe::getCode, model.getCode()) |
| | | .eq(StockSubscribe::getType, model.getType()).ne(StockSubscribe::getNewlistId,model.getNewlistId())); |
| | | if(count > 0){ |
| | | return ServerResponse.createByErrorMsg("新股已存在"); |
| | | } |
| | | //修改新股 |
| | | int resultCount = this.stockSubscribeMapper.updateById(model); |
| | | //修改用户申购的新股代码 |
| | | List<UserStockSubscribe> userStockSubscribes = userStockSubscribeMapper |
| | | .selectList(new LambdaQueryWrapper<UserStockSubscribe>() |
| | | .eq(UserStockSubscribe::getNewCode, stockSubscribe.getCode())); |
| | | for (UserStockSubscribe u : userStockSubscribes) { |
| | | u.setNewCode(model.getCode()); |
| | | userStockSubscribeMapper.updateById(u); |
| | | } |
| | | if (resultCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("修改新股成功"); |
| | | } |