package com.ym.mec.biz.service.impl;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ym.mec.biz.dal.dao.HfMerchantConfigDao;
import com.ym.mec.biz.service.HfMerchantConfigService;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.service.impl.BaseServiceImpl;
import com.ym.mec.thirdparty.adapay.AdapayInit;
import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;

@Service
public class HfMerchantConfigServiceImpl extends BaseServiceImpl<Integer, HfMerchantConfig>  implements HfMerchantConfigService,InitializingBean {
	
	@Autowired
	private HfMerchantConfigDao hfMerchantConfigDao;

	@Override
	public BaseDAO<Integer, HfMerchantConfig> getDAO() {
		return hfMerchantConfigDao;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		AdapayInit adapayInit = AdapayInit.getInstance(false, true);
		adapayInit.initWithMerConfig(hfMerchantConfigDao.findAll(null));
	}

	@Override
	public HfMerchantConfig queryByTenantId(Integer tenantId) {
		return hfMerchantConfigDao.queryByTenantId(tenantId);
	}
	
}