package com.fjhx.sale.service.documents.impl;

import com.fjhx.sale.entity.documents.po.DocumentsProduct;
import com.fjhx.sale.mapper.documents.DocumentsProductMapper;
import com.fjhx.sale.service.documents.DocumentsProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.documents.vo.DocumentsProductVo;
import com.fjhx.sale.entity.documents.dto.DocumentsProductSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;

import java.util.List;


/**
 * <p>
 * 单证-产品表 服务实现类
 * </p>
 *
 * @author
 * @since 2023-04-20
 */
@Service
public class DocumentsProductServiceImpl extends ServiceImpl<DocumentsProductMapper, DocumentsProduct> implements DocumentsProductService {

    @Override
    public Page<DocumentsProductVo> getPage(DocumentsProductSelectDto dto) {
        IWrapper<DocumentsProduct> wrapper = getWrapper();
        wrapper.orderByDesc("dp", DocumentsProduct::getId);
        Page<DocumentsProductVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    /**
     * 获取单证产品
     * @param documentId
     * @return
     */
    @Override
    public List<DocumentsProduct> getDpList(Long documentId) {
        return baseMapper.getDpList(documentId);
    }

    /**
     * 获取最大金额的数据
     * @param documentId
     * @return
     */
    @Override
    public DocumentsProduct getMaxMoneyData(Long documentId) {
        return baseMapper.getMaxMoneyData(documentId);
    }

}
