package com.ichangzuo.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ichangzuo.common.base.BasePageQuery;
import com.ichangzuo.system.mapper.TakeOrderMapper;
import com.ichangzuo.system.model.entity.RealNameInfo;
import com.ichangzuo.system.model.entity.TakeOrder;
import com.ichangzuo.system.model.vo.TakeOrderPageVO;
import org.springframework.stereotype.Service;

@Service
public class TakeOrderServiceImpl extends ServiceImpl<TakeOrderMapper, TakeOrder> {
    public IPage<TakeOrderPageVO> listPagedDraw(BasePageQuery queryParams){
        int pageNum = queryParams.getPageNum();
        int pageSize = queryParams.getPageSize();
        Page<TakeOrderPageVO> page = new Page<>(pageNum, pageSize);
        // 查询数据

        return baseMapper.listPagedDraw(page, queryParams);
    }

    public TakeOrder setDrawState(Integer orderId, int state){
        TakeOrder order = getById(orderId);
        if(order!=null){
            order.setState(state);
            order.setMakeTime((int)(System.currentTimeMillis()/1000));
            if( !updateById(order) )
                return null;
        }

        return order;
    }
}
