zyy
2025-12-09 6eef7f43f9ad3d82727fba36f543f268cfb646d2
大宗
7 files modified
126 ■■■■ changed files
trading-order-admin/src/main/java/com/yami/trading/admin/controller/dz/AdminStockDarkPoolsController.java 56 ●●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiETFDarkPoolsController.java 4 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiETFDzController.java 4 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiStockDarkPoolsController.java 4 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiStockDzController.java 4 ●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/dz/StockDzService.java 4 ●●●● patch | view | raw | blame | history
trading-order-service/src/main/java/com/yami/trading/service/dz/impl/StockDzServiceImpl.java 50 ●●●● patch | view | raw | blame | history
trading-order-admin/src/main/java/com/yami/trading/admin/controller/dz/AdminStockDarkPoolsController.java
@@ -1,13 +1,20 @@
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.*;
@@ -25,6 +32,12 @@
    @Autowired
    private PermissionFacade permissionFacade;
    @Autowired
    UserService userService;
    @Autowired
    StockDzMapper stockDzMapper;
    /**
@@ -101,4 +114,47 @@
        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);
    }
}
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiETFDarkPoolsController.java
@@ -57,7 +57,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.buyDz(dzId, password, num, partyId);
            return stockDzService.buyDz(dzId, password, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
@@ -110,7 +110,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.closeDz(id, num, partyId);
            return stockDzService.closeDz(id, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiETFDzController.java
@@ -64,7 +64,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.buyDz(dzId, password, num, partyId);
            return stockDzService.buyDz(dzId, password, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
@@ -117,7 +117,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.closeDz(id, num, partyId);
            return stockDzService.closeDz(id, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiStockDarkPoolsController.java
@@ -63,7 +63,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.buyDz(dzId, password, num, partyId);
            return stockDzService.buyDz(dzId, password, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
@@ -115,7 +115,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.closeDz(id, num, partyId);
            return stockDzService.closeDz(id, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
trading-order-admin/src/main/java/com/yami/trading/api/controller/dz/ApiStockDzController.java
@@ -64,7 +64,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.buyDz(dzId, password, num, partyId);
            return stockDzService.buyDz(dzId, password, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
@@ -116,7 +116,7 @@
            if (partyId == null || partyId.isEmpty()) {
                throw new YamiShopBindException("请先登录");
            }
            return stockDzService.closeDz(id, num, partyId);
            return stockDzService.closeDz(id, num, partyId, false);
        } catch (Exception e) {
            log.error(e.getMessage());
        }  finally{
trading-order-service/src/main/java/com/yami/trading/service/dz/StockDzService.java
@@ -25,12 +25,12 @@
    Result getDzCheckList(int pageNum, int pageSize, String state, String stockCode, String stockType, List<String> checkedList);
    Result buyDz(String dzId, String password, double num, String partyId);
    Result buyDz(String dzId, String password, double num, String partyId, Boolean isAdmin);
    Result dzCheck(String id, Integer checkType, Double num, double price);
    public void intoPosition(ExchangeApplyOrderDz orderDz, String stockType);
    Result closeDz(String id, Double num, String partyId);
    Result closeDz(String id, Double num, String partyId, Boolean isAdmin);
}
trading-order-service/src/main/java/com/yami/trading/service/dz/impl/StockDzServiceImpl.java
@@ -260,7 +260,7 @@
    @Transactional
    @Override
    public Result buyDz(String dzId, String password, double num, String partyId) {
    public Result buyDz(String dzId, String password, double num, String partyId, Boolean isAdmin) {
        try {
            if (num <= 0) {
                throw new YamiShopBindException("请输入");
@@ -307,11 +307,13 @@
                    return Result.failed("请购买最小数量");
                }
            }
            boolean isOpen = MarketOpenChecker.isMarketOpenBuyDz(Item.US_STOCKS);
            if (!isOpen) {
                return Result.failed("当前股市休市");
            }
            if (!isAdmin) { //后台买入不判断
                boolean isOpen = MarketOpenChecker.isMarketOpenBuyDz(Item.US_STOCKS);
                if (!isOpen) {
                    return Result.failed("当前股市休市");
                }
            }
            Wallet wallet = this.walletService.saveWalletByPartyId(partyId);
            BigDecimal buyAmt;
@@ -521,7 +523,7 @@
    @Transactional
    @Override
    public Result closeDz(String id, Double num, String partyId) {
    public Result closeDz(String id, Double num, String partyId, Boolean isAdmin) {
        try {
            ExchangeApplyOrderDz order = exchangeApplyOrderDzMapper.selectById(id);
            if (order == null) {
@@ -535,6 +537,9 @@
            }
            if (num < 0 || num > order.getSymbolValue()) {
                throw new YamiShopBindException("数量错误");
            }
            if (partyId == null) {
                partyId = order.getPartyId();
            }
            StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("uuid", order.getDzId()));
@@ -554,26 +559,25 @@
            }
            Date now = new Date();
            if (stockDz.getPeriod() != null && stockDz.getPeriod() > 0) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(order.getCreateTime());
                calendar.add(Calendar.DATE, stockDz.getPeriod());
                // 锁仓时间
                Date resultTime = calendar.getTime();
            if (!isAdmin) {
                if (stockDz.getPeriod() != null && stockDz.getPeriod() > 0) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(order.getCreateTime());
                    calendar.add(Calendar.DATE, stockDz.getPeriod());
                    // 锁仓时间
                    Date resultTime = calendar.getTime();
                if(now.getTime() < resultTime.getTime()){
                    return Result.failed("未到平仓时间");
                    if(now.getTime() < resultTime.getTime()){
                        return Result.failed("未到平仓时间");
                    }
                }
                if (!stockDz.getStockName().contains("测试")) {
                    boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(Item.US_STOCKS);
                    if (!isOpen) {
                        return Result.failed("当前股市休市");
                    }
                }
            }
            if (stockDz.getStockName().contains("测试")) {
            } else {
                boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(Item.US_STOCKS);
                if (!isOpen) {
                    return Result.failed("当前股市休市");
                }
            }
            Wallet wallet = this.walletService.saveWalletByPartyId(order.getPartyId());