|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.diagbot.dto.ProductServiceDTO;
|
|
|
import com.diagbot.entity.LantoneProduct;
|
|
|
+import com.diagbot.entity.OpenedProducts;
|
|
|
import com.diagbot.entity.ProductService;
|
|
|
import com.diagbot.entity.ServiceInfo;
|
|
|
import com.diagbot.entity.ServiceToken;
|
|
@@ -41,6 +42,8 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
|
|
|
private ServiceInfoFacade serviceInfoFacade;
|
|
|
@Autowired
|
|
|
private LantoneProductFacade lantoneProductFacade;
|
|
|
+ @Autowired
|
|
|
+ private OpenedProductsFacade openedProductsFacade;
|
|
|
|
|
|
/**
|
|
|
* 建立产品服务端关联并生成令牌
|
|
@@ -52,18 +55,25 @@ public class ProductServiceFacade extends ProductServiceServiceImpl {
|
|
|
ProductServiceDTO productServiceDTO = new ProductServiceDTO();
|
|
|
Long operatorId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
Long userId = null;
|
|
|
- if (null != productServiceSaveVO.getUserId()){
|
|
|
+ if (null != productServiceSaveVO.getUserId()) {
|
|
|
userId = productServiceSaveVO.getUserId();
|
|
|
} else {
|
|
|
userId = operatorId;
|
|
|
}
|
|
|
LantoneProduct lantoneProduct = lantoneProductFacade.getById(productServiceSaveVO.getProductId());
|
|
|
- if (lantoneProduct == null) {
|
|
|
+ if (lantoneProduct == null || lantoneProduct.getIsDeleted().equals(IsDeleteEnum.Y.getKey()) || lantoneProduct.getServiceStatus().equals(StatusEnum.Disable.getKey())) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
+ "产品异常,请刷新页面");
|
|
|
+ }
|
|
|
+ QueryWrapper<OpenedProducts> openedProductsQueryWrapper = new QueryWrapper<>();
|
|
|
+ openedProductsQueryWrapper.eq("product_id", lantoneProduct.getId()).eq("user_id", userId).eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ OpenedProducts openedProducts = openedProductsFacade.getOne(openedProductsQueryWrapper);
|
|
|
+ if (openedProducts == null || openedProducts.getServiceStatus().equals(StatusEnum.Disable.getKey()) || openedProducts.getEndTime().before(new Date())) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
- "找不到产品【" + lantoneProduct.getName() + "】");
|
|
|
+ "产品异常,请刷新页面");
|
|
|
}
|
|
|
ServiceInfo serviceInfo = serviceInfoFacade.getById(productServiceSaveVO.getServiceId());
|
|
|
- if (serviceInfo == null) {
|
|
|
+ if (serviceInfo == null || serviceInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
throw new CommonException(CommonErrorCode.NOT_EXISTS,
|
|
|
"找不到服务端【" + serviceInfo.getName() + "】");
|
|
|
} else if (serviceInfo.getUserId() != userId) {
|