@@ -97,26 +97,26 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
}
//init dateDiff
if (wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null) {
if(wxPropertyContract.getRentalStartDate() != null && wxPropertyContract.getRentalEndDate() != null){
//加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 租赁单价
String rentInfo = wxPropertyContract.getRentInfo();
if (StringUtils.isNotBlank(rentInfo)) {
if(StringUtils.isNotBlank(rentInfo)){
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size();
//查询rent_info 包括shopId
for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
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());
rentPrice = new BigDecimal((double) price / rentArea).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
rentInfoObject.put("rentPrice", rentPrice);
@@ -124,9 +124,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
}
}
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();
Double rentArea = Double.parseDouble(wxPropertyContract.getRentArea()) * 100;
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());
}
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.setPriceUnit(EnumPriceUnit.D.getCode());
}
@@ -171,13 +171,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
//租赁费用欠缴
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setId(wxPropertyContract.getRentContractId());
result.put("rentOweCount", wxRentContractMapper.queryOweCount(wxRentContract));
result.put("rentOweCount",wxRentContractMapper.queryOweCount(wxRentContract));
//物业费用欠缴
WxPropertyContract propertyContract = new WxPropertyContract();
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.setPropertyContractId(id);
@@ -190,8 +190,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
wxFlowRecord.setBusinessId(id);
wxFlowRecord.setStatus(EnumFlowRecordStatus.NEW.getCode());
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;
}
wxBillPropertyMapper.deletePreviewBill(record);
final IdWorker idWorker = IdWorker.get();
int count = 1;
for (WxBillProperty bill : record.getPreviewBillRentList()) {
for (WxBillProperty bill:record.getPreviewBillRentList()) {
bill.setId(idWorker.nextId());
Date date = new Date();
bill.setPropertyContractId(record.getId());
@@ -238,7 +238,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
bill.setIsDel(EnumDelStatus.NOT_DEL.getCode());
bill.setShopId(record.getShopId());
bill.setExpiredDay(0L);
setExpiredDay(bill, Calendar.MONTH, record.getReceivePeriod());
setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod());
if (bill.getReceivePay().equals(0L)) {
bill.setStatus(EnumBillRentStatus.PAID.getCode());
bill.setPayDate(date);
@@ -253,7 +253,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
public ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName) {
// 保存调整金额(预账单调整)
boolean haspreview = false;
if (!CollectionUtils.isEmpty(record.getPreviewBillRentList())) {
if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){
savePreviewBill(record);
haspreview = true;
}
@@ -345,7 +345,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
//生成预览账单
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);
message = "保存物业合同信息成功";
@@ -358,13 +358,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
List<WxBillProperty> billList = wxBillPropertyMapper.findList(wxBillRent);
record.setPreviewBillRentList(billList);
if (!haspreview) {
if(!haspreview){
if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
//删除预账单,重新生成
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);
}
}
@@ -466,7 +466,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
billProperty.setIsPreview(EnumIsPreview.NO.getCode());
billProperty.setMerchantId(record.getMerchantId());
wxBillPropertyMapper.updatePreviewStatus(billProperty);
if (record.getDeposit() > 0) {
if(record.getDeposit() > 0) {
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();
Map<String, Object> shopInfo = new HashMap<>();
if (rentInfo != null) {
@@ -536,7 +536,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
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 rentInfo = wxPropertyContract.getRentInfo();
Map<String, Object> shopInfo = new HashMap<>();
@@ -560,19 +560,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
priceD = priceD + priceD * integers.get(i) / 10000.0;
priceArr[i] = new BigDecimal(priceD).setScale(0, RoundingMode.HALF_EVEN).longValue();
}
} else if (wxPropertyContract.getAdjustRatioWay().equals(EnumRentContractAdjustRatioWay.MONEY.getCode())) {
} else {
long priceD = price;
for (int i = 1; i < size; i++) {
priceD = priceD + integers.get(i);
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 divide = lease / month;
int mod = lease % month;
@@ -592,90 +587,89 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
Calendar instance = Calendar.getInstance();
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;
} else {
}else{
instance.setTime(rentalStartDate);
instance.add(Calendar.MONTH, month * i);
startDate = DateUtils.getFirstDayForCurrMonth(instance.getTime());
}
} else {
}else{
instance.setTime(rentalStartDate);
instance.add(Calendar.MONTH, month * i);
startDate = instance.getTime();
}
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);
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");
Map<String, Object> resultMap = new HashedMap();
Map<String,Object> resultMap = new HashedMap();
List<WxBillProperty> resultList = new ArrayList<>();
final IdWorker idWorker = IdWorker.get();
Date endDate = null;
if (yearList.size() > 1) {
if(yearList.size() > 1){
endDate = yearList.get(1);
}
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.setStartDate(rent.getStarttime());
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);
}
}
int index = 0;
for (int i = 0; i < billTimeVoList.size(); i++) {
BillTimeVo billTimeVo = billTimeVoList.get(i);
BillTimeVo billTimeVo = billTimeVoList.get(i);
//计算金额
long needpay = 0;
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));
index++;
//如果是计算账单金额&cross 拆分日期进行计算
if (!saveDb && billTimeVo.getEndDate().after(endDate)) {
if(!saveDb && billTimeVo.getEndDate().after(endDate)) {
long needpayFront = 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);
needpayAfter = getNeedPayMoney(wxPropertyContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb);
} else {
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), 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,dayType,receivePeriod );
}else{
if(billTimeVo.getStartDate().before(endDate)){
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate,Calendar.DATE,-1), i, billTimeVoList.size(), saveDb,dayType,receivePeriod );
needpayAfter = getNeedPayMoney(wxPropertyContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod );
}else{
needpayFront = getNeedPayMoney(wxPropertyContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod );
}
}
needpay = needpayFront + needpayAfter;
needpay = needpayFront+needpayAfter;
flag = true;
}
if (index >= yearList.size() - 1) {
if(index >= yearList.size()-1){
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));
}
}
@@ -684,8 +678,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,dayType,receivePeriod );
}
WxBillProperty wxBillProperty = new WxBillProperty();
@@ -703,7 +697,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
//截止收租日在当前时间之前
Date date = new Date();
setExpiredDay(wxBillProperty, dayType, receivePeriod);
setExpiredDay(wxBillProperty,dayType,receivePeriod);
wxBillProperty.setTenantId(wxPropertyContract.getTenantId());
wxBillProperty.setIsDel(0);
wxBillProperty.setMerchantId(wxPropertyContract.getMerchantId());
@@ -721,31 +715,31 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
resultList.add(wxBillProperty);
}
//批量生成预账单
if (saveDb) {
if(saveDb) {
wxBillPropertyMapper.insertBills(resultList);
}
resultMap.put("billcount", billcount);
resultMap.put("billList", resultList);
resultMap.put("billcount",billcount);
resultMap.put("billList",resultList);
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,int dayType,int receivePeriod) {
long needpay;
//按日
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) {
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){
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();
} else {
}else{
//年 需要除12
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) {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
if(!saveDb){
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod )).longValue();
return needpay;
}
@@ -754,37 +748,37 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
SimpleDateFormat sd = new SimpleDateFormat("yyyy-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++;
needpay = new Double(months * priceD).longValue();
} else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
}else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod )).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++;
needpay = new Double(months * priceD).longValue();
} else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
}else{
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod )).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++;
}
needpay = new Double(months * priceD).longValue();
} else {
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate)).longValue();
}else{
needpay = new Double(WxRentContractServiceImpl.getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod )).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++;
}
needpay = new Double(months * priceD).longValue();
@@ -793,7 +787,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
return needpay;
}
public void setExpiredDay(WxBillProperty wxBillProperty, int dayType, int receivePeriod) {
public void setExpiredDay(WxBillProperty wxBillProperty,int dayType, int receivePeriod){
Date date = new Date();
wxBillProperty.setExpiredDay(0L);
if (wxBillProperty.getReceiveDate().before(date)) {
@@ -815,9 +809,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));
if (dateInt == 1) {
if(dateInt == 1){
return true;
}
return false;
@@ -825,18 +819,17 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
/**
* 根据商户/指定物业合同生成物业账单
*
* @param wxMerchant
* @param propertyContract
* @return
*/
@Override
@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<>();
WxPropertyContract wxPropertyContract;
if (propertyContract == null) {
if(propertyContract == null){
//根据商户ID找出合同
wxPropertyContract = new WxPropertyContract();
wxPropertyContract.setMerchantId(wxMerchant.getId());
@@ -844,7 +837,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
if (list.size() > 0) {
wxPropertyContract = list.get(0);
}
} else {
}else{
wxPropertyContract = propertyContract;
}
@@ -859,10 +852,10 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
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++) {
result.get(i).setPeriod(i + 1);
result.get(i).setPeriod(i+1);
}
return result;
}
@@ -890,7 +883,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
try {
String exportFileName = wxPropertyContract.getFilename();
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);
} catch (IOException e) {
logger.info("创建本地文件失败" + e.getMessage());
@@ -914,9 +907,9 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService
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);
//需要更新的状态