package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pddserver.entity.CollectMailDetailEntity;
import org.ta.pddserver.mapper.CollectMailDetailMapper;
import org.ta.pddserver.model.api.request.CollectMailDetailListRequest;
import org.ta.pddserver.model.api.response.CollectMailDetailListResponse;
import org.ta.pddserver.model.api.response.LogOrderListResponse;
import org.ta.pddserver.service.CollectMailDetailService;

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

@Service
public class CollectMailDetailImpl extends ServiceImpl<CollectMailDetailMapper, CollectMailDetailEntity> implements CollectMailDetailService {


    public CollectMailDetailEntity getByOrderCodeAndMailNo(String orderCode, String expressCode, String mailNo) {
        return baseMapper.selectByOrderCodeAndExpressCodeAndMailNo(orderCode, expressCode, mailNo);
    }

    public int updateStatusByUid(int status, String uid) {
        return baseMapper.updateStatusByUid(status, uid);
    }

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

    public Object getList(CollectMailDetailListRequest param) {

        Integer count = baseMapper.countUsable(param);
        param.checkPage(count,20);
        List<CollectMailDetailListResponse> 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<CollectMailDetailEntity> findListByOrderCode(String orderCode) {
        return baseMapper.findListByOrderCode(orderCode);
    }
}