package com.wzj.soopin.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzj.soopin.order.domain.bo.OrderBo;
import com.wzj.soopin.order.domain.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import com.wzj.soopin.order.domain.form.ManagerOrderQueryForm;
import com.wzj.soopin.order.domain.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

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

/**
 * 订单表Mapper接口
 *
 * @author zcc
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    /**
     * 查询订单表列表
     *
     * @param order 订单表
     * @return 订单表集合
     */
    List<Order> selectByEntity(Order order);


    List<ManagerOrderVO> selectManagerOrderPage(ManagerOrderQueryForm request);


    IPage<OrderVO> getlist(@Param("page") Page<Order> page,@Param("query") OrderBo query);

    @Select("SELECT " +
        "COUNT(*) AS count1, " +
        "SUM(aftersale = 1) AS count2 " +
        "FROM oms_order")
    Map<String, Object> countOrder();


    @Update("update oms_order set status = #{status} where id = #{orderId}")
    void updateStatusById(@Param("orderId")Long orderId, @Param("status") Integer status);
}
