From b7273b2d46919c6a989a5f60cdad8c23ee105c61 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Wed, 3 Apr 2019 11:07:07 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=95=86=E9=93=BA][=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=95=86=E9=93=BA]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/controller/WxShopController.java | 3 +-- .../java/com/iformall/service/WxShopService.java | 2 +- .../iformall/service/impl/WxShopServiceImpl.java | 14 ++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java index 2a015b9b0..3a4b7474e 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxShopController.java @@ -71,8 +71,7 @@ public class WxShopController extends BaseController { public ResultData delete(Long id) { logger.debug("[" + getIpAddr() + "] WxShopController::delete"); Integer isAdmin = getUser().getIsAdmin(); - wxShopService.deleteById(id, isAdmin); - return new ResultData(Result.SUCCESS, "删除成功", null); + return wxShopService.deleteById(id, isAdmin); } @ApiOperation("根据id查询接口") diff --git a/mallinkService/src/main/java/com/iformall/service/WxShopService.java b/mallinkService/src/main/java/com/iformall/service/WxShopService.java index 728097b45..9144242b8 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxShopService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxShopService.java @@ -42,7 +42,7 @@ public interface WxShopService { * @param id * @param isAdmin */ - void deleteById(Long id, Integer isAdmin); + ResultData deleteById(Long id, Integer isAdmin); ResultData getbshoplist(String tenantId, String shopNumber); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java index 50fa7259a..fc16d0f2a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -13,7 +13,6 @@ import com.iformall.enums.EnumDelStatus; import com.iformall.enums.EnumRentShopType; import com.iformall.enums.EnumShopStatus; import com.iformall.enums.EnumUserAdmin; -import com.iformall.exception.MallinkException; import com.iformall.mapper.WxMerchantShopMapper; import com.iformall.mapper.WxShopMapper; import com.iformall.service.ExcelService; @@ -80,14 +79,14 @@ public class WxShopServiceImpl implements WxShopService { } @Override - public void deleteById(Long id, Integer isAdmin) { + public ResultData deleteById(Long id, Integer isAdmin) { //1、已出租不让删除 WxShop wxShop = wxShopMapper.selectByPrimaryKey(id); if (wxShop == null) { - throw new MallinkException(ErrorCode.SHOP_IS_NOT_FOUND); + return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND); } if (wxShop.getStatus().equals(EnumShopStatus.RENT.getCode())) { - throw new MallinkException(ErrorCode.SHOP_BAN_DELETED); + return new ResultData(ErrorCode.SHOP_BAN_DELETED); } //2、是否关联过商户 WxMerchantShop wxMerchantShop = new WxMerchantShop(); @@ -97,7 +96,7 @@ public class WxShopServiceImpl implements WxShopService { int count = wxMerchantShops.size(); if (count > 0) { if (!isAdmin.equals(EnumUserAdmin.ADMIN.getCode())) { - throw new MallinkException(ErrorCode.SHOP_DELETED_BY_ADMIN); + return new ResultData(ErrorCode.SHOP_DELETED_BY_ADMIN); } //更新标记 wxShop.setIsDel(EnumDelStatus.DEL.getCode()); @@ -108,8 +107,11 @@ public class WxShopServiceImpl implements WxShopService { updateMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); wxMerchantShopMapper.updateByPrimaryKeySelective(updateMerchantShop); } + } else { + //无关联商铺直接删除 + wxShopMapper.deleteByPrimaryKey(id); } - wxShopMapper.deleteByPrimaryKey(id); + return new ResultData(Result.SUCCESS, "删除成功"); } @Override