package com.spot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spot.entity.ExOrder;
import com.spot.mapper.ExOrderMapper;
import com.spot.service.ExOrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 撮合引擎订单查询服务实现类
 *
 * @author jean
 * @date 2026-05-07
 */
@Service
public class ExOrderServiceImpl extends ServiceImpl<ExOrderMapper, ExOrder> implements ExOrderService {

    /**
     * 根据交易对和多个状态查询订单列表，按创建时间升序
     *
     * @param symbol   交易对
     * @param statuses 状态列表
     * @return 订单列表
     */
    @Transactional(readOnly = true)
    @Override
    public List<ExOrder> getOrdersBySymbolAndStatuses(String symbol, List<Integer> statuses) {
        return baseMapper.selectList(
                new LambdaQueryWrapper<ExOrder>()
                        .eq(ExOrder::getSymbol, symbol)
                        .in(ExOrder::getStatus, statuses)
                        .orderByAsc(ExOrder::getCtime)
        );
    }
}
