Browse Source

朗通产品管理——停用删除逻辑补充

wangyu 6 years ago
parent
commit
d7fa13a321

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

@@ -93,6 +93,44 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
         BeanUtil.copyProperties(updateProductVO, lantoneProduct);
         lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
         lantoneProduct.setGmtModified(DateUtil.now());
+        if(updateProductVO.getServiceStatus()==StatusEnum.Disable.getKey()){
+            Page page =new Page();
+            OpenedProductsIndex openedProductsIndex =new OpenedProductsIndex();
+            openedProductsIndex.setProductId(updateProductVO.getId());
+            openedProductsIndex.setServiceStatus(StatusEnum.Enable.getKey());
+            if(openedProductsFacade.getByProductId(page,openedProductsIndex).getRecords().size()>0){
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                        "用户正在使用中,停用失败");
+            }
+        }
+        if (!updateById(lantoneProduct)) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "产品修改失败");
+        }
+        return true;
+    }
+
+    /**
+     * 朗通产品线管理停用启用产品
+     *
+     * @param updateProductVO 所需参数(产品id,停用状态)
+     * @return Boolean true
+     */
+    public Boolean stopProduct(UpdateProductVO updateProductVO) {
+        LantoneProduct lantoneProduct = this.getById(updateProductVO.getId());
+        BeanUtil.copyProperties(updateProductVO, lantoneProduct);
+        lantoneProduct.setModifier(UserUtils.getCurrentPrincipleID());
+        lantoneProduct.setGmtModified(DateUtil.now());
+        if(updateProductVO.getServiceStatus()==StatusEnum.Disable.getKey()){
+            Page page =new Page();
+            OpenedProductsIndex openedProductsIndex =new OpenedProductsIndex();
+            openedProductsIndex.setProductId(updateProductVO.getId());
+            openedProductsIndex.setServiceStatus(StatusEnum.Enable.getKey());
+            if(openedProductsFacade.getByProductId(page,openedProductsIndex).getRecords().size()>0){
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                        "用户正在使用中,停用失败");
+            }
+        }
         if (!updateById(lantoneProduct)) {
             throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
                     "产品修改失败");
@@ -108,6 +146,10 @@ public class LantoneProductFacade extends LantoneProductServiceImpl {
      */
     public Boolean deleteProduct(UpdateProductVO updateProductVO) {
         LantoneProduct lantoneProduct = getById(updateProductVO.getId());
+        if(lantoneProduct.getServiceStatus()==StatusEnum.Enable.getKey()){
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
+                    "当前产品正在使用中不可删除");
+        }
         OpenedProducts openedProducts = new OpenedProducts();
         openedProducts.setProductId(updateProductVO.getId());
         openedProducts.setServiceStatus(StatusEnum.Enable.getKey());

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

@@ -9,8 +9,10 @@ import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.UserOrgDTO;
 import com.diagbot.entity.UserRenewals;
 import com.diagbot.entity.wrapper.UserRenewalsWrapper;
+import com.diagbot.enums.VisibleIdTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.idc.VisibleIdCreater;
 import com.diagbot.service.impl.UserRenewalsServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
@@ -32,6 +34,9 @@ import java.util.Map;
  */
 @Component
 public class UserRenewalsFacade extends UserRenewalsServiceImpl {
+
+    @Autowired
+    private VisibleIdCreater visibleIdCreater;
     @Autowired
     private UserServiceClient userServiceClient;
     @Autowired
@@ -45,6 +50,7 @@ public class UserRenewalsFacade extends UserRenewalsServiceImpl {
         userRenewals.setUserId(userId);
         userRenewals.setApplyTime(DateUtil.now());
         userRenewals.setGmtCreate(DateUtil.now());
+        userRenewals.setRenewalsNo(visibleIdCreater.getNextId(VisibleIdTypeEnum.IS_RENEWALS.getKey()).toString());
         List<Long> productId =this.selectProductIdByUserId(userId);
         for(int i =0 ; i < productId.size(); i++){
             if(productId.get(i).longValue() == addRenewalsInfoVO.getProductId().longValue()){

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

@@ -82,7 +82,7 @@ public class DiagLantoneProductController {
     @SysLogger("updateServiceStatus")
     @Transactional
     public RespDTO<Boolean> updateServiceStatus(@RequestBody UpdateProductVO updateProductVO) {
-        return RespDTO.onSuc(lantoneProductFacade.updateProduct(updateProductVO));
+        return RespDTO.onSuc(lantoneProductFacade.stopProduct(updateProductVO));
     }
 
     @ApiOperation(value = "产品线管理——删除[by:wangyu]",

+ 3 - 0
diagbotman-service/src/main/resources/mapper/OpenedProductsMapper.xml

@@ -206,6 +206,9 @@
                  a.user_id = #{opend.userId}
             </foreach>
         </if>
+        <if test="opend.serviceStatus != null and opend.serviceStatus != ''">
+                and a.service_status = #{opend.serviceStatus}
+        </if>
         ORDER BY b.time desc
     </select>