lyhzzz 2 tahun lalu
induk
melakukan
8640f34838

+ 12 - 1
src/main/java/com/fdkankan/ucenter/controller/AuthLicenseController.java

@@ -1,9 +1,13 @@
 package com.fdkankan.ucenter.controller;
 
 
+import cn.hutool.core.date.DateUnit;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.json.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.ucenter.common.ResultData;
 import com.fdkankan.ucenter.common.utils.AuthLicenseUtil;
+import com.fdkankan.ucenter.util.DateUserUtil;
 import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -28,7 +32,14 @@ public class AuthLicenseController {
 
     @GetMapping("/getAuthInfo")
     public ResultData getAuthInfo(){
-        return ResultData.ok(AuthLicenseUtil.readLicense());
+        JSONObject jsonObject = AuthLicenseUtil.readLicense();
+        JSONObject licenseInfo = jsonObject.getJSONObject("licenseInfo");
+        JSONObject snInfo = licenseInfo.getJSONObject("snInfo");
+        String endDate = snInfo.getStr("endDate");
+        Date date = DateUserUtil.getDate(endDate);
+        Long days = DateUserUtil.between(date,new Date());
+        snInfo.set("expirationDays",days);
+        return ResultData.ok();
     }
 
 }

+ 13 - 0
src/main/java/com/fdkankan/ucenter/util/DateUserUtil.java

@@ -1,5 +1,7 @@
 package com.fdkankan.ucenter.util;
 
+import cn.hutool.core.date.DateUnit;
+import cn.hutool.core.date.DateUtil;
 import com.fdkankan.ucenter.entity.IncrementType;
 import org.joda.time.DateTime;
 
@@ -72,4 +74,15 @@ public class DateUserUtil {
         }
         return time;
     }
+
+    public static Long between(Date endDate, Date newDate) {
+        long between = DateUtil.between(new Date(), newDate, DateUnit.DAY);
+        if(between == 0 && endDate.getTime() > newDate.getTime()){
+            return 1L;
+        }
+        if(endDate.getTime() < newDate.getTime()){
+            return 0L;
+        }
+        return between;
+    }
 }