package com.jeesharp.business.modules.trade.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeesharp.business.modules.trade.entity.TradeOrderItem;
import com.jeesharp.business.modules.trade.mapper.TradeOrderItemMapper;
import com.jeesharp.business.modules.trade.service.TradeOrderItemService;
import com.jeesharp.business.modules.trade.vo.TradeOrderItemQueryVO;
import com.jeesharp.framework.mybatis.core.service.CrudService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;

/**
 * 统一交易订单明细领域服务实现。
 *
 * @author jeesharp
 * @since 2026-05-08
 */
@Service
@Transactional(readOnly = true)
public class TradeOrderItemServiceImpl extends CrudService<TradeOrderItemMapper, TradeOrderItem, TradeOrderItemQueryVO>
    implements TradeOrderItemService {

    @Override
    public List<TradeOrderItem> findByTradeOrderIds(List<String> tradeOrderIds) {
        if (tradeOrderIds == null || tradeOrderIds.isEmpty()) {
            return Collections.emptyList();
        }
        LambdaQueryWrapper<TradeOrderItem> w = new LambdaQueryWrapper<>();
        w.in(TradeOrderItem::getOrderId, tradeOrderIds);
        w.eq(TradeOrderItem::getDelFlag, "0");
        w.orderByAsc(TradeOrderItem::getOrderId).orderByAsc(TradeOrderItem::getLineNo);
        return getBaseMapper().selectList(w);
    }
}
