Просмотр исходного кода

[合同][修改][自定义年租金调整]

release_toaliyun_real
gongbiao 6 лет назад
Родитель
Сommit
fa0d7fb6af
3 измененных файлов: 387 добавлений и 348 удалений
  1. +2
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumRentContractAdjustRatioWay.java
  2. +110
    -103
      mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java
  3. +275
    -244
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java

+ 2
- 1
mallinkService/src/main/java/com/iformall/enums/EnumRentContractAdjustRatioWay.java Просмотреть файл

@@ -8,7 +8,8 @@ package com.iformall.enums;
public enum EnumRentContractAdjustRatioWay { public enum EnumRentContractAdjustRatioWay {


RATIO(1, "按比例"), RATIO(1, "按比例"),
MONEY(2, "按金额"),;
MONEY(2, "按金额"),
CUSTOM(3, "自定义"),;


public static EnumRentContractAdjustRatioWay getEnum(Integer code) { public static EnumRentContractAdjustRatioWay getEnum(Integer code) {
for (EnumRentContractAdjustRatioWay value : values()) { for (EnumRentContractAdjustRatioWay value : values()) {


+ 110
- 103
mallinkService/src/main/java/com/iformall/service/impl/WxPropertyContractServiceImpl.java Просмотреть файл

@@ -97,26 +97,26 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
} }


//init dateDiff //init dateDiff
if(wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null){
if (wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null) {
//加1天 //加1天
Date newEndDate = DateUtils.getDaySet(wxPropertyContract.getRentalEndDate(),Calendar.DATE,1);
int[] array = DateUtils.getDiff(wxPropertyContract.getRentalStartDate(),newEndDate);
result.put("totalPeriodMonth",array[0]);
result.put("totalPeriodDay",array[1]);
Date newEndDate = DateUtils.getDaySet(wxPropertyContract.getRentalEndDate(), Calendar.DATE, 1);
int[] array = DateUtils.getDiff(wxPropertyContract.getRentalStartDate(), newEndDate);
result.put("totalPeriodMonth", array[0]);
result.put("totalPeriodDay", array[1]);
} }


//init 租赁单价 //init 租赁单价
String rentInfo = wxPropertyContract.getRentInfo(); String rentInfo = wxPropertyContract.getRentInfo();
if(StringUtils.isNotBlank(rentInfo)){
if (StringUtils.isNotBlank(rentInfo)) {
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size(); int size = rentInfoArray.size();
//查询rent_info 包括shopId //查询rent_info 包括shopId
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
Double rentPrice = rentInfoObject.getDouble("rentPrice"); Double rentPrice = rentInfoObject.getDouble("rentPrice");
Long price = wxPropertyContract.getPrice()/100;
if(rentPrice == null){
if(StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())&& !"0.0".equals(wxPropertyContract.getRentArea()) ) {
Long price = wxPropertyContract.getPrice() / 100;
if (rentPrice == null) {
if (StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea()) && !"0.0".equals(wxPropertyContract.getRentArea())) {
Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()); Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea());
rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
rentInfoObject.put("rentPrice", rentPrice); rentInfoObject.put("rentPrice", rentPrice);
@@ -124,9 +124,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
} }
} }
wxPropertyContract.setRentInfo(rentInfoArray.toJSONString()); wxPropertyContract.setRentInfo(rentInfoArray.toJSONString());
}else{
if(StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())&& !"0.0".equals(wxPropertyContract.getRentArea()) ) {
if(StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())) {
} else {
if (StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea()) && !"0.0".equals(wxPropertyContract.getRentArea())) {
if (StringUtils.isNotBlank(wxPropertyContract.getRentArea()) && !"0".equals(wxPropertyContract.getRentArea()) && !"0.00".equals(wxPropertyContract.getRentArea())) {
Long price = wxPropertyContract.getPrice(); Long price = wxPropertyContract.getPrice();
Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()) * 100; Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()) * 100;
Double rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); Double rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
@@ -139,10 +139,10 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
} }
} }
} }
if(wxPropertyContract.getPriceUnit() == null){
if (wxPropertyContract.getPriceUnit() == null) {
wxPropertyContract.setPriceUnit(EnumPriceUnit.M.getCode()); wxPropertyContract.setPriceUnit(EnumPriceUnit.M.getCode());
} }
if(wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())){
if (wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode())) {
wxPropertyContract.setAdjustPeriod(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()); wxPropertyContract.setAdjustPeriod(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode());
wxPropertyContract.setPriceUnit(EnumPriceUnit.D.getCode()); wxPropertyContract.setPriceUnit(EnumPriceUnit.D.getCode());
} }
@@ -171,13 +171,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
//租赁费用欠缴 //租赁费用欠缴
WxRentContract wxRentContract = new WxRentContract(); WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setId(wxPropertyContract.getRentContractId()); wxRentContract.setId(wxPropertyContract.getRentContractId());
result.put("rentOweCount",wxRentContractMapper.queryOweCount(wxRentContract));
result.put("rentOweCount", wxRentContractMapper.queryOweCount(wxRentContract));
//物业费用欠缴 //物业费用欠缴
WxPropertyContract propertyContract = new WxPropertyContract(); WxPropertyContract propertyContract = new WxPropertyContract();
propertyContract.setId(id); propertyContract.setId(id);
result.put("propertyOweCount",wxPropertyContractMapper.queryOweCount(propertyContract));
result.put("propertyOweCount", wxPropertyContractMapper.queryOweCount(propertyContract));
//押金欠缴 //押金欠缴
result.put("depositOweCount",wxBillPropertyDepositMapper.queryOweCount(propertyContract));
result.put("depositOweCount", wxBillPropertyDepositMapper.queryOweCount(propertyContract));
//押金状态 //押金状态
WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit(); WxBillPropertyDeposit wxBillPropertyDeposit = new WxBillPropertyDeposit();
wxBillPropertyDeposit.setPropertyContractId(id); wxBillPropertyDeposit.setPropertyContractId(id);
@@ -190,8 +190,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
wxFlowRecord.setBusinessId(id); wxFlowRecord.setBusinessId(id);
wxFlowRecord.setStatus(EnumFlowRecordStatus.NEW.getCode()); wxFlowRecord.setStatus(EnumFlowRecordStatus.NEW.getCode());
List<WxFlowRecord> flowRecordList = wxFlowRecordService.findList(wxFlowRecord); List<WxFlowRecord> flowRecordList = wxFlowRecordService.findList(wxFlowRecord);
if(!CollectionUtils.isEmpty(flowRecordList)){
result.put("remark",flowRecordList.get(0).getRemark());
if (!CollectionUtils.isEmpty(flowRecordList)) {
result.put("remark", flowRecordList.get(0).getRemark());
} }


