Browse Source

fix

release_toaliyun_real
winter 1 year ago
parent
commit
2a375fc75f
8 changed files with 148 additions and 119 deletions
  1. +30
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java
  2. +99
    -60
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java
  3. +0
    -21
      mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java
  4. +4
    -21
      mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java
  5. +1
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxShop.java
  6. +14
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/ShopValidAreaVo.java
  7. +0
    -2
      mallinkService/src/main/java/com/iformall/service/WxShopService.java
  8. +0
    -14
      mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java

+ 30
- 0
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxAgileContractController.java View File

@@ -11,6 +11,7 @@ import com.iformall.common.ResultData;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.BaseEntity.SortField;
import com.iformall.domain.vo.ShopValidAreaVo;
import com.iformall.domain.vo.WxRentContractYearsVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
@@ -103,6 +104,35 @@ public class WxAgileContractController extends WxContractBaseController {
return new ResultData(page);
}
/**
* 计算店铺有效面积
* @param wxRentContract
* @return
*/
@PostMapping("getShopValidArea")
public ResultData getShopValidArea(@RequestBody WxRentContract wxRentContract) {
MallUserInfo user = getUser();
wxRentContract.updateTenantInfo(user);
if (null == wxRentContract.getRentalStartDate() || null == wxRentContract.getRentalEndDate() ) {
return new ResultData(Result.ERROR,"请选择合同开始日期和结束日期");
}
if (null == wxRentContract.getCalcuteShopIds() || wxRentContract.getCalcuteShopIds().size() <= 0 ) {
return new ResultData(Result.ERROR,"请选择店铺");
}
Map<Long,ShopValidAreaVo> map = null;
if (null != wxRentContract.getCalcuteIsProperty()
&& EnumYesOrNo.YES.getCode().intValue() == wxRentContract.getCalcuteIsProperty().intValue()) {
map = this.calcuteShopValidArea(wxRentContract, wxRentContract.getId(), wxRentContract.getRentalStartDate(), wxRentContract.getRentalEndDate(),
wxRentContract.getCalcuteShopIds(), null, false);
}else {
map = this.calcuteShopValidArea(wxRentContract, wxRentContract.getId(), wxRentContract.getRentalStartDate(), wxRentContract.getRentalEndDate(),
wxRentContract.getCalcuteShopIds(), null, true);
}
return new ResultData(map);
}
/**
* 新增/修改第一步
* @param wxRentContract


+ 99
- 60
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxContractBaseController.java View File

@@ -7,7 +7,9 @@ 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.WxShop;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.ShopValidAreaVo;
import com.iformall.domain.vo.WxRentPropertyContractVo;
import com.iformall.enums.EnumContractOperationType;
import com.iformall.enums.EnumFlowContractType;
@@ -22,6 +24,7 @@ import com.iformall.service.WxPropertyContractService;
import com.iformall.service.WxRentContractService;
import com.iformall.service.WxShopService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@@ -31,6 +34,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

@@ -148,79 +152,114 @@ 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 {
protected Map<Long,ShopValidAreaVo> calcuteShopValidArea(TenantEntity tenantEntity,Long contractId,Date contractStartDate,Date contractEndDate,
List<Long> shopIdList,Map<Long, BigDecimal> rentAreaMap,boolean isRent) {
//判断店铺是否还有有效的面积
for (int i = 0 ; i < rentShopIdList.size(); i++) {
Long shopId = rentShopIdList.get(i);
Map<Long,ShopValidAreaVo> shopValidAreaMap = new HashMap<Long,ShopValidAreaVo>();
for (int i = 0 ; i < shopIdList.size(); i++) {
Long shopId = shopIdList.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+"]面积不足。");
BigDecimal shopArea = new BigDecimal(0);
WxShop shop = wxShopService.getById(shopId);
if (StringUtils.isNotBlank(shop.getOperationArea())){
shopArea = new BigDecimal(shop.getOperationArea());
}
ShopValidAreaVo vo = new ShopValidAreaVo();
vo.setShopNumber(shop.getShopNumber());
;
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+"]面积不足。");
}
}
}
}
if (shopArea.compareTo(new BigDecimal(0)) <= 0 ) {
vo.setValidArea(new BigDecimal(0));
}else {
BigDecimal contractShopArea = new BigDecimal(0);
if (null != rentAreaMap) {
contractShopArea = rentAreaMap.get(shopId);
if (null == contractShopArea) {
contractShopArea = new BigDecimal(0);
}
}
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(contractShopArea);
BigDecimal remianArea = wxShopService.calcuteUsedShopArea(tenantEntity, shopId, totalUsedArea);
if (remianArea.compareTo(new BigDecimal(0)) < 0 ) {
vo.setValidArea(new BigDecimal(0));
}else {
vo.setValidArea(remianArea);
}
}
}
}
}
shopValidAreaMap.put(shopId, vo);
}
return shopValidAreaMap;
}
private void contractValidShop(TenantEntity tenantEntity,Long contractId,Date contractStartDate,Date contractEndDate,
List<Long> rentShopIdList,Map<Long, BigDecimal> rentAreaMap,boolean isRent) throws Exception {
//判断店铺是否还有有效的面积
Map<Long,ShopValidAreaVo> shopVliadAreaMap = calcuteShopValidArea(tenantEntity, contractId, contractStartDate, contractEndDate, rentShopIdList, rentAreaMap, isRent);
if (null != shopVliadAreaMap) {
for (Iterator<Long> it = shopVliadAreaMap.keySet().iterator(); it.hasNext();) {
Long shopId = it.next();
ShopValidAreaVo vo = shopVliadAreaMap.get(shopId);
if ( null != vo && null != vo.getValidArea()) {
if (vo.getValidArea().compareTo(new BigDecimal(0)) <= 0 ) {
throw new MallinkException(Result.ERROR, "房间["+vo.getShopNumber()+"]面积不足。");
}
}
}
}
}
protected void rentContractValidShop(WxRentContract rentContract) throws Exception {
contractValidShop(rentContract,rentContract.getId(),rentContract.getRentalStartDate(),rentContract.getRentalEndDate(),rentContract.shopIdsByRentInfo(),
rentContract.getRentShopArea(),rentContract.getRentInfoShopNumberMap(),true);
rentContract.getRentShopArea(),true);
}
protected void propertyContractValidShop(WxPropertyContract propertyContract) throws Exception {
contractValidShop(propertyContract,propertyContract.getId(),propertyContract.getRentalStartDate(),propertyContract.getRentalEndDate(),propertyContract.shopIdsByShop(),
propertyContract.getRentShopArea(),propertyContract.getRentInfoShopNumberMap(),false);
propertyContract.getRentShopArea(),false);
}
}

+ 0
- 21
mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java View File

@@ -339,27 +339,6 @@ 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);


+ 4
- 21
mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java View File

@@ -427,27 +427,6 @@ 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();
@@ -608,5 +587,9 @@ public class WxRentContract extends TenantEntity {
private Date useStartTime;
@TableField(exist = false)
private Date useEndTime;
@TableField(exist = false)
private List<Long> calcuteShopIds;
@TableField(exist = false)
private Integer calcuteIsProperty;
}


+ 1
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxShop.java View File

@@ -249,5 +249,5 @@ public class WxShop extends TenantEntity {
@TableField(exist = false)
private String energyFeesIds;
@TableField(exist = false)
private Integer calcuteContractUsedArea;
private Integer usedContractArea;
}

+ 14
- 0
mallinkService/src/main/java/com/iformall/domain/vo/ShopValidAreaVo.java View File

@@ -0,0 +1,14 @@
package com.iformall.domain.vo;

import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;

@Data
public class ShopValidAreaVo implements Serializable{
private static final long serialVersionUID = 4494858079134918638L;
//核销金额记录
private BigDecimal validArea;
private String shopNumber;
}

+ 0
- 2
mallinkService/src/main/java/com/iformall/service/WxShopService.java View File

@@ -163,6 +163,4 @@ public interface WxShopService {
List<Long> getFloorBuildShopIds(TenantEntity tenantEntity,String floorRule,Long building,Long floor,Integer shopDel ,String shopNumber) ;
BigDecimal calcuteUsedShopArea(TenantEntity tenantEntity,Long shopId,BigDecimal contractUsedArea);
}

+ 0
- 14
mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java View File

@@ -1239,18 +1239,4 @@ public class WxShopServiceImpl implements WxShopService {
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);
}
}
}
}

Loading…
Cancel
Save