package cn.newfeifan.mall.module.distri.dal.mysql.dailybill;

import java.util.*;

import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.module.distri.service.dailybill.dto.MerchantDTO;
import cn.newfeifan.mall.module.distri.dal.dataobject.dailybill.DailyBillDO;
import cn.newfeifan.mall.module.distri.service.dailybill.dto.OrderDTO;
import org.apache.ibatis.annotations.Mapper;
import cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 每日账单 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface DailyBillMapper extends BaseMapperX<DailyBillDO> {

    default PageResult<DailyBillDO> selectPage(DailyBillPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DailyBillDO>()
                .eqIfPresent(DailyBillDO::getPrice, reqVO.getPrice())
                .eqIfPresent(DailyBillDO::getReceivedPrice, reqVO.getReceivedPrice())
                .eqIfPresent(DailyBillDO::getOrderCount, reqVO.getOrderCount())
                .eqIfPresent(DailyBillDO::getShopId, reqVO.getShopId())
                .eqIfPresent(DailyBillDO::getMerchantId, reqVO.getMerchantId())
                .eqIfPresent(DailyBillDO::getOrderIds, reqVO.getOrderIds())
                .betweenIfPresent(DailyBillDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DailyBillDO::getRefundPrice, reqVO.getRefundPrice())
                .eqIfPresent(DailyBillDO::getIntegral, reqVO.getIntegral())
                .eqIfPresent(DailyBillDO::getReceivedIntegral, reqVO.getReceivedIntegral())
                .eqIfPresent(DailyBillDO::getRefundIntegral, reqVO.getRefundIntegral())
                .betweenIfPresent(DailyBillDO::getOrderCalcTime, reqVO.getOrderCalcTime())
                .eqIfPresent(DailyBillDO::getPtDailyBillId, reqVO.getPtDailyBillId())
                .orderByDesc(DailyBillDO::getId));
    }

    List<MerchantDTO> getMerchantDTO();

    List<OrderDTO> getOrderDetails();

    void updateOrderItemByOrderId(@Param("orderIds") List<Long> orderIds);

    String getMerchantName(Long merchantId);

    String getShopName(Long shopId);
}