From cf7a6d979229a1dbeca693429f6d539d5d254f95 Mon Sep 17 00:00:00 2001 From: YJ <YJ> Date: 星期二, 18 五月 2021 13:52:55 +0800 Subject: [PATCH] vip订单 --- service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java | 53 +++++++++++++++++++++++++++++------------------------ 1 files changed, 29 insertions(+), 24 deletions(-) diff --git a/service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java b/service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java index 70f6f93..d09213b 100644 --- a/service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java +++ b/service-vip/src/main/java/com/ks/vip/service/remote/VipCenterServiceImpl.java @@ -4,10 +4,12 @@ import com.ks.vip.mapper.VipCenterMapper; import com.ks.vip.mapper.VipComboMapper; import com.ks.vip.pojo.DO.*; +import com.ks.vip.pojo.Enums.VIPEnum; import com.ks.vip.query.VipCenterQuery; import com.ks.vip.query.VipComboQuery; import com.ks.vip.service.*; import org.apache.dubbo.config.annotation.Service; +import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; import javax.annotation.Resource; @@ -73,6 +75,7 @@ } @Override + @Transactional(rollbackFor = Exception.class) public void saveVipCenter(String uid, Long gradeId, Integer validDays, Long orderId) { VipCenterRecord record = new VipCenterRecord(); @@ -121,42 +124,44 @@ } - @Override - public boolean verifyVIP(String uid) { - VipCenter vipCenter = vipCenterMapper.getByUid(uid); - if (vipCenter == null) { - return false; - } - // 楠岃瘉浼氬憳鏄惁鏈夋晥 - long nowTime = java.lang.System.currentTimeMillis(); - if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { - return true; - } - return false; - } + @Override public VipGradePotence getVipPotence(String uid) { + VipGradePotence potence = null; VipCenter vipCenter = vipCenterMapper.getByUid(uid); - if (vipCenter == null || vipCenter.getGradeId() == null) { - return null; + if (vipCenter != null || vipCenter.getGradeId() != null) { + long nowTime = java.lang.System.currentTimeMillis(); + if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { + potence = vipGradePotenceService.getPotenceByGradeId(vipCenter.getGradeId()); + } } - - long nowTime = java.lang.System.currentTimeMillis(); - if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { - return vipGradePotenceService.selectByPrimaryKey(vipCenter.getGradeId()); + if (potence == null) { + potence = vipGradePotenceService.getDefaultGradePotence(); } - return null; + return potence; } @Override public VipGrade getVipGrade(String uid) { + VipGrade vipGrade = null; VipCenter vipCenter = vipCenterMapper.getByUid(uid); - if (vipCenter == null || vipCenter.getGradeId() == null) { - return null; + if (vipCenter != null || vipCenter.getGradeId() != null) { + long nowTime = java.lang.System.currentTimeMillis(); + if (vipCenter.getStartTime().getTime() <= nowTime && vipCenter.getEndTime().getTime() >= nowTime) { + vipGrade = vipGradeService.selectByPrimaryKey(vipCenter.getGradeId()); + } } - return vipGradeService.selectByPrimaryKey(vipCenter.getGradeId()); + if (vipGrade == null) { + vipGradeService.getDefaultGrade(); + } + return vipGrade; } -} + @Override + public VIPEnum getVIPEnumByUid(String uid) { + VipGrade vipGrade = getVipGrade(uid); + return vipGrade.getIdentity(); + } +} \ No newline at end of file -- Gitblit v1.8.0