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

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

import com.ym.mec.biz.dal.dao.VipGroupDefaultClassesUnitPriceDao;
import com.ym.mec.biz.dal.entity.VipGroupDefaultClassesUnitPrice;
import com.ym.mec.biz.service.VipGroupDefaultClassesUnitPriceService;
import com.ym.mec.common.dal.BaseDAO;
import com.ym.mec.common.service.impl.BaseServiceImpl;

@Service
public class VipGroupDefaultClassesUnitPriceServiceImpl extends BaseServiceImpl<Integer, VipGroupDefaultClassesUnitPrice>  implements VipGroupDefaultClassesUnitPriceService {
	
	@Autowired
	private VipGroupDefaultClassesUnitPriceDao vipGroupDefaultClassesUnitPriceDao;

	@Override
	public BaseDAO<Integer, VipGroupDefaultClassesUnitPrice> getDAO() {
		return vipGroupDefaultClassesUnitPriceDao;
	}

	@Override
	public long insert(VipGroupDefaultClassesUnitPrice bean) {
		VipGroupDefaultClassesUnitPrice byVipGroupCategory = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory( bean.getVipGroupCategoryId().longValue(),bean.getOrganId().longValue());
		if(null!=byVipGroupCategory){
			return vipGroupDefaultClassesUnitPriceDao.updateByVipGroupCategory(bean);
		}else{
			return super.insert(bean);
		}
	}
}