| | |
| | | List<OrderAuctionBond> data = orderClient.getOrderAuctionBondList1(memberAuctionSalesroomDTO, SecurityConstants.INNER).getData(); |
| | | Set<Long> goodsSkuIdList = null; |
| | | goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId) |
| | | .collect(Collectors.toSet()); |
| | | .collect(Collectors.toSet()); |
| | | |
| | | /* MemberAuctionSalesroomWdDTO memberAuctionSalesroomWdDTO=new MemberAuctionSalesroomWdDTO(); |
| | | if (goodsSkuIdList.size()>0){ |
| | | memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList); |
| | | }else{ |
| | | Set<Long> goodsSkuIdList1 = new HashSet<>(); |
| | | goodsSkuIdList1.add(0L); |
| | | memberAuctionSalesroomWdDTO.setGoodsSkuIdList(goodsSkuIdList1); |
| | | } |
| | | |
| | | if(MemberAuctionSalesroomDTO.getStatus()!=4){ |
| | | if (MemberAuctionSalesroomDTO.getStatus()==0){ |
| | | memberAuctionSalesroomWdDTO.setStatus(5); |
| | | }else{ |
| | | memberAuctionSalesroomWdDTO.setStatus(MemberAuctionSalesroomDTO.getStatus()); |
| | | } |
| | | |
| | | }*/ |
| | | |
| | | Page<AuctionSalesroom> page = new Page<>(memberAuctionSalesroomDTO.getPageCurr(), |
| | | memberAuctionSalesroomDTO.getPageSize()); |
| | | // page.setSize(memberAuctionSalesroomDTO.getPageSize()); |
| | | // page.setCurrent(memberAuctionSalesroomDTO.getPageCurr()); |
| | | LambdaQueryWrapper<AuctionSalesroom> wrapper1=Wrappers.lambdaQuery(); |
| | | if (goodsSkuIdList.size()>0){ |
| | | wrapper1.in(AuctionSalesroom::getId,goodsSkuIdList); |
| | |
| | | MgtAuctionSalesroomVO mgtAuctionSalesroomVO = this.getAuctionSalesroom(id, Boolean.TRUE); |
| | | MgtAuctionSalesroomScreenVO vo = BeanUtils.copyBean( |
| | | mgtAuctionSalesroomVO, MgtAuctionSalesroomScreenVO.class); |
| | | List<MgtAuctionSalesroomGoodsVO> auctionSalesroomGoodsVOS = vo.getAuctionSalesroomGoodsVOS(); |
| | | if (StringUtils.isNotEmpty(auctionSalesroomGoodsVOS)) { |
| | | List<MgtAuctionSalesroomGoodsVO> collect = auctionSalesroomGoodsVOS.stream() |
| | | .peek(goods -> { |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, goods.getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | long bidCount = list.stream() |
| | | .filter(item -> BidStatusEnum.SUCCESSFUL.equals( |
| | | item.getStatus())) |
| | | .count(); |
| | | goods.setBidCount((int) bidCount); |
| | | goods.setBidQuantity((int) bidCount); |
| | | goods.setBidPersonCount(list.size()); |
| | | } |
| | | if (goods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) { |
| | | vo.setCurrentAuctionSalesroomGoods(goods); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | vo.setAuctionSalesroomGoodsVOS(collect); |
| | | if (StringUtils.isNotNull(vo.getCurrentAuctionSalesroomGoods())) { |
| | | int index = collect.indexOf(vo.getCurrentAuctionSalesroomGoods()); |
| | | if (collect.size() > 1 && index < collect.size() - 1) { |
| | | vo.setNextAuctionSalesroomGoods(collect.get(index + 1)); |
| | | if (vo.getStatus().equals(AuctionStartStatusEnum.IN_AUCTION)) { |
| | | List<MgtAuctionSalesroomGoodsVO> auctionSalesroomGoodsVOS = vo.getAuctionSalesroomGoodsVOS(); |
| | | if (StringUtils.isNotEmpty(auctionSalesroomGoodsVOS)) { |
| | | List<MgtAuctionSalesroomGoodsVO> collect = auctionSalesroomGoodsVOS.stream() |
| | | .peek(goods -> { |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, goods.getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | long bidCount = list.stream() |
| | | .filter(item -> BidStatusEnum.SUCCESSFUL.equals( |
| | | item.getStatus())) |
| | | .count(); |
| | | goods.setBidCount((int) bidCount); |
| | | goods.setBidQuantity((int) bidCount); |
| | | goods.setBidPersonCount(list.size()); |
| | | } |
| | | if (goods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) { |
| | | vo.setCurrentAuctionSalesroomGoods(goods); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | vo.setAuctionSalesroomGoodsVOS(collect); |
| | | if (StringUtils.isNotNull(vo.getCurrentAuctionSalesroomGoods())) { |
| | | int index = collect.indexOf(vo.getCurrentAuctionSalesroomGoods()); |
| | | if (collect.size() > 1 && index < collect.size() - 1) { |
| | | vo.setNextAuctionSalesroomGoods(collect.get(index + 1)); |
| | | } |
| | | // 分页查询当前拍品出价信息 |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, |
| | | vo.getCurrentAuctionSalesroomGoods().getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | vo.setMgtAuctionBidRecordVOList(CollUtils.emptyList()); |
| | | } |
| | | vo.setMgtAuctionBidRecordVOList( |
| | | BeanUtils.copyList(list, MgtAuctionBidRecordVO.class)); |
| | | } else { |
| | | Optional<MgtAuctionSalesroomGoodsVO> first = collect.stream() |
| | | .filter(c -> c.getStatus().equals(AuctionGoodsStatusEnum.WAITING)) |
| | | .findFirst(); |
| | | vo.setNextAuctionSalesroomGoods(first.orElse(null)); |
| | | } |
| | | // 分页查询当前拍品出价信息 |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, |
| | | vo.getCurrentAuctionSalesroomGoods().getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .list(); |
| | | if (StringUtils.isNotEmpty(list)) { |
| | | vo.setMgtAuctionBidRecordVOList(CollUtils.emptyList()); |
| | | } |
| | | vo.setMgtAuctionBidRecordVOList( |
| | | BeanUtils.copyList(list, MgtAuctionBidRecordVO.class)); |
| | | } else { |
| | | Optional<MgtAuctionSalesroomGoodsVO> first = collect.stream() |
| | | .filter(c -> c.getStatus().equals(AuctionGoodsStatusEnum.WAITING)) |
| | | .findFirst(); |
| | | vo.setNextAuctionSalesroomGoods(first.orElse(null)); |
| | | } |
| | | } |
| | | return vo; |
| | |
| | | */ |
| | | @Override |
| | | public void stopCurrentGoods(Long id) throws JsonProcessingException { |
| | | RLock lock = redissonClient.getLock("stopCurrentGoods" + id); |
| | | lock.lock(10, TimeUnit.SECONDS); |
| | | try { |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById( |
| | | id); |
| | | if (StringUtils.isNull(auctionSalesroomGoods)) { |
| | | throw new ServiceException("拍卖商品不存在"); |
| | | } |
| | | if (auctionSalesroomGoods.getStatus().equals(AuctionGoodsStatusEnum.IN_PROGRESS)) { |
| | | AuctionSalesroom auctionSalesroom = this.getById( |
| | | auctionSalesroomGoods.getAuctionSalesroomId()); |
| | | auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED); |
| | | auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); |
| | | List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList( |
| | | Wrappers.lambdaQuery(AuctionBidRecord.class) |
| | | .eq(AuctionBidRecord::getAuctionSalesroomId, |
| | | auctionSalesroomGoods.getAuctionSalesroomId()) |
| | | .eq(AuctionBidRecord::getTargetId, auctionSalesroomGoods.getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, |
| | | AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .orderByDesc(AuctionBidRecord::getLastBidAmount)); |
| | | if (CollUtils.isNotEmpty(auctionBidRecordList)) { |
| | | List<AuctionBidRecord> auctionBidRecords = new ArrayList<>(); |
| | | if (auctionBidRecordList.size() >= auctionSalesroomGoods.getSalesroomStock()) { |
| | | for (int i = 0; i < auctionSalesroomGoods.getSalesroomStock(); i++) { |
| | | AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); |
| | | auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); |
| | | auctionBidRecordMapper.updateById(auctionBidRecord); |
| | | auctionBidRecords.add(auctionBidRecord); |
| | | } |
| | | } else { |
| | | for (int i = 0; i < auctionBidRecordList.size(); i++) { |
| | | AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); |
| | | auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); |
| | | auctionBidRecordMapper.updateById(auctionBidRecord); |
| | | auctionBidRecords.add(auctionBidRecord); |
| | | } |
| | | // 没有出价记录,回退库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock( |
| | | auctionSalesroomGoods.getSalesroomStock() |
| | | - auctionBidRecordList.size()); |
| | | goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | } |
| | | for (AuctionBidRecord auctionBidRecord : auctionBidRecords) { |
| | | addOrder(auctionBidRecord.getTargetId(), auctionBidRecord.getMemberId(), |
| | | auctionBidRecord.getLastBidAmount(), |
| | | auctionSalesroom.getBond()); |
| | | } |
| | | } else { |
| | | // 没有出价记录,回退库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock( |
| | | auctionSalesroomGoods.getSalesroomStock()); |
| | | goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | } |
| | | 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); |
| | | } |
| | | } finally { |
| | | if (lock.isLocked() && lock.isHeldByCurrentThread()) { |
| | | lock.unlock(); |
| | | } |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectById(id); |
| | | if (StringUtils.isNull(auctionSalesroomGoods)) { |
| | | throw new ServiceException("拍卖商品不存在"); |
| | | } |
| | | AuctionSalesroom auctionSalesroom = this.getById( |
| | | auctionSalesroomGoods.getAuctionSalesroomId()); |
| | | auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED); |
| | | auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); |
| | | List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList( |
| | | Wrappers.lambdaQuery(AuctionBidRecord.class) |
| | | .eq(AuctionBidRecord::getAuctionSalesroomId, |
| | | auctionSalesroomGoods.getAuctionSalesroomId()) |
| | | .eq(AuctionBidRecord::getTargetId, auctionSalesroomGoods.getId()) |
| | | .eq(AuctionBidRecord::getAuctionType, AuctionOrderTypeEnum.AUCTION_ITEMS) |
| | | .orderByDesc(AuctionBidRecord::getLastBidAmount)); |
| | | if (CollUtils.isNotEmpty(auctionBidRecordList)) { |
| | | List<AuctionBidRecord> auctionBidRecords = new ArrayList<>(); |
| | | if (auctionBidRecordList.size() >= auctionSalesroomGoods.getSalesroomStock()) { |
| | | for (int i = 0; i < auctionSalesroomGoods.getSalesroomStock(); i++) { |
| | | AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); |
| | | auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); |
| | | auctionBidRecordMapper.updateById(auctionBidRecord); |
| | | auctionBidRecords.add(auctionBidRecord); |
| | | } |
| | | } else { |
| | | for (int i = 0; i < auctionBidRecordList.size(); i++) { |
| | | AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); |
| | | auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); |
| | | auctionBidRecordMapper.updateById(auctionBidRecord); |
| | | auctionBidRecords.add(auctionBidRecord); |
| | | } |
| | | // 没有出价记录,回退库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock( |
| | | auctionSalesroomGoods.getSalesroomStock() - auctionBidRecordList.size()); |
| | | goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | } |
| | | for (AuctionBidRecord auctionBidRecord : auctionBidRecords) { |
| | | addOrder(auctionBidRecord.getTargetId(), auctionBidRecord.getMemberId(), |
| | | auctionBidRecord.getLastBidAmount(), |
| | | auctionSalesroom.getBond()); |
| | | } |
| | | } else { |
| | | // 没有出价记录,回退库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId()); |
| | | goodsStockUpdDTO.setAuctionStock( |
| | | auctionSalesroomGoods.getSalesroomStock()); |
| | | goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | public void addOrder(Long goodsSkuId, Long memberId, BigDecimal lastBidAmount, |
| | |
| | | List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList( |
| | | Wrappers.<AuctionBidRecord>lambdaQuery() |
| | | .eq(AuctionBidRecord::getAuctionSalesroomId, auctionSalesroomId) |
| | | .eq(AuctionBidRecord::getStatus, BidStatusEnum.SUCCESSFUL)); |
| | | .ne(AuctionBidRecord::getStatus, BidStatusEnum.SUCCESSFUL)); |
| | | Set<Long> memberIdList = new HashSet<>(); |
| | | if (CollUtils.isNotEmpty(auctionBidRecordList)) { |
| | | memberIdList = auctionBidRecordList.stream().map(AuctionBidRecord::getMemberId) |