| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | |
| | | import lombok.Synchronized; |
| | | |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | * @return PageDTO<MgtMallOrderVO> |
| | | */ |
| | | @Override |
| | | public PageDTO<MgtOrderVO> getOrderPage(MgtMallOrderQuery query) { |
| | | public PageDTO<MgtOrderVO> getOrderPage(MgtOrderQuery query) { |
| | | PageDTO<MgtOrderVO> pageVO; |
| | | // 封装会员条件查询对象 |
| | | MemberDTO memberDTO = null; |
| | |
| | | } |
| | | 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()) |
| | |
| | | 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() |
| | |
| | | .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); |
| | | } |
| | |
| | | @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()); |