Browse Source

Merge branch 'dev/one' into debug

zhoutg 6 years atrás
parent
commit
cff88bfdf8
27 changed files with 319 additions and 57 deletions
  1. 10 1
      common/src/main/java/com/diagbot/exception/CommonErrorCode.java
  2. 61 0
      common/src/main/java/com/diagbot/util/EnDecodeUtil.java
  3. 1 1
      config-server/src/main/resources/shared/gateway-service-dev.yml
  4. 1 1
      config-server/src/main/resources/shared/gateway-service-local.yml
  5. 1 1
      config-server/src/main/resources/shared/gateway-service-pro.yml
  6. 1 1
      config-server/src/main/resources/shared/gateway-service-test.yml
  7. 3 1
      config-server/src/main/resources/shared/triage-service-dev.yml
  8. 3 1
      config-server/src/main/resources/shared/triage-service-local.yml
  9. 3 1
      config-server/src/main/resources/shared/triage-service-pro.yml
  10. 3 1
      config-server/src/main/resources/shared/triage-service-test.yml
  11. 21 0
      diagbotman-service/src/main/java/com/diagbot/dto/OpenProductCheckDTO.java
  12. 6 0
      diagbotman-service/src/main/java/com/diagbot/dto/ProductLineDTO.java
  13. 9 9
      diagbotman-service/src/main/java/com/diagbot/facade/LantoneProductFacade.java
  14. 63 0
      diagbotman-service/src/main/java/com/diagbot/facade/OpenedProductsFacade.java
  15. 3 3
      diagbotman-service/src/main/java/com/diagbot/facade/OrderDetailsFacade.java
  16. 21 7
      diagbotman-service/src/main/java/com/diagbot/facade/ProductOrderFacade.java
  17. 11 3
      diagbotman-service/src/main/java/com/diagbot/facade/ProductServiceFacade.java
  18. 7 7
      diagbotman-service/src/main/java/com/diagbot/facade/ServiceTokenFacade.java
  19. 16 0
      diagbotman-service/src/main/java/com/diagbot/facade/UserRenewalsFacade.java
  20. 24 0
      diagbotman-service/src/main/java/com/diagbot/vo/OpenProductCheckVO.java
  21. 21 9
      diagbotman-service/src/main/java/com/diagbot/web/ProductOrderController.java
  22. 2 3
      diagbotman-service/src/main/resources/mapper/OpenedProductsMapper.xml
  23. 1 1
      diagbotman-service/src/main/resources/mapper/ServiceTokenMapper.xml
  24. 2 2
      docs/003.20181024初始化脚本/init_diagbotcloud.sql
  25. 21 0
      gateway-service/src/main/java/com/diagbot/filter/GlobalGatewayFilter.java
  26. 1 1
      triage-service/src/main/java/com/diagbot/client/AIServiceClient.java
  27. 3 3
      user-service/src/main/java/com/diagbot/facade/UserFacade.java

+ 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

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

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

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

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

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

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

@@ -88,5 +88,5 @@ server:
   port: 5050
 
 lantone:
-  product: icss,1;icsstry,2
+  product: triage33,1;icss,2
 

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

@@ -91,4 +91,6 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-
+ai:
+  server:
+    address: http://192.168.2.234:8080

+ 3 - 1
config-server/src/main/resources/shared/triage-service-local.yml

@@ -91,4 +91,6 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-
+ai:
+  server:
+    address: http://192.168.2.234:8080

+ 3 - 1
config-server/src/main/resources/shared/triage-service-pro.yml

@@ -91,4 +91,6 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-
+ai:
+  server:
+    address: http://192.168.2.234:8080

+ 3 - 1
config-server/src/main/resources/shared/triage-service-test.yml

@@ -91,4 +91,6 @@ mybatis-plus:
   configuration:
     map-underscore-to-camel-case: true
     cache-enabled: false
-
+ai:
+  server:
+    address: http://192.168.2.234:8080

+ 21 - 0
diagbotman-service/src/main/java/com/diagbot/dto/OpenProductCheckDTO.java

@@ -0,0 +1,21 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 开通产品状态校验返回类
+ * @Author: rgb
+ * @Date: 2018/11/8 14:10
+ */
+
+@SuppressWarnings("serial")
+@Getter
+@Setter
+public class OpenProductCheckDTO implements Serializable {
+
+    private Boolean hasPermission ;//标志
+
+}

+ 6 - 0
diagbotman-service/src/main/java/com/diagbot/dto/ProductLineDTO.java

