From b4a195f07fc3c0c417d9bb2f06acf76f5a62f29e Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期六, 29 五月 2021 16:33:06 +0800
Subject: [PATCH] 会员权益

---
 service-vip/src/main/java/com/ks/vip/service/remote/VipGradePotenceServiceImpl.java |   40 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 36 insertions(+), 4 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 31a2e4d..e1cedca 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,6 +1,7 @@
 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;
@@ -13,6 +14,7 @@
 import org.apache.dubbo.config.annotation.Service;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 @Service(version = "1.0")
@@ -69,9 +71,31 @@
     }
 
     @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() {
@@ -79,7 +103,7 @@
         if (grade == null) {
             return null;
         }
-       return vipGradePotenceMapper.getByGradeId(grade.getId());
+       return vipGradePotenceMapper.getByGradeId(grade.getId(), new Date());
     }
 
 
@@ -89,7 +113,15 @@
         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);
+    }
 }

--
Gitblit v1.8.0