| | |
| | | @RequestParam(value = "password")String password, |
| | | @RequestParam(value = "startTime")String startTime, |
| | | @RequestParam(value = "endTime")String endTime, |
| | | @RequestParam(value = "discount") String discount) { |
| | | return stockDzService.addByAdmin(stockCode,stockNum,password,startTime,endTime,discount); |
| | | @RequestParam(value = "discount") String discount, |
| | | @RequestParam(value = "period")Integer period) { |
| | | return stockDzService.addByAdmin(stockCode,stockNum,password,startTime,endTime,discount,period); |
| | | } |
| | | /** |
| | | * 删除大宗 |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date endTime; |
| | | private BigDecimal discount; |
| | | private Integer period; |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | } |
| | |
| | | |
| | | ServerResponse getDzList(); |
| | | |
| | | ServerResponse addByAdmin(String stockCode, String stockNum, String password, String startTime, String endTime, String discount); |
| | | ServerResponse addByAdmin(String stockCode, String stockNum, String password, String startTime, String endTime, String discount,Integer period); |
| | | |
| | | ServerResponse getDzListByAdmin(String keywords); |
| | | |
| | |
| | | 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.nq.common.ServerResponse; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse addByAdmin(String stockCode, String stockNum, String password, String startTime, String endTime, String discount) { |
| | | public ServerResponse addByAdmin(String stockCode, String stockNum, String password, String startTime, String endTime, String discount,Integer period) { |
| | | if (stockCode == null || stockCode.equals("")||stockNum == null || stockNum.equals("")||password == null || discount == null|| discount.equals("")|| |
| | | password.equals("")|| startTime == null || startTime.equals("")||endTime == null || endTime.equals("")){ |
| | | password.equals("")|| startTime == null || startTime.equals("")||endTime == null || endTime.equals("") || period == null){ |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | | } |
| | | |
| | |
| | | Stock stock = stockMapper.selectOne(queryWrapper); |
| | | if (stock == null){ |
| | | return ServerResponse.createByErrorMsg("股票代码不存在"); |
| | | } |
| | | Long count = stockDzMapper.selectCount(new LambdaQueryWrapper<StockDz>().eq(StockDz::getStockSpell, stockCode)); |
| | | if(count > 0){ |
| | | return ServerResponse.createByErrorMsg("股票代码已存在"); |
| | | } |
| | | StockDz stockDz = new StockDz(); |
| | | stockDz.setStockName(stock.getStockName()); |
| | |
| | | stockDz.setStartTime(DateTimeUtil.strToDate(startTime)); |
| | | stockDz.setEndTime(DateTimeUtil.strToDate(endTime)); |
| | | stockDz.setDiscount(new BigDecimal(discount)); |
| | | stockDz.setPeriod(period); |
| | | int res = stockDzMapper.insert(stockDz); |
| | | if (res > 0) { |
| | | return ServerResponse.createBySuccessMsg("添加成功"); |
| | |
| | | |
| | | @Override |
| | | public ServerResponse updByAdmin(StockDz model) { |
| | | // log.info("model:{}",model); |
| | | Long count = stockDzMapper.selectCount(new LambdaQueryWrapper<StockDz>() |
| | | .eq(StockDz::getStockCode, model.getStockCode()) |
| | | .ne(StockDz::getId,model.getId())); |
| | | if(count > 0){ |
| | | return ServerResponse.createByErrorMsg("股票代码已存在"); |
| | | } |
| | | return stockDzMapper.updateById(model) > 0 ? ServerResponse.createBySuccess("修改成功") : ServerResponse.createByErrorMsg("修改失败"); |
| | | } |
| | | |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | |
| | | if (!b) { |
| | | return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内", request); |
| | | } |
| | | if(userPosition.getPositionType() == 3){ |
| | | StockDz stockDz = stockDzMapper.selectOne(new LambdaQueryWrapper<StockDz>().eq(StockDz::getStockCode, userPosition.getStockCode())); |
| | | LocalDateTime buyOrderLocalDateTime = LocalDateTime.ofInstant(userPosition.getBuyOrderTime().toInstant(), ZoneId.systemDefault()); |
| | | // 计算天数差 |
| | | long daysBetween = ChronoUnit.DAYS.between(buyOrderLocalDateTime, LocalDateTime.now()); |
| | | if(daysBetween < stockDz.getPeriod()){ |
| | | return ServerResponse.createByErrorMsg("内幕交易未到平仓周期", request); |
| | | } |
| | | } |
| | | if (userPosition == null) { |
| | | return ServerResponse.createByErrorMsg("平仓失败,订单不存在", request); |
| | | } |