From fb224691ed8cf6ffdefa16950131dfdd81e5d4ff Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 1 Sep 2020 16:52:09 +0800 Subject: [PATCH] fix contract --- .../contract/WxRentContractController.java | 15 +- .../service/WxRentContractService.java | 2 +- .../service/impl/WxFlowServiceImpl.java | 4 + .../impl/WxRentContractServiceImpl.java | 610 +++++++++--------- .../resources/mapper/WxRentContractMapper.xml | 1 + 5 files changed, 321 insertions(+), 311 deletions(-) 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 5a5933954..9e6081953 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -770,13 +770,14 @@ public class WxRentContractController extends WxContractBaseController { return wxRentContractService.update(rentContract, user.getId(),user.getName(), EnumFromType.SWITCH.getCode(),oldDate,false); } -// @GetMapping("exportContract") -// @ApiImplicitParams({ -// @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) -// @SystemControllerLog(description = "租赁合同-导出合同") -// public void exportContract(Long id,HttpServletRequest request, HttpServletResponse response){ -// wxRentContractService.exportContract(request,response,id); -// } + @GetMapping("exportContract") + @ApiImplicitParams({ + @ApiImplicitParam(name = "rentId", value = "rentId", dataType = "Long", paramType = "query", required = false), + @ApiImplicitParam(name = "propertyId", value = "propertyId", dataType = "Long", paramType = "query", required = false)}) + @SystemControllerLog(description = "租赁合同-导出合同") + public void exportContract(Long rentId,Long propertyId,HttpServletRequest request, HttpServletResponse response){ + wxRentContractService.exportContract(request,response,rentId,propertyId); + } // @GetMapping("/getRentContractStatusInfo") diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index 98b8830a9..714d38c06 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -64,7 +64,7 @@ public interface WxRentContractService { PageInfo getRentContractList(WxRentContract rentContract, Integer pageNum, Integer pageSize); - //void exportContract(HttpServletRequest request, HttpServletResponse response, Long id); + void exportContract(HttpServletRequest request, HttpServletResponse response, Long rentId,Long propertyId); ResultData updateFile(WxRentContract wxRentContract, Long userId,String userName,Date oldRentStartDate,boolean writeComplate); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index de92478a2..f100221d9 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -223,6 +223,10 @@ public class WxFlowServiceImpl implements WxFlowService { }else if (EnumRentContractAppStatus.SETBACK.getCode().intValue() == applyStatus.intValue() || EnumRentContractAppStatus.REJECT.getCode().intValue() == applyStatus.intValue()) { rent.setStatus(EnumRentContractStatus.DRAFT.getCode()); + //如果是租金+物业,则还要更新物业合同的状态 + if (isrentproperty) { + propertyStatus = EnumRentContractStatus.DRAFT.getCode(); + } } wxRentContractService.updateApplyStatus(rent); if (isrentproperty) { 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 a402a365a..420a140c9 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1593,32 +1593,32 @@ public class WxRentContractServiceImpl implements WxRentContractService { // return resultData; // } -// @Override -// public void exportContract(HttpServletRequest request, HttpServletResponse response, Long id) { -// String contracType = "0"; -// String templatePath = null; -// Map result = null; -// if (EnumContractType.ALL.getCode().toString().equals(contracType)) { -// logger.info("获取租赁及物业合同数据"); -// result = getRentAndPropertyInfo(id); -// result.put("contractType", EnumContractType.ALL.getMessage()); -// if (EnumRentContractType.RENT_BY_AREA.getCode().equals(result.get("type"))) { -// templatePath = "contract-word-template/contract_rent_property.docx"; -// } else { -// templatePath = "contract-word-template/contract_rent_property_by_ratio.docx"; -// } -// logger.info("租赁及物业合同数据结果:" + result); -// } -// -// if (templatePath == null) { -// logger.info("没有租赁及物业合同模板"); -// return; -// } -// String filepath = fmUploadDir; -// String filename = UUID.randomUUID() + ".docx"; -// String exportFileName = result.get("merchantName").toString() + "合同.docx"; -// WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); -// } + @Override + public void exportContract(HttpServletRequest request, HttpServletResponse response, Long rentId,Long propertyId) { + String contracType = "0"; + String templatePath = null; + Map result = null; + if (EnumContractType.ALL.getCode().toString().equals(contracType)) { + logger.info("获取租赁及物业合同数据"); + result = getRentAndPropertyInfo(rentId,propertyId); + result.put("contractType", EnumContractType.ALL.getMessage()); + if (EnumRentContractType.RENT_BY_AREA.getCode().equals(result.get("type"))) { + templatePath = "contract-word-template/contract_rent_property.docx"; + } else { + templatePath = "contract-word-template/contract_rent_property_by_ratio.docx"; + } + logger.info("租赁及物业合同数据结果:" + result); + } + + if (templatePath == null) { + logger.info("没有租赁及物业合同模板"); + return; + } + String filepath = fmUploadDir; + String filename = UUID.randomUUID() + ".docx"; + String exportFileName = result.get("merchantName").toString() + "合同.docx"; + WordUtil.exportWord(templatePath, filepath, filename, exportFileName, result, request, response,null); + } @Override @Transactional(rollbackFor = {Exception.class}) @@ -1703,283 +1703,287 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } -// public Map getRentAndPropertyInfo(Long id) { -// logger.info("获取租赁物业合同数据>>>>>>id:" + id); -// Map result = new HashMap<>(); -// WxRentContract wxRentContract = wxRentContractMapper.selectById(id); -// if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { -// JSONArray jsonArray = JSONArray.parseArray(wxRentContract.getRentInfo()); -// StringBuffer shopNumberStr = new StringBuffer(); -// StringBuffer floorNameStr = new StringBuffer(); -// StringBuffer buildingNameStr = new StringBuffer(); -// StringBuffer buildAreaStr = new StringBuffer(); -// StringBuffer operationAreaStr = new StringBuffer(); -// for (int i = 0, size = jsonArray.size(); i < size; i++) { -// JSONObject jsonObject = jsonArray.getJSONObject(i); -// shopNumberStr.append("[").append(jsonObject.getString("shopNumber")).append("]"); -// floorNameStr.append("[").append(jsonObject.getString("floor")).append("]"); -// buildingNameStr.append("[").append(jsonObject.getString("building")).append("]"); -// buildAreaStr.append("[").append(jsonObject.getString("buildArea")).append("]"); -// operationAreaStr.append("[").append(jsonObject.getString("operationArea")).append("]"); -// } -// result.put("shopNumber", shopNumberStr); -// result.put("floorName", floorNameStr); -// result.put("buildingName", buildingNameStr); -// result.put("buildArea", buildAreaStr); -// result.put("operationArea", operationAreaStr); -// } else { -// //record.setId(wxRentContract.getShopId()); -// if (wxRentContract.shopIdsByRentInfo().size() == 0) { -// result.put("shopNumber", " "); -// result.put("floorName", " "); -// result.put("buildingName", " "); -// result.put("buildArea", " "); -// result.put("operationArea", " "); -// }else { -// WxShop record = new WxShop(); -// record.setIds(wxRentContract.shopIdsByRentInfo()); -// List> wxShops = wxShopMapper.findListMap(record); -// if (!wxShops.isEmpty()) { -// //店铺信息 -// Map wxShop = wxShops.get(0); -// result.put("shopNumber", wxShop.get("shopNumber")); -// result.put("floorName", wxShop.get("floor")); -// result.put("buildingName", wxShop.get("building")); -// result.put("buildArea", wxShop.get("buildArea")); -// result.put("operationArea", wxShop.get("operationArea")); -// } -// } -// } -// //MALL信息 -// WxMall wxMall = new WxMall(); -// wxMall.setTenantInfo(wxRentContract); -// wxMall = wxMallMapper.findList(wxMall).get(0); -// result.put("mallName", wxMall.getName()); -// result.put("province", wxMall.getProvince()); -// result.put("city", wxMall.getCity()); -// -// //商户信息 -// WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); -// //经营业态 -// wxRentContract.getMerchantId(); -// WxBusiness wxBusiness = wxBusinessMapper.selectById(merchant.getBusinessId()); -// result.put("business", wxBusiness.getTitle()); -// -// if (merchant != null) { -// result.put("merchantName", merchant.getName()); -// //法人信息 -// WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp(); -// result.put("corpPapersNumber", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersNumber()) ? wxMerchantCorp.getCorpPapersNumber() : " "); -// result.put("corpPapersType", wxMerchantCorp.getCorpPapersType() != null ? EnumPapersType.getEnum(wxMerchantCorp.getCorpPapersType()).getMessage() : " "); -// result.put("corpPapersPerson", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersPerson()) ? wxMerchantCorp.getCorpPapersPerson() : " "); -// //税务信息 -// WxMerchantTax wxMerchantTax = merchant.getWxMerchantTax(); -// result.put("taxPapersType", wxMerchantTax.getTaxPapersType() != null ? EnumTaxpayerType.getEnum(wxMerchantTax.getTaxPapersType()).getMessage() : " "); -// result.put("bankName", StringUtils.isNotEmpty(wxMerchantTax.getBankName()) ? wxMerchantTax.getBankName() : " "); -// result.put("bankAccount", StringUtils.isNotEmpty(wxMerchantTax.getBankAccount()) ? wxMerchantTax.getBankAccount() : " "); -// result.put("invoiceAddressPhone", StringUtils.isNotEmpty(wxMerchantTax.getInvoiceAddressPhone()) ? wxMerchantTax.getInvoiceAddressPhone() : " "); -// } else { -// result.put("merchantName", ""); -// //法人信息 -// result.put("corpPapersNumber", " "); -// result.put("corpPapersType", " "); -// result.put("corpPapersPerson", " "); -// //税务信息 -// result.put("taxPapersType", " "); -// result.put("bankName", " "); -// result.put("bankAccount", " "); -// result.put("invoiceAddressPhone", " "); -// } -// //租赁合同信息 -// String rentalStartDate = DateUtils.date2String(wxRentContract.getRentalStartDate(), "yyyy-MM-dd"); -// result.put("rentalStartDate", rentalStartDate); -// result.put("rentalStartDateYear", rentalStartDate.substring(0, 4)); -// result.put("rentalStartDateMonth", rentalStartDate.substring(5, 7)); -// result.put("rentalStartDateDay", rentalStartDate.substring(8)); -// String rentalEndDate = DateUtils.date2String(wxRentContract.getRentalEndDate(), "yyyy-MM-dd"); -// result.put("rentalEndDate", rentalEndDate); -// result.put("rentalEndDateYear", rentalEndDate.substring(0, 4)); -// result.put("rentalEndDateMonth", rentalEndDate.substring(5, 7)); -// result.put("rentalEndDateDay", rentalEndDate.substring(8)); -// result.put("price", wxRentContract.getPrice()); -// result.put("contractNumber", wxRentContract.getContractNumber()); -// Integer lease = wxRentContract.getLease(); -// Integer receivePeriod = wxRentContract.getReceivePeriod(); -// result.put("lease", lease); -// result.put("receivePeriod", receivePeriod); -// String payAccountStr = " "; -// if(wxRentContract.getPayAccount() != null && !wxRentContract.getPayAccount().equals("")) { -// payAccountStr = wxRentContract.getPayAccount(); -// } -// result.put("payAccount", payAccountStr); -// result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd")); -// //主体名称-乙方 -// if (StringUtils.isNotEmpty(wxRentContract.getSubjectName())) { -// result.put("corpPapersPerson", wxRentContract.getSubjectName()); -// } else { -// result.put("corpPapersPerson", " "); -// } -// -// //品牌 -// Long brandId = merchant.getBrand(); -// String brand = " "; -// if (brandId != null) { -// WxBrand wxBrand = WxBrandMapper.selectById(brandId); -// if (wxBrand != null) { -// brand = wxBrand.getName(); -// } -// } -// result.put("brand", brand); -// // TODO -// //double adjustRatio = wxRentContract.getAdjustRatio() != null ? wxRentContract.getAdjustRatio() / 100.0 : 0; -// result.put("adjustRatio", 0); -// double priceRent = new BigDecimal(wxRentContract.getPrice()) -// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("priceRent", priceRent); -// if (!wxRentContract.getRentArea().equals("0")) { -// double unitPrice = new BigDecimal(wxRentContract.getPrice()) -// .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) -// .divide(new BigDecimal(100)) -// .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("unitPriceRent", unitPrice); -// result.put("priceRentUpper", PriceUtil.digitUppercase(priceRent)); -// result.put("unitPriceRentUpper", PriceUtil.digitUppercase(unitPrice)); -// } else { -// result.put("unitPriceRent", 0); -// result.put("priceRentUpper", PriceUtil.digitUppercase(0)); -// result.put("unitPriceRentUpper", PriceUtil.digitUppercase(0)); -// } -// -// //租赁保证金 -// int cashDepositMonthRent = 3; -// double cashDepositRent = new BigDecimal(wxRentContract.getPrice()).multiply(new BigDecimal(cashDepositMonthRent)) -// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("cashDepositMonthRent", cashDepositMonthRent); -// result.put("cashDepositRent", cashDepositRent); -// result.put("cashDepositRentUpper", PriceUtil.digitUppercase(cashDepositRent)); -// result.put("type", wxRentContract.getType()); -// int extralease = lease % 12; -// int extracount = extralease > 0 ? 1 : 0; -// int paycount = lease / 12 + extracount; -// int index = 10 - paycount; -// int count = paycount - 1; -// BigDecimal rentPrice = new BigDecimal(priceRent); -// //保底 -// if (wxRentContract.getRevenue() != null) { -// double revenue = new BigDecimal(wxRentContract.getRevenue()) -// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("revenue", revenue); -// result.put("revenueUpper", PriceUtil.digitUppercase(revenue)); -// } else { -// result.put("revenue", 0); -// result.put("revenueUpper", PriceUtil.digitUppercase(0)); -// } -// if (!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { -// areaWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); -// } else { -// ratioWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); -// } -// //物业合同信息 -// WxPropertyContract propertyContract = new WxPropertyContract(); -// propertyContract.updateTenantInfo(wxRentContract); -// propertyContract.setRentContractId(wxRentContract.getId()); -//// Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) -//// .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) -//// && !rc.get("status").equals(EnumRentContractStatus.WAIT_SIGN.getCode()) -//// && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) -//// && !rc.get("status").equals(EnumRentContractStatus.CONTRACT_END.getCode()) -//// && !rc.get("status").equals(EnumRentContractStatus.INTENTION.getCode())).findFirst(); -// Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) -// .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.TERMINATE.getCode()) -// && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) -// && !rc.get("status").equals(EnumRentContractStatus.OUT_DATE.getCode())).findFirst(); -// Map wxPropertyContract = null; -// if (first.isPresent()) { -// wxPropertyContract = first.get(); -// } -// if (wxPropertyContract != null) { -// Integer receivePeriodProperty = (Integer) wxPropertyContract.get("receivePeriod"); -// result.put("receivePeriodProperty", receivePeriodProperty); -// double priceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) -// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("priceProperty", priceProperty); -// if (!wxRentContract.getRentArea().equals("0")) { -// double unitPriceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) -// .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) -// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("unitPriceProperty", unitPriceProperty); -// result.put("pricePropertyUpper", PriceUtil.digitUppercase(priceProperty)); -// result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(unitPriceProperty)); -// } else { -// result.put("unitPriceProperty", 0); -// result.put("pricePropertyUpper", PriceUtil.digitUppercase(0)); -// result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(0)); -// } -// -// //首期物业费 -// Calendar instance = Calendar.getInstance(); -// instance.setTime(wxRentContract.getRentalStartDate()); -// instance.add(Calendar.MONTH, 0); -// Date starttime = instance.getTime(); -// String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); -// result.put("rentalStartDateProperty", startdate); -// result.put("rentalStartDateYearProperty", startdate.substring(0, 4)); -// result.put("rentalStartDateMonthProperty", startdate.substring(5, 7)); -// result.put("rentalStartDateDayProperty", startdate.substring(8)); -// //结束时间 -// instance.clear(); -// instance.setTime(starttime); -// instance.add(Calendar.MONTH, receivePeriodProperty); -// instance.add(Calendar.DAY_OF_MONTH, -1); -// Date endtime = instance.getTime(); -// String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); -// result.put("rentalEndDateProperty", enddate); -// result.put("rentalEndDateYearProperty", enddate.substring(0, 4)); -// result.put("rentalEndDateMonthProperty", enddate.substring(5, 7)); -// result.put("rentalEndDateDayProperty", enddate.substring(8)); -// double pricePropertyFirst = new BigDecimal(priceProperty) -// .multiply(new BigDecimal(receivePeriodProperty)) -// .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("pricePropertyFirst", pricePropertyFirst); -// result.put("pricePropertyFirstUpper", PriceUtil.digitUppercase(pricePropertyFirst)); -// -// -// //物业保证金 -// int cashDepositMonthProperty = 3; -// double cashDepositProperty = new BigDecimal(wxPropertyContract.get("price").toString()).multiply(new BigDecimal(cashDepositMonthProperty)) -// .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); -// result.put("cashDepositMonthProperty", cashDepositMonthProperty); -// result.put("cashDepositProperty", cashDepositProperty); -// result.put("cashDepositPropertyUpper", PriceUtil.digitUppercase(cashDepositProperty)); -// -// -// } else { -// result.put("receivePeriodProperty", " "); -// result.put("priceProperty", " "); -// result.put("unitPriceProperty", " "); -// result.put("pricePropertyUpper", " "); -// result.put("unitPricePropertyUpper", " "); -// //首期物业费 -// result.put("rentalStartDateProperty", " "); -// result.put("rentalStartDateYearProperty", " "); -// result.put("rentalStartDateMonthProperty", " "); -// result.put("rentalStartDateDayProperty", " "); -// //结束时间 -// result.put("rentalEndDateProperty", " "); -// result.put("rentalEndDateYearProperty", " "); -// result.put("rentalEndDateMonthProperty", " "); -// result.put("rentalEndDateDayProperty", " "); -// result.put("pricePropertyFirst", " "); -// result.put("pricePropertyFirstUpper", " "); -// //物业保证金 -// result.put("cashDepositMonthProperty", " "); -// result.put("cashDepositProperty", " "); -// result.put("cashDepositPropertyUpper", " "); -// } -// -// -// return result; -// } + public Map getRentAndPropertyInfo(Long rentId,Long propertyId) { + logger.info("获取租赁物业合同数据>>>>>>rentId:" + rentId +" >>>>propertyId:"+propertyId); + Map result = new HashMap<>(); + WxRentContract wxRentContract = wxRentContractMapper.selectById(rentId); + if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) { + JSONArray jsonArray = JSONArray.parseArray(wxRentContract.getRentInfo()); + StringBuffer shopNumberStr = new StringBuffer(); + StringBuffer floorNameStr = new StringBuffer(); + StringBuffer buildingNameStr = new StringBuffer(); + StringBuffer buildAreaStr = new StringBuffer(); + StringBuffer operationAreaStr = new StringBuffer(); + for (int i = 0, size = jsonArray.size(); i < size; i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + shopNumberStr.append("[").append(jsonObject.getString("shopNumber")).append("]"); + floorNameStr.append("[").append(jsonObject.getString("floor")).append("]"); + buildingNameStr.append("[").append(jsonObject.getString("building")).append("]"); + buildAreaStr.append("[").append(jsonObject.getString("buildArea")).append("]"); + operationAreaStr.append("[").append(jsonObject.getString("operationArea")).append("]"); + } + result.put("shopNumber", shopNumberStr); + result.put("floorName", floorNameStr); + result.put("buildingName", buildingNameStr); + result.put("buildArea", buildAreaStr); + result.put("operationArea", operationAreaStr); + } else { + //record.setId(wxRentContract.getShopId()); + if (wxRentContract.shopIdsByRentInfo().size() == 0) { + result.put("shopNumber", " "); + result.put("floorName", " "); + result.put("buildingName", " "); + result.put("buildArea", " "); + result.put("operationArea", " "); + }else { + WxShop record = new WxShop(); + record.setIds(wxRentContract.shopIdsByRentInfo()); + List> wxShops = wxShopMapper.findListMap(record); + if (!wxShops.isEmpty()) { + //店铺信息 + Map wxShop = wxShops.get(0); + result.put("shopNumber", wxShop.get("shopNumber")); + result.put("floorName", wxShop.get("floor")); + result.put("buildingName", wxShop.get("building")); + result.put("buildArea", wxShop.get("buildArea")); + result.put("operationArea", wxShop.get("operationArea")); + } + } + } + //MALL信息 + WxMall wxMall = new WxMall(); + wxMall.setTenantInfo(wxRentContract); + wxMall = wxMallMapper.findList(wxMall).get(0); + result.put("mallName", wxMall.getName()); + result.put("province", wxMall.getProvince()); + result.put("city", wxMall.getCity()); + + //商户信息 + WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId()); + //经营业态 + wxRentContract.getMerchantId(); + WxBusiness wxBusiness = wxBusinessMapper.selectById(merchant.getBusinessId()); + result.put("business", wxBusiness.getTitle()); + + if (merchant != null) { + result.put("merchantName", merchant.getName()); + //法人信息 + WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp(); + result.put("corpPapersNumber", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersNumber()) ? wxMerchantCorp.getCorpPapersNumber() : " "); + result.put("corpPapersType", wxMerchantCorp.getCorpPapersType() != null ? EnumPapersType.getEnum(wxMerchantCorp.getCorpPapersType()).getMessage() : " "); + result.put("corpPapersPerson", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersPerson()) ? wxMerchantCorp.getCorpPapersPerson() : " "); + //税务信息 + WxMerchantTax wxMerchantTax = merchant.getWxMerchantTax(); + result.put("taxPapersType", wxMerchantTax.getTaxPapersType() != null ? EnumTaxpayerType.getEnum(wxMerchantTax.getTaxPapersType()).getMessage() : " "); + result.put("bankName", StringUtils.isNotEmpty(wxMerchantTax.getBankName()) ? wxMerchantTax.getBankName() : " "); + result.put("bankAccount", StringUtils.isNotEmpty(wxMerchantTax.getBankAccount()) ? wxMerchantTax.getBankAccount() : " "); + result.put("invoiceAddressPhone", StringUtils.isNotEmpty(wxMerchantTax.getInvoiceAddressPhone()) ? wxMerchantTax.getInvoiceAddressPhone() : " "); + } else { + result.put("merchantName", ""); + //法人信息 + result.put("corpPapersNumber", " "); + result.put("corpPapersType", " "); + result.put("corpPapersPerson", " "); + //税务信息 + result.put("taxPapersType", " "); + result.put("bankName", " "); + result.put("bankAccount", " "); + result.put("invoiceAddressPhone", " "); + } + //租赁合同信息 + String rentalStartDate = DateUtils.date2String(wxRentContract.getRentalStartDate(), "yyyy-MM-dd"); + result.put("rentalStartDate", rentalStartDate); + result.put("rentalStartDateYear", rentalStartDate.substring(0, 4)); + result.put("rentalStartDateMonth", rentalStartDate.substring(5, 7)); + result.put("rentalStartDateDay", rentalStartDate.substring(8)); + String rentalEndDate = DateUtils.date2String(wxRentContract.getRentalEndDate(), "yyyy-MM-dd"); + result.put("rentalEndDate", rentalEndDate); + result.put("rentalEndDateYear", rentalEndDate.substring(0, 4)); + result.put("rentalEndDateMonth", rentalEndDate.substring(5, 7)); + result.put("rentalEndDateDay", rentalEndDate.substring(8)); + result.put("price", wxRentContract.getPrice()); + result.put("contractNumber", wxRentContract.getContractNumber()); + Integer lease = wxRentContract.getLease(); + Integer receivePeriod = wxRentContract.getReceivePeriod(); + result.put("lease", lease); + result.put("receivePeriod", receivePeriod); + String payAccountStr = " "; + if(wxRentContract.getPayAccount() != null && !wxRentContract.getPayAccount().equals("")) { + payAccountStr = wxRentContract.getPayAccount(); + } + result.put("payAccount", payAccountStr); + result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd")); + //主体名称-乙方 + if (StringUtils.isNotEmpty(wxRentContract.getSubjectName())) { + result.put("corpPapersPerson", wxRentContract.getSubjectName()); + } else { + result.put("corpPapersPerson", " "); + } + + //品牌 + Long brandId = merchant.getBrand(); + String brand = " "; + if (brandId != null) { + WxBrand wxBrand = WxBrandMapper.selectById(brandId); + if (wxBrand != null) { + brand = wxBrand.getName(); + } + } + result.put("brand", brand); + // TODO + //double adjustRatio = wxRentContract.getAdjustRatio() != null ? wxRentContract.getAdjustRatio() / 100.0 : 0; + result.put("adjustRatio", 0); + double priceRent = new BigDecimal(wxRentContract.getPrice()) + .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("priceRent", priceRent); + if (!wxRentContract.getRentArea().equals("0")) { + double unitPrice = new BigDecimal(wxRentContract.getPrice()) + .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) + .divide(new BigDecimal(100)) + .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("unitPriceRent", unitPrice); + result.put("priceRentUpper", PriceUtil.digitUppercase(priceRent)); + result.put("unitPriceRentUpper", PriceUtil.digitUppercase(unitPrice)); + } else { + result.put("unitPriceRent", 0); + result.put("priceRentUpper", PriceUtil.digitUppercase(0)); + result.put("unitPriceRentUpper", PriceUtil.digitUppercase(0)); + } + + //租赁保证金 + int cashDepositMonthRent = 3; + double cashDepositRent = new BigDecimal(wxRentContract.getPrice()).multiply(new BigDecimal(cashDepositMonthRent)) + .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("cashDepositMonthRent", cashDepositMonthRent); + result.put("cashDepositRent", cashDepositRent); + result.put("cashDepositRentUpper", PriceUtil.digitUppercase(cashDepositRent)); + result.put("type", wxRentContract.getType()); + int extralease = lease % 12; + int extracount = extralease > 0 ? 1 : 0; + int paycount = lease / 12 + extracount; + int index = 10 - paycount; + int count = paycount - 1; + BigDecimal rentPrice = new BigDecimal(priceRent); + //保底 + if (wxRentContract.getRevenue() != null) { + double revenue = new BigDecimal(wxRentContract.getRevenue()) + .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("revenue", revenue); + result.put("revenueUpper", PriceUtil.digitUppercase(revenue)); + } else { + result.put("revenue", 0); + result.put("revenueUpper", PriceUtil.digitUppercase(0)); + } + if (!wxRentContract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { + areaWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); + } else { + ratioWay(wxRentContract, result, lease, extralease, extracount, paycount, index, count, rentPrice); + } + //物业合同信息 + //WxPropertyContract propertyContract = new WxPropertyContract(); + //propertyContract.updateTenantInfo(wxRentContract); + //propertyContract.setRentContractId(wxRentContract.getId()); +// Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) +// .stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) +// && !rc.get("status").equals(EnumRentContractStatus.WAIT_SIGN.getCode()) +// && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) +// && !rc.get("status").equals(EnumRentContractStatus.CONTRACT_END.getCode()) +// && !rc.get("status").equals(EnumRentContractStatus.INTENTION.getCode())).findFirst(); + //Optional> first = wxPropertyContractMapper.queryPropertyContractData(propertyContract) + //.stream().filter(rc -> !rc.get("status").equals(EnumRentContractStatus.TERMINATE.getCode()) + // && !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) + // && !rc.get("status").equals(EnumRentContractStatus.OUT_DATE.getCode())).findFirst(); + // Map wxPropertyContract = null; + // if (first.isPresent()) { + // wxPropertyContract = first.get(); + // } + WxPropertyContract propertyContract = null; + if (null != propertyId) { + propertyContract = wxPropertyContractMapper.selectById(propertyId); + } + if (propertyContract != null) { + Integer receivePeriodProperty = propertyContract.getReceivePeriod(); + result.put("receivePeriodProperty", receivePeriodProperty); + double priceProperty = new BigDecimal(propertyContract.getPrice().toString()) + .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("priceProperty", priceProperty); + if (!wxRentContract.getRentArea().equals("0")) { + double unitPriceProperty = new BigDecimal(propertyContract.getPrice().toString()) + .divide(new BigDecimal(wxRentContract.getRentArea()), 2, RoundingMode.HALF_EVEN) + .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("unitPriceProperty", unitPriceProperty); + result.put("pricePropertyUpper", PriceUtil.digitUppercase(priceProperty)); + result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(unitPriceProperty)); + } else { + result.put("unitPriceProperty", 0); + result.put("pricePropertyUpper", PriceUtil.digitUppercase(0)); + result.put("unitPricePropertyUpper", PriceUtil.digitUppercase(0)); + } + + //首期物业费 + Calendar instance = Calendar.getInstance(); + instance.setTime(wxRentContract.getRentalStartDate()); + instance.add(Calendar.MONTH, 0); + Date starttime = instance.getTime(); + String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); + result.put("rentalStartDateProperty", startdate); + result.put("rentalStartDateYearProperty", startdate.substring(0, 4)); + result.put("rentalStartDateMonthProperty", startdate.substring(5, 7)); + result.put("rentalStartDateDayProperty", startdate.substring(8)); + //结束时间 + instance.clear(); + instance.setTime(starttime); + instance.add(Calendar.MONTH, receivePeriodProperty); + instance.add(Calendar.DAY_OF_MONTH, -1); + Date endtime = instance.getTime(); + String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); + result.put("rentalEndDateProperty", enddate); + result.put("rentalEndDateYearProperty", enddate.substring(0, 4)); + result.put("rentalEndDateMonthProperty", enddate.substring(5, 7)); + result.put("rentalEndDateDayProperty", enddate.substring(8)); + double pricePropertyFirst = new BigDecimal(priceProperty) + .multiply(new BigDecimal(receivePeriodProperty)) + .setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("pricePropertyFirst", pricePropertyFirst); + result.put("pricePropertyFirstUpper", PriceUtil.digitUppercase(pricePropertyFirst)); + + + //物业保证金 + int cashDepositMonthProperty = 3; + double cashDepositProperty = new BigDecimal(propertyContract.getPrice().toString()).multiply(new BigDecimal(cashDepositMonthProperty)) + .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + result.put("cashDepositMonthProperty", cashDepositMonthProperty); + result.put("cashDepositProperty", cashDepositProperty); + result.put("cashDepositPropertyUpper", PriceUtil.digitUppercase(cashDepositProperty)); + + + } else { + result.put("receivePeriodProperty", " "); + result.put("priceProperty", " "); + result.put("unitPriceProperty", " "); + result.put("pricePropertyUpper", " "); + result.put("unitPricePropertyUpper", " "); + //首期物业费 + result.put("rentalStartDateProperty", " "); + result.put("rentalStartDateYearProperty", " "); + result.put("rentalStartDateMonthProperty", " "); + result.put("rentalStartDateDayProperty", " "); + //结束时间 + result.put("rentalEndDateProperty", " "); + result.put("rentalEndDateYearProperty", " "); + result.put("rentalEndDateMonthProperty", " "); + result.put("rentalEndDateDayProperty", " "); + result.put("pricePropertyFirst", " "); + result.put("pricePropertyFirstUpper", " "); + //物业保证金 + result.put("cashDepositMonthProperty", " "); + result.put("cashDepositProperty", " "); + result.put("cashDepositPropertyUpper", " "); + } + + + return result; + } public void ratioWay(WxRentContract wxRentContract, Map result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) { String adjustRatio = wxRentContract.getAdjustRatio(); diff --git a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml index 7bfe03290..63b6827d2 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractMapper.xml @@ -110,6 +110,7 @@ and `filepath` = #{filepath} and `status` = #{status} + and `apply_status` = #{applyStatus} and `contract_number` = #{contractNumber} and `deposit` = #{deposit} and `pay_date` = #{payDate}