From c2931dfdb47b766ea117f711913d4993c818dd6d Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期六, 15 六月 2024 15:50:47 +0800 Subject: [PATCH] 提交【管理后台】订单管理-售后管理相关接口 --- ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 160 ++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 128 insertions(+), 32 deletions(-) diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index ceca2e9..76b0823 100644 --- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -12,6 +12,7 @@ import com.ruoyi.common.core.enums.BondStatusEnum; import com.ruoyi.common.core.enums.OrderFromEnum; import com.ruoyi.common.core.enums.OrderStatusEnum; +import com.ruoyi.common.core.enums.OrderTypeEnum; import com.ruoyi.common.core.enums.PaymentMethodEnum; import com.ruoyi.common.core.enums.RequestTypeEnum; import com.ruoyi.common.core.enums.ReturnRequestStatusEnum; @@ -20,8 +21,8 @@ import com.ruoyi.common.core.utils.page.BeanUtils; import com.ruoyi.common.core.utils.page.PageDTO; import com.ruoyi.common.redis.service.RedisService; -import com.ruoyi.order.controller.management.dto.MgtMallOrderQuery; import com.ruoyi.order.controller.management.dto.MgtOrderConfirmShipmentDTO; +import com.ruoyi.order.controller.management.dto.MgtOrderQuery; import com.ruoyi.order.controller.management.vo.MgtOrderReturnRequestVO; import com.ruoyi.order.controller.management.vo.MgtOrderVO; import com.ruoyi.order.domain.OrderReturnRequest; @@ -125,6 +126,10 @@ @Resource private AuctionClient auctionClient; + @Resource + private GoodsSkuClient GoodsSkuClient; + + @Override public void saveOrderOne(OrderDTO OrderDTO) { Order order=new Order(); @@ -153,7 +158,7 @@ order.setPoints(OrderDTO.getPoints()); order.setGoodsQuantity(OrderDTO.getGoodsQuantity()); order.setReceiverName(OrderDTO.getReceiverName()); - order.setReceiverphone(OrderDTO.getReceiverphone()); + order.setReceiverPhone(OrderDTO.getReceiverphone()); order.setReceiverCity(OrderDTO.getReceiverCity()); order.setReceiverDetailAddress(OrderDTO.getReceiverDetailAddress()); order.setBound(OrderDTO.getBound()); @@ -302,7 +307,8 @@ GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData(); memberOrderVO.setGoodsSkuId(memberOrderDTO.getGoodsSkuId()); - memberOrderVO.setPrice(goodsSku.getPrice()); + memberOrderVO.setPrice(data.getSeckillPrice()); + memberOrderVO.setSjPrice(goodsSku.getPrice()); memberOrderVO.setCoverPic(goodsSku.getCoverPic()); memberOrderVO.setSkuName(goodsSku.getSkuName()); memberOrderVO.setYouhiPrice(data.getSeckillPrice()); @@ -327,7 +333,8 @@ GoodsGroupPurchase data = goodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(memberOrderDTO.getGoodsSkuId(), SecurityConstants.INNER).getData(); GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData(); memberOrderVO.setGoodsSkuId(memberOrderDTO.getGoodsSkuId()); - memberOrderVO.setPrice(goodsSku.getPrice()); + memberOrderVO.setPrice(data.getGroupPurchasePrice()); + memberOrderVO.setSjPrice(goodsSku.getPrice()); memberOrderVO.setCoverPic(goodsSku.getCoverPic()); memberOrderVO.setSkuName(goodsSku.getSkuName()); memberOrderVO.setYouhiPrice(data.getGroupPurchasePrice()); @@ -355,7 +362,7 @@ order.setReceiverName(memberOrderDTO.getReceiverName()); order.setReceiverCity(memberOrderDTO.getReceiverCity()); order.setReceiverDetailAddress(memberOrderDTO.getReceiverDetailAddress()); - order.setReceiverphone(memberOrderDTO.getReceiverphone()); + order.setReceiverPhone(memberOrderDTO.getReceiverphone()); }else{ MemberAddress data = memberClient.getMemberAddressOne( memberOrderDTO.getMemberId(), SecurityConstants.INNER).getData(); @@ -363,7 +370,7 @@ order.setReceiverName(data.getRecipientName()); order.setReceiverCity(data.getReceiverCity()); order.setReceiverDetailAddress(data.getDetailedAddress()); - order.setReceiverphone(data.getRecipientPhone()); + order.setReceiverPhone(data.getRecipientPhone()); } } @@ -384,7 +391,7 @@ memberOrderVO.setReceiverName(order.getReceiverName()); memberOrderVO.setReceiverCity(order.getReceiverCity()); memberOrderVO.setReceiverDetailAddress(order.getReceiverDetailAddress()); - memberOrderVO.setReceiverphone(order.getReceiverphone()); + memberOrderVO.setReceiverphone(order.getReceiverPhone()); Integer delayTime = 30; redisService.setCacheObject(CacheConstants.ORDER_AUTOMATIC_CANCEL + "-" + order.getId(), order.getId() , delayTime.longValue(), TimeUnit.MINUTES); @@ -399,7 +406,7 @@ order.setReceiverName(memberOrderDTO.getReceiverName()); order.setReceiverCity(memberOrderDTO.getReceiverCity()); order.setReceiverDetailAddress(memberOrderDTO.getReceiverDetailAddress()); - order.setReceiverphone(memberOrderDTO.getReceiverphone()); + order.setReceiverPhone(memberOrderDTO.getReceiverphone()); } if (memberOrderDTO.getOrderRemark()!=null){ order.setOrderRemark(memberOrderDTO.getOrderRemark()); @@ -539,7 +546,7 @@ memberOrderVO.setReceiverName(order.getReceiverName()); memberOrderVO.setReceiverCity(order.getReceiverCity()); memberOrderVO.setReceiverDetailAddress(order.getReceiverDetailAddress()); - memberOrderVO.setReceiverphone(order.getReceiverphone()); + memberOrderVO.setReceiverphone(order.getReceiverPhone()); memberOrderVO.setYouhiPrice(order.getDiscountMoney()); return memberOrderVO; @@ -550,14 +557,44 @@ Page<Order> page = new Page<>(memberOrderListDTO.getPageCurr(), memberOrderListDTO.getPageSize()); LambdaQueryWrapper<Order> wrapper= Wrappers.lambdaQuery(); wrapper.eq(Order::getMemberId,memberOrderListDTO.getMemberId()); - wrapper.like(Order::getSkuName,memberOrderListDTO.getGoodsSkuName()); - wrapper.like(Order::getOrderNo,memberOrderListDTO.getOrderNo()); - wrapper.eq(Order::getOrderStatus,memberOrderListDTO.getOrderStatus()); + if(memberOrderListDTO.getGoodsSkuName()!=null){ + wrapper.like(Order::getSkuName,memberOrderListDTO.getGoodsSkuName()); + } + if(memberOrderListDTO.getOrderNo()!=null){ + wrapper.like(Order::getOrderNo,memberOrderListDTO.getOrderNo()); + } + if(memberOrderListDTO.getOrderStatus()!=null){ + wrapper.eq(Order::getOrderStatus,memberOrderListDTO.getOrderStatus().getCode()); + } wrapper.eq(Order::getDelFlag,0); wrapper.orderByDesc(Order::getCancelTime); Page<Order> page1 = this.page(page, wrapper); PageDTO<MemberOrderListVO> memberOrderListVOPageDTO = PageDTO.of(page1, MemberOrderListVO.class); + List<MemberOrderListVO> list = memberOrderListVOPageDTO.getList(); + for (MemberOrderListVO MemberOrderList:list){ + OrderReturnRequest orderReturnRequest = orderReturnRequestService.getOne( + Wrappers.lambdaQuery(OrderReturnRequest.class) + .eq(OrderReturnRequest::getOrderId, + MemberOrderList.getId()).last("limit 1")); + if (StringUtils.isNotNull(orderReturnRequest)) { + MemberOrderList.setStatus(orderReturnRequest.getStatus()); + } + LambdaQueryWrapper<OrderAuctionBond> wrapper3= Wrappers.lambdaQuery(); + wrapper3.eq(OrderAuctionBond::getOrderId,MemberOrderList.getId()); + OrderAuctionBond orderAuctionBond = orderAuctionBondMapper.selectOne(wrapper3); + if (orderAuctionBond!=null){ + if (orderAuctionBond.getBoundStatus().getCode()==1||orderAuctionBond.getBoundStatus().getCode()==2){ + MemberOrderList.setIsAuctionBond(1); + }else{ + MemberOrderList.setIsAuctionBond(2); + } + }else { + MemberOrderList.setIsAuctionBond(1); + } + } + + return memberOrderListVOPageDTO; } @@ -567,6 +604,32 @@ OrderVO orderVO=new OrderVO(); try { orderVO = BeanUtils.copyBean(order, OrderVO.class); + if (orderVO.getOrderFrom().getCode()==3){ + GoodsGroupPurchase data = GoodsSkuClient.getGoodsSeckiGoodsGroupPurchaseOne(order.getGoodsSkuId(), SecurityConstants.INNER).getData(); + orderVO.setGroupTime(data.getGroupTime()); + } + + OrderReturnRequest orderReturnRequest = orderReturnRequestService.getOne( + Wrappers.lambdaQuery(OrderReturnRequest.class) + .eq(OrderReturnRequest::getOrderId, + orderVO.getId()).last("limit 1")); + if (StringUtils.isNotNull(orderReturnRequest)) { + orderVO.setStatus(orderReturnRequest.getStatus()); + } + + 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 { + orderVO.setIsAuctionBond(1); + } + } catch (Exception e) { throw new RuntimeException(e); } @@ -694,7 +757,7 @@ * @return PageDTO<MgtMallOrderVO> */ @Override - public PageDTO<MgtOrderVO> getOrderPage(MgtMallOrderQuery query) { + public PageDTO<MgtOrderVO> getOrderPage(MgtOrderQuery query) { PageDTO<MgtOrderVO> pageVO; // 封装会员条件查询对象 MemberDTO memberDTO = null; @@ -718,9 +781,15 @@ } page = this.lambdaQuery() .in(StringUtils.isNotEmpty(memberIdSet), Order::getMemberId, memberIdSet) + .ne(query.getQueryType().equals(OrderTypeEnum.MALL_ODER), Order::getOrderFrom, + OrderFromEnum.AUCTION_ORDERS) + .eq(query.getQueryType().equals(OrderTypeEnum.AUCTION_ORDER), Order::getOrderFrom, + OrderFromEnum.AUCTION_ORDERS) .like(StringUtils.isNotBlank(query.getOrderNo()), Order::getOrderNo, query.getOrderNo()) - .eq(StringUtils.isNotNull(query.getOrderFrom()), Order::getOrderFrom, + .eq(StringUtils.isNotNull(query.getOrderFrom()) && query.getQueryType() + .equals(OrderTypeEnum.MALL_ODER), + Order::getOrderFrom, query.getOrderFrom()) .like(StringUtils.isNotBlank(query.getSkuName()), Order::getSkuName, query.getSkuName()) @@ -733,12 +802,30 @@ pageVO = PageDTO.of(page, MgtOrderVO.class); if (query.getOrderFrom() == OrderFromEnum.AUCTION_ORDERS) { List<MgtOrderVO> list = pageVO.getList(); + // 封装参数查询拍卖会 + Set<Long> auctionSalesroomGoodsIdSet = list.stream() + .filter(order -> order.getAuctionType() == AuctionOrderTypeEnum.AUCTION_ITEMS) + .map(MgtOrderVO::getGoodsSkuId).collect(Collectors.toSet()); + List<AuctionSalesroom> auctionSalesroomList = auctionClient.getAuctionSalesroomByIds( + auctionSalesroomGoodsIdSet, SecurityConstants.INNER) + .getData(); + Map<Long, String> salesroomMap = auctionSalesroomList.stream() + .collect(Collectors.toMap(AuctionSalesroom::getId, + AuctionSalesroom::getSalesroomName)); // 封装参数查询拍卖订单保证金 - Set<Long> orderIdSet = list.stream().map(MgtOrderVO::getId) + Set<Long> auctionGoodsIdSet = list.stream() + .filter(order -> order.getAuctionType() == AuctionOrderTypeEnum.REGULAR_ITEMS) + .map(MgtOrderVO::getGoodsSkuId) .collect(Collectors.toSet()); + + Set<Long> auctionSalesroomSet = auctionSalesroomList.stream() + .map(AuctionSalesroom::getId) + .collect(Collectors.toSet()); + List<OrderAuctionBond> auctionBondList = orderAuctionBondMapper.selectList( Wrappers.lambdaQuery(OrderAuctionBond.class) - .in(OrderAuctionBond::getOrderId, orderIdSet) + .in(OrderAuctionBond::getAuctionGoodsId, auctionGoodsIdSet) + .in(OrderAuctionBond::getAuctionSalesroomId, auctionSalesroomSet) .eq(OrderAuctionBond::getBoundStatus, BondStatusEnum.PAID)); Map<String, OrderAuctionBond> auctionSalesroomBondMap = auctionBondList.stream() @@ -751,27 +838,18 @@ .collect(Collectors.toMap( bond -> bond.getAuctionGoodsId() + "-" + bond.getMemberId(), Function.identity())); - // 封装参数查询拍卖会 - Set<Long> auctionSalesroomGoodsIdSet = list.stream() - .filter(order -> order.getAuctionType() == AuctionOrderTypeEnum.AUCTION_ITEMS) - .map(MgtOrderVO::getGoodsSkuId).collect(Collectors.toSet()); - List<AuctionSalesroom> auctionSalesroomList = auctionClient.getAuctionSalesroomByIds( - auctionSalesroomGoodsIdSet, SecurityConstants.INNER) - .getData(); - Map<Long, String> salesroomMap = auctionSalesroomList.stream() - .collect(Collectors.toMap(AuctionSalesroom::getId, - AuctionSalesroom::getSalesroomName)); + list.forEach(order -> { if (order.getAuctionType() == AuctionOrderTypeEnum.AUCTION_ITEMS) { order.setSalesroomName( StringUtils.isNotBlank(salesroomMap.get(order.getGoodsSkuId())) - ? salesroomMap.get(order.getGoodsSkuId()) : "无"); + ? salesroomMap.get(order.getAuctionSalesroomId()) : "无"); order.setBoundStatus( StringUtils.isNotNull(auctionSalesroomBondMap.get( - order.getGoodsSkuId() + "-" + order.getMemberId()) + order.getAuctionSalesroomId() + "-" + order.getMemberId()) .getBoundStatus()) ? auctionSalesroomBondMap.get( - order.getGoodsSkuId() + "-" + order.getMemberId()) + order.getAuctionSalesroomId() + "-" + order.getMemberId()) .getBoundStatus() : null); } @@ -979,12 +1057,30 @@ @Override public void refundBond(Long id) { Order order = getOrder(id); - OrderAuctionBond orderAuctionBond = orderAuctionBondMapper.selectOne( - Wrappers.lambdaQuery(OrderAuctionBond.class) - .eq(OrderAuctionBond::getOrderId, id)); + OrderAuctionBond orderAuctionBond; + if (order.getAuctionType() == AuctionOrderTypeEnum.AUCTION_ITEMS) { + orderAuctionBond = orderAuctionBondMapper.selectOne( + Wrappers.lambdaQuery(OrderAuctionBond.class) + .eq(OrderAuctionBond::getAuctionSalesroomId, + order.getAuctionSalesroomId()) + .eq(OrderAuctionBond::getBoundStatus, BondStatusEnum.PAID)); + if (StringUtils.isNotNull(orderAuctionBond) + && orderAuctionBond.getBoundStatus() == BondStatusEnum.REFUNDED) { + throw new ServiceException("改拍卖会已退保证金"); + } + } else { + orderAuctionBond = orderAuctionBondMapper.selectOne( + Wrappers.lambdaQuery(OrderAuctionBond.class) + .eq(OrderAuctionBond::getAuctionGoodsId, + order.getGoodsSkuId()) + .eq(OrderAuctionBond::getBoundStatus, BondStatusEnum.PAID)); + } Paylog paylog = iPaylogService.lambdaQuery() .eq(Paylog::getOutTradeNo, orderAuctionBond.getOrderNo()) .last("limit 1").one(); + if (StringUtils.isNull(paylog)) { + throw new ServiceException("支付记录不存在"); + } PaymentMethodEnum paymentMethod = orderAuctionBond.getPaymentMethod(); if (orderAuctionBond.getBoundStatus() == BondStatusEnum.PAID) { boolean result = handleRefund(paymentMethod, paylog, orderAuctionBond.getOrderNo()); -- Gitblit v1.7.1