//查询预账单用于展示 //查询预账单用于展示
@@ -212,14 +212,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
/** /**
* 重新生成账单(预账单调整) * 重新生成账单(预账单调整)
*/ */
public void savePreviewBill(WxPropertyContract record){
if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){
public void savePreviewBill(WxPropertyContract record) {
if (CollectionUtils.isEmpty(record.getPreviewBillRentList())) {
return; return;
} }
wxBillPropertyMapper.deletePreviewBill(record); wxBillPropertyMapper.deletePreviewBill(record);
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
int count = 1; int count = 1;
for (WxBillProperty bill:record.getPreviewBillRentList()) {
for (WxBillProperty bill : record.getPreviewBillRentList()) {
bill.setId(idWorker.nextId()); bill.setId(idWorker.nextId());
Date date = new Date(); Date date = new Date();
bill.setPropertyContractId(record.getId()); bill.setPropertyContractId(record.getId());
@@ -238,7 +238,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
bill.setIsDel(EnumDelStatus.NOT_DEL.getCode()); bill.setIsDel(EnumDelStatus.NOT_DEL.getCode());
bill.setShopId(record.getShopId()); bill.setShopId(record.getShopId());
bill.setExpiredDay(0L); bill.setExpiredDay(0L);
setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod());
setExpiredDay(bill, Calendar.MONTH, record.getReceivePeriod());
if (bill.getReceivePay().equals(0L)) { if (bill.getReceivePay().equals(0L)) {
bill.setStatus(EnumBillRentStatus.PAID.getCode()); bill.setStatus(EnumBillRentStatus.PAID.getCode());
bill.setPayDate(date); bill.setPayDate(date);
@@ -253,7 +253,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
public ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName) { public ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName) {
// 保存调整金额(预账单调整) // 保存调整金额(预账单调整)
boolean haspreview = false; boolean haspreview = false;
if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){
if (!CollectionUtils.isEmpty(record.getPreviewBillRentList())) {
savePreviewBill(record); savePreviewBill(record);
haspreview = true; haspreview = true;
} }
@@ -345,7 +345,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
//生成预览账单 //生成预览账单
wxBillPropertyMapper.deletePreviewBill(record); wxBillPropertyMapper.deletePreviewBill(record);
//重新生成 //重新生成
List<WxBillProperty> billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true);
List<WxBillProperty> billList = buildProperty(new WxMerchant(), userId, record, EnumIsPreview.YES.getCode(), true);
record.setPreviewBillRentList(billList); record.setPreviewBillRentList(billList);


message = "保存物业合同信息成功"; message = "保存物业合同信息成功";
@@ -358,13 +358,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
List<WxBillProperty> billList = wxBillPropertyMapper.findList(wxBillRent); List<WxBillProperty> billList = wxBillPropertyMapper.findList(wxBillRent);
record.setPreviewBillRentList(billList); record.setPreviewBillRentList(billList);


if(!haspreview){
if (!haspreview) {
if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) { && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
//删除预账单,重新生成 //删除预账单,重新生成
wxBillPropertyMapper.deletePreviewBill(record); wxBillPropertyMapper.deletePreviewBill(record);
//重新生成 //重新生成
billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true);
billList = buildProperty(new WxMerchant(), userId, record, EnumIsPreview.YES.getCode(), true);
record.setPreviewBillRentList(billList); record.setPreviewBillRentList(billList);
} }
} }
@@ -466,7 +466,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
billProperty.setIsPreview(EnumIsPreview.NO.getCode()); billProperty.setIsPreview(EnumIsPreview.NO.getCode());
billProperty.setMerchantId(record.getMerchantId()); billProperty.setMerchantId(record.getMerchantId());
wxBillPropertyMapper.updatePreviewStatus(billProperty); wxBillPropertyMapper.updatePreviewStatus(billProperty);
if(record.getDeposit() > 0) {
if (record.getDeposit() > 0) {
buildDeposit(record); buildDeposit(record);
} }
} }
@@ -523,7 +523,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
} }
} }


