package com.yolo.keyboard.dal.mysql.userpurchaserecords;

import java.util.*;

import com.yolo.keyboard.framework.common.pojo.PageResult;
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
import com.yolo.keyboard.dal.dataobject.userpurchaserecords.KeyboardUserPurchaseRecordsDO;
import org.apache.ibatis.annotations.Mapper;
import com.yolo.keyboard.controller.admin.userpurchaserecords.vo.*;

/**
 * 用户内购记录 Mapper
 *
 * @author ziin
 */
@Mapper
public interface KeyboardUserPurchaseRecordsMapper extends BaseMapperX<KeyboardUserPurchaseRecordsDO> {

    default PageResult<KeyboardUserPurchaseRecordsDO> selectPage(KeyboardUserPurchaseRecordsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardUserPurchaseRecordsDO>()
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getUserId, reqVO.getUserId())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getProductId, reqVO.getProductId())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseQuantity, reqVO.getPurchaseQuantity())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getPrice, reqVO.getPrice())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getCurrency, reqVO.getCurrency())
                .betweenIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseTime, reqVO.getPurchaseTime())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseType, reqVO.getPurchaseType())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getStatus, reqVO.getStatus())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getPaymentMethod, reqVO.getPaymentMethod())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getTransactionId, reqVO.getTransactionId())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getOriginalTransactionId, reqVO.getOriginalTransactionId())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getProductIds, reqVO.getProductIds())
                .betweenIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseDate, reqVO.getPurchaseDate())
                .betweenIfPresent(KeyboardUserPurchaseRecordsDO::getExpiresDate, reqVO.getExpiresDate())
                .eqIfPresent(KeyboardUserPurchaseRecordsDO::getEnvironment, reqVO.getEnvironment())
                .orderByDesc(KeyboardUserPurchaseRecordsDO::getId));
    }

}