package com.yeejoin.amos.boot.module.hygf.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationPageDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.PreparationMoney;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PreparationMoneyMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IPreparationMoneyService;
import com.yeejoin.amos.boot.module.hygf.api.dto.PreparationMoneyDto;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.rdbms.service.BaseService;

import java.util.List;

/**
 * 发货单服务实现类
 *
 * @author system_generator
 * @date 2023-08-17
 */
@Service
public class PreparationMoneyServiceImpl extends BaseService<PreparationMoneyDto,PreparationMoney,PreparationMoneyMapper> implements IPreparationMoneyService {


    @Autowired
    private PreparationMoneyMapper preparationMoneyMapper;



    /**
     * 分页查询
     */
    public IPage<PreparationMoney> queryForPreparationMoneyPage(PreparationPageDto  dto)   {

        //列表数据组装
        QueryWrapper<PreparationMoney> qw = new QueryWrapper<>();
        qw.ge(StringUtils.isNotEmpty(dto.getStartDate()), "order_time", dto.getStartDate());
        qw.le(StringUtils.isNotEmpty(dto.getEndDate()), "order_time", dto.getEndDate());
        qw.eq(StringUtils.isNotEmpty(dto.getConsigneeAddress()), "consignee_address", dto.getConsigneeAddress());
        qw.eq(StringUtils.isNotEmpty(dto.getDealerId()), "dealer_id", dto.getDealerId());
        qw.like(StringUtils.isNotEmpty(dto.getOddNumbers()), "odd_numbers", dto.getOddNumbers());
        qw.like(StringUtils.isNotEmpty(dto.getSalesman()), "salesman", dto.getSalesman());
        qw.eq(StringUtils.isNotEmpty(dto.getDocumentState()), "document_state", dto.getDocumentState());
        qw.eq(StringUtils.isNotEmpty(dto.getShipmentStatus()), "shipment_status", dto.getShipmentStatus());
        qw.eq(StringUtils.isNotEmpty(dto.getReceivingStatus()), "receiving_status", dto.getReceivingStatus());
        if(dto.getIsdocumentStatezf()!=null&&dto.getIsdocumentStatezf()){
            qw.ne( "document_state", "已作废");
        }

        if (StringUtils.isNotEmpty(dto.getOrderBy())) {
            qw.orderBy(Boolean.TRUE, dto.getIsASC(), dto.getOrderBy());
        }else{
            qw.orderBy(Boolean.TRUE, Boolean.FALSE, "order_time");
        }
        IPage<PreparationMoney> warningQuestionInfoIPage = preparationMoneyMapper.selectPage(dto, qw);

        return warningQuestionInfoIPage;
    }

    /**
     * 列表查询 示例
     */
    public List<PreparationMoneyDto> queryForPreparationMoneyList()   {
        return this.queryForList("" , false);
    }
}