public String getShopInfoStr(WxPropertyContract wxPropertyContract){
public String getShopInfoStr(WxPropertyContract wxPropertyContract) {
String rentInfo = wxPropertyContract.getRentInfo(); String rentInfo = wxPropertyContract.getRentInfo();
Map<String, Object> shopInfo = new HashMap<>(); Map<String, Object> shopInfo = new HashMap<>();
if (rentInfo != null) { if (rentInfo != null) {
@@ -536,7 +536,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
return JSONObject.toJSONString(shopInfo); return JSONObject.toJSONString(shopInfo);
} }


public List<WxBillProperty> buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview,boolean saveDb) {
public List<WxBillProperty> buildRentMonth(WxMerchant wxMerchant, Long userId, WxPropertyContract wxPropertyContract, int receivePeriod, Integer lease, Date rentalStartDate, Long price, Integer isPreview, boolean saveDb) {
String adjustRatio = wxPropertyContract.getAdjustRatio(); String adjustRatio = wxPropertyContract.getAdjustRatio();
String rentInfo = wxPropertyContract.getRentInfo(); String rentInfo = wxPropertyContract.getRentInfo();
Map<String, Object> shopInfo = new HashMap<>(); Map<String, Object> shopInfo = new HashMap<>();
@@ -560,14 +560,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
priceD = priceD + priceD * integers.get(i) / 10000.0; priceD = priceD + priceD * integers.get(i) / 10000.0;
priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue(); priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue();
} }
} else {
} else if (wxPropertyContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) {
long priceD = price; long priceD = price;
for (int i = 1; i < size; i++) { for (int i = 1; i < size; i++) {
priceD = priceD + integers.get(i); priceD = priceD + integers.get(i);
priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue(); priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue();
} }
} else {
for (int i = 1; i < size; i++) {
priceArr[i] = new BigDecimal(integers.get(i)).setScale(0, RoundingMode.HALF_EVEN).longValue();
}
} }



