| | |
| | | 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.google.zxing.WriterException; |
| | | import com.ruoyi.auction.controller.management.dto.MgtAuctionSaleroomBidRecordQuery; |
| | |
| | | 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.ClientTypeEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.IDhelper; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | import com.ruoyi.common.core.utils.page.CollUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.AppMiniLoginVO; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import com.ruoyi.system.api.feignClient.PromotionClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.util.WebSocketUsers; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | */ |
| | | private static final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAh+tCVKqUmlHDL8Ki1TUJtzE5IKV1irJuoHWZTvndJCKJJ8bdWxL9mu5xsy8KkfrnS6wJIKBMLTxMoYQHG7l2Gt07YyUCYHS5+yvbHtTkyFFy2KRPeUEWXz1Tm4juvInDvvr+n7v9ETepToGhC+UDlQcBvuSppw8N+463E+1GRrC4APwXYGLzaIvYvDHcQAULkWhXsjzxJSmeSi12kqWKlgnVJC1y0FT8xQtvhwShfaIqKwzErn9S2z7JjdXboJMUYQHoqF1A4SmWY8c0qawqvx2hGP36W3RDQ4cczzFwUHS1Cylhsbgh1COc4OdANCX4Np2NUzaRDCNzN0WVFKtK+QIDAQAB"; |
| | | |
| | | |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | @Override |
| | | public List<AuctionSalesroom> getAuctionBidRecordList(AuctionSalesroomDTO ationSalesroomGoodsDTO) { |
| | |
| | | mgtAuctionSalesroomVO, MgtAuctionSalesroomScreenVO.class); |
| | | if (vo.getStatus().equals(AuctionStartStatusEnum.IN_AUCTION)) { |
| | | List<MgtAuctionSalesroomGoodsVO> auctionSalesroomGoodsVOS = vo.getAuctionSalesroomGoodsVOS(); |
| | | 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()); |
| | | 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()); |
| | | 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()); |
| | | 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 { |
| | | vo.setNextAuctionSalesroomGoods(collect.get(0)); |
| | | } |
| | | vo.setMgtAuctionBidRecordVOList( |
| | | BeanUtils.copyList(list, MgtAuctionBidRecordVO.class)); |
| | | } else { |
| | | vo.setNextAuctionSalesroomGoods(collect.get(0)); |
| | | } |
| | | } |
| | | return vo; |
| | |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtAuctionSalesroomGoodsVO> backupGoods(MgtAuctionSalesroomGoodsQuery query) { |
| | | Page<AuctionSalesroomGoods> page = new Page<>(query.getPageCurr(), query.getPageSize()); |
| | | Set<Long> goodsSkuIdSet = null; |
| | | if (StringUtils.isNotBlank(query.getGoodsName())) { |
| | | List<GoodsSku> data = goodsSkuClient.getGoodsByName(query.getGoodsName(), |
| | |
| | | if (StringUtils.isNotEmpty(data)) { |
| | | goodsSkuIdSet = data.stream().map(GoodsSku::getId) |
| | | .collect(Collectors.toSet()); |
| | | } else { |
| | | return PageDTO.empty(page); |
| | | } |
| | | } |
| | | Page<AuctionSalesroomGoods> page = auctionSalesroomGoodsMapper.selectPage( |
| | | page = auctionSalesroomGoodsMapper.selectPage( |
| | | new Page<>(query.getPageCurr(), query.getPageSize()), |
| | | Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | .eq(AuctionSalesroomGoods::getAuctionSalesroomId, |
| | | query.getAuctionSalesroomId()) |
| | | .eq(AuctionSalesroomGoods::getBackupStatus, Boolean.TRUE) |
| | | .in(StringUtils.isNotEmpty(goodsSkuIdSet), |
| | | AuctionSalesroomGoods::getGoodsSkuId, goodsSkuIdSet)); |
| | | if (StringUtils.isNotEmpty(page.getRecords())) { |
| | | if (StringUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | Set<Long> skuIdList = page.getRecords().stream().map(AuctionSalesroomGoods::getGoodsSkuId) |
| | |
| | | /** |
| | | * 选择备选商品 |
| | | * |
| | | * @param idList 备选商品id集合 |
| | | * @param idStr 备选商品id集合 |
| | | */ |
| | | @Override |
| | | public void addBackupGoods(List<Long> idList) { |
| | | public void addBackupGoods(String idStr) { |
| | | String[] idArr = idStr.split(","); |
| | | List<Long> idList = Arrays.stream(idArr).map(Long::valueOf).collect(Collectors.toList()); |
| | | List<AuctionSalesroomGoods> auctionSalesroomGoods = auctionSalesroomGoodsMapper.selectList( |
| | | Wrappers.<AuctionSalesroomGoods>lambdaQuery() |
| | | .in(AuctionSalesroomGoods::getId, idList) |
| | |
| | | if (StringUtils.isNotEmpty(auctionSalesroomGoods)) { |
| | | auctionSalesroomGoods.forEach(item -> { |
| | | item.setStatus(AuctionGoodsStatusEnum.WAITING); |
| | | item.setBackupStatus(Boolean.FALSE); |
| | | }); |
| | | auctionSalesroomGoodsMapper.updateBatchById(auctionSalesroomGoods); |
| | | } |
| | |
| | | * @param auctionSalesroomId 拍卖场id |
| | | */ |
| | | @Override |
| | | public void startCurrentAuctionSalesroom(Long auctionSalesroomId) { |
| | | public void startCurrentAuctionSalesroom(Long auctionSalesroomId) |
| | | throws JsonProcessingException { |
| | | // 修改拍卖场开始状态 |
| | | AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); |
| | | auctionSalesroom.setStatus(AuctionStartStatusEnum.IN_AUCTION); |
| | |
| | | auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS); |
| | | auctionSalesroomGoods.setStartTime(LocalDateTime.now()); |
| | | auctionSalesroomGoodsMapper.updateById(auctionSalesroomGoods); |
| | | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); |
| | | map.put("auctionSalesroomId", auctionSalesroom.getId()); |
| | | map.put("message_type", "start"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.AUCTIONEER.getCode(), msg); |
| | | } |
| | | |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | @Transactional |
| | | public void stopCurrentAuctionSalesroom(Long auctionSalesroomId) { |
| | | public void stopCurrentAuctionSalesroom(Long auctionSalesroomId) |
| | | throws JsonProcessingException { |
| | | // 修改拍卖场开始状态 |
| | | AuctionSalesroom auctionSalesroom = this.getById(auctionSalesroomId); |
| | | auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED); |
| | |
| | | orderAuctionBondDTO.setUserList(memberIdlist); |
| | | orderClient.getOrderAuctionBond(orderAuctionBondDTO, SecurityConstants.INNER); |
| | | } |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM); |
| | | map.put("auctionSalesroomId", auctionSalesroom.getId()); |
| | | map.put("message_type", "end"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByType(ClientTypeEnum.AUCTIONEER.getCode(), msg); |
| | | } |
| | | } |