Browse Source

Merge branch 'release_toaliyun_real_202210' of https://git.malls.iformall.com/server/formallProject into release_toaliyun_real_202210

release_toaliyun_real
xhxu 3 years ago
parent
commit
49bfd4dc3f
1 changed files with 33 additions and 15 deletions
  1. +33
    -15
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java

+ 33
- 15
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java View File

@@ -1389,6 +1389,18 @@ public class WxRentContractServiceImpl implements WxRentContractService {
} }




private static Date getCurrentYearRentDate(Date yearEndDate,Date rentDate){
Calendar calendar = Calendar.getInstance();
calendar.setTime(yearEndDate);
Calendar rentCalendar = Calendar.getInstance();
rentCalendar.setTime(rentDate);
calendar.set(Calendar.DAY_OF_MONTH,rentCalendar.get(Calendar.DAY_OF_MONTH));
calendar.set(Calendar.MONTH, rentCalendar.get(Calendar.MONTH));
return calendar.getTime();
}
public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) {
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract); WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(wxRentContract);
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
@@ -1422,6 +1434,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
long needpay = 0; long needpay = 0;


boolean flag = false; boolean flag = false;
//此处逻辑处理这一年和下一年交接那一期账单。
if(yearList.size() > 1) { if(yearList.size() > 1) {
if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) { if (endDate!=null && (sd.format(billTimeVo.getStartDate()).equals(sd.format(endDate)) || billTimeVo.getStartDate().after(endDate) || billTimeVo.getEndDate().after(endDate) )) {
if(yearList.size() > 1) { if(yearList.size() > 1) {
@@ -1436,18 +1449,26 @@ public class WxRentContractServiceImpl implements WxRentContractService {
long needpayAfter = 0; long needpayAfter = 0;
//同一天,算一天 //同一天,算一天
if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ 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,false);
needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb,dayType,receivePeriod,false,false);
}else{ }else{
if(billTimeVo.getStartDate().before(endDate)){ if(billTimeVo.getStartDate().before(endDate)){
if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType()) && EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) { if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(wxRentContract.getType()) && EnumMissTimeType.PERIOD.getCode().equals(wxRentContract.getBusDiscountTime())) {
//设置跳点率为年周期 price不变 //设置跳点率为年周期 price不变
needpayFront = priceArrs[index - 1]; needpayFront = priceArrs[index - 1];
}else { }else {
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);
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), DateUtils.getDaySet(endDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false);
needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,false);
} }
}else{ }else{
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false);
//如果是按自然月,则这一年和下一年交叉部分需要重新计算
if(wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_NAR_MONTH.getCode())) {
Date currentYearRentDate = getCurrentYearRentDate(endDate,wxRentContract.getRentalStartDate());
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], endDate, DateUtils.getDaySet(currentYearRentDate, Calendar.DATE, -1), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true);
needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], currentYearRentDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb, dayType, receivePeriod,true,true);
}else {
//按账单日
needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb,dayType,receivePeriod,false,false);
}
} }
} }
needpay = needpayFront+needpayAfter; needpay = needpayFront+needpayAfter;
@@ -1466,7 +1487,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {


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


WxBillRent wxBillRent = new WxBillRent(); WxBillRent wxBillRent = new WxBillRent();
@@ -1519,7 +1540,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return resultMap; return resultMap;
} }


public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part){
public long getNeedPayMoney(WxRentContract wxRentContract,long price,Date startDate,Date endDate,int i,int billTimeVoListSize,boolean saveDb,int dayType,int receivePeriod,boolean part,boolean monthCalDay){
long needpay; long needpay;
//按日 //按日
if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){ if (wxRentContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){
@@ -1591,7 +1612,12 @@ public class WxRentContractServiceImpl implements WxRentContractService {
if(isFirstDay(startDate)){ if(isFirstDay(startDate)){
months++; months++;
} }
needpay = new Double(months * priceD).longValue();
//如果当月费用需要按天计算
if (monthCalDay) {
needpay = new Double(getMonthNeedPay(priceD, startDate, endDate,dayType,receivePeriod,false)).longValue();
}else {
needpay = new Double(months * priceD).longValue();
}
} }
} }
return needpay; return needpay;
@@ -3288,12 +3314,4 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return count; return count;
} }



public static void main(String[] args) {
String s = "{\"siteMoney\":\"2\",\"facilityMoney\":\"3\",\"administratorMoney\":\"4\"}";
JSONObject jsonObject = JSONObject.parseObject(s);
String siteMoney = jsonObject.getString("siteMoney");
System.out.println(siteMoney);
}

} }

Loading…
Cancel
Save