| | |
| | | package com.yami.trading.admin.controller.dz; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.yami.trading.admin.facade.PermissionFacade; |
| | | import com.yami.trading.bean.dz.StockDz; |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.dao.dz.StockDzMapper; |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.dz.StockDzService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Resource |
| | | StockDzService stockDzService; |
| | | |
| | | @Autowired |
| | | private PermissionFacade permissionFacade; |
| | | |
| | | @Autowired |
| | | UserService userService; |
| | | |
| | | @Autowired |
| | | StockDzMapper stockDzMapper; |
| | | |
| | | |
| | | /** |
| | | * @Description: 获取大宗列表 |
| | |
| | | @RequestParam(value = "period", required = false) Integer period, |
| | | @RequestParam(value = "nowPrice") String nowPrice, |
| | | @RequestParam(value = "switchType", defaultValue = "0") Integer switchType) { |
| | | return stockDzService.addByAdmin(stockCode, stockNum, password, startTime, endTime, discount, period,nowPrice,switchType, Constants.US_DARK); |
| | | return stockDzService.addByAdmin(stockCode, null, stockNum, password, startTime, endTime, discount, period,nowPrice,switchType, Constants.US_DARK, 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | public Result getDzCheckList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "15") int pageSize, |
| | | @RequestParam(value = "state", required = false) String state, |
| | | @RequestParam(value = "stockCode", required = false)String stockCode) { |
| | | return stockDzService.getDzCheckList(pageNum, pageSize, state, stockCode, Constants.US_DARK); |
| | | @RequestParam(value = "stockCode", required = false)String stockCode, |
| | | @RequestParam(value = "userName", required = false)String userName |
| | | ) { |
| | | return stockDzService.getDzCheckList(pageNum, pageSize, state, stockCode, Constants.US_DARK, userName, permissionFacade.getOwnerUserIds()); |
| | | } |
| | | |
| | | @ApiOperation("大宗审核") |
| | |
| | | @ResponseBody |
| | | public Result check(@RequestParam(value = "id") String id, |
| | | @RequestParam(value = "checkType") Integer checkType, |
| | | @RequestParam(value = "orderNum", required = false) Double orderNum) { |
| | | @RequestParam(value = "orderNum", required = false) Double orderNum, |
| | | @RequestParam(value = "price", required = false, defaultValue = "0") double price) { |
| | | if(checkType != 2 && (id == null || checkType == null || orderNum == null)){ |
| | | return Result.failed("参数不能为空"); |
| | | } |
| | | return stockDzService.dzCheck(id, checkType, orderNum); |
| | | return stockDzService.dzCheck(id, checkType, orderNum, price); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 大宗列表 |
| | | * @Param: |
| | | * @return: |
| | | */ |
| | | @ApiOperation("获取大宗列表数据") |
| | | @PostMapping({"getDzList.do"}) |
| | | public Result getDzList(@RequestParam(value = "stockName", required = false) String stockName) { |
| | | LambdaQueryWrapper<StockDz> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(StockDz::getStockType, Constants.US_DARK); |
| | | if (StringUtils.isNotBlank(stockName)) { |
| | | queryWrapper.and(wrapper -> wrapper |
| | | .like(StockDz::getStockCode, stockName) |
| | | .or() |
| | | .like(StockDz::getStockName, stockName) |
| | | ); |
| | | } |
| | | return Result.succeed(stockDzMapper.selectList(queryWrapper)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("大宗下单") |
| | | @GetMapping({"buyStockDz.do"}) |
| | | public Result buyDz(@RequestParam("dzId") String dzId, |
| | | @RequestParam("num") double num, |
| | | @RequestParam("userCode") String userCode) { |
| | | if (dzId == null || num ==0 ||userCode == null) { |
| | | return Result.failed("请输入参数"); |
| | | } |
| | | User user = userService.findUserByUserCode(userCode); |
| | | if(user == null){ |
| | | return Result.failed("未找到用户"); |
| | | } |
| | | return stockDzService.buyDz(dzId, null, num, user.getUserId(), true); |
| | | } |
| | | |
| | | @ApiOperation("大宗平仓") |
| | | @GetMapping({"closeStockDz.do"}) |
| | | public Result closeStockDz(@RequestParam("id") String id) { |
| | | return stockDzService.closeDz(id, null, null, true); |
| | | } |
| | | |
| | | |
| | | } |