From d15c73ddaf807593ee45eff8e264f82006f7e1e3 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期六, 29 五月 2021 14:28:53 +0800 Subject: [PATCH] 会员 --- service-vip/src/main/java/com/ks/vip/service/remote/VipGradePotenceServiceImpl.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/service-vip/src/main/java/com/ks/vip/service/remote/VipGradePotenceServiceImpl.java b/service-vip/src/main/java/com/ks/vip/service/remote/VipGradePotenceServiceImpl.java index 79c29fb..44a617d 100644 --- a/service-vip/src/main/java/com/ks/vip/service/remote/VipGradePotenceServiceImpl.java +++ b/service-vip/src/main/java/com/ks/vip/service/remote/VipGradePotenceServiceImpl.java @@ -1,15 +1,20 @@ 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 com.ks.vip.pojo.DO.VipGradePotence; +import com.ks.vip.pojo.Enums.VIPEnum; import com.ks.vip.query.VipGradePotenceQuery; import com.ks.vip.service.VipGradePotenceService; import com.ks.vip.service.VipGradePotenceService; +import com.ks.vip.service.VipGradeService; import org.apache.dubbo.config.annotation.Service; import javax.annotation.Resource; +import java.util.Date; import java.util.List; @Service(version = "1.0") @@ -17,6 +22,9 @@ @Resource private VipGradePotenceMapper vipGradePotenceMapper; + + @Resource + private VipGradeService vipGradeService; @Override @@ -62,9 +70,54 @@ return vipGradePotenceMapper.listByPage(query); } + @Override + public VipGradePotence getPotenceByGradeId(Long gradeId) { + return vipGradePotenceMapper.getByGradeId(gradeId); + } + + + @Override + public void save(VipGradePotence t) throws VipGradePotenceException { + Long gradeId = t.getGradeId(); + if (gradeId == null) { + throw new VipGradePotenceException(1, "绛夌骇ID涓虹┖"); + } + + if(t.getId() != null && t.getId().longValue() > 0) { + t.setUpdateTime(new Date()); + vipGradePotenceMapper.updateByPrimaryKeySelective(t); + } else { + VipGradePotence obj = vipGradePotenceMapper.getByGradeId(gradeId); + if (obj == null) { + t.setCreateTime(new Date()); + vipGradePotenceMapper.insertSelective(t); + } else { + t.setId(obj.getId()); + t.setUpdateTime(new Date()); + vipGradePotenceMapper.updateByPrimaryKeySelective(t); + } + } + } + @Override + public VipGradePotence getDefaultGradePotence() { + VipGrade grade = vipGradeService.getDefaultGrade(); + if (grade == null) { + return null; + } + return vipGradePotenceMapper.getByGradeId(grade.getId()); + } + @Override + public VipGradePotence getPotenceByVipEnum(VIPEnum vipEnum) { + VipGrade grade = vipGradeService.getByVipEnum(vipEnum); + if (grade == null) { + return null; + } + return vipGradePotenceMapper.getByGradeId(grade.getId()); + } + } -- Gitblit v1.8.0