package cn.feast.coding.service.order.impl;

import cn.feast.coding.mapper.order.OrderMapper;
import cn.feast.coding.model.order.MonthStatis;
import cn.feast.coding.model.order.Order;
import cn.feast.coding.model.order.OrderStatis;
import cn.feast.coding.service.order.OrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

/**
 * Created By FeastCoding.
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper mapper;

    public int insert(Order model){
        return mapper.insert(model);
    }

    public int update(Order model){
        return mapper.update(model);
    }

    public int deleteByPrimaryKey(Integer id){
        return mapper.deleteByPrimaryKey(id);
    }

    public List<Order> selectAll(Order model){
        return mapper.selectAll(model);
    }

    public PageInfo<Order> queryPage(Order model, int pageNum, int pageSize) {
        if (pageSize < 1)
            pageSize = 10;
        PageHelper.startPage(pageNum, pageSize);
        List<Order> list = mapper.selectAll(model);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    public Order selectByPrimaryKey(Integer id){
        return mapper.selectByPrimaryKey(id);
    }

    public List<Order> queryAll(){
        return mapper.queryAll();
    }

    @Override
    public List<OrderStatis> statisOrderMoney(String year) {
        return mapper.statisOrderMoney(year);
    }

    @Override
    public List<OrderStatis> statisOrderCount(String year) {
        return mapper.statisOrderCount(year);
    }

    @Override
    public List<MonthStatis> statisOrderMonthCount(String year, String shop) {
        return mapper.statisOrderMonthCount(year, shop);
    }

    @Override
    public List<MonthStatis> statisOrderMonthMoney(String year, String shop) {
        return mapper.statisOrderMonthMoney(year, shop);
    }
}
