package com.td.boss.game.comsnbtran.service;

import com.td.boss.common.service.*;
import com.td.boss.game.comcntorder.vo.ComCntOrderPayTypeSumVo;
import com.td.boss.game.comsnbtran.pojo.ComSnbTran;
import com.td.boss.game.comsnbtran.vo.ComSnbTranTranTypeSumVo;
import com.td.boss.game.comsnbtran.vo.ComSnbTranVo;
import com.td.boss.game.comsnbtran.repository.ComSnbTranRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class ComSnbTranServiceImpl extends CommonServiceImpl<ComSnbTranVo, ComSnbTran, String> implements ComSnbTranService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private ComSnbTranRepository comSnbTranRepository;


    @Override
    public Page<ComSnbTran> findAllByUserId(String userId, Pageable pageable) {
        return comSnbTranRepository.findAllByUserId(userId,pageable);
    }

    @Override
    public List<ComSnbTranTranTypeSumVo> findAllSNBSumGroupByPayType() {
        return comSnbTranRepository.findSnbSumByTranType();
    }

    @Override
    public List<ComSnbTranTranTypeSumVo> findAllSNBSumGroupByPayTypeFromDate(Date startTime, Date endTime) {
        return comSnbTranRepository.findCNTSumByPayTypeFromDate(startTime, endTime);
    }
}
