| @@ -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); | |||
| } | |||
| @@ -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<String,Object> generateFlowParams(WxContractCustomers contractCustomers,EnumFlowKey flowType,EnumFlowContractType contractType,EnumRentAgileType agileType,String remark,Long contractId,Long wholeProperyId) { | |||
| Map<String,Object> map = new HashMap<String,Object>(); | |||
| @@ -136,4 +148,79 @@ public class WxContractBaseController extends BaseController{ | |||
| } | |||
| } | |||
| private void contractValidShop(TenantEntity tenantEntity,Long contractId,Date contractStartDate,Date contractEndDate, | |||
| List<Long> rentShopIdList,Map<Long, BigDecimal> rentAreaMap,Map<Long, String> 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<Long> sidlist = new ArrayList<Long>(); | |||
| sidlist.add(shopId); | |||
| List<Long> contractIds = wxAgileContractService.findShopContractIds(tenantEntity, sidlist); | |||
| //查询是否有跟当前合同时间有冲突的合同 | |||
| if (null != contractIds) { | |||
| if (null != contractId) { | |||
| contractIds.remove(contractId); | |||
| } | |||
| if (contractIds.size() > 0) { | |||
| List<Long> usedContractIds = null; | |||
| List<Integer> statusList = new ArrayList<Integer>(); | |||
| 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); | |||
| } | |||
| } | |||
| @@ -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<Long> shopIds = contract.shopIdsByShop(); | |||
| if (null == shopIds || shopIds.size() <= 0 ) { | |||
| return false; | |||
| } | |||
| List<Long> contractIdList = wxAgileContractService.findShopContractIds(contract, shopIds); | |||
| if (null == contractIdList || contractIdList.size() <= 0 ) { | |||
| return false; | |||
| } | |||
| WxPropertyContract wpc = new WxPropertyContract(); | |||
| wpc.setIds(contractIdList); | |||
| List<Integer> statuss = EnumRentContractStatus.getValidStatus(); | |||
| statuss.add(EnumRentContractStatus.PERFORMANCE.getCode()); | |||
| wpc.setStatuss(statuss); | |||
| List<WxPropertyContract> list = wxPropertyContractService.findList(wpc); | |||
| if (null != list && list.size() > 0 ) { | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| // private boolean shopHasValidProperty(WxPropertyContract contract) { | |||
| // List<Long> shopIds = contract.shopIdsByShop(); | |||
| // if (null == shopIds || shopIds.size() <= 0 ) { | |||
| // return false; | |||
| // } | |||
| // List<Long> contractIdList = wxAgileContractService.findShopContractIds(contract, shopIds); | |||
| // if (null == contractIdList || contractIdList.size() <= 0 ) { | |||
| // return false; | |||
| // } | |||
| // | |||
| // WxPropertyContract wpc = new WxPropertyContract(); | |||
| // wpc.setIds(contractIdList); | |||
| // List<Integer> statuss = EnumRentContractStatus.getValidStatus(); | |||
| // statuss.add(EnumRentContractStatus.PERFORMANCE.getCode()); | |||
| // wpc.setStatuss(statuss); | |||
| // List<WxPropertyContract> 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<String, Object> map = contract.getFlowParams(); | |||
| if (null != map) { | |||
| @@ -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<Long> shopIds = rentContract.shopIdsByRentInfo(); | |||
| for (Long sid: shopIds) { | |||
| WxRentContract rcq = new WxRentContract(); | |||
| rcq.setStatuss(EnumRentContractStatus.getValidStatus()); | |||
| rcq.setQueryShopId(sid); | |||
| List<WxRentContract> 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<Long> shopIdList = rentContract.shopIdsByRentInfo(); | |||
| List<Long> 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<Integer> statusList = new ArrayList<Integer>(); | |||
| 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<WxRentContract> 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<Long> shopIds = rentContract.shopIdsByRentInfo(); | |||
| // for (Long sid: shopIds) { | |||
| // WxRentContract rcq = new WxRentContract(); | |||
| // rcq.setStatuss(EnumRentContractStatus.getValidStatus()); | |||
| // rcq.setQueryShopId(sid); | |||
| // List<WxRentContract> 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()); | |||
| } | |||
| @@ -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<Long> shopIds; | |||
| @TableField(exist = false) | |||
| private List<Long> contractIds; | |||
| } | |||
| @@ -339,6 +339,27 @@ public class WxPropertyContract extends TenantEntity { | |||
| return sb.toString(); | |||
| } | |||
| public Map<Long,String> getRentInfoShopNumberMap() { | |||
| String rentInfo = this.getRentInfo(); | |||
| if (!StringUtils.isBlank(rentInfo)) { | |||
| Map<Long,String> shopNumberMap = new HashMap<Long,String>(); | |||
| 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<WxEnergyFees> getFeesStardarsList() { | |||
| if (StringUtils.isNotBlank(feesStandardsInfo)) { | |||
| return JSON.parseArray(feesStandardsInfo, WxEnergyFees.class); | |||
| @@ -379,5 +400,9 @@ public class WxPropertyContract extends TenantEntity { | |||
| private List<Long> customersIdList; | |||
| @TableField(exist = false) | |||
| private String shopNumbers; | |||
| @TableField(exist = false) | |||
| private Date useStartTime; | |||
| @TableField(exist = false) | |||
| private Date useEndTime; | |||
| } | |||
| @@ -427,6 +427,27 @@ public class WxRentContract extends TenantEntity { | |||
| return sb.toString(); | |||
| } | |||
| public Map<Long,String> getRentInfoShopNumberMap() { | |||
| String rentInfo = this.getRentInfo(); | |||
| if (!StringUtils.isBlank(rentInfo)) { | |||
| Map<Long,String> shopNumberMap = new HashMap<Long,String>(); | |||
| 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<Long> customersIdList; | |||
| @TableField(exist = false) | |||
| private Date useStartTime; | |||
| @TableField(exist = false) | |||
| private Date useEndTime; | |||
| } | |||
| @@ -248,4 +248,6 @@ public class WxShop extends TenantEntity { | |||
| private Long templateId; | |||
| @TableField(exist = false) | |||
| private String energyFeesIds; | |||
| @TableField(exist = false) | |||
| private Integer calcuteContractUsedArea; | |||
| } | |||
| @@ -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<WxContractShop, Strin | |||
| List<Long> findContractIdList(WxContractShop wxShop); | |||
| BigDecimal sumAreas(WxContractShop wxShop); | |||
| void deleteByCondition(WxContractShop wxShop); | |||
| } | |||
| @@ -13,6 +13,8 @@ import java.util.List; | |||
| public interface WxPropertyContractMapper extends CommonMapper<WxPropertyContract, String> { | |||
| List<WxPropertyContract> findList(WxPropertyContract wxPropertyContract); | |||
| List<Long> findIdList(WxPropertyContract wxPropertyContract); | |||
| //List<Map<String,Object>> queryPropertyContractData(WxPropertyContract wxRentContract); | |||
| @@ -11,11 +11,12 @@ import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public interface WxRentContractMapper extends CommonMapper<WxRentContract, Long> { | |||
| List<WxRentContract> findList(WxRentContract wxRentContract); | |||
| List<Long> findIdList(WxRentContract wxRentContract); | |||
| void updateApplyStatus(WxRentContract wxRentContract); | |||
| @@ -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<Long> findShopContractIds(TenantEntity tenantEntity,List<Long> shopIds); | |||
| BigDecimal sumShopContractAreas(TenantEntity tenantEntity,Long shopId,List<Long> contractIds); | |||
| WxContractCustomers findCustomers(TenantEntity tenantEntity,Long customerId); | |||
| PageInfo<WxContractCustomers> getContractCustomersList(WxContractCustomers record, Integer pageIndex, Integer pageSize); | |||
| @@ -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<WxPropertyContract> findList(WxPropertyContract record); | |||
| List<Long> findIdList(WxPropertyContract record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| @@ -85,5 +88,7 @@ public interface WxPropertyContractService { | |||
| //查询还有多少天到期的合同 | |||
| List<WxPropertyContract> findToOutDateContracts(TenantEntity tenantEntity); | |||
| BigDecimal calcuteContractUsedShopArea(WxPropertyContract record); | |||
| } | |||
| @@ -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<WxRentContract> findList(WxRentContract record); | |||
| List<Long> findIdList(WxRentContract record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| @@ -160,4 +164,6 @@ public interface WxRentContractService { | |||
| List<WxRentContractYearsVo> getRentContractYears(WxRentContract rentContract); | |||
| BigDecimal calcuteContractUsedShopArea(WxRentContract wxRentContract,Long shopId); | |||
| } | |||
| @@ -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<WxShop> listAsPage(WxShop record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<Map<String,Object>> listMapAsPage(WxShop record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<Map<String,Object>> 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<Long> getFloorBuildShopIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer shopDel ,String shopNumber) ; | |||
| BigDecimal calcuteUsedShopArea(TenantEntity tenantEntity,Long shopId,BigDecimal contractUsedArea); | |||
| } | |||
| @@ -301,14 +301,16 @@ public class WxAgileContractServiceImpl implements WxAgileContractService { | |||
| sdel.updateTenantInfo(record); | |||
| sdel.setContractId(record.getId()); | |||
| wxContractShopMapper.deleteByCondition(sdel); | |||
| Map<Long, BigDecimal> 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<Long> contractIds) { | |||
| WxContractShop cs = new WxContractShop(); | |||
| cs.updateTenantInfo(tenantEntity); | |||
| cs.setShopId(shopId); | |||
| cs.setContractIds(contractIds); | |||
| return wxContractShopMapper.sumAreas(cs); | |||
| } | |||
| @Override | |||
| @@ -201,6 +201,11 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| public List<WxPropertyContract> findList(WxPropertyContract record) { | |||
| return wxPropertyContractMapper.findList(record); | |||
| } | |||
| @Override | |||
| public List<Long> findIdList(WxPropertyContract record) { | |||
| return wxPropertyContractMapper.findIdList(record); | |||
| } | |||
| @Override | |||
| public Map<String, Object> getById(Long id) { | |||
| @@ -497,14 +502,16 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService | |||
| sdel.updateTenantInfo(record); | |||
| sdel.setContractId(record.getId()); | |||
| wxContractShopMapper.deleteByCondition(sdel); | |||
| Map<Long, BigDecimal> 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; | |||
| } | |||
| } | |||
| @@ -252,6 +252,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return wxRentContractMapper.findList(record); | |||
| } | |||
| @Override | |||
| public List<Long> findIdList(WxRentContract record){ | |||
| return wxRentContractMapper.findIdList(record); | |||
| } | |||
| @Override | |||
| public Map<String, Object> getById(Long id,Integer noBillList) { | |||
| Map<String, Object> result = new HashMap<>(); | |||
| @@ -497,14 +502,16 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| sdel.updateTenantInfo(record); | |||
| sdel.setContractId(record.getId()); | |||
| wxContractShopMapper.deleteByCondition(sdel); | |||
| Map<Long, BigDecimal> 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<WxRentContractRevenueJump> findJumpList(WxRentContractRevenueJump jump) { | |||
| return wxRentContractRevenueJumpMapper.findList(jump); | |||
| } | |||
| @Override | |||
| public BigDecimal calcuteContractUsedShopArea(WxRentContract wxRentContract,Long shopId) { | |||
| //根据合同区间查询已使用合同的总面积 | |||
| return null; | |||
| } | |||
| } | |||
| @@ -160,7 +160,7 @@ public class WxShopServiceImpl implements WxShopService { | |||
| public PageInfo<Map<String,Object>> 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<Long> 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); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -7,12 +7,13 @@ | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="contract_id" jdbcType="BIGINT" property="contractId"/> | |||
| <result column="shop_id" jdbcType="BIGINT" property="shopId"/> | |||
| <result column="rent_area" jdbcType="VARCHAR" property="rentArea"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `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` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -44,6 +45,13 @@ | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != contractIds "> | |||
| and contract_id in | |||
| <foreach collection="contractIds" index="index" item="cidItem" open="(" separator="," close=")"> | |||
| #{cidItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -64,7 +72,13 @@ | |||
| select distinct contract_id | |||
| from wx_contract_shop | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </select> | |||
| <select id="sumAreas" parameterType="com.iformall.domain.po.WxContractShop" resultType="Decimal"> | |||
| select sum(CAST(ifnull(rent_area,'0') AS DECIMAL(20,4))) | |||
| from wx_contract_shop | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <delete id="deleteByCondition" parameterType="com.iformall.domain.po.WxContractShop"> | |||
| delete from wx_contract_shop | |||
| @@ -83,6 +83,13 @@ | |||
| <if test=" null != price ">and `price` = #{price}</if> | |||
| <if test=" null != rentalStartDate ">and `rental_start_date` = #{rentalStartDate}</if> | |||
| <if test=" null != rentalEndDate ">and `rental_end_date` = #{rentalEndDate}</if> | |||
| <if test=" null != useStartTime and null != useEndTime"> | |||
| and ( | |||
| (`rental_start_date` <= #{useStartTime} and rental_end_date > #{useStartTime}) | |||
| or | |||
| (`rental_start_date` >= #{useStartTime} and rental_start_date < #{useEndTime}) | |||
| ) | |||
| </if> | |||
| <if test=" null != outDateNofity ">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 </if> | |||
| <if test=" null != signDate ">and `sign_date` = #{signDate}</if> | |||
| <if test=" null != receivePeriod ">and `receive_period` = #{receivePeriod}</if> | |||
| @@ -152,6 +159,12 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findIdList" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="Long"> | |||
| select id | |||
| from wx_property_contract | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="queryRentContractWaitSignStatus" resultType="int" | |||
| parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| select count(id) from wx_property_contract where status=#{status} | |||
| @@ -114,6 +114,13 @@ | |||
| <if test=" null != price and '' != price">and `price` = #{price}</if> | |||
| <if test=" null != rentalStartDate and '' != rentalStartDate">and `rental_start_date` = #{rentalStartDate}</if> | |||
| <if test=" null != rentalEndDate and '' != rentalEndDate">and `rental_end_date` = #{rentalEndDate}</if> | |||
| <if test=" null != useStartTime and null != useEndTime"> | |||
| and ( | |||
| (`rental_start_date` <= #{useStartTime} and rental_end_date > #{useStartTime}) | |||
| or | |||
| (`rental_start_date` >= #{useStartTime} and rental_start_date < #{useEndTime}) | |||
| ) | |||
| </if> | |||
| <if test=" null != outDateNofity ">and out_date_notify_phone is not null and out_date_notify_phone != '' and out_date_notify_days is not null and out_date_notify_days > 0 </if> | |||
| <if test=" null != signDate and '' != signDate">and `sign_date` = #{signDate}</if> | |||
| <if test=" null != receivePeriod and '' != receivePeriod">and `receive_period` = #{receivePeriod}</if> | |||
| @@ -184,6 +191,12 @@ | |||
| from wx_rent_contract | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findIdList" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long"> | |||
| select id | |||
| from wx_rent_contract | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="java.lang.Long"> | |||
| select count(id) | |||