package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pddserver.entity.LogOrderMailDetailEntity;
import org.ta.pddserver.mapper.LogOrderMailDetailMapper;
import org.ta.pddserver.model.api.request.LogOrderListRequest;
import org.ta.pddserver.model.api.request.LogOrderMailDetailListRequest;
import org.ta.pddserver.model.api.response.LogOrderListResponse;
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 Long getSumByCodeStatus(String logisticsOrderCode, Long status) {
        return baseMapper.getSumByCodeStatus(logisticsOrderCode, status);
    }
}