package cn.iocoder.yudao.module.member.dal.mysql.storeorder;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderCountVO;
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.storeorder.vo.StoreOrderPageVO;
import cn.iocoder.yudao.module.member.dal.dataobject.storeorder.StoreOrderDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * 商品订单 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface StoreOrderMapper extends BaseMapperX<StoreOrderDO> {

    default PageResult<StoreOrderDO> selectPage(StoreOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StoreOrderDO>()
                .eqIfPresent(StoreOrderDO::getCardNumber, reqVO.getCardNumber())
                .eqIfPresent(StoreOrderDO::getOpenId, reqVO.getOpenId())
                .eqIfPresent(StoreOrderDO::getNumber, reqVO.getNumber())
                .eqIfPresent(StoreOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(StoreOrderDO::getBillingExist, reqVO.getBillingExist())
                .eqIfPresent(StoreOrderDO::getEquipmentCode, reqVO.getEquipmentCode())
                .eqIfPresent(StoreOrderDO::getUuid, reqVO.getUuid())
                .eqIfPresent(StoreOrderDO::getTotalPrice, reqVO.getTotalPrice())
                .eqIfPresent(StoreOrderDO::getUserId, reqVO.getUserId())
                .eqIfPresent(StoreOrderDO::getStatus, reqVO.getStatus())
                .inIfPresent(StoreOrderDO::getUserId, reqVO.getUserIds())
                .betweenIfPresent(StoreOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StoreOrderDO::getOrderId));
    }

    IPage<StoreOrderPageVO> getStoreOrderPageNew(IPage<StoreOrderPageVO> page, @Param("vo") StoreOrderPageVO vo);

    List<StoreOrderPageVO> getStoreOrderPageNewList(@Param("vo") StoreOrderPageVO vo);
    Integer updateByIdBillingExist (@Param("ids") Set<Long> ids, @Param("exist")Boolean exist);
    Integer updateByIdBillingNum (@Param("ids") Set<Long> ids, @Param("num")String num);


    List<StoreOrderCountVO> countOrder(@Param("startTime")String startTime,@Param("endTime")String endTime);
}