From 2dcde26e44e85d84c3a20fee0aaed3724edba3bc Mon Sep 17 00:00:00 2001 From: rentaiming <806181062@qq.com> Date: 星期一, 03 六月 2024 14:11:40 +0800 Subject: [PATCH] 用户端商品 --- ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java | 432 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 339 insertions(+), 93 deletions(-) diff --git a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java index c46947e..560659e 100644 --- a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java +++ b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java @@ -2,32 +2,51 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ruoyi.auction.controller.forepart.DTO.AuctionSalesroomGoodsDTO; -import com.ruoyi.auction.controller.forepart.VO.AuctionSalesroomVO; -import com.ruoyi.auction.controller.forepart.VO.ForepartAuctionSalesroomGoodsVO; -import com.ruoyi.auction.domain.pojo.AuctionBidRecord; -import com.ruoyi.auction.domain.pojo.AuctionSalesroom; -import com.ruoyi.auction.domain.pojo.AuctionSalesroomGoods; -import com.ruoyi.auction.mapper.AuctionSalesroomGoodsMapper; -import com.ruoyi.auction.service.IAuctionBidRecordService; -import com.ruoyi.auction.service.IAuctionSalesroomGoodsService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.google.common.collect.Lists; +import com.ruoyi.auction.controller.forepart.dto.AuctionSalesroomGoodsDTO; +import com.ruoyi.auction.controller.forepart.dto.AuctionSalesroomGoodsInfoDTO; +import com.ruoyi.auction.controller.forepart.dto.OrderDTO; +import com.ruoyi.auction.controller.forepart.vo.AuctionBidRecordVO; +import com.ruoyi.auction.controller.forepart.vo.AuctionSalesroomGoodsInfoVO; +import com.ruoyi.auction.controller.forepart.vo.AuctionSalesroomVO; +import com.ruoyi.auction.controller.forepart.vo.ForepartAuctionSalesroomGoodsVO; +import com.ruoyi.auction.domain.AuctionBidRecord; +import com.ruoyi.auction.domain.AuctionBrowseRecord; +import com.ruoyi.auction.domain.AuctionSalesroomGoods; +import com.ruoyi.auction.mapper.AuctionBidRecordMapper; +import com.ruoyi.auction.mapper.AuctionSalesroomGoodsMapper; +import com.ruoyi.auction.mapper.AuctionSalesroomMapper; +import com.ruoyi.auction.service.IAuctionBrowseRecordService; +import com.ruoyi.auction.service.IAuctionSalesroomGoodsService; import com.ruoyi.auction.service.IAuctionSalesroomService; +import com.ruoyi.common.core.constant.SecurityConstants; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.enums.AuctionGoodsStatusEnum; +import com.ruoyi.common.core.enums.AuctionOrderTypeEnum; import com.ruoyi.common.core.enums.AuctionStartStatusEnum; import com.ruoyi.common.core.enums.BidStatusEnum; +import com.ruoyi.common.core.enums.OrderFromEnum; +import com.ruoyi.system.api.domain.AuctionSalesroom; +import com.ruoyi.system.api.domain.GoodsBrand; +import com.ruoyi.system.api.domain.GoodsCategory; +import com.ruoyi.system.api.domain.GoodsFlavorType; +import com.ruoyi.system.api.domain.GoodsSeries; import com.ruoyi.system.api.domain.GoodsSku; +import com.ruoyi.system.api.domain.Member; +import com.ruoyi.system.api.domain.MemberAddress; +import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO; +import com.ruoyi.system.api.domain.dto.OrderAuctionBondDTO; import com.ruoyi.system.api.feignClient.GoodsSkuClient; -import io.swagger.annotations.ApiOperation; -import org.apache.poi.ss.formula.functions.T; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; +import com.ruoyi.system.api.feignClient.MemberClient; +import com.ruoyi.system.api.feignClient.OrderClient; +import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import javax.annotation.Resource; +import org.springframework.stereotype.Service; /** * <p> @@ -43,13 +62,26 @@ private GoodsSkuClient goodsSkuClient; @Resource - private IAuctionSalesroomService iAuctionSalesroomService; + private AuctionSalesroomMapper auctionSalesroomMapper; @Resource - private IAuctionSalesroomGoodsService iAuctionSalesroomGoodsService; + private AuctionBidRecordMapper auctionBidRecordMapper; @Resource - private IAuctionBidRecordService iAuctionBidRecordService; + private MemberClient emberClient; + + @Resource + private OrderClient orderClient; + + @Resource + + private IAuctionBrowseRecordService iAuctionBrowseRecordService; + + @Resource + private IAuctionSalesroomService iAuctionSalesroomService; + + + /** @@ -57,56 +89,62 @@ * */ @Override - public ForepartAuctionSalesroomGoodsVO getAuctionSalesroomGoods(Integer SalesroomId) { + public ForepartAuctionSalesroomGoodsVO getAuctionSalesroomGoods(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO =new ForepartAuctionSalesroomGoodsVO(); - AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(SalesroomId); + AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById( + ationSalesroomGoodsDTO.getAuctionSalesroomId()); forepartAuctionSalesroomGoodsVO.setSalesroomId(auctionSalesroom.getId()); forepartAuctionSalesroomGoodsVO.setSalesroomName(auctionSalesroom.getSalesroomName()); forepartAuctionSalesroomGoodsVO.setSalesroomType(auctionSalesroom.getType().getCode()); LambdaQueryWrapper<AuctionSalesroomGoods> wrapper=Wrappers.lambdaQuery(); wrapper.eq(AuctionSalesroomGoods::getStatus,1); - wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper.eq(AuctionSalesroomGoods::getDelFlag,0); - AuctionSalesroomGoods auctionSalesroomGoods=iAuctionSalesroomGoodsService.getOne(wrapper); + AuctionSalesroomGoods auctionSalesroomGoods = this.getOne(wrapper); if (auctionSalesroomGoods==null){ LambdaQueryWrapper<AuctionSalesroomGoods> wrapper1=Wrappers.lambdaQuery(); wrapper1.eq(AuctionSalesroomGoods::getStatus,2); wrapper1.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper1.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper1.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper1.orderByAsc(AuctionSalesroomGoods::getSortNum); wrapper1.last("limit 1"); - auctionSalesroomGoods=iAuctionSalesroomGoodsService.getOne(wrapper1); + auctionSalesroomGoods = this.getOne(wrapper1); if (auctionSalesroomGoods==null){ LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery(); wrapper2.eq(AuctionSalesroomGoods::getStatus,0); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper2.orderByAsc(AuctionSalesroomGoods::getSortNum); wrapper2.last("limit 1"); - auctionSalesroomGoods=iAuctionSalesroomGoodsService.getOne(wrapper2); + auctionSalesroomGoods = this.getOne(wrapper2); } } - - forepartAuctionSalesroomGoodsVO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId()); - forepartAuctionSalesroomGoodsVO.setGoodsSkuName(auctionSalesroomGoods.getGoodsSkuName()); + GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(auctionSalesroomGoods.getGoodsSkuId(), SecurityConstants.INNER) + .getData(); + forepartAuctionSalesroomGoodsVO.setGoodsSkuId(auctionSalesroomGoods.getId()); + forepartAuctionSalesroomGoodsVO.setGoodsSkuName(goodsSku.getSkuName()); forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(auctionSalesroomGoods.getStatus().getCode()); forepartAuctionSalesroomGoodsVO.setStartingPrice(auctionSalesroomGoods.getStartingPrice()); - forepartAuctionSalesroomGoodsVO.setItemQuantity(auctionSalesroomGoods.getItemQuantity()); + forepartAuctionSalesroomGoodsVO.setSalesroomStock(auctionSalesroomGoods.getSalesroomStock()); forepartAuctionSalesroomGoodsVO.setListingDuration(auctionSalesroomGoods.getListingDuration()); forepartAuctionSalesroomGoodsVO.setStartTime(auctionSalesroomGoods.getStartTime()); - R<GoodsSku> goodsSkuOne = goodsSkuClient.getGoodsSkuOne(auctionSalesroomGoods.getGoodsSkuId()); - GoodsSku goodsSku=goodsSkuOne.getData(); forepartAuctionSalesroomGoodsVO.setCoverPic(goodsSku.getCoverPic()); forepartAuctionSalesroomGoodsVO.setDescription(goodsSku.getDescription()); + forepartAuctionSalesroomGoodsVO.setDetail(goodsSku.getDetail()); + forepartAuctionSalesroomGoodsVO.setYears(String.valueOf(goodsSku.getYears().getYear())); forepartAuctionSalesroomGoodsVO.setUnit(goodsSku.getUnit()); + forepartAuctionSalesroomGoodsVO.setSpec(goodsSku.getSpec()); + forepartAuctionSalesroomGoodsVO.setSpecUnit(goodsSku.getSpecUnit()); if (auctionSalesroomGoods.getStatus().getCode()==0 || auctionSalesroomGoods.getStatus().getCode()==2){ LambdaQueryWrapper<AuctionSalesroomGoods> wrapper1=Wrappers.lambdaQuery(); wrapper1.eq(AuctionSalesroomGoods::getDelFlag,0); wrapper1.eq(AuctionSalesroomGoods::getSortNum,auctionSalesroomGoods.getSortNum()+1); wrapper1.last("limit 1"); - AuctionSalesroomGoods auctionSalesroomGoods1=iAuctionSalesroomGoodsService.getOne(wrapper1); + AuctionSalesroomGoods auctionSalesroomGoods1 = this.getOne(wrapper1); if (auctionSalesroomGoods1!=null){ - forepartAuctionSalesroomGoodsVO.setNextGoodsSkuName(auctionSalesroomGoods1.getGoodsSkuName()); + GoodsSku goodsSku1 = goodsSkuClient.getGoodsSkuOne(auctionSalesroomGoods1.getGoodsSkuId(), SecurityConstants.INNER) + .getData(); + forepartAuctionSalesroomGoodsVO.setNextGoodsSkuName(goodsSku1.getSkuName()); } } return forepartAuctionSalesroomGoodsVO; @@ -120,9 +158,10 @@ * */ @Override - public AuctionSalesroomVO getAuctionSalesroominfo(Integer SalesroomId) { + public AuctionSalesroomVO getAuctionSalesroominfo(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO =new ForepartAuctionSalesroomGoodsVO(); - AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(SalesroomId); + AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById( + ationSalesroomGoodsDTO.getAuctionSalesroomId()); AuctionSalesroomVO auctionSalesroomVO=new AuctionSalesroomVO(); auctionSalesroomVO.setCoverPic(auctionSalesroom.getCoverPic()); auctionSalesroomVO.setDescription(auctionSalesroom.getDescription()); @@ -136,14 +175,15 @@ LambdaQueryWrapper<AuctionSalesroomGoods> wrapper=Wrappers.lambdaQuery(); wrapper.eq(AuctionSalesroomGoods::getStatus,0); wrapper.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper.orderByAsc(AuctionSalesroomGoods::getSortNum); - List<AuctionSalesroomGoods> auctionSalesroomGoods=iAuctionSalesroomGoodsService.list(wrapper); + List<AuctionSalesroomGoods> auctionSalesroomGoods = this.list(wrapper); for (AuctionSalesroomGoods salesroomGoods:auctionSalesroomGoods){ ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO1=new ForepartAuctionSalesroomGoodsVO(); - R<GoodsSku> goodsSkuOne = goodsSkuClient.getGoodsSkuOne(salesroomGoods.getGoodsSkuId()); + R<GoodsSku> goodsSkuOne = goodsSkuClient.getGoodsSkuOne( + salesroomGoods.getGoodsSkuId(), SecurityConstants.INNER); GoodsSku goodsSku=goodsSkuOne.getData(); - forepartAuctionSalesroomGoodsVO1.setGoodsSkuName(salesroomGoods.getGoodsSkuName()); + forepartAuctionSalesroomGoodsVO1.setGoodsSkuName(goodsSku.getSkuName()); forepartAuctionSalesroomGoodsVO1.setCoverPic(goodsSku.getCoverPic()); auctionSalesroomGoodsVOS.add(forepartAuctionSalesroomGoodsVO1); } @@ -152,13 +192,14 @@ LambdaQueryWrapper<AuctionSalesroomGoods> wrapper=Wrappers.lambdaQuery(); wrapper.eq(AuctionSalesroomGoods::getStatus,1); wrapper.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper.last("limit 1"); - AuctionSalesroomGoods auctionSalesroomGoods= iAuctionSalesroomGoodsService.getOne(wrapper); + AuctionSalesroomGoods auctionSalesroomGoods = this.getOne(wrapper); ForepartAuctionSalesroomGoodsVO currentAuctionSalesroomGoods= new ForepartAuctionSalesroomGoodsVO(); - currentAuctionSalesroomGoods.setGoodsSkuName(auctionSalesroomGoods.getGoodsSkuName()); - R<GoodsSku> goodsSkuOne = goodsSkuClient.getGoodsSkuOne(auctionSalesroomGoods.getGoodsSkuId()); + R<GoodsSku> goodsSkuOne = goodsSkuClient.getGoodsSkuOne( + auctionSalesroomGoods.getGoodsSkuId(), SecurityConstants.INNER); GoodsSku goodsSku=goodsSkuOne.getData(); + currentAuctionSalesroomGoods.setGoodsSkuName(goodsSku.getSkuName()); currentAuctionSalesroomGoods.setCoverPic(goodsSku.getCoverPic()); auctionSalesroomVO.setCurrentAuctionSalesroomGoods(currentAuctionSalesroomGoods); @@ -168,35 +209,64 @@ wrapper1.eq(AuctionSalesroomGoods::getDelFlag,0); wrapper1.eq(AuctionSalesroomGoods::getSortNum,auctionSalesroomGoods.getSortNum()+1); wrapper1.last("limit 1"); - AuctionSalesroomGoods auctionSalesroomGoods1=iAuctionSalesroomGoodsService.getOne(wrapper1); + AuctionSalesroomGoods auctionSalesroomGoods1 = this.getOne(wrapper1); ForepartAuctionSalesroomGoodsVO nextAuctionSalesroomGoods= new ForepartAuctionSalesroomGoodsVO(); if (auctionSalesroomGoods1!=null){ list.add(auctionSalesroomGoods.getSortNum()+1); - nextAuctionSalesroomGoods.setNextGoodsSkuName(auctionSalesroomGoods1.getGoodsSkuName()); - R<GoodsSku> goodsSkuOne1 = goodsSkuClient.getGoodsSkuOne(auctionSalesroomGoods.getGoodsSkuId()); + R<GoodsSku> goodsSkuOne1 = goodsSkuClient.getGoodsSkuOne( + auctionSalesroomGoods.getGoodsSkuId(), SecurityConstants.INNER); GoodsSku goodsSku1=goodsSkuOne1.getData(); + nextAuctionSalesroomGoods.setNextGoodsSkuName(goodsSku1.getSkuName()); nextAuctionSalesroomGoods.setCoverPic(goodsSku1.getCoverPic()); auctionSalesroomVO.setNextAuctionSalesroomGoods(nextAuctionSalesroomGoods); } LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery(); - wrapper2.in(AuctionSalesroomGoods::getSortNum,list); + wrapper2.notIn(AuctionSalesroomGoods::getSortNum,list); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper2.orderByAsc(AuctionSalesroomGoods::getSortNum); wrapper2.orderByAsc(AuctionSalesroomGoods::getStatus); - List<AuctionSalesroomGoods> auctionSalesroomGoods2=iAuctionSalesroomGoodsService.list(wrapper2); + List<AuctionSalesroomGoods> auctionSalesroomGoods2 = this.list(wrapper2); for (AuctionSalesroomGoods salesroomGoods:auctionSalesroomGoods2){ ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO1=new ForepartAuctionSalesroomGoodsVO(); - R<GoodsSku> goodsSkuOne2 = goodsSkuClient.getGoodsSkuOne(salesroomGoods.getGoodsSkuId()); + R<GoodsSku> goodsSkuOne2 = goodsSkuClient.getGoodsSkuOne( + salesroomGoods.getGoodsSkuId(), SecurityConstants.INNER); GoodsSku goodsSku2=goodsSkuOne2.getData(); - forepartAuctionSalesroomGoodsVO1.setGoodsSkuName(salesroomGoods.getGoodsSkuName()); - forepartAuctionSalesroomGoodsVO1.setCoverPic(goodsSku.getCoverPic()); + forepartAuctionSalesroomGoodsVO1.setGoodsSkuName(goodsSku2.getSkuName()); + forepartAuctionSalesroomGoodsVO1.setCoverPic(goodsSku2.getCoverPic()); auctionSalesroomGoodsVOS.add(forepartAuctionSalesroomGoodsVO1); } } auctionSalesroomVO.setElseAuctionSalesroomGoods(auctionSalesroomGoodsVOS); + + LocalDateTime now = LocalDateTime.now(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String formattedDate = now.format(formatter); + LocalDateTime parseTime = LocalDateTime.parse(formattedDate, formatter); + LocalDateTime newTime7 = now.minusDays(7); + String formattedDate7 = newTime7.format(formatter); + LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter); + + LambdaQueryWrapper<AuctionBrowseRecord> wrapper3=Wrappers.lambdaQuery(); + wrapper3.eq(AuctionBrowseRecord::getDelFlag,0); + wrapper3.eq(AuctionBrowseRecord::getTargetId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); + wrapper3.eq(AuctionBrowseRecord::getMemberId,ationSalesroomGoodsDTO.getMemberId()); + wrapper3.ge(AuctionBrowseRecord::getCreateTime, parseTime7) + .le(AuctionBrowseRecord::getCreateTime, parseTime); + List<AuctionBrowseRecord> list = iAuctionBrowseRecordService.list(wrapper3); + if (list.size()==0){ + AuctionBrowseRecord auctionBrowseRecord=new AuctionBrowseRecord(); + auctionBrowseRecord.setBrowseType(AuctionOrderTypeEnum.AUCTION_ITEMS); + auctionBrowseRecord.setMemberId(ationSalesroomGoodsDTO.getMemberId()); + auctionBrowseRecord.setTargetId(ationSalesroomGoodsDTO.getAuctionSalesroomId()); + iAuctionBrowseRecordService.save(auctionBrowseRecord); + } + + + + return auctionSalesroomVO; } @@ -210,22 +280,22 @@ * */ @Override - public void auctionSalesroomStart(Integer SalesroomId) { - ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO =new ForepartAuctionSalesroomGoodsVO(); - AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(SalesroomId); + public void auctionSalesroomStart(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { + AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById( + ationSalesroomGoodsDTO.getAuctionSalesroomId()); auctionSalesroom.setStatus(AuctionStartStatusEnum.IN_AUCTION); auctionSalesroom.setStartTime(LocalDateTime.now()); - iAuctionSalesroomService.updateById(auctionSalesroom); + auctionSalesroomMapper.updateById(auctionSalesroom); LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery(); wrapper2.eq(AuctionSalesroomGoods::getStatus,0); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); + wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper2.orderByAsc(AuctionSalesroomGoods::getSortNum); wrapper2.last("limit 1"); - AuctionSalesroomGoods auctionSalesroomGoods=iAuctionSalesroomGoodsService.getOne(wrapper2); - auctionSalesroomGoods.setStatus(AuctionStartStatusEnum.IN_AUCTION); - iAuctionSalesroomGoodsService.updateById(auctionSalesroomGoods); + AuctionSalesroomGoods auctionSalesroomGoods = this.getOne(wrapper2); + auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS); + this.updateById(auctionSalesroomGoods); } @@ -235,21 +305,47 @@ * */ @Override - public void auctionSalesroomEnd(Integer SalesroomId) { - ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO =new ForepartAuctionSalesroomGoodsVO(); - AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(SalesroomId); + public void auctionSalesroomEnd(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { + AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById( + ationSalesroomGoodsDTO.getAuctionSalesroomId()); auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED); auctionSalesroom.setEndTime(LocalDateTime.now()); - iAuctionSalesroomService.updateById(auctionSalesroom); + auctionSalesroomMapper.updateById(auctionSalesroom); LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery(); wrapper2.eq(AuctionSalesroomGoods::getStatus,0); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); - List<AuctionSalesroomGoods> auctionSalesroomGoods=iAuctionSalesroomGoodsService.list(wrapper2); - for (AuctionSalesroomGoods salesroomGoods:auctionSalesroomGoods){ - salesroomGoods.setStatus(AuctionStartStatusEnum.ENDED); - iAuctionSalesroomGoodsService.updateById(salesroomGoods); + wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); + List<AuctionSalesroomGoods> auctionSalesroomGoods=this.list(wrapper2); + if (auctionSalesroomGoods.size()>0){ + for (AuctionSalesroomGoods salesroomGoods:auctionSalesroomGoods){ + salesroomGoods.setStatus(AuctionGoodsStatusEnum.ENDED); + this.updateById(salesroomGoods); + + GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); + goodsStockUpdDTO.setGoodsSkuId(salesroomGoods.getGoodsSkuId()); + goodsStockUpdDTO.setAuctionStock(salesroomGoods.getSalesroomStock()); + goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), + SecurityConstants.INNER); + + } + + } + List<Long> list=new ArrayList<>(); + LambdaQueryWrapper<AuctionBidRecord> wrapper = Wrappers.lambdaQuery(); + wrapper.eq(AuctionBidRecord::getAuctionSalesroomId, ationSalesroomGoodsDTO.getAuctionSalesroomId()); + wrapper.eq(AuctionBidRecord::getDelFlag, 0); + wrapper.eq(AuctionBidRecord::getStatus,0); + List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList(wrapper); + for (AuctionBidRecord auctionBidRecord:auctionBidRecordList){ + list.add(auctionBidRecord.getMemberId()); + } + if (list.size()>0){ + OrderAuctionBondDTO orderAuctionBondDTO=new OrderAuctionBondDTO(); + orderAuctionBondDTO.setAuctionSalesroomId(auctionSalesroom.getId()); + orderAuctionBondDTO.setUserList(list); + orderClient.getOrderAuctionBond(orderAuctionBondDTO, + SecurityConstants.INNER); } } @@ -259,12 +355,12 @@ * */ @Override - public List<AuctionSalesroomGoods> isAuctionSalesroom(Integer SalesroomId) { + public List<AuctionSalesroomGoods> isAuctionSalesroom(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) { LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery(); wrapper2.eq(AuctionSalesroomGoods::getStatus,0); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); - wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,SalesroomId); - List<AuctionSalesroomGoods> auctionSalesroomGoods=iAuctionSalesroomGoodsService.list(wrapper2); + wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,ationSalesroomGoodsDTO.getAuctionSalesroomId()); + List<AuctionSalesroomGoods> auctionSalesroomGoods = this.list(wrapper2); return auctionSalesroomGoods; } @@ -279,9 +375,11 @@ wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,auctionSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); wrapper2.eq(AuctionSalesroomGoods::getGoodsSkuId,auctionSalesroomGoodsDTO.getGoodsSkuId()); - AuctionSalesroomGoods auctionSalesroomGoods=iAuctionSalesroomGoodsService.getOne(wrapper2); - auctionSalesroomGoods.setStatus(AuctionStartStatusEnum.IN_AUCTION); - iAuctionSalesroomGoodsService.updateById(auctionSalesroomGoods); + AuctionSalesroomGoods auctionSalesroomGoods=this.getOne(wrapper2); + auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS); + this.updateById(auctionSalesroomGoods); + + } @@ -296,31 +394,179 @@ wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,auctionSalesroomGoodsDTO.getAuctionSalesroomId()); wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0); wrapper2.eq(AuctionSalesroomGoods::getGoodsSkuId,auctionSalesroomGoodsDTO.getGoodsSkuId()); - AuctionSalesroomGoods auctionSalesroomGood=iAuctionSalesroomGoodsService.getOne(wrapper2); - auctionSalesroomGood.setStatus(AuctionStartStatusEnum.ENDED); - iAuctionSalesroomGoodsService.updateById(auctionSalesroomGood); + AuctionSalesroomGoods auctionSalesroomGood=this.getOne(wrapper2); + AuctionSalesroom auctionSalesroom=iAuctionSalesroomService.getById(auctionSalesroomGood.getAuctionSalesroomId()); - AuctionSalesroomGoods auctionSalesroomGoods=iAuctionSalesroomGoodsService.getById(auctionSalesroomGoodsDTO.getGoodsSkuId()); + AuctionSalesroomGoods auctionSalesroomGoods=this.getById(auctionSalesroomGoodsDTO.getGoodsSkuId()); List<AuctionBidRecord> auctionBidRecordList=new ArrayList<>(); + if (auctionSalesroomGoods.getStatus().getCode()==1) { LambdaQueryWrapper<AuctionBidRecord> wrapper = Wrappers.lambdaQuery(); - wrapper.eq(AuctionBidRecord::getGoodsSkuId, auctionSalesroomGoodsDTO.getGoodsSkuId()); + wrapper.eq(AuctionBidRecord::getAuctionSalesroomId,auctionSalesroomGoodsDTO.getAuctionSalesroomId()); + wrapper.eq(AuctionBidRecord::getTargetId, auctionSalesroomGoodsDTO.getGoodsSkuId()); wrapper.eq(AuctionBidRecord::getDelFlag, 0); wrapper.orderByDesc(AuctionBidRecord::getLastBidAmount); - auctionBidRecordList = iAuctionBidRecordService.list(wrapper); - //判断 - if (auctionBidRecordList.size() >= auctionSalesroomGoods.getItemQuantity()) { - for (int i = 0; i <= auctionSalesroomGoods.getItemQuantity(); i++) { - AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); - auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); - } - } else { - for (int i = 0; i <= auctionBidRecordList.size(); i++) { - AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); - auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + auctionBidRecordList = auctionBidRecordMapper.selectList(wrapper); + if(auctionBidRecordList.size()>0){ + //判断 + if (auctionBidRecordList.size() >= auctionSalesroomGoods.getSalesroomStock()) { + for (int i = 0; i <= auctionSalesroomGoods.getSalesroomStock(); i++) { + AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); + auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + AddOrder(auctionBidRecord.getTargetId(), auctionBidRecord.getMemberId(), + auctionBidRecord.getLastBidAmount(), auctionSalesroom.getBond()); + } + } else { + GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); + goodsStockUpdDTO.setGoodsSkuId(auctionSalesroomGoods.getGoodsSkuId()); + goodsStockUpdDTO.setAuctionStock(auctionSalesroomGoods.getSalesroomStock()- auctionBidRecordList.size()); + goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), + SecurityConstants.INNER); + + + for (int i = 0; i <= auctionBidRecordList.size(); i++) { + AuctionBidRecord auctionBidRecord = auctionBidRecordList.get(i); + auctionBidRecord.setStatus(BidStatusEnum.SUCCESSFUL); + AddOrder(auctionBidRecord.getTargetId(), auctionBidRecord.getMemberId(), + auctionBidRecord.getLastBidAmount(), auctionSalesroom.getBond()); + } } } } + auctionSalesroomGood.setStatus(AuctionGoodsStatusEnum.ENDED); + this.updateById(auctionSalesroomGood); + } + + @Override + public AuctionSalesroomGoodsInfoVO getAuctionSalesroomGoodsInfo(AuctionSalesroomGoodsInfoDTO auctionSalesroomGoodsInfoDTO) { + AuctionSalesroom byId = auctionSalesroomMapper.selectById(auctionSalesroomGoodsInfoDTO.getAuctionSalesroomId()); + AuctionSalesroomGoods byId1 = this.getById(auctionSalesroomGoodsInfoDTO.getGoodsSkuId()); + GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(byId1.getGoodsSkuId(), SecurityConstants.INNER).getData(); + AuctionSalesroomGoodsInfoVO AuctionSalesroomGoodsInfoVO=new AuctionSalesroomGoodsInfoVO(); + AuctionSalesroomGoodsInfoVO.setSalesroomId(byId.getId()); + AuctionSalesroomGoodsInfoVO.setSalesroomName(byId.getSalesroomName()); + AuctionSalesroomGoodsInfoVO.setGoodsSkuId(byId1.getId()); + AuctionSalesroomGoodsInfoVO.setGoodsSkuName(goodsSku.getSkuName()); + AuctionSalesroomGoodsInfoVO.setStartingPrice(byId1.getStartingPrice()); + AuctionSalesroomGoodsInfoVO.setSalesroomStock(byId1.getSalesroomStock()); + AuctionSalesroomGoodsInfoVO.setSalesroomType(byId.getType().getCode()); + AuctionSalesroomGoodsInfoVO.setGoodsSkustatus(byId1.getStatus().getCode()); + AuctionSalesroomGoodsInfoVO.setListingDuration(byId1.getListingDuration()); + AuctionSalesroomGoodsInfoVO.setStartTime(byId1.getStartTime()); + AuctionSalesroomGoodsInfoVO.setUnit(goodsSku.getUnit()); + AuctionSalesroomGoodsInfoVO.setDescription(goodsSku.getDescription()); + AuctionSalesroomGoodsInfoVO.setDetail(goodsSku.getDetail()); + AuctionSalesroomGoodsInfoVO.setYears(String.valueOf(goodsSku.getYears().getYear())); + GoodsBrand data = goodsSkuClient.getBrandOne(goodsSku.getBrandId(), SecurityConstants.INNER).getData(); + GoodsCategory data1 = goodsSkuClient.getCategoryOne(goodsSku.getCategoryId(), SecurityConstants.INNER).getData(); + GoodsSeries data2 = goodsSkuClient.getSeriesOne(goodsSku.getSeriesId(), SecurityConstants.INNER).getData(); + GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(goodsSku.getFlavorTypeId(), SecurityConstants.INNER).getData(); + AuctionSalesroomGoodsInfoVO.setBrand(data.getBrandName()); + AuctionSalesroomGoodsInfoVO.setCategory(data1.getCategoryName()); + AuctionSalesroomGoodsInfoVO.setSeries(data2.getSeriesName()); + AuctionSalesroomGoodsInfoVO.setFlavorType(data3.getFlavorTypeName()); + AuctionSalesroomGoodsInfoVO.setCoverPic(goodsSku.getCoverPic()); + AuctionSalesroomGoodsInfoVO.setAlbum(goodsSku.getAlbum()); + AuctionSalesroomGoodsInfoVO.setSpec(goodsSku.getSpec()); + AuctionSalesroomGoodsInfoVO.setSpecUnit(goodsSku.getSpecUnit()); + AuctionSalesroomGoodsInfoVO.setMinimumMarkupAmount(byId1.getMinimumMarkupAmount()); + LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery(); + wrapper1.eq(AuctionBidRecord::getMemberId,auctionSalesroomGoodsInfoDTO.getMemberId()); + wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId,byId.getId()); + wrapper1.eq(AuctionBidRecord::getAuctionType,2); + wrapper1.eq(AuctionBidRecord::getTargetId,byId1.getId()); + wrapper1.eq(AuctionBidRecord::getDelFlag,0); + AuctionBidRecord list1 = auctionBidRecordMapper.selectOne(wrapper1); + if (list1!=null){ + AuctionSalesroomGoodsInfoVO.setIsBond(2); + AuctionSalesroomGoodsInfoVO.setPresentBid(list1.getLastBidAmount()); + if (list1.getStatus().getCode()==2){ + AuctionSalesroomGoodsInfoVO.setIsStatus(2); + }else{ + AuctionSalesroomGoodsInfoVO.setIsStatus(1); + } + }else{ + AuctionSalesroomGoodsInfoVO.setIsBond(1); + AuctionSalesroomGoodsInfoVO.setIsStatus(1); + } + + return AuctionSalesroomGoodsInfoVO; + } + + @Override + public List<AuctionBidRecordVO> getAuctionBidRecord(AuctionSalesroomGoodsInfoDTO auctionSalesroomGoodsInfoDTO) { + LambdaQueryWrapper<AuctionBidRecord> wrapper=Wrappers.lambdaQuery(); + wrapper.eq(AuctionBidRecord::getAuctionSalesroomId,auctionSalesroomGoodsInfoDTO.getAuctionSalesroomId()); + wrapper.eq(AuctionBidRecord::getDelFlag,0); + wrapper.eq(AuctionBidRecord::getTargetId,auctionSalesroomGoodsInfoDTO.getGoodsSkuId()); + wrapper.orderByDesc(AuctionBidRecord::getLastBidAmount); + wrapper.last("limit 10"); + List<AuctionBidRecord> auctionBidRecordList = auctionBidRecordMapper.selectList(wrapper); + List<AuctionBidRecordVO> auctionBidRecordVOList=new ArrayList<>(); + for (int i=0;i<auctionBidRecordList.size();i++){ + AuctionBidRecordVO auctionBidRecordVO=new AuctionBidRecordVO(); + auctionBidRecordVO.setSort(i+1); + auctionBidRecordVO.setLastBidAmount(auctionBidRecordList.get(i).getLastBidAmount()); + auctionBidRecordVO.setLastBidTime(auctionBidRecordList.get(i).getLastBidTime()); + Member data = emberClient.getMembeOne(auctionBidRecordList.get(i).getMemberId(), + SecurityConstants.INNER).getData(); + auctionBidRecordVO.setMemberName(data.getNickname()); + auctionBidRecordVO.setMemberId(data.getId()); + auctionBidRecordVOList.add(auctionBidRecordVO); + } + LambdaQueryWrapper<AuctionBidRecord> wrapper1=Wrappers.lambdaQuery(); + wrapper1.eq(AuctionBidRecord::getAuctionSalesroomId,auctionSalesroomGoodsInfoDTO.getAuctionSalesroomId()); + wrapper1.eq(AuctionBidRecord::getDelFlag,0); + wrapper1.eq(AuctionBidRecord::getTargetId,auctionSalesroomGoodsInfoDTO.getGoodsSkuId()); + wrapper1.eq(AuctionBidRecord::getMemberId,auctionSalesroomGoodsInfoDTO.getMemberId()); + wrapper.last("limit 1"); + AuctionBidRecord auctionBidRecord = auctionBidRecordMapper.selectOne(wrapper); + + LambdaQueryWrapper<AuctionBidRecord> wrapper3=Wrappers.lambdaQuery(); + wrapper3.eq(AuctionBidRecord::getAuctionSalesroomId,auctionSalesroomGoodsInfoDTO.getAuctionSalesroomId()); + wrapper3.eq(AuctionBidRecord::getDelFlag,0); + wrapper3.eq(AuctionBidRecord::getTargetId,auctionSalesroomGoodsInfoDTO.getGoodsSkuId()); + wrapper3.le(AuctionBidRecord::getId,auctionBidRecord.getId()); + wrapper3.orderByDesc(AuctionBidRecord::getLastBidAmount); + Long count = auctionBidRecordMapper.selectCount(wrapper); + if (count>0){ + AuctionBidRecordVO auctionBidRecordVO=new AuctionBidRecordVO(); + auctionBidRecordVO.setSort(Integer.valueOf(count.intValue())); + auctionBidRecordVO.setLastBidAmount(auctionBidRecord.getLastBidAmount()); + auctionBidRecordVO.setLastBidTime(auctionBidRecord.getLastBidTime()); + Member data = emberClient.getMembeOne(auctionBidRecord.getMemberId(), + SecurityConstants.INNER).getData(); + auctionBidRecordVO.setMemberName(data.getNickname()); + auctionBidRecordVO.setMemberId(data.getId()); + auctionBidRecordVOList.add(auctionBidRecordVO); + } + return auctionBidRecordVOList; + } + + + public void AddOrder(Long goodsSkuId, Long memberId, BigDecimal lastBidAmount,BigDecimal bound) { + OrderDTO order=new OrderDTO(); + order.setGoodsSkuId(goodsSkuId); + order.setOrderTime(LocalDateTime.now()); + order.setOrderFrom(OrderFromEnum.AUCTION_ORDERS); + order.setMemberId(memberId); + AuctionSalesroomGoods auctionSalesroomGoods = this.getById(goodsSkuId); + order.setGoodsQuantity(1); + order.setTotalAmount(lastBidAmount); + + R<MemberAddress> memberAddressR = emberClient.getMemberAddressOne(memberId, + SecurityConstants.INNER); + MemberAddress memberAddress=memberAddressR.getData(); + order.setReceiverCity(memberAddress.getCity()); + order.setReceiverDetailAddress(memberAddress.getDetailedAddress()); + order.setReceiverphone(memberAddress.getRecipientPhone()); + order.setReceiverName(memberAddress.getRecipientName()); + order.setBound(bound); + order.setAuctionType(AuctionOrderTypeEnum.AUCTION_ITEMS); + + } + + } -- Gitblit v1.7.1