package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pdd.entity.LogOrderMailDetailIoEntity;
import org.ta.pddserver.mapper.LogOrderMailDetailIoMapper;
import org.ta.pddserver.model.api.request.LogOrderMailDetailIoRequest;
import org.ta.pddserver.model.api.response.LogOrderMailDetailIoListResponse;
import org.ta.pddserver.model.api.response.MailDetailIoSelectResponse;
import org.ta.pddserver.service.LogOrderMailDetailIoService;

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

@Service
public class LogOrderMailDetailIoImpl extends ServiceImpl<LogOrderMailDetailIoMapper, LogOrderMailDetailIoEntity> implements LogOrderMailDetailIoService {


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


    public List<LogOrderMailDetailIoEntity> getOutByOrderCode(String orderCode) {
        return this.baseMapper.findOutByOrderCode(orderCode);
    }

    public List<LogOrderMailDetailIoEntity> getOutByWxOrderCode(String orderCode) {
        return this.baseMapper.findOutByWxOrderCode(orderCode);
    }

    public LogOrderMailDetailIoEntity getOutboundByMailNo(String mailNo) {
        return this.baseMapper.findOutboundByMailNo(mailNo);
    }

    public LogOrderMailDetailIoEntity getOutboundByUpMailNo(String mailNo) {
        return this.baseMapper.findOutboundByUpMailNo(mailNo);
    }

    public MailDetailIoSelectResponse findInfoByMailNoAction(String mailNo, String action) {
        return baseMapper.findInfoByMailNoAction(mailNo, action);
    }

    public Long countOutboundOrder() {
        return baseMapper.countOutboundOrder();
    }

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

    public Long countOutboundPackage() {
        return baseMapper.countOutboundPackage();
    }

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

    public List<LogOrderMailDetailIoEntity> getByKeyWord(String keyword) {
        return this.baseMapper.findByReqKeyword(keyword);
    }
}