Browse Source

Merge branch 'develop' into dev/icss

gaodm 6 years ago
parent
commit
bca97d04b6

+ 10 - 1
common/src/main/java/com/diagbot/exception/CommonErrorCode.java

@@ -23,7 +23,16 @@ public enum CommonErrorCode implements ErrorCode {
     NO_PERMISSION("00020008", "无权访问!"),
     IS_EXISTS("00020009", "已存在!"),
     ANALYZER_TOKEN_FAIL("10020010", "解析token失败"),
-    TOKEN_PAST("10020011", "token已失效,请重新登录");
+    TOKEN_PAST("10020011", "token已失效,请重新登录"),
+
+    SECURITYCODE_ERROR("20020001", "防伪码错误"),
+    APPKEY_ERROR("20020002", "appkey或secret错误"),
+    PRODUCT_STOP_ERROR("20020003", "该产品已停用"),
+    OVERDUE_ERROR("20020004", "访问权限已过期"),
+    NOPERMISSION_ERROR("20020005", "无权限访问"),
+    SERVICE_STOP_ERROR("20020006", "当前服务已停用"),
+    NOTVALID_ERROR("20020007", "该产品未在有效服务期内,无法使用"),
+    EXPIRE_ERROR("20020008", "该产品已超出有效服务期,无法使用");
 
     private String code;
     private String msg;

+ 61 - 0
common/src/main/java/com/diagbot/util/EnDecodeUtil.java

@@ -0,0 +1,61 @@
+package com.diagbot.util;
+
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @Description: 加解密工具类
+ * @author: ztg
+ * @time: 2018/11/8 14:38
+ */
+public class EnDecodeUtil {
+
+    /**
+     * 采用BASE64算法对字符串进行加密
+     * @param str 原字符串
+     * @return 加密后的字符串
+     */
+    public static String encode(String str) {
+        byte[] b = null;
+        String s = null;
+        try {
+            b = str.getBytes("utf-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        if (b != null) {
+            s = new BASE64Encoder().encode(b);
+        }
+        return s;
+    }
+
+    /**
+     * 字符串解密,采用BASE64的算法
+     * @param s 需要解密的字符串
+     * @return 解密后的字符串
+     */
+    public static String decode(String s) {
+        byte[] b = null;
+        String result = null;
+        if (s != null) {
+            BASE64Decoder decoder = new BASE64Decoder();
+            try {
+                b = decoder.decodeBuffer(s);
+                result = new String(b, "utf-8");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+
+    public static void main(String[] args) {
+        String abc = "201811081616";
+        String c = encode(abc);
+        System.out.println(c);
+        System.out.println(decode(c));
+    }
+}

+ 1 - 1
config-server/src/main/resources/shared/gateway-service-dev.yml

@@ -103,5 +103,5 @@ server:
   port: 5050
 
 lantone:
-  product: triage,1;icss,2
+  product: triage,143;icss,2
 

+ 2 - 3
diagbotman-service/src/main/java/com/diagbot/dto/OpenProductCheckDTO.java

@@ -11,12 +11,11 @@ import java.io.Serializable;
  * @Date: 2018/11/8 14:10
  */
 
+@SuppressWarnings("serial")
 @Getter
 @Setter
 public class OpenProductCheckDTO implements Serializable {
 
-    private static final long serialVersionUID = 1L;
-
     private Boolean hasPermission ;//标志
-    private String userId;         //用户ID
+
 }

+ 5 - 5
diagbotman-service/src/main/java/com/diagbot/facade/LantoneProductFacade.java

@@ -104,7 +104,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
      */
     public Boolean updateProduct(UpdateProductVO updateProductVO) {
         LantoneProduct lantoneProductInfo = this.selectProductByName(updateProductVO.getName());
-        if(null != lantoneProductInfo && updateProductVO.getName().equals(lantoneProductInfo.getName()) && updateProductVO.getId() != lantoneProductInfo.getId()){
+        if(null != lantoneProductInfo && updateProductVO.getName().equals(lantoneProductInfo.getName()) && updateProductVO.getId().intValue() != lantoneProductInfo.getId().intValue()){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "产品名称重复");
         }
@@ -145,11 +145,11 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
             throw new CommonException(CommonErrorCode.NOT_EXISTS,
                     "该产品已删除,请刷新页面");
         }
-        if(updateProductVO.getServiceStatus() == lantoneProduct.getServiceStatus() && updateProductVO.getServiceStatus() == StatusEnum.Enable.getKey()){
+        if(updateProductVO.getServiceStatus().intValue() == lantoneProduct.getServiceStatus().intValue() && updateProductVO.getServiceStatus().intValue() == StatusEnum.Enable.getKey()){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "该产品已启用,启用失败");
         }
-        if(updateProductVO.getServiceStatus() == lantoneProduct.getServiceStatus() && updateProductVO.getServiceStatus() == StatusEnum.Disable.getKey()){
+        if(updateProductVO.getServiceStatus().intValue() == lantoneProduct.getServiceStatus().intValue() && updateProductVO.getServiceStatus().intValue() == StatusEnum.Disable.getKey()){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "该产品已停用,停用失败");
         }
@@ -203,7 +203,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
             throw new CommonException(CommonErrorCode.NOT_EXISTS,
                     "该产品已删除,请刷新页面");
         }
-        if(lantoneProduct.getServiceStatus()==StatusEnum.Enable.getKey()){
+        if(lantoneProduct.getServiceStatus().intValue() == StatusEnum.Enable.getKey()){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "当前产品正在使用中不可删除");
         }
@@ -351,7 +351,7 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         BeanUtil.copyProperties(oppendedProductVO,page);
         OpenedProductsIndex openedProductsIndex = new OpenedProductsIndex();
         BeanUtil.copyProperties(oppendedProductVO, openedProductsIndex);
-        if(oppendedProductVO.getOrgName()!=null&&oppendedProductVO.getOrgName()!=""){
+        if(oppendedProductVO.getOrgName() != null && oppendedProductVO.getOrgName() != ""){
             RespDTO<List<Long>> rlist = userServiceClient.getUserByOrgName(oppendedProductVO.getOrgName());
             if(rlist.data.size() == 0){
                 rlist.data.add(-1L);

+ 66 - 7
diagbotman-service/src/main/java/com/diagbot/facade/OpenedProductsFacade.java

@@ -1,9 +1,18 @@
 package com.diagbot.facade;
 
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
 import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.EnShowOptionDTO;
 import com.diagbot.dto.GetConsoleOnTrialDTO;
 import com.diagbot.dto.GetConsoleOpenedDTO;
+import com.diagbot.dto.OpenProductCheckDTO;
 import com.diagbot.dto.OpenUpOnTrialDTO;
 import com.diagbot.dto.ProductServiceDTO;
 import com.diagbot.dto.RespDTO;
@@ -27,16 +36,10 @@ import com.diagbot.util.DateUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.ModifyOpeningTimeVO;
+import com.diagbot.vo.OpenProductCheckVO;
 import com.diagbot.vo.OpenUpOnTrialVO;
 import com.diagbot.vo.ProductServiceSaveVO;
 import com.diagbot.vo.StartAndendByUserIdVO;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 /**
  * @Description:已开通产品业务层
@@ -94,6 +97,12 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
         	}else{
         		i.setIsCreateToken(0);
         	}
+        	if(DateUtil.parseDateTime(i.getEndTime()).getTime()<DateUtil.now().getTime()){
+        		i.setIsExpire(0);
+        	}else{
+        		i.setIsExpire(1);
+        	}
+        	i.setEndTime(i.getEndTime().substring(0, 10));
         }
         
         return retList;
@@ -226,6 +235,56 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
 
         return enShowOptionDTO;
     }
+    
+    /**
+     * 控制台-已开通产品状态校验
+     * @param openProductCheckVO
+     * @return
+     */
+    public OpenProductCheckDTO openProductCheck(OpenProductCheckVO openProductCheckVO){
+    	OpenProductCheckDTO openProductCheckDTO = new OpenProductCheckDTO();
+    	openProductCheckDTO.setHasPermission(false);
+    	
+    	LantoneProduct lantoneProduct =new LantoneProduct();
+        lantoneProduct.setId(openProductCheckVO.getProductId());
+        lantoneProduct = lantoneProductFacade.getById(lantoneProduct);
+        
+    	if(lantoneProduct==null){
+    		throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品不存在,请刷新页面");
+    	}
+    	if(lantoneProduct.getIsDeleted().equals("Y")){
+			 throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "【"+lantoneProduct.getName()+"】已删除,请刷新页面");
+		}
+    	if(lantoneProduct.getServiceStatus()==StatusEnum.Disable.getKey()){
+			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "【"+lantoneProduct.getName()+"】已停用,请刷新页面");
+		}
+    	
+    	Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
+    	if(openProductCheckVO.getOpenId()!=null){
+    		OpenedProducts openedProducts = new OpenedProducts();
+    		openedProducts.setId(openProductCheckVO.getOpenId());
+    		openedProducts.setUserId(userId);
+    		openedProducts = this.getById(openedProducts);
+    		if(openedProducts==null||openedProducts.getProductId().longValue()!=openProductCheckVO.getProductId().longValue()){
+    			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品不存在,请刷新页面");
+    		}
+    		if(openedProducts.getIsDeleted().equals("Y")){
+    			 throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品已删除,请刷新页面");
+    		}
+    		if(openedProducts.getEndTime().getTime()<DateUtil.now().getTime()){
+    			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "【"+lantoneProduct.getName()+"】已到期,请刷新页面");
+    		}
+    		if(openedProducts.getServiceStatus()==StatusEnum.Disable.getKey()){
+    			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品已停用,请刷新页面");
+    		}
+    	}
+    	
+    	
+    	
+    	openProductCheckDTO.setHasPermission(true);
+    	return openProductCheckDTO;
+    }
+    
 
     /**
      * @param startAndendByUserIdVO

+ 3 - 3
diagbotman-service/src/main/java/com/diagbot/facade/OrderDetailsFacade.java

@@ -80,14 +80,14 @@ public class OrderDetailsFacade extends OrderDetailsServiceImpl {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "订单明细不存在");
         }
-        if(orderDetails.getAuditStatus() != AuditStatusEnum.NotAudit.getKey()){
+        if(orderDetails.getAuditStatus().intValue() != AuditStatusEnum.NotAudit.getKey()){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "该订单已被审核请勿重复操作");
         }
         orderDetails.setGmtModified(DateUtil.now());
         orderDetails.setModifier(UserUtils.getCurrentPrincipleID());
         orderDetails.setAuditStatus(auditStatusVO.getAuditStatus());
-        if(auditStatusVO.getAuditStatus()== AuditStatusEnum.Veto.getKey()){
+        if(auditStatusVO.getAuditStatus().intValue() == AuditStatusEnum.Veto.getKey()){
             if(auditStatusVO.getRejectReason() != null && !auditStatusVO.getRejectReason().equals("") ){
                 orderDetails.setRejectType(-1);
                 if(auditStatusVO.getRejectReason().length()>100){
@@ -177,7 +177,7 @@ public class OrderDetailsFacade extends OrderDetailsServiceImpl {
             if(bean.getRejectType().intValue() != 0){
                 bean.setRejectTypeName(NotPassEnum.getName(bean.getRejectType()));
             }
-            if(bean.getAuditStatus() == AuditStatusEnum.Adopt.getKey()){
+            if(bean.getAuditStatus().intValue() == AuditStatusEnum.Adopt.getKey()){
                 for (UserAndProdutDTO openedProducts:openedProductTime) {
                     if(bean.getUserId().intValue() == openedProducts.getUserId().intValue() && bean.getProductId().intValue() == openedProducts.getProductId().intValue()){
                         bean.setStartTime(openedProducts.getStartTime());

+ 13 - 82
diagbotman-service/src/main/java/com/diagbot/facade/ProductOrderFacade.java

@@ -1,23 +1,9 @@
 package com.diagbot.facade;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.AuthDetailDTO;
-import com.diagbot.dto.HasPermissionDTO;
 import com.diagbot.dto.OrderDetialsDTO;
 import com.diagbot.dto.ProductAuthProgressDTO;
 import com.diagbot.dto.ProductLineDTO;
@@ -26,20 +12,17 @@ import com.diagbot.dto.ProductOrderExportDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.UserOrgDTO;
 import com.diagbot.dto.WaitExamOrderCouDTO;
-import com.diagbot.entity.OpenedProducts;
 import com.diagbot.entity.OrderDetailStatus;
 import com.diagbot.entity.OrderDetails;
 import com.diagbot.entity.ProductOrder;
 import com.diagbot.entity.ProductOrderIndex;
 import com.diagbot.entity.User;
 import com.diagbot.entity.wrapper.ProductOrderWrapper;
-import com.diagbot.entity.wrapper.ServiceTokenWrapper;
 import com.diagbot.enums.AuditStatusEnum;
 import com.diagbot.enums.AuthStatusEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.NotPassEnum;
 import com.diagbot.enums.StatusEnum;
-import com.diagbot.enums.TokenTypeEnum;
 import com.diagbot.enums.VisibleIdTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
@@ -50,13 +33,20 @@ import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ExportBeanExcelUtil;
 import com.diagbot.util.GsonUtil;
-import com.diagbot.util.ListUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.AddOrderVO;
-import com.diagbot.vo.OpenProductCheckVO;
 import com.diagbot.vo.OrderDetialsVO;
 import com.diagbot.vo.ProductOrderExportVO;
 import com.diagbot.vo.ProductOrderVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 订单业务
@@ -181,7 +171,7 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
         }
         Map<Long, UserOrgDTO> dataMap =mapRespDTO.data;
         UserOrgDTO uo =dataMap.get(userId);
-        if(uo.getAuStatus() != AuthStatusEnum.Authorized.getKey()){
+        if(uo.getAuStatus().intValue() != AuthStatusEnum.Authorized.getKey()){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "账号信息系不完善,请先认证");
         }
@@ -197,12 +187,12 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
                 }
             }
             for (int j =0; j<opendId.size();j++){
-                if(addOrderVO.getProductId().get(i)==opendId.get(j)){
+                if(addOrderVO.getProductId().get(i).longValue() == opendId.get(j).longValue()){
                     throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请勿重复提交已开通产品");
                 }
             }
             for (int k =0; k<orderDetailsId.size();k++){
-                if(addOrderVO.getProductId().get(i)==orderDetailsId.get(k)){
+                if(addOrderVO.getProductId().get(i).longValue() == orderDetailsId.get(k).longValue()){
                     throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "产品正在审核中请勿重复提交");
                 }
             }
@@ -271,65 +261,6 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
         return waitExamOrderCouDTO;
     }
     
-    /**
-     * 已开通产品状态校验
-     *
-     * @param serviceTokenVo 参数
-     * @return 是否有权限
-     */
-    public RespDTO<HasPermissionDTO> hasPermission(OpenProductCheckVO serviceTokenVo) {
-        HasPermissionDTO hasPermissionDTO = new HasPermissionDTO();
-        String appkey = serviceTokenVo.getAppkey();
-        String secret = serviceTokenVo.getSecret();
-        Map<String, Object> paramMap = new HashMap<>();
-        paramMap.put("appkey", appkey);
-        paramMap.put("secret", secret);
-        paramMap.put("productId", serviceTokenVo.getProductId());
-
-        //获取用户的id
-        List<ServiceTokenWrapper> serviceTokenWrapperList = serviceTokenFacade.getByAppkeyAndSecretAndProductId(paramMap);
-
-        if (ListUtil.isEmpty(serviceTokenWrapperList)) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "appkey或secret错误,appkey=【" + appkey + "】," + "secret=【" + secret + "】");
-        }
-        ServiceTokenWrapper st = serviceTokenWrapperList.get(0);
-        if (StatusEnum.Disable.getKey() == st.getServiceStatus()) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品已停用");
-        }
-        if (TokenTypeEnum.Trial.getKey() == st.getType()) {
-            Date date = new Date();
-            if (st.getExpiringDate().getTime() < date.getTime()) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "访问权限已过期");
-            }
-        } else {
-            QueryWrapper<OpenedProducts> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
-            queryWrapper.eq("user_id", st.getUserId());
-            queryWrapper.eq("product_id", st.getProductId());
-            OpenedProducts op = openedProductsFacade.getOne(queryWrapper);
-            if (op == null) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问");
-            }
-            Date date = new Date();
-            if (!(StatusEnum.Enable.getKey() == op.getServiceStatus())) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前服务已停用");
-            }
-            if (op.getStartTime().getTime() > date.getTime()) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品未在有效服务期内,无法使用");
-            }
-            if (op.getEndTime().getTime() < date.getTime()) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品已超出有效服务期,无法使用");
-            }
-        }
-        hasPermissionDTO.setHasPermission(true);
-        //获取用户的id
-        if (st.getUserId() != null) {
-            hasPermissionDTO.setUserId(st.getUserId().toString());
-        }
-        return RespDTO.onSuc(hasPermissionDTO);
-    }
-
-
 	/**
 	 * 产品申请查询所有订单信息
      *
@@ -342,7 +273,7 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
 		ProductOrderIndex productOrderIndex =new ProductOrderIndex();
 		BeanUtil.copyProperties(productOrderVO, productOrderIndex);
 		//TODO
-        if(productOrderVO.getOrgName()!=null&&productOrderVO.getOrgName()!=""){
+        if(productOrderVO.getOrgName() != null && productOrderVO.getOrgName()!=""){
             RespDTO<List<Long>> rlist = userServiceClient.getUserByOrgName(productOrderVO.getOrgName());
             if(rlist == null || !"0".equals(rlist.code) ) {
                 throw new CommonException(CommonErrorCode.RPC_ERROR,

+ 7 - 7
diagbotman-service/src/main/java/com/diagbot/facade/ServiceTokenFacade.java

@@ -66,16 +66,16 @@ public class ServiceTokenFacade extends ServiceTokenServiceImpl {
         List<ServiceTokenWrapper> serviceTokenWrapperList = this.getByAppkeyAndSecretAndProductId(paramMap);
 
         if (ListUtil.isEmpty(serviceTokenWrapperList)) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "appkey或secret错误,appkey=【" + appkey + "】," + "secret=【" + secret + "】");
+            throw new CommonException(CommonErrorCode.APPKEY_ERROR);
         }
         ServiceTokenWrapper st = serviceTokenWrapperList.get(0);
         if (StatusEnum.Disable.getKey() == st.getServiceStatus()) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品已停用");
+            throw new CommonException(CommonErrorCode.PRODUCT_STOP_ERROR);
         }
         if (TokenTypeEnum.Trial.getKey() == st.getType()) {
             Date date = new Date();
             if (st.getExpiringDate().getTime() < date.getTime()) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "访问权限已过期");
+                throw new CommonException(CommonErrorCode.OVERDUE_ERROR);
             }
         } else {
             QueryWrapper<OpenedProducts> queryWrapper = new QueryWrapper<>();
@@ -84,17 +84,17 @@ public class ServiceTokenFacade extends ServiceTokenServiceImpl {
             queryWrapper.eq("product_id", st.getProductId());
             OpenedProducts op = openedProductsFacade.getOne(queryWrapper);
             if (op == null) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "无权限访问");
+                throw new CommonException(CommonErrorCode.NOPERMISSION_ERROR);
             }
             Date date = new Date();
             if (!(StatusEnum.Enable.getKey() == op.getServiceStatus())) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "当前服务已停用");
+                throw new CommonException(CommonErrorCode.SERVICE_STOP_ERROR);
             }
             if (op.getStartTime().getTime() > date.getTime()) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品未在有效服务期内,无法使用");
+                throw new CommonException(CommonErrorCode.NOTVALID_ERROR);
             }
             if (op.getEndTime().getTime() < date.getTime()) {
-                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该产品已超出有效服务期,无法使用");
+                throw new CommonException(CommonErrorCode.EXPIRE_ERROR);
             }
         }
         hasPermissionDTO.setHasPermission(true);

+ 6 - 4
diagbotman-service/src/main/java/com/diagbot/vo/OpenProductCheckVO.java

@@ -5,18 +5,20 @@ import lombok.Setter;
 
 import java.io.Serializable;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * @Description: appkey 和 secret接收类
  * @Author: rgb
  * @Date: 2018/11/8 14:10
  */