int month = 12; int month = 12;
int divide = lease / month; int divide = lease / month;
int mod = lease % month; int mod = lease % month;
@@ -587,89 +592,90 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
Calendar instance = Calendar.getInstance(); Calendar instance = Calendar.getInstance();
Date startDate; Date startDate;
//自然月 //自然月
if(wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
if(i == 0){ //第一期
if (wxPropertyContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) {
if (i == 0) { //第一期
startDate = rentalStartDate; startDate = rentalStartDate;
}else{
} else {
instance.setTime(rentalStartDate); instance.setTime(rentalStartDate);
instance.add(Calendar.MONTH, month * i); instance.add(Calendar.MONTH, month * i);
startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime()); startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime());
} }
}else{
} else {
instance.setTime(rentalStartDate); instance.setTime(rentalStartDate);
instance.add(Calendar.MONTH, month * i); instance.add(Calendar.MONTH, month * i);
startDate = instance.getTime(); startDate = instance.getTime();
} }
yearList.add(startDate); yearList.add(startDate);
} }
Map<String, Object> resultMap = buildRent(receivePeriod, priceArr, yearList, Calendar.MONTH, wxPropertyContract, userId, wxMerchant, billcount, isPreview, shopInfo,saveDb);
List<WxBillProperty> billRentList = (List<WxBillProperty>)resultMap.get("billList");

Map<String, Object> resultMap = buildRent(receivePeriod, priceArr, yearList, Calendar.MONTH, wxPropertyContract, userId, wxMerchant, billcount, isPreview, shopInfo, saveDb);
List<WxBillProperty> billRentList = (List<WxBillProperty>) resultMap.get("billList");
resultList.addAll(billRentList); resultList.addAll(billRentList);
return resultList; return resultList;
} }


