package com.aircraft.modules.order.service.impl;

import cn.hutool.core.util.StrUtil;
import com.aircraft.modules.order.domain.SettlementMain;
import com.aircraft.modules.order.mapper.SettlementMainMapper;
import com.aircraft.modules.order.service.ISettlementMainService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 订单结算主表 服务实现类
 * </p>
 *
 * @author cli
 * @since 2025-07-10
 */
@Service
public class SettlementMainServiceImpl extends ServiceImpl<SettlementMainMapper, SettlementMain> implements ISettlementMainService {

    @Override
    public IPage<SettlementMain> allSettlementOrderList(String batchNo, Page<SettlementMain> page) {
        return lambdaQuery().eq(StrUtil.isNotBlank(batchNo), SettlementMain::getBatchNo, batchNo)
                .orderByDesc(SettlementMain::getId).page(page);
    }

    @Override
    public List<SettlementMain> batchInsert(List<SettlementMain> settlementMainList) {
        this.saveBatch(settlementMainList);
        return settlementMainList;
    }

    @Override
    public SettlementMain obtainSettlementMainById(Long settlementOrderId) {
        return this.getById(settlementOrderId);
    }

    @Override
    public void updateSettlementStatus(Long settlementOrderId, Integer settlementOrderStatus) {
        this.update(Wrappers.<SettlementMain>lambdaUpdate()
                .eq(SettlementMain::getId, settlementOrderId)
                .set(SettlementMain::getSettlementStatus, settlementOrderStatus));
    }
}
