1
zj
2024-04-24 29446dbdaea7d11eb28a4210ec69a186c54e705e
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -1,5 +1,6 @@
package com.nq.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nq.dao.*;
import com.nq.enums.EConfigKey;
@@ -337,7 +338,7 @@
        }
        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode()));
        if (!priceServices.isLimitDownSell(stock.getStockCode())) {
            return ServerResponse.createByErrorMsg("股票垫停,无法平仓", request);
            return ServerResponse.createByErrorMsg("股票跌停,无法平仓", request);
        }
        BigDecimal nowPrice = priceServices.getNowPrice(userPosition.getStockCode());
        if (nowPrice.compareTo(new BigDecimal("0")) != 1) {
@@ -1159,19 +1160,18 @@
            return ServerResponse.createByErrorMsg("该新股不存在");
        }
        if (userStockSubscribe.getStatus() == 4 || userStockSubscribe.getStatus() == 3 && stockSubscribe.getType() == 2) {
//                String sinaStock = SinaStockApi.getSinaStock(stockSubscribe.getStockType()+userStockSubscribe.getNewCode());
//                String[] arrayOfString = sinaStock.split(",");
//                 if (arrayOfString.length < 10){
//                 return ServerResponse.createByErrorMsg("数据源无该新股数据,转持仓失败");
//                 }
            Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockSpell, userStockSubscribe.getNewCode()));
            if(null == stock){
                return ServerResponse.createByErrorMsg("该新股不存在");
            }
            UserPosition userPosition = new UserPosition();
            userPosition.setPositionType(1);
            userPosition.setPositionSn(KeyUtils.getUniqueKey());
            userPosition.setUserId(userStockSubscribe.getUserId());
            userPosition.setNickName(userStockSubscribe.getRealName());
            userPosition.setAgentId(userStockSubscribe.getAgentId());
            userPosition.setStockCode(userStockSubscribe.getNewCode());
            userPosition.setStockCode(stock.getStockCode());
            userPosition.setStockSpell(stock.getStockSpell());
            userPosition.setStockName(userStockSubscribe.getNewName());
            userPosition.setStockGid(stockSubscribe.getStockType() + userStockSubscribe.getNewCode());
@@ -1208,14 +1208,6 @@
            log.info("用户购买印花税(配资后总资金 * 百分比) = {}", buy_yhs_amt);
            userPosition.setOrderSpread(buy_yhs_amt);
            //            SiteSpread siteSpread = iSiteSpreadService.findSpreadRateOne(new BigDecimal(stock_crease), buy_amt, stock.getStockCode(), now_price);
            //            BigDecimal spread_rate_amt = new BigDecimal("0");
            //            if(siteSpread != null){
            //                spread_rate_amt = buy_amt.multiply(siteSpread.getSpreadRate()).setScale(2, 4);
            //                log.info("用户购买点差费(配资后总资金 * 百分比{}) = {}", siteSpread.getSpreadRate(), spread_rate_amt);
            //            } else{
            //                log.info("用户购买点差费(配资后总资金 * 百分比{}) = {}", "设置异常", spread_rate_amt);
            //            }
            BigDecimal spread_rate_amt = new BigDecimal(0);
            userPosition.setSpreadRatePrice(spread_rate_amt);
@@ -1239,7 +1231,7 @@
                userStockSubscribeMapper.update1(userStockSubscribe);
                if (userStockSubscribe.getType() == 1 || userStockSubscribe.getType() == 2) {
                    User user = userMapper.selectById(userStockSubscribe.getUserId());
                    ret = userMapper.updateByPrimaryKey(user);
                    ret = userMapper.updateById(user);
                }
                if (ret > 0) {
                    return ServerResponse.createBySuccessMsg("新股转持仓成功");
@@ -1538,7 +1530,7 @@
        //价格处理
        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", stockDz.getStockCode()));
        if(stockDz.getStartTime().after(new Date()) || stockDz.getEndTime().after(new Date())){
        if(stockDz.getStartTime().getTime() > new Date().getTime() || stockDz.getEndTime().getTime() < new Date().getTime()){
            return ServerResponse.createByErrorMsg("不在大宗交易所时间之内", request);
        }
        BigDecimal nowPrice = priceServices.getNowPrice(stockCode).multiply(stockDz.getDiscount());
@@ -1654,7 +1646,7 @@
        // 检查股票是否垫停
        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", position.getStockCode()));
        if (!priceServices.isLimitDownSell(stock.getStockCode())) {
            log.info("股票垫停,无法平仓,订单id: {}", position.getId());
            log.info("股票跌停,无法平仓,订单id: {}", position.getId());
            return null;
        }