public Map<String, Object> buildRent(int receivePeriod,long[] priceArrs, List<Date> yearList,int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview,Map<String, Object> shopInfo,boolean saveDb) {
public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxPropertyContract wxPropertyContract, Long userId, WxMerchant wxMerchant, int billcount, Integer isPreview, Map<String, Object> shopInfo, boolean saveDb) {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Map<String,Object> resultMap = new HashedMap();
Map<String, Object> resultMap = new HashedMap();
List<WxBillProperty> resultList = new ArrayList<>(); List<WxBillProperty> resultList = new ArrayList<>();
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();


Date endDate = null; Date endDate = null;
if(yearList.size() > 1){
if (yearList.size() > 1) {
endDate = yearList.get(1); endDate = yearList.get(1);
} }


List<BillTimeVo> billTimeVoList = new ArrayList<>(); List<BillTimeVo> billTimeVoList = new ArrayList<>();
if(saveDb){
billTimeVoList = WxRentContractServiceImpl.initBillTimeList(wxPropertyContract.getRentalStartDate(),wxPropertyContract.getRentalEndDate(),wxPropertyContract.getAdjustPeriod(),dayType,receivePeriod);
}else{
if (saveDb) {
billTimeVoList = WxRentContractServiceImpl.initBillTimeList(wxPropertyContract.getRentalStartDate(), wxPropertyContract.getRentalEndDate(), wxPropertyContract.getAdjustPeriod(), dayType, receivePeriod);
} else {
//预账单编辑账期,生成金额 //预账单编辑账期,生成金额
for (WxBillProperty rent:wxPropertyContract.getPreviewBillRentList()) {
for (WxBillProperty rent : wxPropertyContract.getPreviewBillRentList()) {
BillTimeVo billTimeVo = new BillTimeVo(); BillTimeVo billTimeVo = new BillTimeVo();
billTimeVo.setStartDate(rent.getStarttime()); billTimeVo.setStartDate(rent.getStarttime());
billTimeVo.setEndDate(rent.getEndtime()); billTimeVo.setEndDate(rent.getEndtime());
billTimeVo.setReceiveDate(DateUtils.getDaySet(rent.getStarttime(),Calendar.DATE,-1));
billTimeVo.setReceiveDate(DateUtils.getDaySet(rent.getStarttime(), Calendar.DATE, -1));
billTimeVoList.add(billTimeVo); billTimeVoList.add(billTimeVo);
} }
} }


int index = 0; int index = 0;
for (int i = 0; i < billTimeVoList.size(); i++) { for (int i = 0; i < billTimeVoList.size(); i++) {
BillTimeVo billTimeVo = billTimeVoList.get(i);
BillTimeVo billTimeVo = billTimeVoList.get(i);
//计算金额 //计算金额
long needpay = 0; long needpay = 0;


boolean flag = false; boolean flag = false;
if(yearList.size() > 1) {
if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) {
if(yearList.size() > 1) {
if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) {
if (yearList.size() > 1) {
if (endDate != null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate))) {
if (yearList.size() > 1) {
if (endDate != null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate))) {
//logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate)); //logger.info("=====billTimeVo.getStartDate():"+sd.format(billTimeVo.getStartDate())+" endDate:"+sd.format(endDate));


index++; index++;


//如果是计算账单金额&cross 拆分日期进行计算 //如果是计算账单金额&cross 拆分日期进行计算
if(!saveDb && billTimeVo.getEndDate().after(endDate)) {
if (!saveDb && billTimeVo.getEndDate().after(endDate)) {
long needpayFront = 0; long needpayFront = 0;
long needpayAfter = 0; long needpayAfter = 0;
//同一天,算一天 //同一天,算一天
if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){
needpayFront = getNeedPayMoney(wxPropertyContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb);
}else{
if(billTimeVo.getStartDate().before(endDate)){
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate,Calendar.DATE,-1), i, billTimeVoList.size(), saveDb);
if (sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))) {
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index - 1], billTimeVo.getStartDate(), endDate, i, billTimeVoList.size(), saveDb);
} else {
if (billTimeVo.getStartDate().before(endDate)) {
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb);
needpayAfter = getNeedPayMoney(wxPropertyContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb); needpayAfter = getNeedPayMoney(wxPropertyContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb);
}else{
} else {
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb); needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb);
} }
} }
needpay = needpayFront+needpayAfter;
needpay = needpayFront + needpayAfter;
flag = true; flag = true;
} }
if(index >= yearList.size()-1){
if (index >= yearList.size() - 1) {
endDate = null; endDate = null;
}else{
endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始
} else {
endDate = yearList.get(index + 1);//price index 0开始,year.end 从第二年开始
//logger.info("==========cross:"+sd.format(endDate)); //logger.info("==========cross:"+sd.format(endDate));
} }
} }
@@ -678,8 +684,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
} }


//计算金额 //计算金额
if(!flag){
needpay = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb);
if (!flag) {
needpay = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb);
} }


WxBillProperty wxBillProperty = new WxBillProperty(); WxBillProperty wxBillProperty = new WxBillProperty();
@@ -697,7 +703,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService


