| | |
| | | package com.ruoyi.auction.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.auction.controller.management.dto.AuctionGoodsDTO; |
| | | import com.ruoyi.auction.controller.management.dto.AuctionGoodsQuery; |
| | | import com.ruoyi.auction.controller.management.vo.AuctionBidRecordVO; |
| | | import com.ruoyi.auction.controller.management.vo.AuctionGoodsVO; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionGoodsDTO; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionGoodsQuery; |
| | | 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.AuctionBrowseRecord; |
| | | import com.ruoyi.auction.domain.MemberAuctionCollection; |
| | | import com.ruoyi.auction.mapper.AuctionGoodsMapper; |
| | | import com.ruoyi.auction.service.IAuctionBidRecordService; |
| | | import com.ruoyi.auction.service.IAuctionBrowseRecordService; |
| | | import com.ruoyi.auction.service.IAuctionGoodsService; |
| | | import com.ruoyi.auction.service.IMemberAuctionCollectionService; |
| | | import com.ruoyi.auction.service.async.AuctionAsyncMethodService; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | 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.BondStatusEnum; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.OrderFromEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | 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.OrderAuctionBond; |
| | | import com.ruoyi.system.api.domain.dto.AuctionGoodsListDTO; |
| | | import com.ruoyi.system.api.domain.dto.AuctionGoodsListPageDTO; |
| | | import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO; |
| | | import com.ruoyi.system.api.domain.dto.ListStatusDTO; |
| | | import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderDTO; |
| | | import com.ruoyi.system.api.domain.dto.RefundDTO; |
| | | import com.ruoyi.system.api.domain.vo.AuctionGoodsListVO; |
| | | import com.ruoyi.system.api.domain.vo.AuctionGoodsinfoVO; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import com.ruoyi.system.api.util.WebSocketUsers; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private final GoodsSkuClient goodsSkuClient; |
| | | private final MemberClient memberClient; |
| | | private final OrderClient orderClient; |
| | | |
| | | private final AuctionClient auctionClient; |
| | | private final IAuctionBidRecordService auctionBidRecordService; |
| | | private final AuctionAsyncMethodService auctionAsyncMethodService; |
| | | // 创建一个静态共享的ObjectMapper实例以重用 |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | @Resource |
| | | private IMemberAuctionCollectionService memberAuctionCollectionService; |
| | | |
| | | @Resource |
| | | private AuctionGoodsMapper auctionGoodsMapper; |
| | | |
| | | @Resource |
| | | private IAuctionBrowseRecordService iAuctionBrowseRecordService; |
| | | |
| | | /** |
| | | * 获取拍卖商品列表的分页数据 |
| | | * |
| | |
| | | * @return PageDTO<AuctionGoodsVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<AuctionGoodsVO> getAuctionGoodsPage(AuctionGoodsQuery query) { |
| | | public PageDTO<MgtAuctionGoodsVO> getAuctionGoodsPage(MgtAuctionGoodsQuery query) { |
| | | Set<Long> goodsSkuIdList = null; |
| | | if (StringUtils.isNotEmpty(query.getGoodsSkuName())) { |
| | | List<GoodsSku> goodsSku = goodsSkuClient.getGoodsByName(query.getGoodsSkuName(), |
| | |
| | | .select(AuctionGoods::getId, AuctionGoods::getGoodsSkuId, |
| | | AuctionGoods::getListingStatus, AuctionGoods::getStartStatus, |
| | | AuctionGoods::getStartTime, AuctionGoods::getEndTime, |
| | | AuctionGoods::getAuctionStock, AuctionGoods::getMinimumMarkupAmount).in( |
| | | AuctionGoods::getAuctionStock, AuctionGoods::getMinimumMarkupAmount, |
| | | AuctionGoods::getAuthentication, AuctionGoods::getStartingPrice).in( |
| | | StringUtils.isNotEmpty(goodsSkuIdList), AuctionGoods::getGoodsSkuId, |
| | | goodsSkuIdList).eq(StringUtils.isNotNull(query.getAuthentication()), |
| | | AuctionGoods::getAuthentication, query.getAuthentication()) |
| | |
| | | .eq(StringUtils.isNotNull(query.getStartStatus()), AuctionGoods::getStartStatus, |
| | | query.getStartStatus()) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | return PageDTO.of(page, AuctionGoodsVO.class); |
| | | if (StringUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page.getTotal(), page.getPages()); |
| | | } |
| | | // 查询商品信息 |
| | | Set<Long> goodsIdList = page.getRecords().stream().map(AuctionGoods::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | List<GoodsSku> data = goodsSkuClient.getGoodsListByIds(goodsIdList, SecurityConstants.INNER) |
| | | .getData(); |
| | | PageDTO<MgtAuctionGoodsVO> pageDTO = PageDTO.of(page, |
| | | MgtAuctionGoodsVO.class); |
| | | if (StringUtils.isNotEmpty(data)) { |
| | | Map<Long, GoodsSku> goodsSkuMap = data.stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, e -> e)); |
| | | for (MgtAuctionGoodsVO mgtAuctionGoodsVO : pageDTO.getList()) { |
| | | GoodsSku goodsSku = goodsSkuMap.get(mgtAuctionGoodsVO.getGoodsSkuId()); |
| | | if (StringUtils.isNotNull(goodsSku)) { |
| | | mgtAuctionGoodsVO.setGoodsSkuName(goodsSku.getSkuName()); |
| | | mgtAuctionGoodsVO.setSpec(goodsSku.getSpec()); |
| | | } |
| | | } |
| | | } |
| | | return pageDTO; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void saveAuctionGoods(AuctionGoodsDTO dto) { |
| | | public void saveAuctionGoods(MgtAuctionGoodsDTO dto) { |
| | | Long id = dto.getId(); |
| | | Long goodsSkuId = dto.getGoodsSkuId(); |
| | | AuctionGoods auctionGoods = BeanUtils.copyBean(dto, AuctionGoods.class); |
| | |
| | | auctionGoodsOrg.getAuctionStock() - dto.getAuctionStock()); |
| | | goodsSkuClient.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO), |
| | | SecurityConstants.INNER); |
| | | auctionAsyncMethodService.auctionGoodsScheduleTask(Lists.newArrayList(auctionGoods)); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return AuctionGoodsVO |
| | | */ |
| | | @Override |
| | | public AuctionGoodsVO getAuctionGoodsById(Long id) { |
| | | public MgtAuctionGoodsVO getAuctionGoodsById(Long id) { |
| | | AuctionGoods auctionGoods = this.getById(id); |
| | | if (StringUtils.isNull(auctionGoods)) { |
| | | throw new ServiceException("拍卖商品不存在"); |
| | | } |
| | | AuctionGoodsVO auctionGoodsVO = BeanUtils.copyBean(auctionGoods, AuctionGoodsVO.class); |
| | | MgtAuctionGoodsVO auctionGoodsVO = BeanUtils.copyBean(auctionGoods, |
| | | MgtAuctionGoodsVO.class); |
| | | // 远程调用商品服务,获取商品信息 |
| | | GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(auctionGoods.getGoodsSkuId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (StringUtils.isNotNull(goodsSku)) { |
| | | auctionGoodsVO.setGoodsSkuName(goodsSku.getSkuName()); |
| | | } |
| | | if (!auctionGoods.getStartStatus().equals(AuctionStartStatusEnum.IN_PREVIEW)) { |
| | | List<AuctionBidRecord> list = auctionBidRecordService.lambdaQuery() |
| | | .eq(AuctionBidRecord::getTargetId, auctionGoodsVO.getId()) |
| | |
| | | getMemberListByIds(collect, SecurityConstants.INNER).getData(); |
| | | Map<Long, String> memberMap = memberList.stream() |
| | | .collect(Collectors.toMap(Member::getId, Member::getNickname)); |
| | | List<AuctionBidRecordVO> auctionBidRecordVOS = BeanUtils.copyList(list, |
| | | AuctionBidRecordVO.class); |
| | | for (AuctionBidRecordVO vo : auctionBidRecordVOS) { |
| | | List<MgtAuctionBidRecordVO> mgtAuctionBidRecordVOS = BeanUtils.copyList(list, |
| | | MgtAuctionBidRecordVO.class); |
| | | for (MgtAuctionBidRecordVO vo : mgtAuctionBidRecordVOS) { |
| | | String memberName = memberMap.get(vo.getMemberId()); |
| | | vo.setMemberName(StringUtils.isNotEmpty(memberName) ? memberName : ""); |
| | | } |
| | | auctionGoodsVO.setRecordList(auctionBidRecordVOS); |
| | | auctionGoodsVO.setRecordList(mgtAuctionBidRecordVOS); |
| | | } |
| | | } |
| | | return auctionGoodsVO; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<AuctionGoodsListVO> getAuctionGoodsList(AuctionGoodsListDTO auctionGoodsListDTO) { |
| | | Set<Long> goodsSkuIdList = null; |
| | | if (StringUtils.isNotEmpty(auctionGoodsListDTO.getGoodsSkuName())) { |
| | | List<GoodsSku> goodsSku = goodsSkuClient.getGoodsByName(auctionGoodsListDTO.getGoodsSkuName(), |
| | | SecurityConstants.INNER) |
| | | .getData(); |
| | | goodsSkuIdList = goodsSku.stream().map(GoodsSku::getId) |
| | | .collect(Collectors.toSet()); |
| | | } |
| | | AuctionGoodsListPageDTO auctionGoodsListPageDTO=new AuctionGoodsListPageDTO(); |
| | | auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList); |
| | | |
| | | Page<AuctionGoodsListVO> page = new Page<>(); |
| | | page.setSize(auctionGoodsListDTO.getPageSize()); |
| | | page.setCurrent(auctionGoodsListDTO.getPageCurr()); |
| | | List<AuctionGoods> auctionGoodsPgeList = auctionGoodsMapper.getAuctionGoodsPgeList(page, auctionGoodsListPageDTO); |
| | | List<AuctionGoodsListVO> auctionGoodsVOS=new ArrayList<>(); |
| | | for (AuctionGoods auctionGoods:auctionGoodsPgeList){ |
| | | AuctionGoodsListVO auctionGoodsVO=new AuctionGoodsListVO(); |
| | | auctionGoodsVO.setAuctionStock(auctionGoods.getAuctionStock()); |
| | | auctionGoodsVO.setGoodsSkuId(auctionGoods.getId()); |
| | | auctionGoodsVO.setEndTime(auctionGoods.getEndTime()); |
| | | auctionGoodsVO.setStartTime(auctionGoods.getStartTime()); |
| | | auctionGoodsVO.setStartingPrice(auctionGoods.getStartingPrice()); |
| | | auctionGoodsVO.setStartStatus(auctionGoods.getStartStatus()); |
| | | GoodsSku goodsSkuOne = goodsSkuClient.getGoodsSkuOne(auctionGoods.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | auctionGoodsVO.setUnit(goodsSkuOne.getUnit()); |
| | | auctionGoodsVO.setSpec(goodsSkuOne.getSpec()); |
| | | auctionGoodsVO.setSpecUnit(goodsSkuOne.getSpecUnit()); |
| | | auctionGoodsVO.setGoodsSkuName(goodsSkuOne.getSkuName()); |
| | | auctionGoodsVO.setCoverPic(goodsSkuOne.getCoverPic()); |
| | | auctionGoodsVO.setYears(String.valueOf(goodsSkuOne.getYears())); |
| | | auctionGoodsVOS.add(auctionGoodsVO); |
| | | |
| | | } |
| | | page.setRecords(auctionGoodsVOS); |
| | | return PageDTO.of(page); |
| | | } |
| | | |
| | | @Override |
| | | public AuctionGoodsinfoVO getAuctionGoodsInfo(AuctionGoodsListDTO auctionGoodsListDTO) { |
| | | AuctionGoods byId = auctionGoodsMapper.selectById(auctionGoodsListDTO.getGoodsSkuId()); |
| | | GoodsSku goodsSkuOne = goodsSkuClient.getGoodsSkuOne(byId.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | AuctionGoodsinfoVO auctionGoodsinfoVO=new AuctionGoodsinfoVO(); |
| | | auctionGoodsinfoVO.setGoodsSkuId(byId.getGoodsSkuId()); |
| | | auctionGoodsinfoVO.setGoodsSkuName(goodsSkuOne.getSkuName()); |
| | | auctionGoodsinfoVO.setStartingPrice(byId.getStartingPrice()); |
| | | auctionGoodsinfoVO.setSalesroomStock(byId.getAuctionStock()); |
| | | auctionGoodsinfoVO.setStartStatus(byId.getStartStatus()); |
| | | auctionGoodsinfoVO.setStartTime(byId.getStartTime()); |
| | | auctionGoodsinfoVO.setEndTime(byId.getEndTime()); |
| | | auctionGoodsinfoVO.setUnit(goodsSkuOne.getUnit()); |
| | | auctionGoodsinfoVO.setDescription(goodsSkuOne.getDescription()); |
| | | auctionGoodsinfoVO.setYears(String.valueOf(goodsSkuOne.getYears())); |
| | | GoodsBrand data = goodsSkuClient.getBrandOne(goodsSkuOne.getBrandId(), SecurityConstants.INNER).getData(); |
| | | GoodsCategory data1 = goodsSkuClient.getCategoryOne(goodsSkuOne.getCategoryId(), SecurityConstants.INNER).getData(); |
| | | GoodsSeries data2 = goodsSkuClient.getSeriesOne(goodsSkuOne.getSeriesId(), SecurityConstants.INNER).getData(); |
| | | GoodsFlavorType data3 = goodsSkuClient.getFlavorTypeOne(goodsSkuOne.getFlavorTypeId(), SecurityConstants.INNER).getData(); |
| | | auctionGoodsinfoVO.setBrand(data.getBrandName()); |
| | | auctionGoodsinfoVO.setCategory(data1.getCategoryName()); |
| | | auctionGoodsinfoVO.setSeries(data2.getSeriesName()); |
| | | auctionGoodsinfoVO.setFlavorType(data3.getFlavorTypeName()); |
| | | auctionGoodsinfoVO.setCoverPic(goodsSkuOne.getCoverPic()); |
| | | auctionGoodsinfoVO.setAlbum(goodsSkuOne.getAlbum()); |
| | | auctionGoodsinfoVO.setAuthentication(byId.getAuthentication()); |
| | | auctionGoodsinfoVO.setMinimumMarkupAmount(byId.getMinimumMarkupAmount()); |
| | | auctionGoodsinfoVO.setSpec(goodsSkuOne.getSpec()); |
| | | auctionGoodsinfoVO.setSpecUnit(goodsSkuOne.getSpecUnit()); |
| | | auctionGoodsinfoVO.setShareTitle(goodsSkuOne.getShareTitle()); |
| | | auctionGoodsinfoVO.setSpecUnit(goodsSkuOne.getSpecUnit()); |
| | | auctionGoodsinfoVO.setDetail(goodsSkuOne.getDetail()); |
| | | auctionGoodsinfoVO.setYears(String.valueOf(goodsSkuOne.getYears())); |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper1= Wrappers.lambdaQuery(); |
| | | wrapper1.eq(AuctionBidRecord::getMemberId,auctionGoodsListDTO.getMemberId()); |
| | | wrapper1.eq(AuctionBidRecord::getAuctionType,1); |
| | | wrapper1.eq(AuctionBidRecord::getTargetId,byId.getId()); |
| | | wrapper1.eq(AuctionBidRecord::getDelFlag,0); |
| | | AuctionBidRecord list1 = auctionBidRecordService.getOne(wrapper1); |
| | | if (list1!=null){ |
| | | auctionGoodsinfoVO.setIsBond(2); |
| | | auctionGoodsinfoVO.setPresentBid(list1.getLastBidAmount()); |
| | | if (list1.getStatus().getCode()==2){ |
| | | auctionGoodsinfoVO.setIsStatus(2); |
| | | }else{ |
| | | auctionGoodsinfoVO.setIsStatus(1); |
| | | } |
| | | }else{ |
| | | auctionGoodsinfoVO.setIsBond(1); |
| | | auctionGoodsinfoVO.setIsStatus(1); |
| | | } |
| | | LambdaQueryWrapper<MemberAuctionCollection> wrapper2= Wrappers.lambdaQuery(); |
| | | wrapper2.eq(MemberAuctionCollection::getMemberId,auctionGoodsListDTO.getMemberId()); |
| | | wrapper2.eq(MemberAuctionCollection::getTargetId,byId.getId()); |
| | | wrapper2.eq(MemberAuctionCollection::getDelFlag,0); |
| | | MemberAuctionCollection one = memberAuctionCollectionService.getOne(wrapper2); |
| | | if (one!=null){ |
| | | auctionGoodsinfoVO.setIsCollection(2); |
| | | }else { |
| | | auctionGoodsinfoVO.setIsCollection(1); |
| | | } |
| | | List<OrderAuctionBond> datas = auctionClient.getAuctionGoodsOrderAuctionBondList(auctionGoodsListDTO, SecurityConstants.INNER).getData(); |
| | | if (datas.size()>0){ |
| | | auctionGoodsinfoVO.setIsApply(2); |
| | | }else{ |
| | | auctionGoodsinfoVO.setIsApply(1); |
| | | } |
| | | |
| | | 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,auctionGoodsListDTO.getGoodsSkuId()); |
| | | wrapper3.eq(AuctionBrowseRecord::getMemberId,auctionGoodsListDTO.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.REGULAR_ITEMS); |
| | | auctionBrowseRecord.setMemberId(auctionGoodsListDTO.getMemberId()); |
| | | auctionBrowseRecord.setTargetId(auctionGoodsListDTO.getGoodsSkuId()); |
| | | iAuctionBrowseRecordService.save(auctionBrowseRecord); |
| | | } |
| | | |
| | | |
| | | |
| | | return auctionGoodsinfoVO; |
| | | } |
| | | |
| | | @Override |
| | | public PageDTO<AuctionGoodsListVO> getWdAuctionSalesList(AuctionGoodsListDTO auctionGoodsListDTO) { |
| | | MemberAuctionSalesroomDTO memberAuctionSalesroomDTO =new MemberAuctionSalesroomDTO(); |
| | | memberAuctionSalesroomDTO.setMemberId(auctionGoodsListDTO.getMemberId()); |
| | | List<OrderAuctionBond> data = auctionClient.getAuctionGoodsOrderAuctionBondList(auctionGoodsListDTO, SecurityConstants.INNER).getData(); |
| | | Set<Long> goodsSkuIdList = null; |
| | | goodsSkuIdList = data.stream().map(OrderAuctionBond::getAuctionSalesroomId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | AuctionGoodsListPageDTO auctionGoodsListPageDTO=new AuctionGoodsListPageDTO(); |
| | | auctionGoodsListPageDTO.setGoodsSkuIdList(goodsSkuIdList); |
| | | if (auctionGoodsListDTO.getStartStatus()!=4){ |
| | | auctionGoodsListPageDTO.setStartStatus(auctionGoodsListDTO.getStartStatus()); |
| | | } |
| | | |
| | | Page<AuctionGoodsListVO> page = new Page<>(); |
| | | page.setSize(auctionGoodsListDTO.getPageSize()); |
| | | page.setCurrent(auctionGoodsListDTO.getPageCurr()); |
| | | List<AuctionGoods> auctionGoodsPgeList = auctionGoodsMapper.getAuctionGoodsPgeList(page, auctionGoodsListPageDTO); |
| | | List<AuctionGoodsListVO> auctionGoodsVOS=new ArrayList<>(); |
| | | for (AuctionGoods auctionGoods:auctionGoodsPgeList){ |
| | | AuctionGoodsListVO auctionGoodsVO=new AuctionGoodsListVO(); |
| | | auctionGoodsVO.setAuctionStock(auctionGoods.getAuctionStock()); |
| | | auctionGoodsVO.setGoodsSkuId(auctionGoods.getId()); |
| | | auctionGoodsVO.setEndTime(auctionGoods.getEndTime()); |
| | | auctionGoodsVO.setStartTime(auctionGoods.getStartTime()); |
| | | auctionGoodsVO.setStartingPrice(auctionGoods.getStartingPrice()); |
| | | auctionGoodsVO.setStartStatus(auctionGoods.getStartStatus()); |
| | | GoodsSku goodsSkuOne = goodsSkuClient.getGoodsSkuOne(auctionGoods.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | auctionGoodsVO.setUnit(goodsSkuOne.getUnit()); |
| | | auctionGoodsVO.setSpec(goodsSkuOne.getSpec()); |
| | | auctionGoodsVO.setSpecUnit(goodsSkuOne.getSpecUnit()); |
| | | auctionGoodsVO.setGoodsSkuName(goodsSkuOne.getSkuName()); |
| | | auctionGoodsVO.setCoverPic(goodsSkuOne.getCoverPic()); |
| | | |
| | | LambdaQueryWrapper<AuctionBidRecord> wrapper1= Wrappers.lambdaQuery(); |
| | | wrapper1.eq(AuctionBidRecord::getMemberId,auctionGoodsListDTO.getMemberId()); |
| | | wrapper1.eq(AuctionBidRecord::getAuctionType,1); |
| | | wrapper1.eq(AuctionBidRecord::getTargetId,auctionGoods.getId()); |
| | | wrapper1.eq(AuctionBidRecord::getDelFlag,0); |
| | | AuctionBidRecord list1 = auctionBidRecordService.getOne(wrapper1); |
| | | if (list1!=null){ |
| | | if (list1.getStatus().getCode()==2){ |
| | | auctionGoodsVO.setIsStatus(2); |
| | | }else{ |
| | | auctionGoodsVO.setIsStatus(1); |
| | | } |
| | | }else{ |
| | | auctionGoodsVO.setIsStatus(1); |
| | | } |
| | | |
| | | auctionGoodsVOS.add(auctionGoodsVO); |
| | | |
| | | } |
| | | page.setRecords(auctionGoodsVOS); |
| | | return PageDTO.of(page); |
| | | } |
| | | |
| | | @Override |
| | | public void endAuctionGoods(Long id) throws JsonProcessingException { |
| | | AuctionGoods auctionGoods = this.getById(id); |
| | | if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getListingStatus().equals( |
| | | ListingStatusEnum.ON_SHELVES) && auctionGoods.getStartStatus() |
| | | .equals(AuctionStartStatusEnum.IN_AUCTION)) { |
| | | this.lambdaUpdate().set(AuctionGoods::getStartStatus, AuctionStartStatusEnum.ENDED) |
| | | .eq(AuctionGoods::getId, id); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_GOODS); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", id); |
| | | map.put("message_type", "end"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | | log.info("===================>发送websocket通知,消息体{}", msg); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void startAuctionGoods(Long id) throws JsonProcessingException { |
| | | AuctionGoods auctionGoods = this.getById(id); |
| | | if (StringUtils.isNotNull(auctionGoods) && auctionGoods.getListingStatus().equals( |
| | | ListingStatusEnum.ON_SHELVES) && auctionGoods.getStartStatus() |
| | | .equals(AuctionStartStatusEnum.IN_PREVIEW)) { |
| | | this.lambdaUpdate().set(AuctionGoods::getStartStatus, AuctionStartStatusEnum.IN_AUCTION) |
| | | .eq(AuctionGoods::getId, id); |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_GOODS); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", id); |
| | | map.put("message_type", "start"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | | log.info("===================>发送websocket通知,消息体{}", msg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下架/上架 拍卖商品 |
| | | * |
| | | * @param dto 商品上下架状态对象 |
| | | */ |
| | | @Override |
| | | public void updStatus(ListStatusDTO dto) { |
| | | AuctionGoods auctionGoods = this.getById(dto.getId()); |
| | | if (StringUtils.isNull(auctionGoods)) { |
| | | throw new ServiceException("拍卖商品不存在"); |
| | | } |
| | | auctionGoods.setListingStatus(dto.getListingStatus()); |
| | | this.updateById(auctionGoods); |
| | | } |
| | | } |