package com.yd.dal.service.commission;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yd.api.agms.vo.statistics.statementData;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.yd.dal.entity.commission.CommissionEGolden;
import com.yd.dal.mapper.commission.CommissionEGoldenMapper;
import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;

import javax.annotation.Resource;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Simon
 * @version 1.0
 */
@Service("commissionEGoldenDA")
public class CommissionEGoldenDAImpl implements CommissionEGoldenDA {

    private static final Logger LOG = Logger.getLogger(CommissionEGoldenDAImpl.class);

    @Resource
    private CommissionEGoldenMapper commissionEGoldenMapper;

    @Override
    @TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
    public PageInfo<statementData> getStatementDataByPage(int pageNum, int size, Integer isStatement,Integer type, String inCommissionStartTime, String outCommissionStartTime,String inCommissionEndTime, String outCommissionEndTime, String insurerBranchId, String deptId, String subordinateId) {
        PageHelper.startPage(pageNum, size);
        Page<statementData> statementData = commissionEGoldenMapper.getStatementDataByPage(isStatement,type,inCommissionStartTime,outCommissionStartTime,inCommissionEndTime,outCommissionEndTime,insurerBranchId,deptId,subordinateId);
        PageInfo<statementData> pageInfo = new PageInfo<>(statementData);
        return pageInfo;
    }

    /*
     * 按照手机号从EGolden DB中查询用户保单列表
     * 通过标签指定数据源：dataSourceKey = DataSourceKey.DB_EGOLDEN
     * (non-Javadoc)
     * @see com.yd.dataccess.service.commission.CommissionEGoldenDA#listSalesCommissionfromEGolden(java.lang.String)
     */
    @Override
    @TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
    public List<CommissionEGolden> listSalesCommissionfromEGolden(String login) {

        List<CommissionEGolden> destList = new ArrayList<CommissionEGolden>();

        destList = commissionEGoldenMapper.listSalesCommissionfromEGolden(login);

        return destList;
    }

    @Override
    @TargetDataSource(dataSourceKey = DataSourceKey.DB_EGOLDEN)
    public List<statementData> getStatementData(Integer isStatement, Integer type, String inCommissionStartTime, String outCommissionStartTime, String inCommissionEndTime, String outCommissionEndTime, String insurerBranchId, String deptId, String subordinateId) {
        return commissionEGoldenMapper.getStatementDataByPage(isStatement,type,inCommissionStartTime,outCommissionStartTime,inCommissionEndTime,outCommissionEndTime,insurerBranchId,deptId,subordinateId);
    }
}