//截止收租日在当前时间之前 //截止收租日在当前时间之前
Date date = new Date(); Date date = new Date();
setExpiredDay(wxBillProperty,dayType,receivePeriod);
setExpiredDay(wxBillProperty, dayType, receivePeriod);
wxBillProperty.setTenantId(wxPropertyContract.getTenantId()); wxBillProperty.setTenantId(wxPropertyContract.getTenantId());
wxBillProperty.setIsDel(0); wxBillProperty.setIsDel(0);
wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId()); wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId());
@@ -715,30 +721,30 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
resultList.add(wxBillProperty); resultList.add(wxBillProperty);
} }
//批量生成预账单 //批量生成预账单
if(saveDb) {
if (saveDb) {
wxBillPropertyMapper.insertBills(resultList); wxBillPropertyMapper.insertBills(resultList);
} }
resultMap.put("billcount",billcount);
resultMap.put("billList",resultList);
resultMap.put("billcount", billcount);
resultMap.put("billList", resultList);
return resultMap; return resultMap;
} }


public long getNeedPayMoney(WxPropertyContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb){
public long getNeedPayMoney(WxPropertyContract wxRentContract, long price, Date startDate, Date endDate, int i, int billTimeVoListSize, boolean saveDb) {
long needpay; long needpay;
//按日 //按日
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) {
Double priceD = new Double(price); Double priceD = new Double(price);
double needpayD = WxRentContractServiceImpl.getNeedPay(0,priceD,startDate,endDate);
double needpayD = WxRentContractServiceImpl.getNeedPay(0, priceD, startDate, endDate);
needpay = new Double(needpayD).longValue(); needpay = new Double(needpayD).longValue();
}else{
} else {
//年 需要除12 //年 需要除12
Double priceD = new Double(price); Double priceD = new Double(price);
if(EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())){
priceD = new Double(price)/12;
if (EnumPriceUnit.Y.getCode().equals(wxRentContract.getPriceUnit())) {
priceD = new Double(price) / 12;
} }


//生成金额直接计算 //生成金额直接计算
if(!saveDb){
if (!saveDb) {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
return needpay; return needpay;
} }
@@ -748,37 +754,37 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdMR = new SimpleDateFormat("MM-dd"); SimpleDateFormat sdMR = new SimpleDateFormat("MM-dd");


if(i == billTimeVoListSize - 1){//最后
if(sdMR.format(startDate).equals(sdMR.format(wxRentContract.getStartDate())) && sdMR.format(endDate).equals(sdMR.format(wxRentContract.getEndDate())) ){
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01");
if (i == billTimeVoListSize - 1) {//最后
if (sdMR.format(startDate).equals(sdMR.format(wxRentContract.getStartDate())) && sdMR.format(endDate).equals(sdMR.format(wxRentContract.getEndDate()))) {
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate) + "-01", sdM.format(endDate) + "-01");
months++; months++;
needpay = new Double(months * priceD).longValue(); needpay = new Double(months * priceD).longValue();
}else {
} else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
} }
}else if(i == 0){//第一期
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
if(isFirstDay(startDate)){
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01");
} else if (i == 0) {//第一期
if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) {
if (isFirstDay(startDate)) {
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate) + "-01", sdM.format(endDate) + "-01");
months++; months++;
needpay = new Double(months * priceD).longValue(); needpay = new Double(months * priceD).longValue();
}else{
} else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
} }
}else{
if(isFirstDay(startDate)){
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01");
if(isFirstDay(startDate)){
} else {
if (isFirstDay(startDate)) {
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate) + "-01", sdM.format(endDate) + "-01");
if (isFirstDay(startDate)) {
months++; months++;
} }
needpay = new Double(months * priceD).longValue(); needpay = new Double(months * priceD).longValue();
}else{
} else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue(); needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
} }
} }
}else{//中间
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate)+"-01",sdM.format(endDate)+"-01");
if(isFirstDay(startDate)){
} else {//中间
int months = WxRentContractServiceImpl.getMonths(sdM.format(startDate) + "-01", sdM.format(endDate) + "-01");
if (isFirstDay(startDate)) {
months++; months++;
} }
needpay = new Double(months * priceD).longValue(); needpay = new Double(months * priceD).longValue();
@@ -787,7 +793,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
return needpay; return needpay;
} }


