| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.google.common.collect.Sets; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.AuctionOrderTypeEnum; |
| | |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections.map.HashedMap; |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | order.setPrice(OrderDTO.getPrice()); |
| | | order.setCoverPic(OrderDTO.getCoverPic()); |
| | | order.setOrderTimeSx(OrderDTO.getOrderTimeSx()); |
| | | order.setGoodsId(OrderDTO.getGoodsId()); |
| | | this.save(order); |
| | | |
| | | |
| | |
| | | order.setSkuName(goodsSku.getSkuName()); |
| | | order.setPrice(goodsSku.getPrice()); |
| | | order.setCoverPic(goodsSku.getCoverPic()); |
| | | order.setGoodsId(goodsSku.getId()); |
| | | } |
| | | memberOrderVO.setGoodsSkuId(memberOrderDTO.getGoodsSkuId()); |
| | | memberOrderVO.setPrice(goodsSku.getPrice()); |
| | |
| | | order.setPrice(data.getSeckillPrice()); |
| | | order.setCoverPic(goodsSku.getCoverPic()); |
| | | order.setSjPrice(goodsSku.getPrice()); |
| | | order.setGoodsId(goodsSku.getId()); |
| | | redisService.setCacheObject(CacheConstants.SECKILL_GOODS + data.getId(), surpNum - memberOrderDTO.getGoodsQuantity()); |
| | | } |
| | | if (memberOrderDTO.getOrderFrom()==3){ |
| | |
| | | order.setPrice(data.getGroupPurchasePrice()); |
| | | order.setCoverPic(goodsSku.getCoverPic()); |
| | | order.setSjPrice(goodsSku.getPrice()); |
| | | order.setGoodsId(goodsSku.getId()); |
| | | } |
| | | order.setOrderRemark(memberOrderDTO.getOrderRemark()); |
| | | order.setMemberId(memberOrderDTO.getMemberId()); |
| | |
| | | |
| | | PageDTO<MemberOrderListVO> memberOrderListVOPageDTO = PageDTO.of(page1, MemberOrderListVO.class); |
| | | List<MemberOrderListVO> list = memberOrderListVOPageDTO.getList(); |
| | | Map<Long, GoodsSku> goodsUnitMap = getGoodsUnitMap(list); |
| | | for (MemberOrderListVO MemberOrderList:list){ |
| | | if (MemberOrderList.getOrderStatus().getCode()==1){ |
| | | if (MemberOrderList.getOrderFrom().getCode()==1||MemberOrderList.getOrderFrom().getCode()==2||MemberOrderList.getOrderFrom().getCode()==3){ |
| | |
| | | MemberOrderList.setOrderShuoMin(memberPointsPoints.getConfigValue()); |
| | | CustomConfig ReturnCycle = sysUserClient.getconfig("RETURN_CYCLE").getData(); |
| | | MemberOrderList.setOrderZq(Integer.valueOf(ReturnCycle.getConfigValue())); |
| | | |
| | | GoodsSku goodsSku = |
| | | Objects.nonNull(goodsUnitMap.get(MemberOrderList.getGoodsId())) |
| | | ? goodsUnitMap.get(MemberOrderList.getGoodsId()) |
| | | : goodsUnitMap.get(MemberOrderList.getGoodsSkuId()); |
| | | if (Objects.nonNull(goodsSku)) { |
| | | MemberOrderList.setUnit(goodsSku.getUnit()); |
| | | MemberOrderList.setSpec(goodsSku.getSpec()); |
| | | MemberOrderList.setSpecUnit(goodsSku.getSpecUnit()); |
| | | } |
| | | } |
| | | |
| | | |
| | | return memberOrderListVOPageDTO; |
| | | } |
| | | |
| | | @NotNull |
| | | private Map<Long, GoodsSku> getGoodsUnitMap(List<MemberOrderListVO> list) { |
| | | Map<Long, GoodsSku> goodsSkuMap = new HashedMap(); |
| | | Set<Long> goodsSkuIdSet = list.stream() |
| | | .filter(vo -> vo.getOrderFrom().equals(OrderFromEnum.COMMODITY_ORDER)) |
| | | .map(MemberOrderListVO::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | if (CollUtils.isNotEmpty(goodsSkuIdSet)) { |
| | | goodsSkuMap = goodsSkuClient.getGoodsListByIds(goodsSkuIdSet, |
| | | SecurityConstants.INNER).getData().stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | } |
| | | Set<Long> seckillIdSet = list.stream() |
| | | .filter(vo -> vo.getOrderFrom().equals(OrderFromEnum.SNAP_ORDERS)) |
| | | .map(MemberOrderListVO::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | if (CollUtils.isNotEmpty(seckillIdSet)) { |
| | | Map<Long, GoodsSku> goodsSkuMap2 = goodsSkuClient.getGoodsSkuBySeckillIdSet( |
| | | seckillIdSet, |
| | | SecurityConstants.INNER).getData().stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | // 将goodsSkuMap2合并到goodsSkuMap中 |
| | | goodsSkuMap.putAll(goodsSkuMap2); |
| | | } |
| | | Set<Long> groupPurchaseIdSet = list.stream() |
| | | .filter(vo -> vo.getOrderFrom().equals(OrderFromEnum.GROUP_PURCHASE_ORDERS)) |
| | | .map(MemberOrderListVO::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | if (CollUtils.isNotEmpty(groupPurchaseIdSet)) { |
| | | Map<Long, GoodsSku> goodsSkuMap3 = goodsSkuClient.getGoodsSkuByGroupPurchaseIdSet( |
| | | groupPurchaseIdSet, |
| | | SecurityConstants.INNER).getData().stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | goodsSkuMap.putAll(goodsSkuMap3); |
| | | } |
| | | Set<Long> auctionGoodsIdSet = list.stream() |
| | | .filter(vo -> vo.getOrderFrom().equals(OrderFromEnum.AUCTION_ORDERS) |
| | | && vo.getAuctionOrderType().equals(AuctionOrderTypeEnum.REGULAR_ITEMS)) |
| | | .map(MemberOrderListVO::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | if (CollUtils.isNotEmpty(auctionGoodsIdSet)) { |
| | | Map<Long, GoodsSku> goodsSkuMap4 = auctionClient.getGoodsSkuByAuctionGoodsIdSet( |
| | | auctionGoodsIdSet, |
| | | SecurityConstants.INNER).getData().stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | goodsSkuMap.putAll(goodsSkuMap4); |
| | | } |
| | | Set<Long> auctionSalesroomGoodsSet = list.stream() |
| | | .filter(vo -> vo.getOrderFrom().equals(OrderFromEnum.AUCTION_ORDERS) |
| | | && vo.getAuctionOrderType().equals(AuctionOrderTypeEnum.AUCTION_ITEMS)) |
| | | .map(MemberOrderListVO::getGoodsSkuId) |
| | | .collect(Collectors.toSet()); |
| | | if (CollUtils.isNotEmpty(auctionSalesroomGoodsSet)) { |
| | | Map<Long, GoodsSku> goodsSkuMap5 = auctionClient.getGoodsSkuByAuctionSalesroomGoodsSet( |
| | | auctionSalesroomGoodsSet, |
| | | SecurityConstants.INNER).getData().stream() |
| | | .collect(Collectors.toMap(GoodsSku::getId, Function.identity())); |
| | | goodsSkuMap.putAll(goodsSkuMap5); |
| | | } |
| | | return goodsSkuMap; |
| | | } |
| | | |
| | | @Override |
| | | public OrderVO MemberOrderOne(MemberOrderListDTO memberOrderListDTO) { |
| | | Order order = baseMapper.selectById(memberOrderListDTO.getId()); |
| | | OrderVO orderVO=new OrderVO(); |
| | | try { |
| | | orderVO = BeanUtils.copyBean(order, OrderVO.class); |
| | | orderVO.setAuctionType(order.getAuctionOrderType()); |
| | | orderVO.setCouponId(order.getCouponId()); |
| | | orderVO.setBound(order.getBound()); |
| | | orderVO.setIsRequest(order.getIsRequest()); |
| | | if (orderVO.getOrderFrom().getCode()==3){ |
| | | GoodsGroupPurchase data = GoodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(order.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | orderVO.setGroupTime(data.getGroupTime()); |
| | | orderVO.setSkuId(data.getGoodsSkuId()); |
| | | } |
| | | orderVO = BeanUtils.copyBean(order, OrderVO.class); |
| | | orderVO.setAuctionType(order.getAuctionOrderType()); |
| | | orderVO.setCouponId(order.getCouponId()); |
| | | orderVO.setBound(order.getBound()); |
| | | orderVO.setIsRequest(order.getIsRequest()); |
| | | if (orderVO.getOrderFrom().getCode() == 3) { |
| | | GoodsGroupPurchase data = GoodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne( |
| | | order.getGoodsSkuId(), SecurityConstants.INNER).getData(); |
| | | orderVO.setGroupTime(data.getGroupTime()); |
| | | orderVO.setSkuId(data.getGoodsSkuId()); |
| | | } |
| | | |
| | | LambdaQueryWrapper<OrderAuctionBond> wrapper3= Wrappers.lambdaQuery(); |
| | | wrapper3.eq(OrderAuctionBond::getOrderId,order.getId()); |
| | | OrderAuctionBond orderAuctionBond = orderAuctionBondMapper.selectOne(wrapper3); |
| | | if (orderAuctionBond!=null){ |
| | | if (orderAuctionBond.getBoundStatus().getCode()==1||orderAuctionBond.getBoundStatus().getCode()==2){ |
| | | orderVO.setIsAuctionBond(1); |
| | | }else{ |
| | | orderVO.setIsAuctionBond(2); |
| | | } |
| | | }else { |
| | | LambdaQueryWrapper<OrderAuctionBond> wrapper3 = Wrappers.lambdaQuery(); |
| | | wrapper3.eq(OrderAuctionBond::getOrderId, order.getId()); |
| | | OrderAuctionBond orderAuctionBond = orderAuctionBondMapper.selectOne(wrapper3); |
| | | if (orderAuctionBond != null) { |
| | | if (orderAuctionBond.getBoundStatus().getCode() == 1 |
| | | || orderAuctionBond.getBoundStatus().getCode() == 2) { |
| | | orderVO.setIsAuctionBond(1); |
| | | } else { |
| | | orderVO.setIsAuctionBond(2); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } else { |
| | | orderVO.setIsAuctionBond(1); |
| | | } |
| | | if (order.getTotalAmount()==null){ |
| | | order.setTotalAmount(new BigDecimal(0)); |
| | | } |
| | | GoodsSku goodsSku = getGoodsSku(orderVO); |
| | | if (Objects.nonNull(goodsSku)) { |
| | | orderVO.setUnit(goodsSku.getUnit()); |
| | | orderVO.setSpec(goodsSku.getSpec()); |
| | | orderVO.setSpecUnit(goodsSku.getSpecUnit()); |
| | | } |
| | | CustomConfig memberPointsPoints = sysUserClient.getconfig("MALL_ORDER_DESCRIPTION").getData(); |
| | | orderVO.setOrderShuoMin(memberPointsPoints.getConfigValue()); |
| | |
| | | orderVO.setStatus(orderReturnRequest.getStatus()); |
| | | } |
| | | return orderVO; |
| | | } |
| | | |
| | | private GoodsSku getGoodsSku(OrderVO orderVO) { |
| | | GoodsSku goodsSku = null; |
| | | switch (orderVO.getOrderFrom()) { |
| | | case COMMODITY_ORDER: |
| | | goodsSku = goodsSkuClient.getGoodsSkuOne(orderVO.getGoodsSkuId(), |
| | | SecurityConstants.INNER).getData(); |
| | | break; |
| | | case SNAP_ORDERS: |
| | | List<GoodsSku> skuList = goodsSkuClient.getGoodsSkuBySeckillIdSet( |
| | | Sets.newHashSet(orderVO.getGoodsSkuId()), |
| | | SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(skuList)) { |
| | | goodsSku = skuList.get(0); |
| | | } |
| | | break; |
| | | case GROUP_PURCHASE_ORDERS: |
| | | List<GoodsSku> data = goodsSkuClient.getGoodsSkuByGroupPurchaseIdSet( |
| | | Sets.newHashSet(orderVO.getGoodsSkuId()), |
| | | SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(data)) { |
| | | goodsSku = data.get(0); |
| | | } |
| | | break; |
| | | case AUCTION_ORDERS: |
| | | List<GoodsSku> goodsSkuList; |
| | | if (orderVO.getAuctionType().equals(AuctionOrderTypeEnum.REGULAR_ITEMS)) { |
| | | goodsSkuList = auctionClient.getGoodsSkuByAuctionGoodsIdSet( |
| | | Sets.newHashSet(orderVO.getGoodsSkuId()), |
| | | SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(goodsSkuList)) { |
| | | goodsSku = goodsSkuList.get(0); |
| | | } |
| | | } else { |
| | | goodsSkuList = auctionClient.getGoodsSkuByAuctionSalesroomGoodsSet( |
| | | Sets.newHashSet(orderVO.getGoodsSkuId()), |
| | | SecurityConstants.INNER).getData(); |
| | | } |
| | | if (CollUtils.isNotEmpty(goodsSkuList)) { |
| | | goodsSku = goodsSkuList.get(0); |
| | | } |
| | | break; |
| | | } |
| | | return goodsSku; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | Order byId = this.getById(memberOrderListDTO.getId()); |
| | | |
| | | if(byId.getOrderNo().contains("TG")){ |
| | | if (byId.getOrderNo().contains("TG") && StringUtils.isNotBlank(byId.getGroupNo())) { |
| | | GoodsGroupPurchaseInfo goodsSeckiGoodsGroupPurchaseInfo = GoodsSkuClient.getGoodsSeckiGoodsGroupPurchaseInfo2(byId.getGroupNo(), SecurityConstants.INNER).getData(); |
| | | if (goodsSeckiGoodsGroupPurchaseInfo!=null){ |
| | | goodsSeckiGoodsGroupPurchaseInfo.setPurchaseNum(byId.getGoodsQuantity()); |