| | |
| | | import com.ruoyi.system.api.domain.OrderAuctionBond; |
| | | import com.ruoyi.system.api.domain.dto.MemberAuctionSalesroomBondDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderAuctionBondDTO; |
| | | import com.ruoyi.system.api.domain.dto.RefundDTO; |
| | | import com.ruoyi.system.api.domain.vo.PayInfoVO; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | |
| | | * @author mitao |
| | | * @since 2024-05-16 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class OrderAuctionBondServiceImpl extends ServiceImpl<OrderAuctionBondMapper, OrderAuctionBond> implements IOrderAuctionBondService { |
| | | |
| | |
| | | } |
| | | return payInfoVO; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) |
| | | public void returnBondByAuctionGoodsId(Long id) { |
| | | List<OrderAuctionBond> list = this.lambdaQuery().eq(OrderAuctionBond::getAuctionGoodsId, id) |
| | | .eq(OrderAuctionBond::getBoundStatus, BondStatusEnum.PAID).list(); |
| | | Set<String> orderNoSet = list.stream().map(OrderAuctionBond::getOrderNo) |
| | | .collect(Collectors.toSet()); |
| | | List<RefundDTO> refundDTOList = list.stream().map(item -> { |
| | | RefundDTO refundDTO = new RefundDTO(); |
| | | refundDTO.setAmount(item.getBond()); |
| | | refundDTO.setOrderNo(item.getOrderNo()); |
| | | return refundDTO; |
| | | }).collect(Collectors.toList()); |
| | | Map<String, Object> data = iPaylogService.refund(refundDTOList); |
| | | // 处理退款返回结果 |
| | | List<String> successfulOrders = new ArrayList<>(); |
| | | List<String> failedOrders = new ArrayList<>(); |
| | | |
| | | data.forEach((key, value) -> { |
| | | if ((boolean) value) { |
| | | successfulOrders.add(key); |
| | | } else { |
| | | failedOrders.add(key); |
| | | } |
| | | }); |
| | | log.info("订单号:{},退款失败", failedOrders); |
| | | // 退款成功的订单修改状态 |
| | | List<OrderAuctionBond> collect = list.stream().map(bond -> { |
| | | if (successfulOrders.contains(bond.getOrderNo())) { |
| | | bond.setBoundStatus(BondStatusEnum.REFUNDED); |
| | | return bond; |
| | | } |
| | | return null; |
| | | }).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | this.updateBatchById(collect); |
| | | } |
| | | |
| | | } |