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

import com.liangjian.dataplatform.member.entity.po.secondary.MemIngProductOrder;
import com.liangjian.dataplatform.member.entity.po.secondary.UserPointClearRule;
import net.sf.json.JSONObject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

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


public interface UserOrderProductRepository extends JpaRepository<MemIngProductOrder,String>, JpaSpecificationExecutor<MemIngProductOrder> {


    @Query(value = "SELECT SUM(amount) amount FROM mem_ingProductOrder where secret_phone=?1 and crt_date>=?2",nativeQuery=true)
    JSONObject findByProductIdAndCrtDateGreaterThanEqual(String ProductId, Date date);

    @Query(value = "SELECT SUM(point) amount FROM mem_ingProductOrder where secret_phone=?1 and crt_date>=?2",nativeQuery=true)
    JSONObject findBySecretPhoneAndCrtDateGreaterThanEqual(String ProductId, Date date);
}
