diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java index 2f48dc09a..15e677232 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java @@ -167,6 +167,14 @@ public class WxAgileContractController extends WxContractBaseController { } wxRentContract.setRentArea(rentAreaDecimal.toPlainString()); wxRentContract.setShopIdStr(shopIdStr); + + try { + rentContractValidShop(wxRentContract); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + + return wxAgileContractService.saveOrUpdate(wxRentContract, user); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java index 118db78e7..158c5b024 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java @@ -1,19 +1,25 @@ package com.iformall.controller.contract; +import com.iformall.common.Result; import com.iformall.controller.base.BaseController; import com.iformall.domain.po.WxContractCustomers; import com.iformall.domain.po.WxFlowModel; import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxPropertyContract; import com.iformall.domain.po.WxRentContract; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxRentPropertyContractVo; import com.iformall.enums.EnumContractOperationType; import com.iformall.enums.EnumFlowContractType; import com.iformall.enums.EnumFlowKey; import com.iformall.enums.EnumRentAgileType; +import com.iformall.enums.EnumRentContractStatus; import com.iformall.enums.EnumRentShopType; +import com.iformall.exception.MallinkException; import com.iformall.service.WxAgileContractService; import com.iformall.service.WxFlowService; +import com.iformall.service.WxPropertyContractService; +import com.iformall.service.WxRentContractService; import com.iformall.service.WxShopService; import org.springframework.beans.factory.annotation.Autowired; @@ -39,6 +45,12 @@ public class WxContractBaseController extends BaseController{ @Autowired private WxAgileContractService wxAgileContractService; + + @Autowired + private WxRentContractService wxRentContractService; + + @Autowired + private WxPropertyContractService wxPropertyContractService; protected Map generateFlowParams(WxContractCustomers contractCustomers,EnumFlowKey flowType,EnumFlowContractType contractType,EnumRentAgileType agileType,String remark,Long contractId,Long wholeProperyId) { Map map = new HashMap(); @@ -136,4 +148,79 @@ public class WxContractBaseController extends BaseController{ } } + + private void contractValidShop(TenantEntity tenantEntity,Long contractId,Date contractStartDate,Date contractEndDate, + List rentShopIdList,Map rentAreaMap,Map shopNumberMap,boolean isRent) throws Exception { + //判断店铺是否还有有效的面积 + for (int i = 0 ; i < rentShopIdList.size(); i++) { + Long shopId = rentShopIdList.get(i); + + BigDecimal shopRentArea = rentAreaMap.get(shopId); + String shopNumber = shopNumberMap.get(shopId); + if (shopRentArea.compareTo(new BigDecimal(0)) <= 0 ) { + throw new MallinkException(Result.ERROR, "房间["+shopNumber+"]面积不足。"); + } + + List sidlist = new ArrayList(); + sidlist.add(shopId); + List contractIds = wxAgileContractService.findShopContractIds(tenantEntity, sidlist); + //查询是否有跟当前合同时间有冲突的合同 + if (null != contractIds) { + if (null != contractId) { + contractIds.remove(contractId); + } + if (contractIds.size() > 0) { + List usedContractIds = null; + List statusList = new ArrayList(); + statusList.add(EnumRentContractStatus.DRAFT.getCode()); + statusList.add(EnumRentContractStatus.PAING.getCode()); + statusList.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); + statusList.add(EnumRentContractStatus.PERFORMANCE.getCode()); + statusList.add(EnumRentContractStatus.UNWRITE.getCode()); + if (isRent) { + WxRentContract rc = new WxRentContract(); + rc.updateTenantInfo(tenantEntity); + rc.setIds(contractIds); + rc.setStatuss(statusList); + /**满足下面条件的都算 + * 1. 合同开始日期<=当前合同开始日期 && 合同结束日期 > 当前合同开始日期 + * 2. 合同开始日期 >= 当前合同开始日期 && 合同开始日期 <= 当前结束日期 + */ + rc.setUseStartTime(contractStartDate); + rc.setUseEndTime(contractEndDate); + usedContractIds = wxRentContractService.findIdList(rc); + }else { + WxPropertyContract rc = new WxPropertyContract(); + rc.updateTenantInfo(tenantEntity); + rc.setIds(contractIds); + rc.setStatuss(statusList); + rc.setUseStartTime(contractStartDate); + rc.setUseEndTime(contractEndDate); + usedContractIds = wxPropertyContractService.findIdList(rc); + } + if (null != usedContractIds && usedContractIds.size() > 0 ) { + BigDecimal usedArea = wxAgileContractService.sumShopContractAreas(tenantEntity, shopId,usedContractIds); + BigDecimal totalUsedArea = usedArea.add(shopRentArea); + BigDecimal remianArea = wxShopService.calcuteUsedShopArea(tenantEntity, shopId, totalUsedArea); + if (remianArea.compareTo(new BigDecimal(0)) < 0 ) { + throw new MallinkException(Result.ERROR, "房间["+shopNumber+"]面积不足。"); + } + } + } + + } + + } + } + + protected void rentContractValidShop(WxRentContract rentContract) throws Exception { + contractValidShop(rentContract,rentContract.getId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(), + rentContract.getRentShopArea(),rentContract.getRentInfoShopNumberMap(),true); + } + + protected void propertyContractValidShop(WxPropertyContract propertyContract) throws Exception { + contractValidShop(propertyContract,propertyContract.getId(),propertyContract.getRentalStartDate(),propertyContract.getRentalEndDate(),propertyContract.shopIdsByShop(), + propertyContract.getRentShopArea(),propertyContract.getRentInfoShopNumberMap(),false); + } + } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index 512f9b1f7..d26dd92de 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java @@ -184,6 +184,11 @@ public class WxPropertyContractController extends WxContractBaseController { } } wxPropertyContract.setRentStartType(EnumRentStartType.RENTTIME.getCode()); + try { + propertyContractValidShop(wxPropertyContract); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } return wxPropertyContractService.save(wxPropertyContract, user, user.getName(),false); } @@ -358,40 +363,44 @@ public class WxPropertyContractController extends WxContractBaseController { } if (contract.getCreateType().intValue() == EnumPropertyCreateType.BY_SHOP.getCode().intValue()) { - if (shopHasValidProperty(contract)) { - return new ResultData(Result.ERROR, "店铺存在有效或者审批中的物业合同。"); - } +// if (shopHasValidProperty(contract)) { +// return new ResultData(Result.ERROR, "店铺存在有效或者审批中的物业合同。"); +// } }else { if (rentHasValidProperty(contract)) { return new ResultData(Result.ERROR, "租金合同["+contract.getContractNumber()+"]存在有效或者审批中的物业合同。"); } } - + try { + propertyContractValidShop(contract); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } wxPropertyContractService.updatePropertyContractStatus(proertyContract.getId()); return new ResultData(Result.SUCCESS,"合同生效成功!"); } - private boolean shopHasValidProperty(WxPropertyContract contract) { - List shopIds = contract.shopIdsByShop(); - if (null == shopIds || shopIds.size() <= 0 ) { - return false; - } - List contractIdList = wxAgileContractService.findShopContractIds(contract, shopIds); - if (null == contractIdList || contractIdList.size() <= 0 ) { - return false; - } - - WxPropertyContract wpc = new WxPropertyContract(); - wpc.setIds(contractIdList); - List statuss = EnumRentContractStatus.getValidStatus(); - statuss.add(EnumRentContractStatus.PERFORMANCE.getCode()); - wpc.setStatuss(statuss); - List list = wxPropertyContractService.findList(wpc); - if (null != list && list.size() > 0 ) { - return true; - } - return false; - } +// private boolean shopHasValidProperty(WxPropertyContract contract) { +// List shopIds = contract.shopIdsByShop(); +// if (null == shopIds || shopIds.size() <= 0 ) { +// return false; +// } +// List contractIdList = wxAgileContractService.findShopContractIds(contract, shopIds); +// if (null == contractIdList || contractIdList.size() <= 0 ) { +// return false; +// } +// +// WxPropertyContract wpc = new WxPropertyContract(); +// wpc.setIds(contractIdList); +// List statuss = EnumRentContractStatus.getValidStatus(); +// statuss.add(EnumRentContractStatus.PERFORMANCE.getCode()); +// wpc.setStatuss(statuss); +// List list = wxPropertyContractService.findList(wpc); +// if (null != list && list.size() > 0 ) { +// return true; +// } +// return false; +// } private boolean rentHasValidProperty(WxPropertyContract contract) { WxPropertyContract wpc = new WxPropertyContract(); @@ -421,15 +430,21 @@ public class WxPropertyContractController extends WxContractBaseController { } if (contract.getCreateType().intValue() == EnumPropertyCreateType.BY_SHOP.getCode().intValue()) { - if (shopHasValidProperty(contract)) { - return new ResultData(Result.ERROR, "店铺存在有效或者审批中的物业合同。"); - } +// if (shopHasValidProperty(contract)) { +// return new ResultData(Result.ERROR, "店铺存在有效或者审批中的物业合同。"); +// } }else { if (rentHasValidProperty(contract)) { return new ResultData(Result.ERROR, "租金合同["+contract.getContractNumber()+"]存在有效或者审批中的物业合同。"); } } + try { + propertyContractValidShop(contract); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + String remark = ""; Map map = contract.getFlowParams(); if (null != map) { 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 6cf88a708..f305622f9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -138,7 +138,7 @@ public class WxRentContractController extends WxContractBaseController { // wxRentContract.setRentalStartDate(wxRentContract.getStartDate()); // } try { - validShop(wxRentContract); + rentContractValidShop(wxRentContract); } catch (Exception e) { return new ResultData(Result.ERROR,e.getMessage()); } @@ -285,7 +285,7 @@ public class WxRentContractController extends WxContractBaseController { } try { - validShop(rentContract); + rentContractValidShop(rentContract); } catch (Exception e) { return new ResultData(Result.ERROR,e.getMessage()); } @@ -416,14 +416,14 @@ public class WxRentContractController extends WxContractBaseController { // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"店铺已经在其他计租中或者已签约未到期的合同里面了。"); // } - try { - validConfilit(contract); - } catch (Exception e) { - return new ResultData(Result.ERROR,e.getMessage()); - } +// try { +// validConfilit(contract); +// } catch (Exception e) { +// return new ResultData(Result.ERROR,e.getMessage()); +// } try { - validShop(contract); + rentContractValidShop(contract); } catch (Exception e) { return new ResultData(Result.ERROR,e.getMessage()); } @@ -452,60 +452,25 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(Result.SUCCESS,"合同生效成功!"); } - private void validConfilit(WxRentContract rentContract) throws Exception { - //判断是否该合同的时间和有效的合同是否冲突 - List shopIds = rentContract.shopIdsByRentInfo(); - for (Long sid: shopIds) { - WxRentContract rcq = new WxRentContract(); - rcq.setStatuss(EnumRentContractStatus.getValidStatus()); - rcq.setQueryShopId(sid); - List crcs = wxRentContractService.findList(rcq); - if (null != crcs) { - for (WxRentContract crc : crcs) { - if((rentContract.getRentalEndDate().before(crc.getRentalStartDate()) && rentContract.getRentalStartDate().after(new Date())) || - rentContract.getRentalStartDate().after(crc.getRentalEndDate())) { - }else { - throw new MallinkException(Result.ERROR, "店铺["+sid+"]的计租时间区间与合同["+crc.getContractNumber()+"]有冲突。"); - } - } - } - } - } - - private void validShop(WxRentContract rentContract) throws Exception { - //判断该合同的店铺是不是存在有效的合同,或者审批中的合同,要判断时间区间是否有重复 - List shopIdList = rentContract.shopIdsByRentInfo(); - List contractIds = wxAgileContractService.findShopContractIds(rentContract, shopIdList); - //查询是否有跟当前合同时间有冲突的合同 - if (null != contractIds) { - if (null != rentContract.getId()) { - contractIds.remove(rentContract.getId()); - } - if (contractIds.size() > 0) { - WxRentContract rc = new WxRentContract(); - rc.updateTenantInfo(rentContract); - rc.setIds(contractIds); - List statusList = new ArrayList(); - statusList.add(EnumRentContractStatus.DRAFT.getCode()); - statusList.add(EnumRentContractStatus.PAING.getCode()); - statusList.add(EnumRentContractStatus.READY_FOR_PAING.getCode()); - statusList.add(EnumRentContractStatus.PERFORMANCE.getCode()); - statusList.add(EnumRentContractStatus.UNWRITE.getCode()); - rc.setStatuss(statusList); - List contractList = wxRentContractService.findList(rc); - if (null != contractList && contractList.size() > 0 ) { - for (int i = 0 ; i < contractList.size(); i ++ ) { - WxRentContract wrc = contractList.get(i); - if (dateHasIntersection(rentContract.getRentalStartDate(),rentContract.getRentalEndDate(), - wrc.getRentalStartDate(),wrc.getRentalEndDate())) { - throw new MallinkException(Result.ERROR, "房间资源存在时间冲突的合同。"); - } - } - } - } - - } - } +// private void validConfilit(WxRentContract rentContract) throws Exception { +// //判断是否该合同的时间和有效的合同是否冲突 +// List shopIds = rentContract.shopIdsByRentInfo(); +// for (Long sid: shopIds) { +// WxRentContract rcq = new WxRentContract(); +// rcq.setStatuss(EnumRentContractStatus.getValidStatus()); +// rcq.setQueryShopId(sid); +// List crcs = wxRentContractService.findList(rcq); +// if (null != crcs) { +// for (WxRentContract crc : crcs) { +// if((rentContract.getRentalEndDate().before(crc.getRentalStartDate()) && rentContract.getRentalStartDate().after(new Date())) || +// rentContract.getRentalStartDate().after(crc.getRentalEndDate())) { +// }else { +// throw new MallinkException(Result.ERROR, "店铺["+sid+"]的计租时间区间与合同["+crc.getContractNumber()+"]有冲突。"); +// } +// } +// } +// } +// } @PostMapping("apply") public ResultData apply(@RequestBody WxRentContract wxRentContract) { @@ -519,14 +484,14 @@ public class WxRentContractController extends WxContractBaseController { return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"租赁合同不存在工作流,不能提交审批。"); } - try { - validConfilit(rentContract); - } catch (Exception e) { - return new ResultData(Result.ERROR,e.getMessage()); - } +// try { +// validConfilit(rentContract); +// } catch (Exception e) { +// return new ResultData(Result.ERROR,e.getMessage()); +// } try { - validShop(rentContract); + rentContractValidShop(rentContract); } catch (Exception e) { return new ResultData(Result.ERROR,e.getMessage()); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java index 31849bfb6..079070a4c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxContractShop.java @@ -33,6 +33,9 @@ public class WxContractShop extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="店铺编号",name="shopId") private Long shopId; + + @io.swagger.annotations.ApiModelProperty(value="租赁面积",name="rentArea") + private String rentArea; @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") private Date createDate; @@ -42,5 +45,7 @@ public class WxContractShop extends TenantEntity { @TableField(exist = false) private List shopIds; + @TableField(exist = false) + private List contractIds; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java index 9e1e1f7c6..9dff1bcf2 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java @@ -339,6 +339,27 @@ public class WxPropertyContract extends TenantEntity { return sb.toString(); } + public Map getRentInfoShopNumberMap() { + String rentInfo = this.getRentInfo(); + if (!StringUtils.isBlank(rentInfo)) { + Map shopNumberMap = new HashMap(); + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + int size = rentInfoArray.size(); + for (int i = 0; i < size; i++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + String shopNumber = rentInfoObject.getString("shopNumber"); + Long shopId = rentInfoObject.getLong("id"); + if (StringUtils.isBlank(shopNumber)) { + shopNumberMap.put(shopId, ""); + }else { + shopNumberMap.put(shopId, shopNumber); + } + } + return shopNumberMap; + } + return null; + } + public List getFeesStardarsList() { if (StringUtils.isNotBlank(feesStandardsInfo)) { return JSON.parseArray(feesStandardsInfo, WxEnergyFees.class); @@ -379,5 +400,9 @@ public class WxPropertyContract extends TenantEntity { private List customersIdList; @TableField(exist = false) private String shopNumbers; + @TableField(exist = false) + private Date useStartTime; + @TableField(exist = false) + private Date useEndTime; } 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 67a357158..01f772345 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java @@ -427,6 +427,27 @@ public class WxRentContract extends TenantEntity { return sb.toString(); } + public Map getRentInfoShopNumberMap() { + String rentInfo = this.getRentInfo(); + if (!StringUtils.isBlank(rentInfo)) { + Map shopNumberMap = new HashMap(); + JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); + int size = rentInfoArray.size(); + for (int i = 0; i < size; i++) { + JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); + String shopNumber = rentInfoObject.getString("shopNumber"); + Long shopId = rentInfoObject.getLong("id"); + if (StringUtils.isBlank(shopNumber)) { + shopNumberMap.put(shopId, ""); + }else { + shopNumberMap.put(shopId, shopNumber); + } + } + return shopNumberMap; + } + return null; + } + public String getRentInfoShopId() { StringBuffer sb = new StringBuffer(""); String rentInfo = this.getRentInfo(); @@ -583,5 +604,9 @@ public class WxRentContract extends TenantEntity { private String queryShopIdStr; @TableField(exist = false) private List customersIdList; + @TableField(exist = false) + private Date useStartTime; + @TableField(exist = false) + private Date useEndTime; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java index edcbce060..fb6afd71f 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java @@ -248,4 +248,6 @@ public class WxShop extends TenantEntity { private Long templateId; @TableField(exist = false) private String energyFeesIds; + @TableField(exist = false) + private Integer calcuteContractUsedArea; } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java index 24a42444b..29a69db1f 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxContractShopMapper.java @@ -4,6 +4,7 @@ import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxContractCustomers; import com.iformall.domain.po.WxContractShop; +import java.math.BigDecimal; import java.util.List; /** @@ -14,5 +15,7 @@ public interface WxContractShopMapper extends CommonMapper findContractIdList(WxContractShop wxShop); + BigDecimal sumAreas(WxContractShop wxShop); + void deleteByCondition(WxContractShop wxShop); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java index 75ae5bba6..74a2fd715 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java @@ -13,6 +13,8 @@ import java.util.List; public interface WxPropertyContractMapper extends CommonMapper { List findList(WxPropertyContract wxPropertyContract); + + List findIdList(WxPropertyContract wxPropertyContract); //List> queryPropertyContractData(WxPropertyContract wxRentContract); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java index c22d3b30f..5896f71fb 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxRentContractMapper.java @@ -11,11 +11,12 @@ import java.util.List; import java.util.Map; /** - * @author gongbiao */ public interface WxRentContractMapper extends CommonMapper { List findList(WxRentContract wxRentContract); + + List findIdList(WxRentContract wxRentContract); void updateApplyStatus(WxRentContract wxRentContract); diff --git a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java index 0457c751c..360d1dd22 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxAgileContractService.java @@ -9,6 +9,8 @@ import com.iformall.domain.po.WxRentContractAgileDeposit; import com.iformall.domain.po.WxRentContractAgileUnDeposit; import com.iformall.domain.po.base.TenantEntity; +import java.math.BigDecimal; +import java.util.Date; import java.util.List; /** @@ -39,6 +41,8 @@ public interface WxAgileContractService { List findShopContractIds(TenantEntity tenantEntity,List shopIds); + BigDecimal sumShopContractAreas(TenantEntity tenantEntity,Long shopId,List contractIds); + WxContractCustomers findCustomers(TenantEntity tenantEntity,Long customerId); PageInfo getContractCustomersList(WxContractCustomers record, Integer pageIndex, Integer pageSize); diff --git a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java index be8b795ce..144c2ef66 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPropertyContractService.java @@ -8,11 +8,12 @@ import org.apache.ibatis.annotations.Param; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import java.math.BigDecimal; import java.util.List; import java.util.Map; /** - * @author gongbiao */ public interface WxPropertyContractService { @@ -28,6 +29,8 @@ public interface WxPropertyContractService { List findList(WxPropertyContract record); + List findIdList(WxPropertyContract record); + /** * 根据Id获得实体 * @@ -85,5 +88,7 @@ public interface WxPropertyContractService { //查询还有多少天到期的合同 List findToOutDateContracts(TenantEntity tenantEntity); + + BigDecimal calcuteContractUsedShopArea(WxPropertyContract record); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index 0aafddf1a..6fc04b234 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -9,6 +9,7 @@ import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxRentContractFreePeriod; import com.iformall.domain.po.WxRentContractRevenueJump; import com.iformall.domain.po.WxRentContractRevenueSales; +import com.iformall.domain.po.WxShop; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.RentContractFreePeriodVo; import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo; @@ -17,12 +18,13 @@ import com.iformall.domain.vo.WxRentContractYearsVo; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.Map; /** - * @author gongbiao */ public interface WxRentContractService { @@ -38,6 +40,8 @@ public interface WxRentContractService { List findList(WxRentContract record); + List findIdList(WxRentContract record); + /** * 根据Id获得实体 * @@ -160,4 +164,6 @@ public interface WxRentContractService { List getRentContractYears(WxRentContract rentContract); + BigDecimal calcuteContractUsedShopArea(WxRentContract wxRentContract,Long shopId); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxShopService.java b/mallinkService/src/main/java/com/iformall/service/WxShopService.java index 727fe5fb3..ba409c2a1 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxShopService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxShopService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.WxMerchant; +import com.iformall.domain.po.WxRentContract; import com.iformall.domain.po.WxShop; import com.iformall.domain.po.WxShopUsersInfo; import com.iformall.domain.po.WxShopUsersPerson; @@ -36,7 +37,7 @@ public interface WxShopService { PageInfo listAsPage(WxShop record, Integer pageIndex, Integer pageSize); PageInfo> listMapAsPage(WxShop record, Integer pageIndex, Integer pageSize); - + PageInfo> notRentListMapAsPage(WxShop record,Integer pageIndex,Integer pageSize); long findCount(WxShop wxShop); @@ -161,5 +162,7 @@ public interface WxShopService { WxShopUsers getCurrentShopUser(TenantEntity tenantEntity,Long shopId); List getFloorBuildShopIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer shopDel ,String shopNumber) ; + + BigDecimal calcuteUsedShopArea(TenantEntity tenantEntity,Long shopId,BigDecimal contractUsedArea); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java index 22cc4310a..f15442051 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxAgileContractServiceImpl.java @@ -301,14 +301,16 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { sdel.updateTenantInfo(record); sdel.setContractId(record.getId()); wxContractShopMapper.deleteByCondition(sdel); - + Map shopAreaMap = record.getRentShopArea(); if (null != shopIdList && shopIdList.size() > 0 ) { final IdWorker idWorker = IdWorker.get(); for ( int i = 0 ; i < shopIdList.size(); i ++) { + Long shopId = shopIdList.get(i); WxContractShop s = new WxContractShop(); s.updateTenantInfo(record); s.setContractId(record.getId()); - s.setShopId(shopIdList.get(i)); + s.setShopId(shopId); + s.setRentArea(shopAreaMap.get(shopId).toPlainString()); s.setCreateDate(new Date()); s.setUpdateDate(new Date()); s.setId(idWorker.nextId()); @@ -809,6 +811,15 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { cs.setShopIds(shopIds); return wxContractShopMapper.findContractIdList(cs); } + + @Override + public BigDecimal sumShopContractAreas(TenantEntity tenantEntity,Long shopId,List contractIds) { + WxContractShop cs = new WxContractShop(); + cs.updateTenantInfo(tenantEntity); + cs.setShopId(shopId); + cs.setContractIds(contractIds); + return wxContractShopMapper.sumAreas(cs); + } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java index e0efc1efb..b689e80a3 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java @@ -201,6 +201,11 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService public List findList(WxPropertyContract record) { return wxPropertyContractMapper.findList(record); } + + @Override + public List findIdList(WxPropertyContract record) { + return wxPropertyContractMapper.findIdList(record); + } @Override public Map getById(Long id) { @@ -497,14 +502,16 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService sdel.updateTenantInfo(record); sdel.setContractId(record.getId()); wxContractShopMapper.deleteByCondition(sdel); - + Map shopAreaMap = record.getRentShopArea(); if (null != shopIdList && shopIdList.size() > 0 ) { final IdWorker idWorker = IdWorker.get(); for ( int i = 0 ; i < shopIdList.size(); i ++) { + Long shopId = shopIdList.get(i); WxContractShop s = new WxContractShop(); s.updateTenantInfo(record); s.setContractId(record.getId()); - s.setShopId(shopIdList.get(i)); + s.setShopId(shopId); + s.setRentArea(shopAreaMap.get(shopId).toPlainString()); s.setCreateDate(new Date()); s.setUpdateDate(new Date()); s.setId(idWorker.nextId()); @@ -1511,6 +1518,11 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService wrc.setOutDateNofity(1); return wxPropertyContractMapper.findList(wrc); } + + @Override + public BigDecimal calcuteContractUsedShopArea(WxPropertyContract record) { + return null; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index b6bad3c6d..d9316ad5e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -252,6 +252,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { return wxRentContractMapper.findList(record); } + @Override + public List findIdList(WxRentContract record){ + return wxRentContractMapper.findIdList(record); + } + @Override public Map getById(Long id,Integer noBillList) { Map result = new HashMap<>(); @@ -497,14 +502,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { sdel.updateTenantInfo(record); sdel.setContractId(record.getId()); wxContractShopMapper.deleteByCondition(sdel); - + Map shopAreaMap = record.getRentShopArea(); if (null != shopIdList && shopIdList.size() > 0 ) { final IdWorker idWorker = IdWorker.get(); for ( int i = 0 ; i < shopIdList.size(); i ++) { + Long shopId = shopIdList.get(i); WxContractShop s = new WxContractShop(); s.updateTenantInfo(record); s.setContractId(record.getId()); s.setShopId(shopIdList.get(i)); + s.setRentArea(shopAreaMap.get(shopId).toPlainString()); s.setCreateDate(new Date()); s.setUpdateDate(new Date()); s.setId(idWorker.nextId()); @@ -3246,5 +3253,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { public List findJumpList(WxRentContractRevenueJump jump) { return wxRentContractRevenueJumpMapper.findList(jump); } + + @Override + public BigDecimal calcuteContractUsedShopArea(WxRentContract wxRentContract,Long shopId) { + //根据合同区间查询已使用合同的总面积 + return null; + } } 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 5bec0ac1f..680922240 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -160,7 +160,7 @@ public class WxShopServiceImpl implements WxShopService { public PageInfo> listMapAsPage(WxShop record, Integer pageIndex, Integer pageSize) { return findListMap(record, pageIndex, pageSize); } - + @Override public WxShop getById(Long id) { return wxShopMapper.selectById(id); @@ -1238,4 +1238,19 @@ public class WxShopServiceImpl implements WxShopService { List shopIds = wxShopMapper.findIdList(shopQ); return shopIds; } + + @Override + public BigDecimal calcuteUsedShopArea(TenantEntity tenantEntity, Long shopId, BigDecimal contractUsedArea) { + WxShop shop = this.getById(shopId); + if (StringUtils.isBlank(shop.getOperationArea())){ + return new BigDecimal(0); + }else { + BigDecimal shopArea = new BigDecimal(shop.getOperationArea()); + if (null == contractUsedArea) { + return shopArea; + }else { + return shopArea.subtract(contractUsedArea); + } + } + } } diff --git a/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml b/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml index 962bfe571..82a20d7f5 100644 --- a/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxContractShopMapper.xml @@ -7,12 +7,13 @@ + - `id`,`tenant_id`,`parent_tenant_id`,`contract_id`,`shop_id`,`create_date`,`update_date` + `id`,`tenant_id`,`parent_tenant_id`,`contract_id`,`shop_id`,`rent_area`,`create_date`,`update_date` @@ -44,6 +45,13 @@ + + and contract_id in + + #{cidItem} + + + and id in @@ -64,7 +72,13 @@ select distinct contract_id from wx_contract_shop - + + + delete from wx_contract_shop diff --git a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml index 3e7a40c46..cf59729d6 100644 --- a/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml @@ -83,6 +83,13 @@ and `price` = #{price} and `rental_start_date` = #{rentalStartDate} and `rental_end_date` = #{rentalEndDate} + + and ( + (`rental_start_date` <= #{useStartTime} and rental_end_date > #{useStartTime}) + or + (`rental_start_date` >= #{useStartTime} and rental_start_date < #{useEndTime}) + ) + and out_date_notify_phone is not null and out_date_notify_phone != '' and and out_date_notify_days is not null and out_date_notify_days > 0 and `sign_date` = #{signDate} and `receive_period` = #{receivePeriod} @@ -152,6 +159,12 @@ + + + +