Quellcode durchsuchen

删除车辆增加是否有业务判断

qzyReal vor 3 Jahren
Ursprung
Commit
c2f5599ad5

+ 11 - 0
sp-server/src/main/java/com/pj/project/tb_business_car/TbBusinessCarService.java

@@ -354,6 +354,17 @@ public class TbBusinessCarService extends ServiceImpl<TbBusinessCarMapper, TbBus
         if (!tbFeeDetails.isEmpty()) {
             return AjaxJson.getError("该车有付款记录,不能删除");
         }
+        List<TbBusiness> businesses = tbBusinessService.findOtherBusinessByCarId(id);
+        if (!businesses.isEmpty()) {
+            return AjaxJson.getError("该车有业务,不能删除");
+        }
+        TbBusinessCar db = this.getById(id);
+        if (StrUtil.isNotEmpty(db.getBusinessId())) {
+            TbBusiness tbBusiness = tbBusinessService.getById(db.getBusinessId());
+            if (tbBusiness != null) {
+                return AjaxJson.getError("该车有业务,不能删除");
+            }
+        }
         this.removeById(id);
         return AjaxJson.getSuccess();
     }