@@ -24,6 +24,12 @@ public class ProductLineDTO {
      * 产品名称
      */
     private String name;
+
+    /**
+     * 是否删除 N:未删除,Y:删除
+     */
+    private String isDeleted;
+
     /**
      * 产品介绍
      */

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

@@ -104,14 +104,14 @@ 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,
                     "产品名称重复");
         }
         LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
         if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
             throw new CommonException(CommonErrorCode.NOT_EXISTS,
-                    "该产品已删除");
+                    "该产品已删除,请刷新页面");
         }
         BeanUtil.copyProperties(updateProductVO, lantoneProduct);
         lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
@@ -143,13 +143,13 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
         if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
             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,
                     "该产品已停用,停用失败");
         }
@@ -201,9 +201,9 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
         if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
             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,
                     "当前产品正在使用中不可删除");
         }
@@ -345,13 +345,13 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         LantoneProduct lantoneProducts = this.getById(lantoneProduct.getId());
         if(lantoneProducts.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
             throw new CommonException(CommonErrorCode.NOT_EXISTS,
-                    "该产品已删除");
+                    "该产品已删除,请刷新页面");
         }
         Page page =new Page();
         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);

+ 63 - 0
diagbotman-service/src/main/java/com/diagbot/facade/OpenedProductsFacade.java

@@ -12,6 +12,7 @@ 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;
@@ -35,6 +36,7 @@ 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;
@@ -95,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;
@@ -227,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
@@ -311,6 +369,11 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
         map.put("productId",modifyOpeningTimeVO.getProductId());
         List<OpenedProducts> opendList = openedProductsFacade.selectOpenedProducts(map);
         List<Long> renewalsList = userRenewalsFacade.selectProductIdByUserId(map);
+        for (OpenedProducts opened:opendList) {
+            if(opened.getServiceStatus().intValue() == StatusEnum.Disable.getKey()){
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "用户产品已停用,请刷新页面");
+            }
+        }
         if(!renewalsList.contains(modifyOpeningTimeVO.getProductId())){
             throw new CommonException(CommonErrorCode.NOT_EXISTS, "续费单已审核,请刷新重试");
         }

+ 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());

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

@@ -6,6 +6,7 @@ import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.AuthDetailDTO;
 import com.diagbot.dto.OrderDetialsDTO;
 import com.diagbot.dto.ProductAuthProgressDTO;
+import com.diagbot.dto.ProductLineDTO;
 import com.diagbot.dto.ProductOrderDTO;
 import com.diagbot.dto.ProductOrderExportDTO;
 import com.diagbot.dto.RespDTO;
@@ -19,7 +20,9 @@ import com.diagbot.entity.User;
 import com.diagbot.entity.wrapper.ProductOrderWrapper;
 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.VisibleIdTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
@@ -44,7 +47,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * 订单业务
@@ -69,6 +71,8 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
     private ProductOrderFacade productOrderFacade;
     @Autowired
     private OpenedProductsFacade openedProductsFacade;
