package org.ta.pddserver.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.ta.pddserver.entity.CollectOrderEntity;
import org.ta.pddserver.mapper.CollectOrderMapper;
import org.ta.pddserver.model.api.request.CollectOrderListRequest;
import org.ta.pddserver.model.api.response.CollectMailDetailListResponse;
import org.ta.pddserver.model.api.response.CollectOrderListResponse;
import org.ta.pddserver.model.api.response.CollectOrderResponse;
import org.ta.pddserver.service.CollectOrderService;

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

@Service
public class CollectOrderImpl extends ServiceImpl<CollectOrderMapper, CollectOrderEntity> implements CollectOrderService {


    public CollectOrderResponse getByOrderCode(String orderCode) {
        return this.baseMapper.findByOrderCode(orderCode);
    }

    public int updateOrderStatus(int status, String uid) {
        return this.baseMapper.updateOrderStatusById(status, uid);
    }

    public Map getList(CollectOrderListRequest param) {
        Integer count = baseMapper.countUsable(param);
        param.checkPage(count,20);
        List<CollectOrderListResponse> 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 CollectOrderResponse getInfoByOrderCode(String orderCode) {
        return baseMapper.getInfoByOrderCode(orderCode);
    }

    public CollectOrderEntity getAllInfoByOrderCode(String orderCode) {
        return baseMapper.getAllInfoByOrderCode(orderCode);
    }

}