+@SuppressWarnings("serial")
 @Getter
 @Setter
 public class OpenProductCheckVO implements Serializable {
 
-    private static final long serialVersionUID = 1L;
-
-    private String appkey;
-    private String secret;
+    private Long openId;
+    
+    @NotNull(message = "产品id不能为空")
     private Long productId;
 }

+ 2 - 2
diagbotman-service/src/main/java/com/diagbot/web/ProductOrderController.java

@@ -105,11 +105,11 @@ public class ProductOrderController {
         return RespDTO.onSuc(productOrderFacade.waitExamOrderCou());
     }
     
-    @ApiOperation(value = "已开通产品状态校验[by:rengb]", notes = "已开通产品状态校验")
+    @ApiOperation(value = "控制台-已开通产品状态校验[by:rengb]", notes = "控制台-已开通产品状态校验")
     @PostMapping("/openProductCheck")
     @SysLogger("openProductCheck")
     public RespDTO<OpenProductCheckDTO> openProductCheck(@RequestBody OpenProductCheckVO openProductCheckVO) {
-        return RespDTO.onSuc(productOrderFacade.hasPermission(openProductCheckVO));
+        return RespDTO.onSuc(openedProductsFacade.openProductCheck(openProductCheckVO));
     }
 
     @ApiOperation(value = "客户中心-传入用户id查询已开通的功能(传userId)[by:wangfeng]", notes = "已开通信息")

