|
@@ -1,5 +1,6 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -27,6 +28,7 @@ import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.OpenedProductsServiceImpl;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.ModifyOpeningTimeVO;
|
|
|
import com.diagbot.vo.OpenUpOnTrialVO;
|
|
@@ -77,7 +79,36 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
|
|
|
*/
|
|
|
public List<GetConsoleOnTrialDTO> getConsoleOnTrial() {
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
- return baseMapper.getConsoleOnTrial(userId);
|
|
|
+ List<GetConsoleOnTrialDTO> retList = baseMapper.getConsoleOnTrial(userId);
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ Date expirTime = null;
|
|
|
+ for(GetConsoleOnTrialDTO i : retList){
|
|
|
+ String accessTypeMsg = "";
|
|
|
+ for(String j:i.getAccessType().split(",")){
|
|
|
+ accessTypeMsg+=AccessTypeEnum.getName(Integer.parseInt(j))+" ";
|
|
|
+ }
|
|
|
+ i.setAccessTypeMsg(accessTypeMsg);
|
|
|
+ i.setServiceStatusMsg(StatusEnum.getName(i.getServiceStatus()));
|
|
|
+
|
|
|
+ if(StringUtil.isBlank(i.getAppKeyId())){
|
|
|
+ i.setIsUsed("N");
|
|
|
+ }else{
|
|
|
+ expirTime = DateUtil.parseDateTime(i.getExpiringDate());
|
|
|
+ if(expirTime.getTime()<now.getTime()
|
|
|
+ ||i.getServiceStatus()==StatusEnum.Disable.getKey()
|
|
|
+ ||i.getTokenStatus()==StatusEnum.Disable.getKey()){
|
|
|
+ i.setIsUsed("N");
|
|
|
+ }else{
|
|
|
+ i.setIsUsed("Y");
|
|
|
+ }
|
|
|
+ i.setSurplusTime(getDatePoor(expirTime, now));
|
|
|
+ i.setTokenStatusMsg(StatusEnum.getName(i.getTokenStatus()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return retList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -191,4 +222,22 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
|
|
|
}
|
|
|
return RespDTO.onSuc(res);
|
|
|
}
|
|
|
+ private String getDatePoor(Date endDate, Date nowDate) {
|
|
|
+ long nd = 1000 * 24 * 60 * 60;
|
|
|
+ long nh = 1000 * 60 * 60;
|
|
|
+ long nm = 1000 * 60;
|
|
|
+ // long ns = 1000;
|
|
|
+ // 获得两个时间的毫秒时间差异
|
|
|
+ long diff = endDate.getTime() - nowDate.getTime();
|
|
|
+ // 计算差多少天
|
|
|
+ long day = diff / nd;
|
|
|
+ // 计算差多少小时
|
|
|
+ long hour = diff % nd / nh;
|
|
|
+ // 计算差多少分钟
|
|
|
+ long min = diff % nd % nh / nm;
|
|
|
+ // 计算差多少秒//输出结果
|
|
|
+ // long sec = diff % nd % nh % nm / ns;
|
|
|
+ return day + "天" + hour + "小时" + min + "分钟";
|
|
|
+ }
|
|
|
+
|
|
|
}
|