+    @Autowired
+    private ServiceTokenFacade serviceTokenFacade;
 
 
     /**
@@ -157,6 +161,7 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
         Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
         List<Long> opendId = openedProductsFacade.getOpendCountByUserId(userId);
         List<Long> orderDetailsId = orderDetailsFacade.getOrderDetailsByUser(userId);
+        List<ProductLineDTO> productList = lantoneProductFacade.productLinesB();
         List<Long> userIdList =new ArrayList<>();
         userIdList.add(userId);
         RespDTO<Map<Long, UserOrgDTO>> mapRespDTO = userServiceClient.getUserAndOrg(userIdList);
@@ -166,18 +171,28 @@ 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,
                     "账号信息系不完善,请先认证");
         }
         for (int i =0; i<addOrderVO.getProductId().size();i++){
+            for(int l = 0; l< productList.size(); l++){
+                if(addOrderVO.getProductId().get(i).intValue() == productList.get(l).getId().intValue() && productList.get(l).getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
+                        throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                                "【"+productList.get(l).getName()+"】已删除,请刷新重试");
+                }
+                if(addOrderVO.getProductId().get(i).intValue() == productList.get(l).getId().intValue() && productList.get(l).getServiceStatus().intValue() == StatusEnum.Disable.getKey()){
+                    throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                            "【"+productList.get(l).getName()+"】已停用,请刷新重试");
+                }
+            }
             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, "产品正在审核中请勿重复提交");
                 }
             }
@@ -245,8 +260,7 @@ public class ProductOrderFacade extends ProductOrderServiceImpl {
         waitExamOrderCouDTO.setCount(baseMapper.waitExamOrderCou(userIds));
         return waitExamOrderCouDTO;
     }
-
-
+    
 	/**
 	 * 产品申请查询所有订单信息
      *
@@ -259,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,

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

@@ -12,6 +12,7 @@ import com.diagbot.entity.ServiceInfo;
 import com.diagbot.entity.ServiceToken;
 import com.diagbot.entity.wrapper.ProductServiceWrapper;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.enums.ServiceTypeEnum;
 import com.diagbot.enums.StatusEnum;
 import com.diagbot.enums.TokenTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
@@ -23,6 +24,7 @@ import com.diagbot.util.GuidUtil;
 import com.diagbot.util.UserUtils;
 import com.diagbot.vo.ProductServiceSaveVO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
@@ -197,13 +199,19 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
         serviceTokenFacade.update(new ServiceToken(), tokenUpdateWrapper);
 
         //删除产品服务端关联
-        for (ProductService productService : productServiceList) {
-            productService.setIsDeleted(IsDeleteEnum.Y.getKey());
-        }
         UpdateWrapper<ProductService> productServiceUpdateWrapper = new UpdateWrapper<>();
         productServiceUpdateWrapper.in("id", map.keySet());
         productServiceUpdateWrapper.set("is_deleted", IsDeleteEnum.Y.getKey());
         this.update(new ProductService(), productServiceUpdateWrapper);
+
+        //删除系统自动生成的服务端
+        Map<Long, List<ProductService>> serviceMap = EntityUtil.makeEntityListMap(productServiceList, "serviceId");
+        UpdateWrapper<ServiceInfo> serviceInfoUpdateWrapper = new UpdateWrapper<>();
+        serviceInfoUpdateWrapper.in("id", serviceMap.keySet())
+                .eq("type", ServiceTypeEnum.Sys_Create.getKey())
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .set("is_deleted", IsDeleteEnum.Y.getKey());
+        serviceInfoFacade.update(new ServiceInfo(), serviceInfoUpdateWrapper);
         return true;
     }
 

+ 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);

+ 16 - 0
diagbotman-service/src/main/java/com/diagbot/facade/UserRenewalsFacade.java

@@ -7,6 +7,7 @@ import com.diagbot.dto.ProductLineDTO;
 import com.diagbot.dto.RenewalsInfosDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.UserOrgDTO;
+import com.diagbot.entity.LantoneProduct;
 import com.diagbot.entity.OpenedProducts;
 import com.diagbot.entity.User;
 import com.diagbot.entity.UserRenewals;
@@ -14,6 +15,7 @@ import com.diagbot.entity.wrapper.UserRenewalsWrapper;
 import com.diagbot.enums.CancelRenewalsEnum;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.RenewalsEnum;
+import com.diagbot.enums.StatusEnum;
 import com.diagbot.enums.VisibleIdTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
@@ -61,6 +63,15 @@ public class UserRenewalsFacade extends UserRenewalsServiceImpl {
      * @return Boolean
      */
     public RespDTO<Boolean> addRenewalsInfos(AddRenewalsInfoVO addRenewalsInfoVO){
+        LantoneProduct lantoneProduct = lantoneProductFacade.getById(addRenewalsInfoVO.getProductId());
+        if(lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey())){
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "【"+lantoneProduct.getName()+"】已删除,请刷新页面");
+        }
+        if(lantoneProduct.getServiceStatus().intValue() == StatusEnum.Disable.getKey()){
+            throw new CommonException(CommonErrorCode.NOT_EXISTS,
+                    "【"+lantoneProduct.getName()+"】已停用,请刷新页面");
+        }
         UserRenewals userRenewals =new UserRenewals();
         Map map =new HashMap();
         String user = UserUtils.getCurrentPrincipleID();
@@ -79,6 +90,11 @@ public class UserRenewalsFacade extends UserRenewalsServiceImpl {
         if(this.selectProductIdByUserId(map).contains(addRenewalsInfoVO.getProductId())){
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请勿重复提交申请");
         }
+        for (OpenedProducts openedProducts:openedProductsList) {
+            if(openedProducts.getServiceStatus().intValue() == StatusEnum.Disable.getKey()){
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品已停用,请刷新页面");
+            }
+        }
         userRenewals.setProductId(addRenewalsInfoVO.getProductId());
         return RespDTO.onSuc(this.save(userRenewals));
     }

+ 24 - 0
diagbotman-service/src/main/java/com/diagbot/vo/OpenProductCheckVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+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 Long openId;
+    
+    @NotNull(message = "产品id不能为空")
+    private Long productId;
+}

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

@@ -1,10 +1,22 @@
 package com.diagbot.web;
 
+import java.util.List;
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
 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.ProductAuthProgressDTO;
 import com.diagbot.dto.ProductOrderDTO;
@@ -20,22 +32,15 @@ import com.diagbot.facade.OrderDetailsFacade;
 import com.diagbot.facade.ProductOrderFacade;
 import com.diagbot.facade.UserRenewalsFacade;
 import com.diagbot.vo.ModifyOpeningTimeVO;
