
package com.tmerclub.cloud.order.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.tmerclub.cloud.api.order.vo.OrderSettlementSimpleVO;
import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.util.PageUtil;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.order.mapper.OrderSettlementMapper;
import com.tmerclub.cloud.order.model.OrderSettlement;
import com.tmerclub.cloud.order.service.OrderSettlementService;
import com.tmerclub.cloud.order.vo.OrderSettlementVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * 订单结算表
 *
 * @author tmerclub
 * @date 2020-12-05 14:13:50
 */
@Service
public class OrderSettlementServiceImpl implements OrderSettlementService {

    @Autowired
    private OrderSettlementMapper orderSettlementMapper;

    @Override
    public PageVO<OrderSettlementVO> page(PageDTO pageDTO) {
        return PageUtil.doPage(pageDTO, () -> orderSettlementMapper.list());
    }

    @Override
    public OrderSettlementVO getBySettlementId(Long settlementId) {
        return orderSettlementMapper.getBySettlementId(settlementId);
    }

    @Override
    public void update(OrderSettlement orderSettlement) {
        orderSettlementMapper.update(orderSettlement);
    }

    @Override
    public void deleteById(Long settlementId) {
        orderSettlementMapper.deleteById(settlementId);
    }

    @Override
    public OrderSettlement getByOrderId(Long orderId) {
        return orderSettlementMapper.getByOrderId(orderId);
    }

    @Override
    public List<OrderSettlementSimpleVO> listOrderIdsByPayIds(Long userId, List<Long> payIds) {
        if (CollUtil.isEmpty(payIds)) {
            return new ArrayList<>(0);
        }
        return orderSettlementMapper.listOrderIdsByPayIds(userId, payIds);
    }
}