+ 1 - 2
diagbotman-service/src/main/resources/mapper/OpenedProductsMapper.xml

@@ -60,14 +60,13 @@
 			b.id as productId,
 			b.name as name,
 			DATE_FORMAT(a.start_time,'%Y-%m-%d') as startTime,
-			DATE_FORMAT(a.end_time,'%Y-%m-%d') as endTime,
+			DATE_FORMAT(a.end_time,'%Y-%m-%d %H:%i:%s') as endTime,
 			a.service_status as serviceStatus,
 			b.url as url,
 			b.access_type as accessType,
 			d.app_key_id as appKeyId,
 			d.app_key_secret as appKeySecret,
 			case when c.id is null then 0 else 1 end as renewalsStutas,
-			case when sysdate()>a.end_time then 0 else 1 end as isExpire,
 			case when a.start_time>sysdate() then 0 else 1 end as isBegin
 		from diag_opened_products a join diag_lantone_product b on a.product_id=b.id
 		left join diag_user_renewals c on a.user_id=c.user_id and a.product_id=c.product_id and c.renewals_status=0 and c.cancel_renewals=0 and c.is_deleted='N'

+ 1 - 1
diagbotman-service/src/main/resources/mapper/ServiceTokenMapper.xml

@@ -49,7 +49,7 @@
 
     <select id="getByAppkeyAndSecretAndProduct" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.ServiceTokenWrapper">
         SELECT
