|
|
|
@@ -33,7 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import org.joda.time.DateTime; |
|
|
|
import org.joda.time.Months; |
|
|
|
import org.joda.time.format.DateTimeFormat; |
|
|
|
import org.joda.time.format.DateTimeFormatter; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.File; |
|
|
|
@@ -732,7 +735,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
//按月计租 |
|
|
|
// if (wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_MONTH.getCode()) |
|
|
|
// ||wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) { |
|
|
|
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); |
|
|
|
rentList = buildRentMonth(wxMerchant, userId, wxRentContract, receivePeriod, lease, rentalStartDate, price,isPreview); |
|
|
|
// } else { |
|
|
|
// //如果按日 |
|
|
|
// List<Date> yearList = new ArrayList<>(); |
|
|
|
@@ -882,9 +885,11 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
// } |
|
|
|
|
|
|
|
int index = 0; |
|
|
|
for (BillTimeVo billTimeVo : billTimeVoList){ |
|
|
|
for (int i = 0; i < billTimeVoList.size(); i++) { |
|
|
|
BillTimeVo billTimeVo = billTimeVoList.get(i); |
|
|
|
|
|
|
|
if(yearList.size() > 1) { |
|
|
|
if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate))) { |
|
|
|
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++; |
|
|
|
@@ -895,7 +900,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
endDate = yearList.get(index+1);//price index 0开始,year.end 从第二年开始 |
|
|
|
logger.info("==========cross:"+sd.format(endDate)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -916,8 +920,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo); |
|
|
|
int rentSize = rentInfoArray.size(); |
|
|
|
Map<String, Object> shopInfoMap = new HashMap<>(); |
|
|
|
for (int i = 0; i < rentSize; i++) { |
|
|
|
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i); |
|
|
|
for (int j = 0; j < rentSize; j++) { |
|
|
|
JSONObject rentInfoObject = rentInfoArray.getJSONObject(j); |
|
|
|
shopInfoMap.put(rentInfoObject.getString("shopNumber"), 0); |
|
|
|
} |
|
|
|
shopInfoStr = JSONObject.toJSONString(shopInfoMap); |
|
|
|
@@ -934,7 +938,6 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
wxBillRent.setReceiveDate(billTimeVo.getReceiveDate()); |
|
|
|
|
|
|
|
long needpay; |
|
|
|
|
|
|
|
//按日 |
|
|
|
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ |
|
|
|
Double priceD = new Double(price); |
|
|
|
@@ -947,14 +950,17 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
priceD = new Double(price)/12; |
|
|
|
} |
|
|
|
|
|
|
|
//当天也算,加1天 |
|
|
|
Date newEndDate = DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1); |
|
|
|
//按月 |
|
|
|
int[] diff = DateUtils.getDiff(wxBillRent.getStarttime(),newEndDate); |
|
|
|
needpay =new Double( diff[0]*priceD).longValue(); |
|
|
|
|
|
|
|
double oneDayProce = priceD/DateUtils.getMonthDayCount(wxRentContract.getRentalEndDate()); |
|
|
|
needpay += diff[1] * oneDayProce; |
|
|
|
if(i == 0){//第一期 |
|
|
|
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){ |
|
|
|
needpay = new Double(getMonthNeedPay(priceD,billTimeVo.getStartDate(),billTimeVo.getEndDate())).longValue(); |
|
|
|
}else{ |
|
|
|
needpay = new Double(receivePeriod * priceD).longValue(); |
|
|
|
} |
|
|
|
}else if(i == billTimeVoList.size()-1){//最后 |
|
|
|
needpay = new Double(getMonthNeedPay(priceD,billTimeVo.getStartDate(),billTimeVo.getEndDate())).longValue(); |
|
|
|
}else{//中间 |
|
|
|
needpay = new Double(receivePeriod * priceD).longValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wxBillRent.setNeedPay(needpay); |
|
|
|
@@ -1001,6 +1007,23 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isFirstDay(Date date){ |
|
|
|
int dateInt = Integer.parseInt(new SimpleDateFormat("d").format(date)); |
|
|
|
if(dateInt == 1){ |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public static int getMonths(String startStr,String endStr){ |
|
|
|
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); |
|
|
|
DateTime start = formatter.parseDateTime(startStr); |
|
|
|
DateTime end = formatter.parseDateTime(endStr); |
|
|
|
int months = Months.monthsBetween(start, end).getMonths(); |
|
|
|
return months; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
|
@Override |
|
|
|
public ResultData deleteById(String id) { |
|
|
|
@@ -1769,6 +1792,30 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
return wxRentContractMapper.getShopType(wxRentContract); |
|
|
|
} |
|
|
|
|
|
|
|
public static double getMonthNeedPay(Double price,Date start,Date end){ |
|
|
|
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); |
|
|
|
Double total = new Double(0); |
|
|
|
int[] diff; |
|
|
|
|
|
|
|
//第一个月 |
|
|
|
Date lastMonthDay = DateUtils.getLastDayForMonth(start); |
|
|
|
diff = DateUtils.getDiff(start,lastMonthDay); |
|
|
|
int dayCount = DateUtils.getMonthDayCount(start); |
|
|
|
total += (diff[1]+1) * (price/dayCount); |
|
|
|
|
|
|
|
//中间月份 |
|
|
|
Date newStartDate = DateUtils.getDaySet(lastMonthDay,Calendar.DATE,1); |
|
|
|
int months = getMonths(sdM.format(newStartDate)+"-01",sdM.format(end)+"-01"); |
|
|
|
total += months * price; |
|
|
|
|
|
|
|
//最后一个月 |
|
|
|
diff = DateUtils.getDiff(DateUtils.getFirstDayForCurrMonth(end),end); |
|
|
|
dayCount = DateUtils.getMonthDayCount(end); |
|
|
|
total += (diff[1]+1) * (price/dayCount); |
|
|
|
return total; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 按日计租 根据每月的日期总数计算needpay |
|
|
|
* @param monthPrice |
|
|
|
@@ -1908,3 +1955,4 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|