/**
 * @filename:/rderReceivePaymentAssociationServiceImpl 2024-11-06
 * @project KJT v1.1.0 Copyright(c) 2024 wanglang Co. Ltd. All right reserved.
 */
package com.trade.service.finance.paymentcollection.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trade.service.finance.paymentcollection.domain.OrderReceivePaymentAssociation;
import com.trade.service.finance.paymentcollection.mapper.OrderReceivePaymentAssociationMapper;
import com.trade.service.finance.paymentcollection.service.OrderReceivePaymentAssociationService;
import com.trade.service.trade.salesorder.dto.OrderListInfoDto;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:订单与收款关联表服务实现
 * @version: v1.1.0
 * @author: wanglang
 */
@Service
public class OrderReceivePaymentAssociationServiceImpl extends ServiceImpl<OrderReceivePaymentAssociationMapper, OrderReceivePaymentAssociation> implements OrderReceivePaymentAssociationService {

    @Override
    public List<OrderListInfoDto> queryByBusinessBatchNumber(String businessBatchNumber) {
        List<OrderListInfoDto> list = new ArrayList<>();
        List<OrderReceivePaymentAssociation> paymentAssociations = this.lambdaQuery()
                .eq(OrderReceivePaymentAssociation::getBusinessBatchNumber, businessBatchNumber).list();
        for (OrderReceivePaymentAssociation paymentAssociation : paymentAssociations) {
            OrderListInfoDto orderListInfoDto = new OrderListInfoDto(paymentAssociation);
            list.add(orderListInfoDto);
        }
        return list;
    }

    @Override
    public OrderReceivePaymentAssociation queryByBusinessBatchNumberAndOrderId(String businessBatchNumber, Long orderId) {
        return this.lambdaQuery().eq(OrderReceivePaymentAssociation::getBusinessBatchNumber, businessBatchNumber).eq(OrderReceivePaymentAssociation::getOrderId, orderId).one();
    }
}