public void setExpiredDay(WxBillProperty wxBillProperty,int dayType, int receivePeriod){
public void setExpiredDay(WxBillProperty wxBillProperty, int dayType, int receivePeriod) {
Date date = new Date(); Date date = new Date();
wxBillProperty.setExpiredDay(0L); wxBillProperty.setExpiredDay(0L);
if (wxBillProperty.getReceiveDate().before(date)) { if (wxBillProperty.getReceiveDate().before(date)) {
@@ -809,9 +815,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
} }
} }


public boolean isFirstDay(Date date){
public boolean isFirstDay(Date date) {
int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date)); int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date));
if(dateInt == 1){
if (dateInt == 1) {
return true; return true;
} }
return false; return false;
@@ -819,17 +825,18 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService


/** /**
* 根据商户/指定物业合同生成物业账单 * 根据商户/指定物业合同生成物业账单
*
* @param wxMerchant * @param wxMerchant
* @param propertyContract * @param propertyContract
* @return * @return
*/ */
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public List<WxBillProperty> buildProperty(WxMerchant wxMerchant,Long userId,WxPropertyContract propertyContract,Integer isPreview,boolean saveDb) {
public List<WxBillProperty> buildProperty(WxMerchant wxMerchant, Long userId, WxPropertyContract propertyContract, Integer isPreview, boolean saveDb) {
List<WxBillProperty> result = new ArrayList<>(); List<WxBillProperty> result = new ArrayList<>();


WxPropertyContract wxPropertyContract; WxPropertyContract wxPropertyContract;
if(propertyContract == null){
if (propertyContract == null) {
//根据商户ID找出合同 //根据商户ID找出合同
wxPropertyContract = new WxPropertyContract(); wxPropertyContract = new WxPropertyContract();
wxPropertyContract.setMerchantId(wxMerchant.getId()); wxPropertyContract.setMerchantId(wxMerchant.getId());
@@ -837,7 +844,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
if (list.size() > 0) { if (list.size() > 0) {
wxPropertyContract = list.get(0); wxPropertyContract = list.get(0);
} }
}else{
} else {
wxPropertyContract = propertyContract; wxPropertyContract = propertyContract;
} }


@@ -852,10 +859,10 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
Long price = propertyContract.getPrice(); Long price = propertyContract.getPrice();


//按月计租 //按月计租
result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price,isPreview,saveDb);
result = buildRentMonth(wxMerchant, userId, propertyContract, receivePeriod, lease, rentalStartDate, price, isPreview, saveDb);
} }
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
result.get(i).setPeriod(i+1);
result.get(i).setPeriod(i + 1);
} }
return result; return result;
} }
@@ -883,7 +890,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
try { try {
String exportFileName = wxPropertyContract.getFilename(); String exportFileName = wxPropertyContract.getFilename();
downLoadFromUrl(wxPropertyContract.getFilepath(), filename, filepath); downLoadFromUrl(wxPropertyContract.getFilepath(), filename, filepath);
downFile(destPath, wxPropertyContract.getFilename(), exportFileName,response, request);
downFile(destPath, wxPropertyContract.getFilename(), exportFileName, response, request);
org.apache.commons.io.FileUtils.forceDelete(dest); org.apache.commons.io.FileUtils.forceDelete(dest);
} catch (IOException e) { } catch (IOException e) {
logger.info("创建本地文件失败" + e.getMessage()); logger.info("创建本地文件失败" + e.getMessage());
@@ -907,9 +914,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
HashMap<String, Object> shopMap = new HashMap<>(3); HashMap<String, Object> shopMap = new HashMap<>(3);
int rentedCount = rentedList.size(); int rentedCount = rentedList.size();
int unrentedCount = unrentedList.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); resultData.put("shopCountInfo", shopMap);


//需要更新的状态 //需要更新的状态


+ 275
- 244
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


Загрузка…
Отмена
Сохранить