package com.ssj.service.weixin.push.service.dao;

import com.ssj.bean.weixin.push.domain.PushTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/** 
 * @author  ZhangCaibao 
 * @version 2017年5月5日 下午2:57:49 
 * 类说明 
 */
@Repository
public interface PushTemplateDao extends JpaRepository<PushTemplate, String>{

	 @Query(nativeQuery = true, value = " select *  from  tb_push_template  where stat = 1 and  total <3 ")
	 public List<PushTemplate> getPushTemplateStat();
	
	 //有效的，没发送成功并且重试少于6的（只重试6次，无限的重试会影响正常的推送运行），或者当前重推少于总需推数的
	 @Query(nativeQuery = true, value = " SELECT * FROM tb_push_template where stat = 1 AND (try_time<=6 && is_success=0 ) OR (try_time<=6 && cur_total<total) ORDER BY create_time ASC ")
	 public List<PushTemplate> getPushWxTemplateStat();    
	 
	 
	 
	 
	 
	 
}
