package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pdd.entity.LogOrderMailDetailEntity;
import org.ta.pddserver.mapper.LogOrderMailDetailMapper;
import org.ta.pddserver.model.api.request.LogOrderMailDetailListRequest;
import org.ta.pddserver.model.api.response.LogOrderMailDetailListResponse;
import org.ta.pddserver.model.api.response.MailNoResponse;
import org.ta.pddserver.service.LogOrderMailDetailService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LogOrderMailDetailImpl extends ServiceImpl<LogOrderMailDetailMapper, LogOrderMailDetailEntity> implements LogOrderMailDetailService {

    public Boolean updateByMailNo(String mailNo, int status) {
       return baseMapper.updateByMailNo(mailNo, status);
    }

    public List<LogOrderMailDetailEntity> getListByCode(String logisticsOrderCode) {
        return baseMapper.getListByCode(logisticsOrderCode);
    }

    public LogOrderMailDetailEntity getByMailNo(String mailNo) {
        return baseMapper.findByMailNo(mailNo);
    }

    public List<LogOrderMailDetailEntity> getNewPackListByCode(String logisticsOrderCode) {
        return baseMapper.getNewPackListByCode(logisticsOrderCode);
    }





    public Map<String, Object> getListByCodeNo(LogOrderMailDetailListRequest param) {
        Integer count = baseMapper.countUsable(param);
        param.checkPage(count,20);
        List<LogOrderMailDetailListResponse> list = baseMapper.getListByCodeNo(param);
        Map<String, Object> map = new HashMap<>();
        map.put("total", count);
        map.put("list", list);
        map.put("page", param.getPage());
        return map;
    }


    public MailNoResponse getInfoByMailNo(String mailNo) {
        return baseMapper.getInfoByMailNo(mailNo);
    }

    public LogOrderMailDetailEntity getAllInfoByMailNo(String mailNo) {
        return baseMapper.getAllInfoByMailNo(mailNo);
    }



    public Long getSumByCodeStatus(String logisticsOrderCode, Long status) {
        return baseMapper.getSumByCodeStatus(logisticsOrderCode, status);
    }

    public int findCountByLogisticsOrderCode(String logisticsOrderCode) {
        return baseMapper.findCountByLogisticsOrderCode(logisticsOrderCode);
    }

    public int getInboundedCountByOrderCode(String logisticsOrderCode) {
        return this.baseMapper.countInboundedByOrderCode(logisticsOrderCode);
    }

    public Long countFromDate(String today) {
        return this.baseMapper.countFromDate(today);
    }

    public Long countEntered() {
        return this.baseMapper.countEntered();
    }

    public Long countEnteredFromDate(String today) {
        return this.baseMapper.countEnteredFromDate(today);
    }

    public Integer updateMailToProblem(String mailNo) {
        return this.baseMapper.updateMailToProblem(mailNo);
    }

    public List<LogOrderMailDetailEntity> getListByMailNo(String mailNo) {
        return this.baseMapper.findListByMailNo(mailNo);
    }

    public Integer updateMailToReturnBack(String mailNo) {
        return this.baseMapper.updateMailToReturnBack(mailNo);
    }
}