diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index c431bead6..b80df9888 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -249,60 +250,65 @@ public class WxRentContractController extends WxContractBaseController { @GetMapping("/merchantShops") @ApiImplicitParams({ - @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true)}) + @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true), + @ApiImplicitParam(name = "contractId", value = "contractId", dataType = "Long", paramType = "query", required = true)}) @SystemControllerLog(description = "租赁合同-终结合同") - public ResultData merchantShops(Long merchantId) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::endRentContract"); - return new ResultData(wxMerchantService.getMerchantShopList(merchantId)); - } - - @GetMapping("/merchantShopsRenewable") - @ApiImplicitParams({ - @ApiImplicitParam(name = "contractId", value = "contractId", dataType = "Long", paramType = "query", required = true), - @ApiImplicitParam(name = "merchantId", value = "merchantId", dataType = "Long", paramType = "query", required = true)}) - @SystemControllerLog(description = "租赁合同-终结合同") - public ResultData merchantShopsRenewable(Long merchantId,Long contractId) { - logger.debug("[" + getIpAddr() + "] WxRentContractController::endRentContract"); - List allist = new ArrayList(); - - List shopList = wxMerchantService.getMerchantShopList(merchantId); + public ResultData merchantShops(Long merchantId,Long contractId) { + + List shopList = wxMerchantService.getMerchantShopIds(merchantId); if (null == shopList) { return new ResultData(Result.ERROR,"商户未绑定店铺!"); } - - WxRentContract rentContract = wxRentContractService.getSimpleDeatil(contractId); - if (null == rentContract) { - return new ResultData(Result.ERROR,"租金合同不存在!"); + WxRentContract rentq = new WxRentContract(); + List status = new ArrayList(); + status.add(EnumRentContractStatus.PAING.getCode()); + status.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); + rentq.setStatuss(status); + rentq.updateTenantInfo(getUser()); + List rentContractList = wxRentContractService.findList(rentq); + List rentShopList = new ArrayList(); + if (null != rentContractList) { + for (WxRentContract rent : rentContractList) { + List shopidlist = rent.shopIdsByRentInfo(); + if (null != shopidlist) { + for (Long sid: shopidlist) { + if (!rentShopList.contains(sid)) { + rentShopList.add(sid); + } + } + } + } } + //如果是新建,或者修改,此时能查询出来未在有效合同里面的店铺 - if (rentContract.getStatus().intValue() != EnumRentContractStatus.PAING.getCode() - && rentContract.getStatus().intValue() != EnumRentContractStatus.OUT_DATE.getCode()) { - return new ResultData(Result.ERROR,"租金合同状态为计租中或者正常到期才能续签。"); + //如果是续签,则还能查询出来合同本身的店铺 + List currentContractShopIds = null; + if (null != contractId) { + WxRentContract rentContract = wxRentContractService.getSimpleDeatil(contractId); + if (null == rentContract) { + return new ResultData(Result.ERROR,"租金合同不存在!"); + } + if (rentContract.getStatus().intValue() != EnumRentContractStatus.PAING.getCode() + && rentContract.getStatus().intValue() != EnumRentContractStatus.OUT_DATE.getCode()) { + return new ResultData(Result.ERROR,"租金合同状态为计租中或者正常到期才能续签。"); + } + currentContractShopIds = rentContract.shopIdsByRentInfo(); + if (null != currentContractShopIds) { + currentContractShopIds.stream().filter(si -> shopList.contains(si)); + } } - - List shopIds = rentContract.shopIdsByRentInfo(); - if (null != shopIds) { - List contractShops = wxShopService.getByIds(shopIds); - //如果合同状态是计租中,则商铺不显示 - if (rentContract.getStatus().intValue() != EnumRentContractStatus.PAING.getCode()) { - if (null != contractShops) { - for (WxShop s:contractShops) { - if (shopList.contains(s)) { - shopList.remove(s); - } - } - } - } - } - return new ResultData(shopList); - } - - - - - - - + //去掉正常状态的合同里的店铺 + shopList.stream().filter(s -> !rentShopList.contains(s)); + List shops = wxShopService.getByIds(shopList); + //再加上合同里面店铺 + if(null != currentContractShopIds && currentContractShopIds.size() > 0 ) { + List contractShops = wxShopService.getByIds(currentContractShopIds); + contractShops.stream().filter( cs -> !shopList.contains(cs.getId())); + shops.addAll(contractShops); + } + + return new ResultData(shops); + } @GetMapping("getMerchantList") @SystemControllerLog(description = "获取商户列表") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index f9a359e9b..68977685f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -98,8 +98,10 @@ public class WxRentContract extends TenantEntity { private Integer receivePeriod; @io.swagger.annotations.ApiModelProperty(value = "合同文件路径", name = "filepath") private String filepath; - @io.swagger.annotations.ApiModelProperty(value = "合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期", name = "status") + @io.swagger.annotations.ApiModelProperty(value = "合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期", name = "status") private Integer status; + @TableField(exist = false) + private List statuss; @io.swagger.annotations.ApiModelProperty(value = "合同编号", name = "contractNumber") private String contractNumber; @io.swagger.annotations.ApiModelProperty(value = "押金", name = "deposit") diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxMerchantShopMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxMerchantShopMapper.java index 7a41427bf..ac447b336 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxMerchantShopMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxMerchantShopMapper.java @@ -1,6 +1,9 @@ package com.iformall.mapper; import java.util.*; + +import org.apache.ibatis.annotations.Param; + import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxMerchantShop; @@ -8,7 +11,7 @@ public interface WxMerchantShopMapper extends CommonMapper findList(WxMerchantShop wxMerchantShop); - + List findShopIds(@Param("merchantId") Long merchantId); diff --git a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java index d067bf279..cef1e1d79 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMerchantService.java @@ -155,5 +155,5 @@ public interface WxMerchantService { void disableMerchat(Long id); - List getMerchantShopList(Long merchantId); + List getMerchantShopIds(Long merchantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index 410685a10..745c65aff 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -863,21 +863,7 @@ public class WxMerchantServiceImpl implements WxMerchantService { } @Override - public List getMerchantShopList(Long merchantId) { - WxMerchantShop wxMerchantShop = new WxMerchantShop(); - wxMerchantShop.setMerchantId(merchantId); - wxMerchantShop.setIsDel(0); - List shopList = wxMerchantShopMapper.findList(wxMerchantShop); - if (null != shopList) { - List shopIds = new ArrayList(); - for (WxMerchantShop ws: shopList) { - shopIds.add(ws.getShopId()); - } - - WxShop shop = new WxShop(); - shop.setIds(shopIds); - return wxShopMapper.findList(shop); - } - return null; + public List getMerchantShopIds(Long merchantId) { + return wxMerchantShopMapper.findShopIds(merchantId); } } diff --git a/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml index 57c278ca6..3d517ce4c 100644 --- a/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMerchantShopMapper.xml @@ -71,7 +71,9 @@ - + diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 0bceca796..be9393007 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -129,6 +129,12 @@ and `rent_shop_type` = #{rentShopType} and `operation_type` = #{operationType} + + and status in + + #{statusItem} + + and id in