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

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

import java.util.List;

/**
 * 订单结算信息表，记录店铺的结算信息 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface ShopSettlementMapper extends BaseMapperX<ShopSettlementDO> {

    default PageResult<ShopSettlementDO> selectPage(ShopSettlementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ShopSettlementDO>()
                .eqIfPresent(ShopSettlementDO::getPlatformCollectionAmount, reqVO.getPlatformCollectionAmount())
                .eqIfPresent(ShopSettlementDO::getShopAmount, reqVO.getShopAmount())
                .eqIfPresent(ShopSettlementDO::getAttachment, reqVO.getAttachment())
                .betweenIfPresent(ShopSettlementDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ShopSettlementDO::getShopId, reqVO.getShopId())
                .eqIfPresent(ShopSettlementDO::getMerchantId, reqVO.getMerchantId())
                .eqIfPresent(ShopSettlementDO::getShopTotalHighAmount, reqVO.getShopTotalHighAmount())
                .eqIfPresent(ShopSettlementDO::getPtSettlementId, reqVO.getPtSettlementId())
                .orderByDesc(ShopSettlementDO::getId));
    }

    List<OrderDTO> getOrderByMerchantIdWithsShopId(@Param("shopId") Long shopId, @Param("merchantId") Long merchantId);

    void setOrderItemById(@Param("ids") List<Long> ids);

    String getShopName(@Param("shopId") Long shopId);

}