From 884f5c68ac8c738f90f1ca257605cfbb5d7f12db Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期三, 26 六月 2024 09:09:27 +0800 Subject: [PATCH] 提交【管理后台】-工作台接口 --- ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java | 73 ++++++++++++++++++++++++------------ 1 files changed, 48 insertions(+), 25 deletions(-) diff --git a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java index 9da3265..08f2342 100644 --- a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java +++ b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomServiceImpl.java @@ -470,6 +470,7 @@ LambdaQueryWrapper<AuctionBrowseRecord> wrapper3=Wrappers.lambdaQuery(); wrapper3.eq(AuctionBrowseRecord::getDelFlag,0); wrapper3.eq(AuctionBrowseRecord::getTargetId,memberAuctionSalesroomDTO.getAuctionSalesroomId()); + wrapper3.eq(AuctionBrowseRecord::getBrowseType,AuctionOrderTypeEnum.AUCTION_ITEMS); wrapper3.eq(AuctionBrowseRecord::getMemberId,memberAuctionSalesroomDTO.getMemberId()); wrapper3.ge(AuctionBrowseRecord::getCreateTime, now) .le(AuctionBrowseRecord::getCreateTime, newTime7); @@ -649,15 +650,9 @@ } catch (JsonProcessingException e) { } String finalMsg = msg; - Thread socketSender=new Thread(()->{ - try { - Thread.sleep(1000);//先休眠1秒 sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg) .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER); - } catch (Exception e) { - e.printStackTrace(); - } - }); + @@ -719,15 +714,9 @@ } catch (JsonProcessingException e) { } String finalMsg = msg; - Thread socketSender=new Thread(()->{ - try { - Thread.sleep(1000);//先休眠1秒 - sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg) + sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(finalMsg) .clientType(ClientTypeEnum.MEMBER).build(), SecurityConstants.INNER); - } catch (Exception e) { - e.printStackTrace(); - } - }); + } } @@ -777,7 +766,9 @@ query.getEndTime()), AuctionSalesroom::getStartTime, query.getStartTime(), query.getEndTime()) + .orderByDesc(AuctionSalesroom::getCreateTime) .page(new Page<>(query.getPageCurr(), query.getPageSize())); + List<AuctionSalesroom> records = page.getRecords(); if (StringUtils.isNull(records)) { return PageDTO.empty(page); @@ -1081,6 +1072,7 @@ .between(StringUtils.isNotNull(query.getStartTime()) && StringUtils.isNotNull( query.getEndTime()), AuctionSalesroom::getStartTime, query.getStartTime(), query.getEndTime()) + .orderByAsc(AuctionSalesroom::getStartTime) .page(new Page<>(query.getPageCurr(), query.getPageSize())); List<AuctionSalesroom> records = page.getRecords(); if (StringUtils.isNull(records)) { @@ -1283,13 +1275,22 @@ * @param id 拍卖场商品id */ @Override - public void stopCurrentGoods(Long id) { + public void stopCurrentGoods(Long id) throws JsonProcessingException { AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id); if (StringUtils.isNull(auctionSalesroomGoods)) { throw new ServiceException("拍卖商品不存在"); } auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED); auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); + Map<String, Object> map = new ConcurrentHashMap<>(); + map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS); + map.put("auctionSalesroomId", auctionSalesroomGoods.getAuctionSalesroomId().toString()); + map.put("auctionSalesroomGoodsId", auctionSalesroomGoods.getId().toString()); + map.put("AuctionTypeEnum", auctionSalesroomGoods.getStatus()); + map.put("message_type", "stop"); + map.put("type", "2"); + String msg = objectMapper.writeValueAsString(map); + sysUserClient.pushAll(msg, SecurityConstants.INNER); } /** @@ -1298,13 +1299,22 @@ * @param id 拍卖场商品id */ @Override - public void startNextGoods(Long id) { + public void startNextGoods(Long id) throws JsonProcessingException { AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id); if (StringUtils.isNull(auctionSalesroomGoods)) { throw new ServiceException("拍卖商品不存在"); } auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS); auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); + Map<String, Object> map = new ConcurrentHashMap<>(); + map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS); + map.put("auctionSalesroomId", auctionSalesroomGoods.getAuctionSalesroomId().toString()); + map.put("auctionSalesroomGoodsId", auctionSalesroomGoods.getId().toString()); + map.put("AuctionTypeEnum", auctionSalesroomGoods.getStatus()); + map.put("message_type", "start"); + map.put("type", "2"); + String msg = objectMapper.writeValueAsString(map); + sysUserClient.pushAll(msg, SecurityConstants.INNER); } /** @@ -1319,6 +1329,8 @@ if (StringUtils.isNull(data)) { throw new ServiceException("视频不存在"); } + iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq + (AuctionVideo::getAuctionSalesroomId, dto.getAuctionSalesroomId())); AuctionVideo auctionVideo = new AuctionVideo(); auctionVideo.setAuctionSalesroomId(dto.getAuctionSalesroomId()); auctionVideo.setPromotionVideoId(dto.getVideoId()); @@ -1334,7 +1346,7 @@ @Override public void stopPlay(Long auctionSalesroomId) { iAuctionVideoService.remove(Wrappers.<AuctionVideo>lambdaQuery().eq - (AuctionVideo::getAuctionSalesroomId, 1L)); + (AuctionVideo::getAuctionSalesroomId, auctionSalesroomId)); } /** @@ -1364,8 +1376,10 @@ Map<String, Object> map = new ConcurrentHashMap<>(); map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); - map.put("auctionSalesroomId", auctionSalesroom.getId()); + map.put("auctionSalesroomId", auctionSalesroom.getId().toString()); + map.put("AuctionTypeEnum", auctionSalesroom.getStatus()); map.put("message_type", "start"); + map.put("type", "1"); String msg = objectMapper.writeValueAsString(map); sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg) .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER); @@ -1376,17 +1390,24 @@ @Transactional public void stopCurrentAuctionSalesroom(Long auctionSalesroomId) throws JsonProcessingException { - // 修改拍卖场开始状态 - AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); - auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED); - auctionSalesroom.setEndTime(LocalDateTime.now()); - auctionSalesroomMapper.updateById(auctionSalesroom); LambdaQueryWrapper<AuctionSalesroomGoods> wrapper = Wrappers.lambdaQuery(); wrapper.eq(AuctionSalesroomGoods::getStatus, AuctionGoodsStatusEnum.WAITING); wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId, auctionSalesroomId); wrapper.orderByDesc(AuctionSalesroomGoods::getSortNum); List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList( wrapper); + long count = auctionSalesroomGoods.stream() + .filter(goods -> goods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) + .count(); + if (count > 0) { + throw new ServiceException("当前拍卖场正在拍卖商品,不能停止"); + } + // 修改拍卖场开始状态 + AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); + auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED); + auctionSalesroom.setEndTime(LocalDateTime.now()); + auctionSalesroomMapper.updateById(auctionSalesroom); + if (StringUtils.isNotEmpty(auctionSalesroomGoods)) { List<GoodsStockUpdDTO> dtoList = new ArrayList<>(); for (AuctionSalesroomGoods salesroomGoods : auctionSalesroomGoods) { @@ -1415,8 +1436,10 @@ } Map<String, Object> map = new ConcurrentHashMap<>(); map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); - map.put("auctionSalesroomId", auctionSalesroom.getId()); + map.put("auctionSalesroomId", auctionSalesroom.getId().toString()); + map.put("AuctionTypeEnum",auctionSalesroom.getStatus()); map.put("message_type", "end"); + map.put("type", "1"); String msg = objectMapper.writeValueAsString(map); sysUserClient.pushByClientType(WebsocketMessageDTO.builder().message(msg) .clientType(ClientTypeEnum.AUCTIONEER).build(), SecurityConstants.INNER); -- Gitblit v1.7.1