1
zj
2024-09-03 dc3080f50c19b89b895e5c56baa53abbd8976464
src/main/java/com/nq/service/impl/UserPendingorderServiceImpl.java
@@ -14,7 +14,7 @@
import com.nq.dao.*;
import com.nq.pojo.*;
import com.nq.service.*;
import com.nq.utils.DateTimeUtil;
import com.nq.utils.timeutil.DateTimeUtil;
import com.nq.utils.PropertiesUtil;
import com.nq.utils.redis.JsonUtil;
import com.nq.utils.redis.RedisShardedPoolUtils;
@@ -71,20 +71,20 @@
        User user = this.iUserService.getCurrentRefreshUser(request);
        if (user == null) {
            return ServerResponse.createByErrorMsg("Please log in first");
            return ServerResponse.createByErrorMsg("Please log in first",request);
        }
        SiteSetting siteSetting = this.iSiteSettingService.getSiteSetting();
        if (buyNum.intValue() < siteSetting.getBuyMinNum().intValue()) {
            return ServerResponse.createByErrorMsg("The pending order failed, and the purchased quantity was less than" + siteSetting
                    .getBuyMinNum() + "stocks");
                    .getBuyMinNum() + "stocks",request);
        }
        if (buyNum.intValue() > siteSetting.getBuyMaxNum().intValue()) {
            return ServerResponse.createByErrorMsg("The pending order failed because the purchased quantity was greater than" + siteSetting
                    .getBuyMaxNum() + "stocks");
                    .getBuyMaxNum() + "stocks",request);
        }
        UserPendingorder userPendingorder = userPendingorderMapper.selectOne(new QueryWrapper<UserPendingorder>().eq("user_id", user.getId()).eq("stock_id", stockId).eq("status", 0));
        if (userPendingorder != null) {
            return ServerResponse.createByErrorMsg("Please do not repeat the order");
            return ServerResponse.createByErrorMsg("Please do not repeat the order",request);
        }
        userPendingorder = new UserPendingorder();
@@ -101,9 +101,9 @@
        userPendingorder.setStatus(0);
        int ret = userPendingorderMapper.insert(userPendingorder);
        if (ret > 0) {
            return ServerResponse.createBySuccessMsg("If the pending order is successfully added, the order will be automatically placed if the order conditions are met");
            return ServerResponse.createBySuccessMsg("If the pending order is successfully added, the order will be automatically placed if the order conditions are met",request);
        }
        return ServerResponse.createByErrorMsg("Add failure");
        return ServerResponse.createByErrorMsg("Add failure",request);
    }
@@ -163,7 +163,7 @@
        log.info("当前有挂单的用户数量 为 {}", Integer.valueOf(userPendingorders.size()));
        for (int i = 0; i < userPendingorders.size(); i++) {
            Integer userId = (Integer) userPendingorders.get(i).getUserId();
            User user = this.userMapper.selectByPrimaryKey(userId);
            User user = this.userMapper.selectById(userId);
            if (user == null) {
                continue;
            }
@@ -172,7 +172,6 @@
                continue;
            }
            log.info("用户id = {} 姓名 = {} 已挂单数: {}", new Object[]{userId, user.getRealName(), Integer.valueOf(userPendingorders.size())});
            BigDecimal enable_user_amt = user.getEnableAmt();
            BigDecimal all_freez_amt = new BigDecimal("0");
            String nowPrice = "";
            String code = "";
@@ -234,8 +233,6 @@
                                SiteTaskLog siteTaskLog = new SiteTaskLog();
                                siteTaskLog.setTaskType("股票挂单转持仓");
                                String accountType = (user.getAccountType() == 0) ? "正式用户" : "模拟用户";
                                String taskcnt = accountType + "-" + user.getRealName() + "挂单[达到目标价格] 用户id = " + user.getId() + ", 可用资金 = " + enable_user_amt + "冻结保证金 = " + all_freez_amt + ", 目标价格 = " + userPendingorder.getTargetPrice() + ",现价" + nowPrice + ", 涨跌:" + (userPendingorder.getBuyType().intValue() == 0 ? "涨" : "跌");
                                siteTaskLog.setTaskCnt(taskcnt);
                                String tasktarget = "此次挂单买入id:" + userPendingorder.getId();
                                siteTaskLog.setTaskTarget(tasktarget);
                                siteTaskLog.setAddTime(new Date());
@@ -260,8 +257,6 @@
                                SiteTaskLog siteTaskLog = new SiteTaskLog();
                                siteTaskLog.setTaskType("指数挂单转持仓");
                                String accountType = (user.getAccountType() == 0) ? "正式用户" : "模拟用户";
                                String taskcnt = accountType + "-" + user.getRealName() + "挂单[达到目标价格] 用户id = " + user.getId() + ", 可用资金 = " + enable_user_amt + "冻结保证金 = " + all_freez_amt + ", 目标价格 = " + userPendingorder.getTargetPrice() + ",现价" + nowPrice + ", 涨跌:" + (userPendingorder.getBuyType().intValue() == 0 ? "涨" : "跌");
                                siteTaskLog.setTaskCnt(taskcnt);
                                String tasktarget = "此次挂单买入id:" + userPendingorder.getId();
                                siteTaskLog.setTaskTarget(tasktarget);
                                siteTaskLog.setAddTime(new Date());
@@ -301,19 +296,19 @@
            User user = (User) JsonUtil.string2Obj(userJson, User.class);
            UserPendingorder userPendingorder = this.userPendingorderMapper.selectById(id);
            if (userPendingorder == null) {
                return ServerResponse.createByErrorMsg("The pending order does not exist");
                return ServerResponse.createByErrorMsg("The pending order does not exist",request);
            }
            if (user.getId().intValue() != userPendingorder.getUserId().intValue()) {
                return ServerResponse.createByErrorMsg("The pending order does not belong to you");
                return ServerResponse.createByErrorMsg("The pending order does not belong to you",request);
            }
            int delCount = this.userPendingorderMapper.deleteById(id);
            if (delCount > 0) {
                return ServerResponse.createByErrorMsg("Successfully deleted");
                return ServerResponse.createByErrorMsg("Successfully deleted",request);
            }
            return ServerResponse.createByErrorMsg("Deletion failure");
            return ServerResponse.createByErrorMsg("Deletion failure",request);
        }
        return ServerResponse.createByErrorMsg("Please log in");
        return ServerResponse.createByErrorMsg("Please log in",request);
    }