|
|
|
@@ -1019,7 +1019,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
String price = wxRentContract.getPrice();
|
|
|
|
if(EnumContractOperationType.JINMAO.getCode().equals(wxRentContract.getOperationType())){
|
|
|
|
Date startDate = wxRentContract.getStartDate();
|
|
|
|
rentList = buildRentJinmao(user, wxRentContract, receivePeriod, lease, startDate, price, isPreview,saveDb);
|
|
|
|
//rentList = buildRentJinmao(user, wxRentContract, receivePeriod, lease, startDate, price, isPreview,saveDb);
|
|
|
|
}else{
|
|
|
|
rentList = buildRentMonth(user, wxRentContract, receivePeriod, lease, rentalStartDate, isPreview,saveDb);
|
|
|
|
}
|
|
|
|
@@ -1067,106 +1067,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
return resultList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<WxAllBill> buildRentJinmao(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview, boolean saveDb) {
|
|
|
|
int size = 0;
|
|
|
|
String[] priceArrs = null;
|
|
|
|
if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_AREA.getCode())){
|
|
|
|
|
|
|
|
String adjustRatio = wxRentContract.getAdjustRatio();
|
|
|
|
JSONArray array = JSONArray.parseArray(adjustRatio);
|
|
|
|
List<Integer> integers = new ArrayList<>();
|
|
|
|
if(array != null && array.size() > 0){
|
|
|
|
for (int i=0;i<array.size();i++){
|
|
|
|
JSONObject jsonObject = array.getJSONObject(i);
|
|
|
|
String increasingProportion = jsonObject.getString("increasingProportion");
|
|
|
|
if(StringUtils.isNotBlank(increasingProportion) && !"0".equals(increasingProportion)){
|
|
|
|
int ratio = new BigDecimal(increasingProportion).multiply(new BigDecimal(100)).intValue();
|
|
|
|
integers.add(ratio);
|
|
|
|
}else{
|
|
|
|
integers.add(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
integers.add(0, 0);
|
|
|
|
size = integers.size();
|
|
|
|
priceArrs = new String[size];
|
|
|
|
priceArrs[0] = price;
|
|
|
|
BigDecimal priceD = new BigDecimal(price);
|
|
|
|
if (wxRentContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.RATIO.getCode())) {
|
|
|
|
for (int i = 1; i < size; i++) {
|
|
|
|
BigDecimal divide = priceD.multiply(new BigDecimal(integers.get(i))).divide(new BigDecimal(100));
|
|
|
|
logger.info("价格算法------递增前价格:"+priceD.doubleValue()+" 递增率:"+integers.get(i)+" 递增价格:"+divide.doubleValue());
|
|
|
|
priceD = priceD.add(divide);
|
|
|
|
priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if (wxRentContract.getType().equals(EnumRentContractType.RENT_BY_CUSTOMIZE.getCode())) {
|
|
|
|
String adjustRatio = wxRentContract.getAdjustRatio();
|
|
|
|
JSONArray array = JSONArray.parseArray(adjustRatio);
|
|
|
|
if(array != null && array.size() > 0){
|
|
|
|
priceArrs = new String[array.size()];
|
|
|
|
size = array.size();
|
|
|
|
for (int i=0;i<array.size();i++){
|
|
|
|
JSONObject jsonObject = array.getJSONObject(i);
|
|
|
|
String perMonthMoney = jsonObject.getString("perMonthMoney");
|
|
|
|
if(StringUtils.isNotBlank(perMonthMoney) && !"0".equals(perMonthMoney)){
|
|
|
|
BigDecimal priceD = new BigDecimal(perMonthMoney);
|
|
|
|
priceArrs[i] = priceD.setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN).toPlainString();
|
|
|
|
}else{
|
|
|
|
priceArrs[i] = "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
size = 1;
|
|
|
|
priceArrs = new String[size];
|
|
|
|
priceArrs[0] = "0";
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
return new ArrayList<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
int month = 12;
|
|
|
|
// int divide = lease / month;
|
|
|
|
// int mod = lease % month;
|
|
|
|
// int[] leaseArr = new int[size];
|
|
|
|
// for (int i = 0; i < divide; i++) {
|
|
|
|
// leaseArr[i] = month;
|
|
|
|
// }
|
|
|
|
// if (mod > 0) {
|
|
|
|
// leaseArr[divide] = mod;
|
|
|
|
// }
|
|
|
|
|
|
|
|
int billcount = 0;
|
|
|
|
List<WxAllBill> resultList = new ArrayList<WxAllBill>();
|
|
|
|
|
|
|
|
List<Date> yearList = new ArrayList<>();
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
Calendar instance = Calendar.getInstance();
|
|
|
|
Date startDate;
|
|
|
|
//自然月
|
|
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
|
|
|
|
if(i == 0){ //第一期
|
|
|
|
startDate = rentalStartDate;
|
|
|
|
}else{
|
|
|
|
instance.setTime(rentalStartDate);
|
|
|
|
instance.add(Calendar.MONTH, month * i);
|
|
|
|
startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime());
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
instance.setTime(rentalStartDate);
|
|
|
|
instance.add(Calendar.MONTH, month * i);
|
|
|
|
startDate = instance.getTime();
|
|
|
|
}
|
|
|
|
yearList.add(startDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
String shopInfoStr = getShopInfoStr(wxRentContract);
|
|
|
|
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,null,null, yearList, Calendar.MONTH, wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb);
|
|
|
|
List<WxAllBill> billRentList = (List<WxAllBill>)resultMap.get("billList");
|
|
|
|
resultList.addAll(billRentList);
|
|
|
|
return resultList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getShopInfoStr(WxRentContract wxRentContract){
|
|
|
|
String shopInfoStr = null;
|
|
|
|
// if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
|
|
|
|
@@ -1748,143 +1648,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void areaWay(WxRentContract wxRentContract, Map<String, Object> result, Integer lease, int extralease, int extracount, int paycount, int index, int count, BigDecimal rentPrice) {
|
|
|
|
|
|
|
|
String[] priceArrs = new String[]{};
|
|
|
|
List<String> adjustRatioList = new ArrayList<>();
|
|
|
|
adjustRatioList.add(0, "0");
|
|
|
|
if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
|
|
|
|
String rentInfo = wxRentContract.getRentInfo();
|
|
|
|
JSONArray objects = JSONArray.parseArray(rentInfo);
|
|
|
|
JSONObject jsonObject = objects.getJSONObject(0);
|
|
|
|
JSONArray adjustRatio = jsonObject.getJSONArray("adjustRatio");
|
|
|
|
for (int i = 0, size = adjustRatio.size(); i < size; i++) {
|
|
|
|
StringBuffer adjustRatioStr = new StringBuffer();
|
|
|
|
for (int j = 0, shopSize = objects.size(); j < shopSize; j++) {
|
|
|
|
JSONObject shopObject = objects.getJSONObject(j);
|
|
|
|
JSONArray adjustRatioArr = shopObject.getJSONArray("adjustRatio");
|
|
|
|
String shopNumber = shopObject.getString("shopNumber");
|
|
|
|
adjustRatioStr.append(shopNumber).append("[").append(adjustRatioArr.getString(i)).append("]");
|
|
|
|
}
|
|
|
|
adjustRatioList.add(adjustRatioStr.toString());
|
|
|
|
}
|
|
|
|
List<String[]> priceList = WxRentContractHelper.computeRentPriceByShop(wxRentContract);
|
|
|
|
int size = priceList.size();
|
|
|
|
priceArrs = new String[size];
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
String[] priceInt = priceList.get(i);
|
|
|
|
BigDecimal sum = new BigDecimal(0);
|
|
|
|
for (String p : priceInt) {
|
|
|
|
sum = sum.add(new BigDecimal(p));
|
|
|
|
}
|
|
|
|
priceArrs[i] = sum.toPlainString();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
String adjustRatio = wxRentContract.getAdjustRatio();
|
|
|
|
List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class);
|
|
|
|
for (int i = 0, size = integers.size(); i < size; i++) {
|
|
|
|
double ratioStr = new BigDecimal(integers.get(i)).divide(new BigDecimal(100)).doubleValue();
|
|
|
|
adjustRatioList.add(String.valueOf(ratioStr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String payRatioStr = "0";
|
|
|
|
if (wxRentContract.getPayRatio() != null) {
|
|
|
|
payRatioStr = new BigDecimal(wxRentContract.getPayRatio()).divide(new BigDecimal(100)).toPlainString();
|
|
|
|
}
|
|
|
|
//常规租期
|
|
|
|
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 (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
|
|
|
|
rentPrice = new BigDecimal(priceArrs[i]).divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN);
|
|
|
|
result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue()));
|
|
|
|
result.put("priceRent" + i, rentPrice.toPlainString());
|
|
|
|
result.put("adjustRatio" + i, adjustRatioList.get(i));
|
|
|
|
} else {
|
|
|
|
rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(i)))
|
|
|
|
.add(rentPrice).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN);
|
|
|
|
result.put("priceRentUpper" + i, PriceUtil.digitUppercase(rentPrice.doubleValue()));
|
|
|
|
result.put("priceRent" + i, rentPrice.toPlainString());
|
|
|
|
result.put("adjustRatio" + i, adjustRatioList.get(i));
|
|
|
|
}
|
|
|
|
result.put("payRatio" + i, payRatioStr);
|
|
|
|
result.put("adjustPeriod" + i, wxRentContract.getAdjustPeriod());
|
|
|
|
}
|
|
|
|
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));
|
|
|
|
|
|
|
|
if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
|
|
|
|
rentPrice = new BigDecimal(priceArrs[count]).divide(new BigDecimal(100)).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN);
|
|
|
|
result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue()));
|
|
|
|
result.put("priceRent" + count, rentPrice.toPlainString());
|
|
|
|
} else {
|
|
|
|
rentPrice = rentPrice.multiply(new BigDecimal(adjustRatioList.get(count)))
|
|
|
|
.add(rentPrice).setScale(wxRentContract.getDecimalSize(), RoundingMode.HALF_EVEN);
|
|
|
|
result.put("priceRentUpper" + count, PriceUtil.digitUppercase(rentPrice.doubleValue()));
|
|
|
|
result.put("priceRent" + count, rentPrice.toPlainString());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//无数据租期
|
|
|
|
for (int i = paycount; i <= 10; 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, "/");
|
|
|
|
result.put("adjustRatio" + i, "/");
|
|
|
|
result.put("payRatio" + i, "/");
|
|
|
|
result.put("adjustPeriod" + i, "/");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateApplyStatus(WxRentContract wxRentContract) {
|
|
|
|
wxRentContractMapper.updateApplyStatus(wxRentContract);
|
|
|
|
@@ -2351,8 +2114,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
@Override
|
|
|
|
public List<WxRentContractYearsVo> getRentContractYears(WxRentContract rentContract) {
|
|
|
|
String adjustRatio = rentContract.getAdjustRatio();
|
|
|
|
List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class);
|
|
|
|
integers.add(0, 0);
|
|
|
|
List<String> integers = JSONArray.parseArray(adjustRatio, String.class);
|
|
|
|
integers.add(0, "0");
|
|
|
|
int years = integers.size();
|
|
|
|
//合同以什么日期来计算开始计租日期
|
|
|
|
if(rentContract.getRentStartType()!=null &&rentContract.getRentStartType().equals(EnumRentStartType.STARTTIME.getCode())){
|
|
|
|
|