+import com.diagbot.vo.OpenProductCheckVO;
 import com.diagbot.vo.OpenUpOnTrialVO;
 import com.diagbot.vo.ProductOrderVO;
 import com.diagbot.vo.StartAndendByUserIdVO;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
-import javax.validation.Valid;
-import java.util.List;
-
 /**
  * @author rgb
  * @Description 订单产品相关的操作
@@ -99,6 +104,13 @@ public class ProductOrderController {
     public RespDTO<WaitExamOrderCouDTO> waitExamOrderCou() {
         return RespDTO.onSuc(productOrderFacade.waitExamOrderCou());
     }
+    
+    @ApiOperation(value = "控制台-已开通产品状态校验[by:rengb]", notes = "控制台-已开通产品状态校验")
+    @PostMapping("/openProductCheck")
+    @SysLogger("openProductCheck")
+    public RespDTO<OpenProductCheckDTO> openProductCheck(@RequestBody OpenProductCheckVO openProductCheckVO) {
+        return RespDTO.onSuc(openedProductsFacade.openProductCheck(openProductCheckVO));
+    }
 
     @ApiOperation(value = "客户中心-传入用户id查询已开通的功能(传userId)[by:wangfeng]", notes = "已开通信息")
     @PostMapping("/getInformationAvailableByUserId")

+ 2 - 3
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'
@@ -85,7 +84,7 @@
 		AND b.is_deleted = 'N'
 		AND c.is_deleted = 'N'
 		AND a.user_id = #{userId}
-		AND a.type = 1
+		AND a.type = 2
 		AND c.type = 1) d on b.id=d.product_id
 		where a.is_deleted='N' and b.is_deleted='N' and a.user_id=#{userId}
     </select>

+ 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,

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

@@ -34,10 +34,10 @@ CREATE TABLE `diag_lantone_product` (
   `name` varchar(50) NOT NULL DEFAULT '' COMMENT '产品名称',
   `decription` text NOT NULL COMMENT '产品介绍',
   `charge_type` varchar(50) NOT NULL DEFAULT '0' COMMENT '计费方式(1.流程计费2.机构计费3.用户计费)',
-  `url` varchar(255) NOT NULL COMMENT '产品地址',
+  `url` varchar(2083) NOT NULL COMMENT '产品地址',
   `service_status` int(11) NOT NULL DEFAULT '1' COMMENT '停用状态',
   `trial_status` int(11) NOT NULL DEFAULT '0' COMMENT '是否试用(0.否1.是)',
-  `trial_url` varchar(255) DEFAULT NULL COMMENT '试用地址',
+  `trial_url` varchar(2083) DEFAULT NULL COMMENT '试用地址',
   `access_type` varchar(50) NOT NULL DEFAULT '1,2,3' COMMENT '接入方式(1:online,2:接口方式,3:嵌入式)',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='朗通产品表';

+ 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();

+ 1 - 1
triage-service/src/main/java/com/diagbot/client/AIServiceClient.java

@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
  * @author: gaodm
  * @time: 2018/10/25 9:56
  */
-@FeignClient(name = "AI", url = "http://192.168.2.234:8080", fallback = AIServiceHystrix.class)
+@FeignClient(name = "AI", url = "${ai.server.address}", fallback = AIServiceHystrix.class)
 public interface AIServiceClient {
 
     @PostMapping(value = "/web/doc/algorithm/neural")

+ 3 - 3
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -973,7 +973,7 @@ public class UserFacade extends UserServiceImpl {
         int renewalSum = renewalSums.data;
         //System.out.println("========renewalSu====="+renewalSum);
         if(renewalSum>0){
-   		 return RespDTO.onError("该用户存在续费申请单,请先审核");
+   		 return RespDTO.onError("该用户无法删除,请先处理产品申请信息");
       	}
         //查询用户是否有待审核的产品数量
         RespDTO<Integer> auditSums = diagbotmanClient.getOrderByUserToAudit(baseIdVO.getId());
@@ -1304,7 +1304,7 @@ public class UserFacade extends UserServiceImpl {
         listName.add("编号");
         listName.add("注册时间");
         listName.add("认证单号");
-        listName.add("超管名称");
+        listName.add("超管名称");
         listName.add("所在机构");
         listName.add("岗位名称");
         listName.add("手机号");
@@ -1356,7 +1356,7 @@ public class UserFacade extends UserServiceImpl {
         listName.add("编号");
         listName.add("注册时间");
         listName.add("审核通过时间");
-        listName.add("超管名称");
+        listName.add("超管名称");
         listName.add("所在机构");
         listName.add("岗位名称");
         listName.add("手机号");