Browse Source

开通产品修改

rgb 6 years ago
parent
commit
254678d0eb

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

+ 54 - 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,44 @@ public class OpenedProductsFacade extends OpenedProductsServiceImpl {
 
         return enShowOptionDTO;
     }
+    
+    public OpenProductCheckDTO openProductCheck(OpenProductCheckVO openProductCheckVO){
+    	OpenProductCheckDTO openProductCheckDTO = new OpenProductCheckDTO();
+    	openProductCheckDTO.setHasPermission(false);
+    	
+    	LantoneProduct lantoneProduct =new LantoneProduct();
+        lantoneProduct.setId(openProductCheckVO.getProductId());
+        LantoneProduct lantoneProducts = lantoneProductFacade.getById(lantoneProduct);
+    	
+    	if(openProductCheckVO.getOpenId()!=null){
+    		OpenedProducts openedProducts = baseMapper.selectById(openProductCheckVO.getOpenId());
+    		if(openedProducts==null){
+    			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品不存在,请刷新页面");
+    		}
+    		if(openedProducts.getIsDeleted().equals("Y")){
+    			 throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品已删除,请刷新页面");
+    		}
+    		if(openedProducts.getServiceStatus()==StatusEnum.Disable.getKey()){
+    			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "您的产品已停用,请刷新页面");
+    		}
+    		if(openedProducts.getEndTime().getTime()<DateUtil.now().getTime()){
+    			throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "【"+lantoneProducts.getName()+"】已到期,请刷新页面");
+    		}
+    	}
+    	
+    	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()+"】已停用,请刷新页面");
+		}
+    	
+    	return openProductCheckDTO;
+    }
+    
 
     /**
      * @param startAndendByUserIdVO

+ 0 - 59
diagbotman-service/src/main/java/com/diagbot/facade/ProductOrderFacade.java

@@ -271,65 +271,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);
-    }
-
-
 	/**
 	 * 产品申请查询所有订单信息
      *

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

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

@@ -109,7 +109,7 @@ public class ProductOrderController {
     @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'