From 5f03bc4afa17904c9c9a03336c4acdeffa0dcc98 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Sat, 25 May 2019 17:09:25 +0800 Subject: [PATCH] =?UTF-8?q?[BUG][ID1001638][=E4=BA=91=E7=AB=AF=20version:.?= =?UTF-8?q?1259.1735=EF=BC=9A=E5=A6=82=E6=9E=9C=E6=9C=89=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=E5=90=88=E5=90=8C=E5=9C=A8=E5=88=A0=E9=99=A4=E5=95=86?= =?UTF-8?q?=E9=93=BA=E6=97=B6=E9=9C=80=E8=A6=81=E8=BF=9B=E8=A1=8C=E9=99=90?= =?UTF-8?q?=E5=88=B6]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/common/ErrorCode.java | 2 +- .../service/impl/WxShopServiceImpl.java | 28 +++++++++++++++++++ .../resources/mapper/WxRentContractMapper.xml | 4 ++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index e1d41db9a..9b1f50afb 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -361,7 +361,7 @@ public enum ErrorCode{ SHOP_NOT_SELECTED(22002, "未选择商铺"), SHOP_BAN_DELETED(22003, "已出租的商铺无法删除"), SHOP_DELETED_BY_ADMIN(22004, "仅系统管理员能删除该商铺"), - + SHOP_CONTRACT_HAS_CONNECT(22005, "有合同签约此商铺,请先解除相应的合同再删除"), /** * 迈外迪 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 06151ab76..2c3a4f662 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -7,11 +7,13 @@ import com.iformall.common.IdWorker; import com.iformall.common.Result; import com.iformall.common.ResultData; import com.iformall.domain.po.WxMerchantShop; +import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxShop; import com.iformall.domain.vo.WxNotRentShopVo; import com.iformall.domain.vo.WxShopVo; import com.iformall.enums.*; import com.iformall.mapper.WxMerchantShopMapper; +import com.iformall.mapper.WxRentContractMapper; import com.iformall.mapper.WxShopMapper; import com.iformall.service.ExcelService; import com.iformall.service.WxShopService; @@ -20,6 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.*; @@ -37,6 +40,9 @@ public class WxShopServiceImpl implements WxShopService { @Autowired ExcelService excelService; + @Autowired + WxRentContractMapper wxRentContractMapper; + @Override public PageInfo listAsPage(WxShop record, Integer pageIndex, Integer pageSize) { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxShopMapper.findList(record)); @@ -99,6 +105,28 @@ public class WxShopServiceImpl implements WxShopService { WxMerchantShop wxMerchantShop = new WxMerchantShop(); wxMerchantShop.setShopId(wxShop.getId()); List wxMerchantShops = wxMerchantShopMapper.select(wxMerchantShop); + + if (isAdmin.equals(EnumUserAdmin.ADMIN.getCode())) { + //3、合同 两种 都要查一下 存在时不能删除 + WxRentContract wxRentContract = new WxRentContract(); + wxRentContract.setShopId(wxShop.getId()); + wxRentContract.setTenantId(wxShop.getTenantId()); + long count = 0; + if (wxShop.getType().equals(EnumRentShopType.SHOP.getCode())) { + count = wxRentContractMapper.selectRentContractByShopId(wxRentContract).parallelStream() + .filter(r -> !r.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) && + !r.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) && + !r.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); + } else { + count = wxRentContractMapper.select(wxRentContract).parallelStream() + .filter(r -> !r.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) && + !r.getStatus().equals(EnumRentContractStatus.RENT_PAID.getCode()) && + !r.getStatus().equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count(); + } + if (count > 0) { + return new ResultData(ErrorCode.SHOP_CONTRACT_HAS_CONNECT); + } + } //有关联过商户必须是管理员才能删除 int count = wxMerchantShops.size(); if (count > 0) { diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 1a6792bd5..43768aba7 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -243,7 +243,9 @@