|
|
@@ -336,6 +336,7 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
|
|
|
if (!Status.ENABLE.getDisplay().equals(product.getPr_status())){
|
|
|
throw new BizException(BizExceptionCode.BIZ_BANNED);
|
|
|
}
|
|
|
+ beforeClose(id);
|
|
|
product.setPr_status(Status.BANNED.getDisplay());
|
|
|
product.setPr_statuscode(Status.BANNED.name());
|
|
|
product.setUpdaterId(BaseContextHolder.getUserId());
|
|
|
@@ -350,6 +351,33 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 物料禁用前校验
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ private void beforeClose(Long id){
|
|
|
+ //1.库存大于0
|
|
|
+ int count = getMapper().selectStockById(id);
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.PRODUCT_HASSTOCK);
|
|
|
+ }
|
|
|
+ //2.存在未审核出入库单据
|
|
|
+ count = getMapper().selectProdIOCount(id);
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.PRODUCT_EXISTS_PRODIO);
|
|
|
+ }
|
|
|
+ //3.存在未关闭且状态非已出库销售订单
|
|
|
+ count = getMapper().selectSale(id);
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.PRODUCT_EXISTS_SALE);
|
|
|
+ }
|
|
|
+ //4.存在未关闭且状态非已入库采购订单
|
|
|
+ count = getMapper().selectPurchase(id);
|
|
|
+ if (count > 0){
|
|
|
+ throw new BizException(BizExceptionCode.PRODUCT_EXISTS_PURCHASE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public DocBaseDTO open(Long id) {
|
|
|
DocBaseDTO docBaseDTO = null;
|