@@ -1258,18 +1258,18 @@ public class WxRentContractServiceImpl implements WxRentContractService {
long needpayAfter = 0;
//同一天,算一天
if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){
needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod);
needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false );
}else{
if(billTimeVo.getStartDate().before(endDate)){
if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType()) && EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) {
//设置跳点率为年周期 price不变
needpayFront = priceArrs[index - 1];
}else {
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod);
needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod);
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true );
needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true );
}
}else{
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod);
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false );
}
}
needpay = needpayFront+needpayAfter;
@@ -1288,7 +1288,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//计算金额
if(!flag){
needpay = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod);
needpay = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(),saveDb,dayType,receivePeriod,false );
}
WxBillRent wxBillRent = new WxBillRent();
@@ -1332,7 +1332,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return resultMap;
}
public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod){
public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part ){
long needpay;
//按日
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){
@@ -1360,7 +1360,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//生成金额直接计算
if(!saveDb){
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod)).longValue();
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,part )).longValue();
return needpay;
}
@@ -1377,7 +1377,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
int months = getMonths(sdM.format(startDate)+"-01",sdM.format(DateUtils.getDaySet(endDate,Calendar.DATE,1))+"-01");
needpay = new Double(months * priceD).longValue();
}else{
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod)).longValue();
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false )).longValue();
}
}else if(i == 0){//第一期
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())){
@@ -1386,7 +1386,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
months++;
needpay = new Double(months * priceD).longValue();
}else{
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod)).longValue();
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false )).longValue();
}
}else{
if(isFirstDay(startDate)){
@@ -1396,7 +1396,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
needpay = new Double(months * priceD).longValue();
}else{
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod)).longValue();
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false )).longValue();
}
}
}else{//中间
@@ -2253,7 +2253,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return wxRentContractMapper.getShopType(wxRentContract);
}
public static double getMonthNeedPay(Double price,Date start,Date end,int dayType,int receivePeriod){
public static double getMonthNeedPay(Double price,Date start,Date end,int dayType,int receivePeriod,boolean part ){
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM");
SimpleDateFormat sdD = new SimpleDateFormat("d");
@@ -2276,11 +2276,24 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
//判断是否满足整月
Calendar instance = Calendar.getInstance();
instance.setTime(start);
instance.add(dayType, receivePeriod);
instance.add(Calendar.DATE, -1);
if(sd.format(instance.getTime()).equals(sd.format(end))){
boolean isFullMonth = false;
if(part){
int startInt = Integer.parseInt(sdD.format(start));
int endInt = Integer.parseInt(sdD.format(DateUtils.getDaySet(end,Calendar.DATE,1)));
if(startInt == endInt){
isFullMonth = true;
}
}else{
Calendar instance = Calendar.getInstance();
instance.setTime(start);
instance.add(dayType, receivePeriod);
instance.add(Calendar.DATE, -1);
if(sd.format(instance.getTime()).equals(sd.format(end))){
isFullMonth = true;
}
}
if(isFullMonth){
int months = getMonths(sdM.format(start)+"-01",sdM.format(DateUtils.getDaySet(end,Calendar.DATE,1))+"-01");
return (months) * price;
}