-            st.*, ps.product_id, lp.service_status
+            st.*, ps.product_id, lp.service_status, si.user_id
         FROM
             diag_service_token st,
             diag_product_service ps,

+ 5 - 2
docs/003.20181024初始化脚本/init_diagbotcloud.sql

@@ -462,7 +462,7 @@ CREATE TABLE `sys_permission` (
   `descritpion` varchar(255) NOT NULL DEFAULT '' COMMENT '资源描述',
   `remark` varchar(255) DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8 COMMENT='系统资源表';
+) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 COMMENT='系统资源表';
 
 -- ----------------------------
 -- Records of sys_permission
@@ -540,6 +540,8 @@ INSERT INTO `sys_permission` VALUES ('81', 'N', '1970-01-01 12:00:00', '1970-01-
 INSERT INTO `sys_permission` VALUES ('82', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '续费管理-取消续费', '/userRenewals/cancelRenewalsInfos', 'ALL', '续费管理-取消续费', null);
 INSERT INTO `sys_permission` VALUES ('83', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '客户中心-认证用户信息和机构信息不通过接口(新)', '/userInfo/auditUserInfoAllNopass', 'ALL', '客户中心-认证用户信息和机构信息不通过接口(新)', null);
 INSERT INTO `sys_permission` VALUES ('84', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '客户中心-认证用户信息和机构信息通过接口(新)', '/userInfo/auditUserInfoAllPass', 'ALL', '客户中心-认证用户信息和机构信息通过接口(新)', null);
+INSERT INTO `sys_permission` VALUES ('85', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '客户中心-已开通产品状态校验', '/productOrder/openProductCheck', 'ALL', '客户中心-已开通产品状态校验', NULL);
+
 
 
 /*
@@ -675,7 +677,7 @@ CREATE TABLE `sys_role_permission` (
   `permission_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '资源id',
   `remark` varchar(255) DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`id`)
-) ENGINE=InnoDB AUTO_INCREMENT=103 DEFAULT CHARSET=utf8 COMMENT='角色和资源的映射表';
+) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COMMENT='角色和资源的映射表';
 
 -- ----------------------------
 -- Records of sys_role_permission
@@ -754,6 +756,7 @@ INSERT INTO `sys_role_permission` VALUES ('99', 'N', '1970-01-01 12:00:00', '197
 INSERT INTO `sys_role_permission` VALUES ('100', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '2', '82', '续费管理-取消续费');
 INSERT INTO `sys_role_permission` VALUES ('101', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '2', '83', '客户中心-认证用户信息和机构信息不通过接口(新)');
 INSERT INTO `sys_role_permission` VALUES ('102', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '2', '84', '客户中心-认证用户信息和机构信息通过接口(新)');
+INSERT INTO `sys_role_permission` VALUES ('103', 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '1', '85', '客户中心-已开通产品状态校验');
 
 
 /*

+ 21 - 0
gateway-service/src/main/java/com/diagbot/filter/GlobalGatewayFilter.java

@@ -7,7 +7,9 @@ import com.diagbot.entity.ServiceFilter;
 import com.diagbot.entity.ServiceToken;
 import com.diagbot.entity.SysLog;
 import com.diagbot.enums.SysTypeEnum;
+import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.rabbit.MySender;
+import com.diagbot.util.EnDecodeUtil;
 import com.diagbot.util.GsonUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -95,6 +97,25 @@ public class GlobalGatewayFilter implements GlobalFilter {
         if (serviceFilters.get(serviceName) != null) {
             String appkey = request.getHeaders().getFirst("appKeyId");
             String secret = request.getHeaders().getFirst("appKeySecret");
+            String securityCode = request.getHeaders().getFirst("securityCode"); //防伪码
+            try {
+                String encodeTime = EnDecodeUtil.decode(securityCode);
+                Long time = Long.parseLong(encodeTime);
+                Long curTime = new Date().getTime();
+                // 防伪码主要是为了防止别人窃取url地址后直接长期使用,这边设了失效,目前暂定为24小时
+                // 前端实时获取当前时间跟系统时间作比较,如果时差超出24小时将会抛异常
+                if((curTime - time) > 1000 * 3600 * 24) {
+                    RespDTO respDTO = new RespDTO();
+                    respDTO.code = CommonErrorCode.SECURITYCODE_ERROR.getCode();
+                    respDTO.msg = CommonErrorCode.SECURITYCODE_ERROR.getMsg();
+                    return getVoidMono(serverWebExchange, respDTO);
+                }
+            } catch (Exception e) {
+                RespDTO respDTO = new RespDTO();
+                respDTO.code = CommonErrorCode.SECURITYCODE_ERROR.getCode();
+                respDTO.msg = CommonErrorCode.SECURITYCODE_ERROR.getMsg();
+                return getVoidMono(serverWebExchange, respDTO);
+            }
             Long productId = serviceFilters.get(serviceName);
             //获取appkey,secret对应的权限信息
             ServiceToken st = new ServiceToken();