package com.liangjian.dataplatform.member.dao.elasticsearch;

import com.liangjian.dataplatform.member.entity.po.elasticsearch.UserPointLog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * @Author: 黄子奇
 * @Date: 2019/11/15
 */
public interface UserPointLogRepository extends ElasticsearchCrudRepository<UserPointLog,String> {

    List<UserPointLog> findBySecretPhoneAndCrtDateAfterAndCrtDateBeforeOrderByCrtDateDesc(String secretPhone, Long after, Long before);

    Page<UserPointLog> findBySecretPhone(String secretPhone, Pageable pageable);

    Page<UserPointLog> findBySecretPhoneAndIncrease(String secretPhone, boolean increase, Pageable pageable);

    //已更换成ES, 这块不清楚会不会运行成功
//    @Query(value = "SELECT sum(value) as pointsSendOut from mem_user_point_log WHERE value > 0;", nativeQuery = true)
//    Long getPointsSendOut();
//
//    @Query(value = "SELECT sum(value) as pointsSendOut from mem_user_point_log WHERE value > 0;", nativeQuery = true)
//    Long getPointsConsumed();
//
//    @Query(value = "SELECT sum(point) as pointsSendOut from mem_weixin_user_info WHERE point > 0;", nativeQuery = true)
//    Long getPointsToBeConsumed();
//
//    @Query(value = "SELECT sum(value) as pointsSendOut from mem_user_point_log WHERE value > 0;", nativeQuery = true)
//    Long getPointsExpired();
}
