package com.sckw.order.repository;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sckw.core.model.base.BaseModel;
import com.sckw.order.dao.KwoTradeOrderContractMapper;
import com.sckw.order.model.KwoTradeOrderContract;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
 * @author :chenXiaoFei
 * @version :1.0
 * @description : 贸易合同和贸易订单关联接口
 * @create :2025-11-07 10:58:00
 */
@Repository
public class KwoTradeOrderContractRepository extends ServiceImpl<KwoTradeOrderContractMapper, KwoTradeOrderContract> {
    public List<KwoTradeOrderContract> queryByOrderIds(Set<Long> tradeOrderIds) {
        return list(Wrappers.<KwoTradeOrderContract>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwoTradeOrderContract::getTOrderId, tradeOrderIds));
    }

    public KwoTradeOrderContract queryByTradeOrderId(Long traceOrderId) {
        return getOne(Wrappers.<KwoTradeOrderContract>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .eq(KwoTradeOrderContract::getTOrderId, traceOrderId)
                .last("limit 1"));
    }

    public List<KwoTradeOrderContract> queryByContractIds(Set<Long> tradeContractIds) {
       return list(Wrappers.<KwoTradeOrderContract>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwoTradeOrderContract::getContractId, tradeContractIds));
    }

    public List<KwoTradeOrderContract> queryTradeOrderIds(Set<Long> tradeOrderIds) {
        return list(Wrappers.<KwoTradeOrderContract>lambdaQuery()
                .eq(BaseModel::getDelFlag,0)
                .in(KwoTradeOrderContract::getTOrderId, tradeOrderIds));
    }
}
