@@ -33,7 +33,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
/**
@@ -140,6 +139,16 @@ public class WxRentContractServiceImpl implements WxRentContractService {
record.setEndDate(record.getStartDate());
}
if (record.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) {
BigDecimal hundred = new BigDecimal(100);
BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred);
BigDecimal payRatio = new BigDecimal(record.getPayRatio() == null ? 0 : record.getPayRatio()).divide(hundred);
BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN);
record.setPrice(price.multiply(hundred).intValue());
}
record.setPrice(record.getPrice() == null ? 0 : record.getPrice());
record.setDeposit(record.getDeposit() == null ? 0 : record.getDeposit());
Date date = new Date();
record.setCreatetime(date);
record.setUpdatetime(date);
@@ -417,9 +426,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
pDest.mkdirs();
}
try {
String exportFileName=wxRentContract.getFilename()+filesuffix;
String exportFileName = wxRentContract.getFilename() + filesuffix;
downLoadFromUrl(wxRentContract.getFilepath(), filename, filepath);
downFile(destPath, wxRentContract.getFilename(),exportFileName, response, request);
downFile(destPath, wxRentContract.getFilename(), exportFileName, response, request);
org.apache.commons.io.FileUtils.forceDelete(dest);
} catch (IOException e) {
logger.info("创建本地文件失败" + e.getMessage());
@@ -665,7 +674,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
String filepath = Constant.fileDirectory;
String filename = UUID.randomUUID() + ".docx";
String exportFileName = result.get("merchantName").toString() + "合同.docx";
exportWord(templatePath, filepath, filename, exportFileName,result, request, response);
exportWord(templatePath, filepath, filename, exportFileName, result, request, response);
}
@Override
@@ -697,7 +706,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
buildDeposit(wxMerchant);
}
}
return new ResultData(Result.SUCCESS,"操作成功") ;
return new ResultData(Result.SUCCESS, "操作成功");
}
public Map<String, Object> getRentAndPropertyInfo(Long id) {
@@ -725,8 +734,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
result.put("operationArea", wxShop.get("operationArea"));
//商户信息
WxMerchant merchant = wxMerchantService.getById(wxRentContract.getMerchantId());
if (merchant!=null) {
result.put("merchantName",merchant.getName());
if (merchant != null) {
result.put("merchantName", merchant.getName());
//法人信息
WxMerchantCorp wxMerchantCorp = merchant.getWxMerchantCorp();
result.put("corpPapersNumber", StringUtils.isNotEmpty(wxMerchantCorp.getCorpPapersNumber()) ? wxMerchantCorp.getCorpPapersNumber() : " ");
@@ -739,7 +748,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
result.put("bankAccount", StringUtils.isNotEmpty(wxMerchantTax.getBankAccount()) ? wxMerchantTax.getBankAccount() : " ");
result.put("invoiceAddressPhone", StringUtils.isNotEmpty(wxMerchantTax.getInvoiceAddressPhone()) ? wxMerchantTax.getInvoiceAddressPhone() : " ");
} else {
result.put("merchantName","");
result.put("merchantName", "");
//法人信息
result.put("corpPapersNumber", " ");
result.put("corpPapersType", " ");
@@ -771,11 +780,11 @@ public class WxRentContractServiceImpl implements WxRentContractService {
result.put("signDate", DateUtils.date2String(wxRentContract.getSignDate(), "yyyy-MM-dd"));
//品牌
Long brandId = wxRentContract.getBrand();
String brand=" ";
if(brandId!=null){
String brand = " ";
if (brandId != null) {
WxBrand wxBrand = WxBrandMapper.selectByPrimaryKey(brandId);
if(wxBrand!=null){
brand=wxBrand.getName();
if (wxBrand != null) {
brand = wxBrand.getName();
}
}
result.put("brand", brand);
@@ -830,8 +839,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
.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()),2,RoundingMode.HALF_EVEN)
.divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
.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", digitUppercase(priceProperty));
result.put("unitPricePropertyUpper", digitUppercase(unitPriceProperty));
@@ -904,7 +913,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
double payRatio = wxRentContract.getPayRatio() != null ? wxRentContract.getPayRatio() / 100.0 : 0;
//常规租期
for (int i = 0; i <=count; i++) {
for (int i = 0; i <= count; i++) {
//开始时间
Calendar instance = Calendar.getInstance();
instance.setTime(wxRentContract.getRentalStartDate());
@@ -977,7 +986,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, double adjustRatio, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) {
//常规租期
for (int i = 0; i <=count; i++) {
for (int i = 0; i <= count; i++) {
//开始时间
Calendar instance = Calendar.getInstance();
instance.setTime(wxRentContract.getRentalStartDate());
@@ -1068,7 +1077,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
* @param request HttpServletRequest
* @param response HttpServletResponse
*/
public void exportWord(String templatePath, String temDir, String fileName, String exportFileName,Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
public void exportWord(String templatePath, String temDir, String fileName, String exportFileName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
Assert.notNull(templatePath, "模板路径不能为空");
Assert.notNull(temDir, "临时文件路径不能为空");
Assert.notNull(exportFileName, "导出文件名不能为空");