From fc8b51f40e71aa09bb49f407c1e9f68ac94ceb58 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期一, 29 七月 2024 18:51:32 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionGoodsServiceImpl.java | 125 +++++++++++++++++++++++++++++------------ 1 files changed, 88 insertions(+), 37 deletions(-) diff --git a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionGoodsServiceImpl.java b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionGoodsServiceImpl.java index fa8ca17..94e674d 100644 --- a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionGoodsServiceImpl.java +++ b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionGoodsServiceImpl.java @@ -12,8 +12,10 @@ import com.ruoyi.auction.controller.management.vo.MgtAuctionBidRecordVO; import com.ruoyi.auction.controller.management.vo.MgtAuctionGoodsVO; import com.ruoyi.auction.domain.AuctionBidRecord; +import com.ruoyi.auction.domain.AuctionBondJl; import com.ruoyi.auction.domain.AuctionBrowseRecord; import com.ruoyi.auction.domain.MemberAuctionCollection; +import com.ruoyi.auction.mapper.AuctionBondJlMapper; import com.ruoyi.auction.mapper.AuctionGoodsMapper; import com.ruoyi.auction.service.IAuctionBidRecordService; import com.ruoyi.auction.service.IAuctionBrowseRecordService; @@ -114,6 +116,9 @@ @Resource private IAuctionBrowseRecordService iAuctionBrowseRecordService; + + @Resource + private AuctionBondJlMapper auctionBondJlMapper; /** * 获取拍卖商品列表的分页数据 @@ -317,12 +322,29 @@ id); List<AuctionBidRecord> auctionBidRecordList = new ArrayList<>(); if (StringUtils.isNotEmpty(auctionBidRecords)) { - // 中标 - for (int i = 0; i < auctionGoods.getAuctionStock(); i++) { - AuctionBidRecord auctionBidRecord = auctionBidRecords.get(i); - auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); - auctionBidRecordList.add(auctionBidRecord); + if (auctionBidRecords.size() >= auctionGoods.getAuctionStock()) { + // 中标 + for (int i = 0; i < auctionGoods.getAuctionStock(); i++) { + AuctionBidRecord auctionBidRecord = auctionBidRecords.get(i); + auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + auctionBidRecordList.add(auctionBidRecord); + } + } else { + // 中标 + for (int i = 0; i < auctionBidRecords.size(); i++) { + AuctionBidRecord auctionBidRecord = auctionBidRecords.get(i); + auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + auctionBidRecordList.add(auctionBidRecord); + } + // 退回剩余库存 + GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); + goodsStockUpdDTO.setGoodsSkuId(auctionGoods.getGoodsSkuId()); + goodsStockUpdDTO.setAuctionStock( + auctionGoods.getAuctionStock() - auctionBidRecords.size()); + goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), + SecurityConstants.INNER); } + auctionBidRecordService.updateBatchById(auctionBidRecordList); // 创建待支付订单 @@ -330,11 +352,12 @@ ConfigEnum.MEMBER_POINTS_MONEY.getKey()).getData(); CustomConfig pointsConfig = sysUserClient.getconfig( ConfigEnum.MEMBER_POINTS_POINTS.getKey()).getData(); - double ratio = - Double.parseDouble( - pointsConfig.getConfigValue()) / Double.parseDouble( - moneyConfig.getConfigValue()); for (AuctionBidRecord auctionBidRecord : auctionBidRecordList) { + BigDecimal lastBidAmount = auctionBidRecord.getLastBidAmount(); + BigDecimal divide = lastBidAmount.divide( + new BigDecimal(moneyConfig.getConfigValue()), 0, RoundingMode.DOWN); + int points = divide.multiply( + new BigDecimal(pointsConfig.getConfigValue())).intValue(); OrderDTO orderDTO = new OrderDTO(); orderDTO.setAuctionType(AuctionOrderTypeEnum.REGULAR_ITEMS); orderDTO.setGoodsQuantity(auctionGoods.getAuctionStock()); @@ -344,8 +367,7 @@ orderDTO.setTotalAmount(auctionBidRecord.getLastBidAmount()); orderDTO.setOrderFrom(OrderFromEnum.AUCTION_ORDERS); orderDTO.setOrderTime(LocalDateTime.now()); - orderDTO.setPoints(auctionBidRecord.getLastBidAmount() - .multiply(BigDecimal.valueOf(ratio)).intValue()); + orderDTO.setPoints(points); orderDTO.setBound(auctionGoods.getBond()); MemberAddress data = memberClient.getMemberAddressOne( auctionBidRecord.getMemberId(), SecurityConstants.INNER).getData(); @@ -393,6 +415,7 @@ RefundDTO refundDTO = new RefundDTO(); refundDTO.setOrderNo(orderAuctionBond.getOrderNo()); refundDTO.setAmount(orderAuctionBond.getBond()); + refundDTOList.add(refundDTO); } // 远程调用订单服务进行退款 Map<String, Object> data = orderClient.refund(refundDTOList, @@ -417,7 +440,8 @@ return null; }).filter(Objects::nonNull).collect(Collectors.toList()); // 远程调用订单服务修改订单状态 - orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.PAID,SecurityConstants.INNER); + orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.REFUNDED, + SecurityConstants.INNER); } } } @@ -429,12 +453,23 @@ List<GoodsSku> goodsSku = goodsSkuClient.getGoodsByName(auctionGoodsListDTO.getGoodsSkuName(), SecurityConstants.INNER) .getData(); - goodsSkuIdList = goodsSku.stream().map(GoodsSku::getId) - .collect(Collectors.toSet()); + if (goodsSku!=null){ + goodsSkuIdList = goodsSku.stream().map(GoodsSku::getId) + .collect(Collectors.toSet()); + } + } AuctionGoodsListPageDTO auctionGoodsListPageDTO=new AuctionGoodsListPageDTO(); - auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList); + if (StringUtils.isNotEmpty(auctionGoodsListDTO.getGoodsSkuName())) { + if (goodsSkuIdList != null) { + auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList); + } else { + goodsSkuIdList = new HashSet<>(); + goodsSkuIdList.add(0L); + auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList); + } + } Page<AuctionGoodsListVO> page = new Page<>(); page.setSize(auctionGoodsListDTO.getPageSize()); @@ -504,7 +539,6 @@ auctionGoodsinfoVO.setSpec(goodsSkuOne.getSpec()); auctionGoodsinfoVO.setSpecUnit(goodsSkuOne.getSpecUnit()); auctionGoodsinfoVO.setShareTitle(goodsSkuOne.getShareTitle()); - auctionGoodsinfoVO.setSpecUnit(goodsSkuOne.getSpecUnit()); auctionGoodsinfoVO.setDetail(goodsSkuOne.getDetail()); auctionGoodsinfoVO.setBond(byId.getBond()); auctionGoodsinfoVO.setYears(goodsSkuOne.getYears()); @@ -547,12 +581,18 @@ }else { auctionGoodsinfoVO.setIsCollection(1); } - List<OrderAuctionBond> datas = orderClient.getAuctionGoodsOrderAuctionBondList(auctionGoodsListDTO, SecurityConstants.INNER).getData(); - if (datas.size()>0){ - auctionGoodsinfoVO.setIsApply(2); - }else{ - auctionGoodsinfoVO.setIsApply(1); - } + LambdaQueryWrapper<AuctionBondJl> wrapper8=Wrappers.lambdaQuery(); + wrapper8.eq(AuctionBondJl::getAuctionGoodsId,byId.getId()); + wrapper8.eq(AuctionBondJl::getMemberId,auctionGoodsListDTO.getMemberId()); + wrapper8.eq(AuctionBondJl::getIsState,0); + AuctionBondJl auctionBondJl = auctionBondJlMapper.selectOne(wrapper8); + if(auctionBondJl!=null){ + auctionGoodsinfoVO.setIsApply(2); + }else{ + auctionGoodsinfoVO.setIsApply(1); + } + + LocalDateTime now = LocalDateTime.now(); LocalDateTime newTime7 = now.minusDays(7); @@ -634,7 +674,7 @@ Page<AuctionGoodsListVO> page = new Page<>(); page.setSize(auctionGoodsListDTO.getPageSize()); page.setCurrent(auctionGoodsListDTO.getPageCurr()); - List<AuctionGoods> auctionGoodsPgeList = auctionGoodsMapper.getAuctionGoodsPgeList(page, auctionGoodsListPageDTO); + List<AuctionGoods> auctionGoodsPgeList = auctionGoodsMapper.getAuctionGoodsPgeList1(page, auctionGoodsListPageDTO); List<AuctionGoodsListVO> auctionGoodsVOS=new ArrayList<>(); for (AuctionGoods auctionGoods:auctionGoodsPgeList){ AuctionGoodsListVO auctionGoodsVO=new AuctionGoodsListVO(); @@ -679,8 +719,7 @@ @Transactional public void endAuctionGoods(Long id) throws JsonProcessingException { AuctionGoods auctionGoods = this.getById(id); - if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getListingStatus().equals( - ListingStatusEnum.ON_SHELVES) && auctionGoods.getStartStatus() + if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getStartStatus() .equals(AuctionStartStatusEnum.IN_AUCTION)) { // 远程调用商品服务,获取商品信息 GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(auctionGoods.getGoodsSkuId(), @@ -692,12 +731,29 @@ id); List<AuctionBidRecord> auctionBidRecordList = new ArrayList<>(); if (StringUtils.isNotEmpty(auctionBidRecords)) { - // 中标 - for (int i = 0; i < auctionGoods.getAuctionStock(); i++) { - AuctionBidRecord auctionBidRecord = auctionBidRecords.get(i); - auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); - auctionBidRecordList.add(auctionBidRecord); + if (auctionBidRecords.size() >= auctionGoods.getAuctionStock()) { + // 中标 + for (int i = 0; i < auctionGoods.getAuctionStock(); i++) { + AuctionBidRecord auctionBidRecord = auctionBidRecords.get(i); + auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + auctionBidRecordList.add(auctionBidRecord); + } + } else { + // 中标 + for (int i = 0; i < auctionBidRecords.size(); i++) { + AuctionBidRecord auctionBidRecord = auctionBidRecords.get(i); + auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + auctionBidRecordList.add(auctionBidRecord); + } + // 退回剩余库存 + GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); + goodsStockUpdDTO.setGoodsSkuId(auctionGoods.getGoodsSkuId()); + goodsStockUpdDTO.setAuctionStock( + auctionGoods.getAuctionStock() - auctionBidRecords.size()); + goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), + SecurityConstants.INNER); } + auctionBidRecordService.updateBatchById(auctionBidRecordList); // 创建待支付订单 @@ -705,12 +761,6 @@ ConfigEnum.MEMBER_POINTS_MONEY.getKey()).getData(); CustomConfig pointsConfig = sysUserClient.getconfig( ConfigEnum.MEMBER_POINTS_POINTS.getKey()).getData(); - BigDecimal ratio = - BigDecimal.valueOf(Double.parseDouble( - pointsConfig.getConfigValue())) - .divide(BigDecimal.valueOf(Double.parseDouble( - moneyConfig.getConfigValue())), 0, RoundingMode.DOWN); - for (AuctionBidRecord auctionBidRecord : auctionBidRecordList) { BigDecimal lastBidAmount = auctionBidRecord.getLastBidAmount(); BigDecimal divide = lastBidAmount.divide( @@ -774,6 +824,7 @@ RefundDTO refundDTO = new RefundDTO(); refundDTO.setOrderNo(orderAuctionBond.getOrderNo()); refundDTO.setAmount(orderAuctionBond.getBond()); + refundDTOList.add(refundDTO); } // 远程调用订单服务进行退款 Map<String, Object> data = orderClient.refund(refundDTOList, @@ -798,7 +849,7 @@ return null; }).filter(Objects::nonNull).collect(Collectors.toList()); // 远程调用订单服务修改订单状态 - orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.PAID, + orderClient.updateOrderAuctionBondStatus(ids, BondStatusEnum.REFUNDED, SecurityConstants.INNER); } } -- Gitblit v1.7.1