1
zj
2024-09-03 dc3080f50c19b89b895e5c56baa53abbd8976464
1
3 files modified
34 ■■■■■ changed files
src/main/java/com/nq/common/ServerResponse.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/nq/service/impl/UserPendingorderServiceImpl.java 22 ●●●● patch | view | raw | blame | history
src/main/java/com/nq/ws/WebsocketRunClient.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/nq/common/ServerResponse.java
@@ -74,7 +74,7 @@
    public static <T> ServerResponse<T> createBySuccessMsg(String msg,HttpServletRequest request) {
        return new ServerResponse(ResponseCode.SUCCESS.getCode(),msg);
        return new ServerResponse(ResponseCode.SUCCESS.getCode(), new GoogleTranslateUtil().translate(msg,request.getHeader(LANG)));
    }
    public static <T> ServerResponse<T> createBySuccess(T data) {
@@ -83,7 +83,7 @@
    public static <T> ServerResponse<T> createBySuccess(String data,HttpServletRequest request) {
        return new ServerResponse(ResponseCode.SUCCESS.getCode(), data);
        return new ServerResponse(ResponseCode.SUCCESS.getCode(), new GoogleTranslateUtil().translate(data,request.getHeader(LANG)));
    }
    public static <T> ServerResponse<T> createBySuccess(String msg, T data) {
@@ -103,7 +103,7 @@
        return new ServerResponse(ResponseCode.ERROR.getCode(), errormsg);
    }
    public static <T> ServerResponse<T> createByErrorMsg(String errormsg, HttpServletRequest request) {
        return new ServerResponse(ResponseCode.ERROR.getCode(), errormsg);
        return new ServerResponse(ResponseCode.ERROR.getCode(), new GoogleTranslateUtil().translate(errormsg,request.getHeader(LANG)));
    }
src/main/java/com/nq/service/impl/UserPendingorderServiceImpl.java
@@ -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);
    }
@@ -296,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);
    }
src/main/java/com/nq/ws/WebsocketRunClient.java
@@ -45,10 +45,16 @@
    @Override
    public void onMessage(String s) {
       try {
           if(!s.equals("pong") && !s.equals("身份验证成功")){
        StockRealTimeBean stockDetailBean =  new Gson().fromJson(s, StockRealTimeBean.class);
        RedisKeyUtil.setCacheRealTimeStock(eStockType,stockDetailBean);
        send(s);
    }
       }catch (Exception e){
           log.error("ws 消息接收错误:"+s);
       }
    }
    public static Map<String, Object> jsonToMap(String json) {
        Gson gson = new Gson();