|
|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.word.WordExportUtil; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
@@ -13,12 +14,16 @@ import com.iformall.mapper.*; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
import com.iformall.service.WxRentContractService; |
|
|
|
import com.iformall.utils.Constant; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.apache.poi.xwpf.usermodel.XWPFDocument; |
|
|
|
import org.apache.shiro.SecurityUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
@@ -27,6 +32,7 @@ import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.net.HttpURLConnection; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -57,6 +63,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
@Autowired |
|
|
|
WxMerchantMapper wxMerchantMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxBusinessMapper wxBusinessMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMallMapper wxMallMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) { |
|
|
|
@@ -80,7 +91,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
|
|
|
|
wxRentContract.setPrice(wxRentContract.getPrice() != null ? wxRentContract.getPrice() : 0); |
|
|
|
wxRentContract.setDeposit(wxRentContract.getDeposit() != null ? wxRentContract.getDeposit() : 0); |
|
|
|
|
|
|
|
result.put("wxRentContract", wxRentContract); |
|
|
|
//关联的商户 |
|
|
|
if (wxRentContract.getMerchantId() != null) { |
|
|
|
@@ -125,7 +135,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
&& !rc.get("status").equals(EnumRentContractStatus.WAIT_SIGN.getCode()) |
|
|
|
&& !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) |
|
|
|
&& !rc.get("status").equals(EnumRentContractStatus.CONTRACT_END.getCode())).count(); |
|
|
|
if(count>0){ |
|
|
|
if (count > 0) { |
|
|
|
return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND); |
|
|
|
} |
|
|
|
wxRentContractMapper.insertSelective(record); |
|
|
|
@@ -145,25 +155,24 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
record.setRentalEndDate(instance.getTime()); |
|
|
|
|
|
|
|
if(record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())){ |
|
|
|
if(record.getRevenue()==null || record.getRevenue().intValue()==0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"营业额不能为空且大于0"); |
|
|
|
if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) { |
|
|
|
if (record.getRevenue() == null || record.getRevenue().intValue() == 0) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "营业额不能为空且大于0"); |
|
|
|
} |
|
|
|
if(record.getPayRatio()==null || record.getPayRatio().intValue()==0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"支付比例不能为空且大于0"); |
|
|
|
if (record.getPayRatio() == null || record.getPayRatio().intValue() == 0) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "支付比例不能为空且大于0"); |
|
|
|
} |
|
|
|
BigDecimal hundred = new BigDecimal(100); |
|
|
|
BigDecimal oneThousand = new BigDecimal(10000); |
|
|
|
BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(hundred); |
|
|
|
BigDecimal payRatio = new BigDecimal(record.getPayRatio()).divide(oneThousand); |
|
|
|
BigDecimal price = revenue.multiply(payRatio).setScale(2,RoundingMode.HALF_EVEN); |
|
|
|
BigDecimal payRatio = new BigDecimal(record.getPayRatio()).divide(hundred); |
|
|
|
BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); |
|
|
|
record.setPrice(price.multiply(hundred).intValue()); |
|
|
|
} |
|
|
|
if(record.getPrice()==null || record.getPrice().intValue()==0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"租金不能为空且大于0"); |
|
|
|
if (record.getPrice() == null || record.getPrice().intValue() == 0) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "租金不能为空且大于0"); |
|
|
|
} |
|
|
|
if(record.getDeposit()==null || record.getDeposit().intValue()==0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"押金不能为空且大于0"); |
|
|
|
if (record.getDeposit() == null || record.getDeposit().intValue() == 0) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "押金不能为空且大于0"); |
|
|
|
} |
|
|
|
|
|
|
|
record.setUpdatetime(new Date()); |
|
|
|
@@ -177,7 +186,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
&& !rc.get("status").equals(EnumRentContractStatus.INVALID.getCode()) |
|
|
|
&& !rc.get("status").equals(EnumRentContractStatus.CONTRACT_END.getCode()) |
|
|
|
&& !rc.get("id").equals(wxRentContract.getId())).count(); |
|
|
|
if(count>0){ |
|
|
|
if (count > 0) { |
|
|
|
return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND); |
|
|
|
} |
|
|
|
wxRentContractMapper.updateByPrimaryKeySelective(record); |
|
|
|
@@ -422,9 +431,9 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
HashMap<String, Object> shopMap = new HashMap<>(3); |
|
|
|
int rentedCount = rentedList.size(); |
|
|
|
int unrentedCount = unrentedList.size(); |
|
|
|
shopMap.put("rentedCount",rentedCount); |
|
|
|
shopMap.put("unrentedCount",unrentedCount); |
|
|
|
shopMap.put("allCount",rentedCount+unrentedCount); |
|
|
|
shopMap.put("rentedCount", rentedCount); |
|
|
|
shopMap.put("unrentedCount", unrentedCount); |
|
|
|
shopMap.put("allCount", rentedCount + unrentedCount); |
|
|
|
resultData.put("shopCountInfo", shopMap); |
|
|
|
|
|
|
|
//需要更新的状态 |
|
|
|
@@ -447,15 +456,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
//停用商户 |
|
|
|
wxMerchantService.disable(wxRentContract.getMerchantId()); |
|
|
|
//物业合同终止 |
|
|
|
if(status==1){ |
|
|
|
if (status == 1) { |
|
|
|
WxPropertyContract wxPropertyContract = new WxPropertyContract(); |
|
|
|
wxRentContract.setTenantId(wxRentContract.getTenantId()); |
|
|
|
wxPropertyContract.setRentContractId(id); |
|
|
|
List<Map<String, Object>> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContract); |
|
|
|
if(contractData.size()>0){ |
|
|
|
if (contractData.size() > 0) { |
|
|
|
Map<String, Object> propertyContract = contractData.get(0); |
|
|
|
Long propertyContractId = (Long) propertyContract.get("id"); |
|
|
|
if(propertyContract!=null && propertyContractId!=null){ |
|
|
|
if (propertyContract != null && propertyContractId != null) { |
|
|
|
WxPropertyContract propertyContractUpdate = wxPropertyContractMapper.selectByPrimaryKey(propertyContractId); |
|
|
|
propertyContractUpdate.setStatus(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()); |
|
|
|
propertyContractUpdate.setUpdatetime(new Date()); |
|
|
|
@@ -540,14 +549,14 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
wxRentContract.setTenantId(tenantId); |
|
|
|
wxRentContract.setStatus(EnumRentContractStatus.CONTRACT_END.getCode()); |
|
|
|
List<Map<String, Object>> rentContractData = wxRentContractMapper.queryRentContractData(wxRentContract); |
|
|
|
for(int i=0,size=rentContractData.size();i<size;i++){ |
|
|
|
for (int i = 0, size = rentContractData.size(); i < size; i++) { |
|
|
|
Map<String, Object> contract = rentContractData.get(i); |
|
|
|
Object merchantId = contract.get("merchantId"); |
|
|
|
if(merchantId!=null){ |
|
|
|
if (merchantId != null) { |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(merchantId); |
|
|
|
Integer status = merchant.getStatus(); |
|
|
|
if(status.equals(EnumMerchantStatus.VALID.getCode())){ |
|
|
|
wxMerchantService.disable((Long)merchantId); |
|
|
|
if (status.equals(EnumMerchantStatus.VALID.getCode())) { |
|
|
|
wxMerchantService.disable((Long) merchantId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -621,4 +630,360 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportContract(HttpServletRequest request, HttpServletResponse response, String tenantId) { |
|
|
|
String id = request.getParameter("id"); |
|
|
|
String contracType = "0"; |
|
|
|
String templatePath = null; |
|
|
|
Map<String, Object> result = null; |
|
|
|
if (EnumContractType.ALL.getCode().toString().equals(contracType)) { |
|
|
|
logger.info("获取租赁及物业合同数据"); |
|
|
|
result = getRentAndPropertyInfo(id); |
|
|
|
result.put("contractType",EnumContractType.ALL.getMessage()); |
|
|
|
templatePath = "contract-word-template/contract_rent_property.docx"; |
|
|
|
logger.info("租赁及物业合同数据结果:" + result); |
|
|
|
} |
|
|
|
|
|
|
|
if (templatePath == null) { |
|
|
|
logger.info("没有租赁及物业合同模板"); |
|
|
|
return; |
|
|
|
} |
|
|
|
String filepath = Constant.fileDirectory; |
|
|
|
String filename = UUID.randomUUID() + ".docx"; |
|
|
|
exportWord(templatePath, filepath, filename, result, request, response); |
|
|
|
} |
|
|
|
|
|
|
|
public Map<String, Object> getRentAndPropertyInfo(String id) { |
|
|
|
logger.info("获取租赁物业合同数据>>>>>>id:"+id); |
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(id); |
|
|
|
WxShop record = new WxShop(); |
|
|
|
record.setId(wxRentContract.getShopId()); |
|
|
|
Map<String, Object> wxShop = wxShopMapper.findListMap(record).get(0); |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
//MALL信息 |
|
|
|
WxMall wxMall = new WxMall(); |
|
|
|
wxMall.setTenantId(wxRentContract.getTenantId()); |
|
|
|
wxMall = wxMallMapper.findList(wxMall).get(0); |
|
|
|
result.put("mallName", wxMall.getName()); |
|
|
|
result.put("province", wxMall.getProvince()); |
|
|
|
result.put("city", wxMall.getCity()); |
|
|
|
//经营业态 |
|
|
|
WxBusiness wxBusiness = wxBusinessMapper.selectByPrimaryKey(wxRentContract.getBusinessId()); |
|
|
|
result.put("business", wxBusiness.getTitle()); |
|
|
|
//店铺信息 |
|
|
|
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")); |
|
|
|
//商户信息 |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(wxRentContract.getMerchantId()); |
|
|
|
result.put("corpPapersNumber", merchant.getCorpPapersNumber()!=null?merchant.getCorpPapersNumber():" "); |
|
|
|
result.put("corpPapersType", merchant.getCorpPapersType()!=null?EnumPapersType.getEnum(merchant.getCorpPapersType()).getMessage():" "); |
|
|
|
result.put("corpPapersPerson", merchant.getCorpPapersPerson()!=null?merchant.getCorpPapersPerson():" "); |
|
|
|
result.put("taxPapersType", merchant.getTaxPapersType()!=null?EnumTaxpayerType.getEnum(merchant.getTaxPapersType()).getMessage():" "); |
|
|
|
result.put("bankName", merchant.getBankName()!=null?merchant.getBankName():" "); |
|
|
|
result.put("bankAccount", merchant.getBankAccount()!=null?merchant.getBankAccount():" "); |
|
|
|
result.put("invoiceAddressPhone", merchant.getInvoiceAddressPhone()!=null?merchant.getInvoiceAddressPhone():" "); |
|
|
|
//租赁合同信息 |
|
|
|
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); |
|
|
|
result.put("payAccount", wxRentContract.getPayAccount().equals("") ? " " : wxRentContract.getPayAccount()); |
|
|
|
result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd")); |
|
|
|
result.put("brand", wxRentContract.getBrand()); |
|
|
|
double adjustRatio = wxRentContract.getAdjustRatio()!=null?wxRentContract.getAdjustRatio() / 100.0:0; |
|
|
|
result.put("adjustRatio", adjustRatio); |
|
|
|
double priceRent = new BigDecimal(wxRentContract.getPrice()) |
|
|
|
.divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
|
|
|
result.put("priceRent",priceRent); |
|
|
|
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",digitUppercase(priceRent)); |
|
|
|
result.put("unitPriceRentUpper", digitUppercase(unitPrice)); |
|
|
|
//租赁保证金 |
|
|
|
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", digitUppercase(cashDepositRent)); |
|
|
|
|
|
|
|
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); |
|
|
|
//常规租期 |
|
|
|
for (int i = 0; i < count; i++) { |
|
|
|
//开始时间 |
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
instance.setTime(wxRentContract.getRentalStartDate()); |
|
|
|
instance.add(Calendar.MONTH, lease*i); |
|
|
|
Date starttime = instance.getTime(); |
|
|
|
String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); |
|
|
|
result.put("rentalStartDate"+i,startdate); |
|
|
|
result.put("rentalStartDateYear"+i, startdate.substring(0, 4)); |
|
|
|
result.put("rentalStartDateMonth"+i, startdate.substring(5, 7)); |
|
|
|
result.put("rentalStartDateDay"+i, startdate.substring(8)); |
|
|
|
//结束时间 |
|
|
|
instance.clear(); |
|
|
|
instance.setTime(starttime); |
|
|
|
instance.add(Calendar.MONTH, lease); |
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
Date endtime = instance.getTime(); |
|
|
|
String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); |
|
|
|
result.put("rentalEndDate"+i,enddate); |
|
|
|
result.put("rentalEndDateYear"+i, enddate.substring(0, 4)); |
|
|
|
result.put("rentalEndDateMonth"+i, enddate.substring(5, 7)); |
|
|
|
result.put("rentalEndDateDay"+i, enddate.substring(8)); |
|
|
|
if(i>0){ |
|
|
|
rentPrice = rentPrice.multiply(new BigDecimal(adjustRatio)) |
|
|
|
.add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); |
|
|
|
result.put("priceRentUpper"+i,digitUppercase(rentPrice.doubleValue())); |
|
|
|
result.put("priceRent"+i,digitUppercase(rentPrice.doubleValue())); |
|
|
|
} |
|
|
|
} |
|
|
|
if(extracount>0){ |
|
|
|
//额外租期 |
|
|
|
//开始时间 |
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
instance.setTime(wxRentContract.getRentalStartDate()); |
|
|
|
instance.add(Calendar.MONTH, lease*count); |
|
|
|
Date starttime = instance.getTime(); |
|
|
|
String startdate = DateUtils.date2String(starttime, "yyyy-MM-dd"); |
|
|
|
result.put("rentalStartDate"+count,startdate); |
|
|
|
result.put("rentalStartDateYear"+count, startdate.substring(0, 4)); |
|
|
|
result.put("rentalStartDateMonth"+count, startdate.substring(5, 7)); |
|
|
|
result.put("rentalStartDateDay"+count, startdate.substring(8)); |
|
|
|
//结束时间 |
|
|
|
instance.clear(); |
|
|
|
instance.setTime(starttime); |
|
|
|
instance.add(Calendar.MONTH, extralease); |
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
Date endtime = instance.getTime(); |
|
|
|
String enddate = DateUtils.date2String(endtime, "yyyy-MM-dd"); |
|
|
|
result.put("rentalEndDate"+count,enddate); |
|
|
|
result.put("rentalEndDateYear"+count, enddate.substring(0, 4)); |
|
|
|
result.put("rentalEndDateMonth"+count, enddate.substring(5, 7)); |
|
|
|
result.put("rentalEndDateDay"+count, enddate.substring(8)); |
|
|
|
|
|
|
|
rentPrice = rentPrice.multiply(new BigDecimal(adjustRatio)) |
|
|
|
.add(rentPrice).setScale(2, RoundingMode.HALF_EVEN); |
|
|
|
result.put("priceRentUpper"+count,digitUppercase(rentPrice.doubleValue())); |
|
|
|
result.put("priceRent"+count,digitUppercase(rentPrice.doubleValue())); |
|
|
|
|
|
|
|
} |
|
|
|
//无数据租期 |
|
|
|
for(int i=paycount;i<index;i++){ |
|
|
|
result.put("rentalStartDate"+i,"/"); |
|
|
|
result.put("rentalStartDateYear"+i, "/"); |
|
|
|
result.put("rentalStartDateMonth"+i, "/"); |
|
|
|
result.put("rentalStartDateDay"+i, "/"); |
|
|
|
result.put("rentalEndDate"+i,"/"); |
|
|
|
result.put("rentalEndDateYear"+i, "/"); |
|
|
|
result.put("rentalEndDateMonth"+i, "/"); |
|
|
|
result.put("rentalEndDateDay"+i, "/"); |
|
|
|
result.put("priceRentUpper"+i,"/"); |
|
|
|
result.put("priceRent"+i,"/"); |
|
|
|
} |
|
|
|
|
|
|
|
//物业合同信息 |
|
|
|
WxPropertyContract propertyContract = new WxPropertyContract(); |
|
|
|
propertyContract.setTenantId(wxRentContract.getTenantId()); |
|
|
|
propertyContract.setRentContractId(wxRentContract.getId()); |
|
|
|
Optional<Map<String, Object>> 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())).findFirst(); |
|
|
|
Map<String, Object> 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); |
|
|
|
double unitPriceProperty = new BigDecimal(wxPropertyContract.get("price").toString()) |
|
|
|
.divide(new BigDecimal(wxRentContract.getRentArea()) |
|
|
|
.divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN)).doubleValue(); |
|
|
|
result.put("unitPriceProperty", unitPriceProperty); |
|
|
|
result.put("pricePropertyUpper",digitUppercase(priceProperty)); |
|
|
|
result.put("unitPricePropertyUpper", digitUppercase(unitPriceProperty)); |
|
|
|
//首期物业费 |
|
|
|
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",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", 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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出word |
|
|
|
* <p>第一步生成替换后的word文件,只支持docx</p> |
|
|
|
* <p>第二步下载生成的文件</p> |
|
|
|
* <p>第三步删除生成的临时文件</p> |
|
|
|
* 模版变量中变量格式:{{foo}} |
|
|
|
* |
|
|
|
* @param templatePath word模板地址 |
|
|
|
* @param temDir 生成临时文件存放地址 |
|
|
|
* @param fileName 文件名 |
|
|
|
* @param params 替换的参数 |
|
|
|
* @param request HttpServletRequest |
|
|
|
* @param response HttpServletResponse |
|
|
|
*/ |
|
|
|
public void exportWord(String templatePath, String temDir, String fileName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) { |
|
|
|
Assert.notNull(templatePath, "模板路径不能为空"); |
|
|
|
Assert.notNull(temDir, "临时文件路径不能为空"); |
|
|
|
Assert.notNull(fileName, "导出文件名不能为空"); |
|
|
|
Assert.isTrue(fileName.endsWith(".docx"), "word导出请使用docx格式"); |
|
|
|
if (!temDir.endsWith("/")) { |
|
|
|
temDir = temDir + File.separator; |
|
|
|
} |
|
|
|
File dir = new File(temDir); |
|
|
|
if (!dir.exists()) { |
|
|
|
dir.mkdirs(); |
|
|
|
} |
|
|
|
try { |
|
|
|
String userAgent = request.getHeader("user-agent").toLowerCase(); |
|
|
|
if (userAgent.contains("msie") || userAgent.contains("like gecko")) { |
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8"); |
|
|
|
} else { |
|
|
|
fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1"); |
|
|
|
} |
|
|
|
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, params); |
|
|
|
String tmpPath = temDir + fileName; |
|
|
|
FileOutputStream fos = new FileOutputStream(tmpPath); |
|
|
|
doc.write(fos); |
|
|
|
// 设置强制下载不打开 |
|
|
|
response.setContentType("application/force-download"); |
|
|
|
// 设置文件名 |
|
|
|
response.addHeader("Content-Disposition", "attachment;fileName=" + fileName); |
|
|
|
OutputStream out = response.getOutputStream(); |
|
|
|
doc.write(out); |
|
|
|
out.close(); |
|
|
|
FileUtils.forceDelete(new File(tmpPath)); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
BigDecimal multiply = new BigDecimal(8059.99).multiply(new BigDecimal(0.07)); |
|
|
|
BigDecimal add = multiply.add(new BigDecimal(8059.99)).setScale(2,RoundingMode.HALF_EVEN); |
|
|
|
System.out.println(add.doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 数字金额大写转换,思想先写个完整的然后将如零拾替换成零 要用到正则表达式 |
|
|
|
*/ |
|
|
|
public static String digitUppercase(double n) { |
|
|
|
String fraction[] = {"角", "分"}; |
|
|
|
String digit[] = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; |
|
|
|
String unit[][] = {{"圆", "万", "亿"}, {"", "拾", "佰", "仟"}}; |
|
|
|
|
|
|
|
String head = n < 0 ? "负" : ""; |
|
|
|
n = Math.abs(n); |
|
|
|
|
|
|
|
String s = ""; |
|
|
|
for (int i = 0; i < fraction.length; i++) { |
|
|
|
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", ""); |
|
|
|
} |
|
|
|
if (s.length() < 1) { |
|
|
|
s = "整"; |
|
|
|
} |
|
|
|
int integerPart = (int) Math.floor(n); |
|
|
|
|
|
|
|
for (int i = 0; i < unit[0].length && integerPart > 0; i++) { |
|
|
|
String p = ""; |
|
|
|
for (int j = 0; j < unit[1].length && n > 0; j++) { |
|
|
|
p = digit[integerPart % 10] + unit[1][j] + p; |
|
|
|
integerPart = integerPart / 10; |
|
|
|
} |
|
|
|
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s; |
|
|
|
} |
|
|
|
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); |
|
|
|
} |
|
|
|
|
|
|
|
} |