| | |
| | | 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.CollUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.order.controller.management.dto.MgtOrderConfirmShipmentDTO; |
| | |
| | | @Override |
| | | public void refundBond(Long id) { |
| | | Order order = getOrder(id); |
| | | OrderAuctionBond orderAuctionBond; |
| | | List<OrderAuctionBond> orderAuctionBond; |
| | | if (order.getAuctionOrderType() == AuctionOrderTypeEnum.AUCTION_ITEMS) { |
| | | orderAuctionBond = orderAuctionBondMapper.selectOne( |
| | | orderAuctionBond = orderAuctionBondMapper.selectList( |
| | | 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( |
| | | orderAuctionBond = orderAuctionBondMapper.selectList( |
| | | 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()); |
| | | if (result) { |
| | | paylog.setState(3);// 已退款 |
| | | orderAuctionBond.setBoundStatus(BondStatusEnum.REFUNDED); |
| | | iPaylogService.updateById(paylog); |
| | | this.updateById(order); |
| | | if (CollUtils.isNotEmpty(orderAuctionBond)) { |
| | | for (OrderAuctionBond auctionBond : orderAuctionBond) { |
| | | Paylog paylog = iPaylogService.lambdaQuery() |
| | | .in(Paylog::getOutTradeNo, auctionBond.getOrderNo()) |
| | | .one(); |
| | | boolean result = handleRefund(auctionBond.getPaymentMethod(), paylog, |
| | | auctionBond.getOrderNo()); |
| | | if (result) { |
| | | paylog.setState(3);// 已退款 |
| | | auctionBond.setBoundStatus(BondStatusEnum.REFUNDED); |
| | | iPaylogService.updateById(paylog); |
| | | this.updateById(order); |
| | | } |
| | | } |
| | | } |
| | | } |