| | |
| | | package com.ks.vip.service.remote; |
| | | |
| | | |
| | | import com.ks.vip.exception.VipGradePotenceException; |
| | | import com.ks.vip.mapper.VipGradePotenceMapper; |
| | | import com.ks.vip.mapper.VipGradePotenceMapper; |
| | | import com.ks.vip.pojo.DO.VipGrade; |
| | |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service(version = "1.0") |
| | |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByGradeId(Long gradeId) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId); |
| | | public VipGradePotence getByGradeIdAndTime(Long gradeId, Date time) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId, time); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getCurrentByGradeId(Long gradeId) { |
| | | return vipGradePotenceMapper.getByGradeId(gradeId, new Date()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void add(VipGradePotence t) throws VipGradePotenceException { |
| | | Long gradeId = t.getGradeId(); |
| | | if (gradeId == null) { |
| | | throw new VipGradePotenceException(1, "等级ID为空"); |
| | | } |
| | | |
| | | if (t.getEffectiveTime() == null) { |
| | | t.setEffectiveTime(new Date()); |
| | | } |
| | | t.setCreateTime(new Date()); |
| | | vipGradePotenceMapper.insertSelective(t); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public VipGradePotence getDefaultGradePotence() { |
| | |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId(), new Date()); |
| | | } |
| | | |
| | | |
| | |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return vipGradePotenceMapper.getByGradeId(grade.getId()); |
| | | return getCurrentByGradeId(grade.getId()); |
| | | } |
| | | |
| | | @Override |
| | | public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum, Date time) { |
| | | VipGrade grade = vipGradeService.getByVipEnum(vipEnum); |
| | | if (grade == null) { |
| | | return null; |
| | | } |
| | | return getByGradeIdAndTime(grade.getId(), time); |
| | | } |
| | | } |