|
|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.iformall.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
@@ -13,11 +14,16 @@ import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxBillActionMapper; |
|
|
|
import com.iformall.mapper.WxBillDepositMapper; |
|
|
|
import com.iformall.mapper.WxBillRentMapper; |
|
|
|
import com.iformall.mapper.WxRentContractMapper; |
|
|
|
import com.iformall.service.ExcelService; |
|
|
|
import com.iformall.service.WxBillActionService; |
|
|
|
import com.iformall.service.WxBillRentService; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.joda.time.DateTime; |
|
|
|
import org.joda.time.Months; |
|
|
|
import org.joda.time.format.DateTimeFormat; |
|
|
|
import org.joda.time.format.DateTimeFormatter; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -27,6 +33,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@@ -52,24 +60,13 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
@Autowired |
|
|
|
WxBillActionMapper wxBillActionMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxRentContractMapper wxRentContractMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxBillRent> listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { |
|
|
|
PageHelper.startPage(pageIndex, pageSize); |
|
|
|
List<WxBillRent> billRentList = wxBillRentMapper.queryBillRentList(record); |
|
|
|
// billRentList.stream().forEach(b -> { |
|
|
|
// if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ |
|
|
|
// int latePayDay = 0; //默认第次日开始交滞纳金 |
|
|
|
// if(b.getLatePayDay() != null){ |
|
|
|
// latePayDay = b.getLatePayDay(); |
|
|
|
// } |
|
|
|
// Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); |
|
|
|
// long dayCount = DateUtils.startToEnd(startPay,new Date()); |
|
|
|
// if(dayCount >0) { |
|
|
|
// BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).multiply(new BigDecimal(dayCount)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); |
|
|
|
// b.setLatePayPrice(divide.longValue()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }); |
|
|
|
PageInfo<WxBillRent> pageInfo = new PageInfo<>(billRentList); |
|
|
|
return pageInfo; |
|
|
|
} |
|
|
|
@@ -255,10 +252,83 @@ public class WxBillRentServiceImpl implements WxBillRentService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取设置的跳点率 |
|
|
|
* ["1000-1200:10",">3000:20"] |
|
|
|
* @param record |
|
|
|
*/ |
|
|
|
public Integer getPayRatio(WxBillRent record,WxRentContract wxRentContract){ |
|
|
|
BigDecimal revenue = new BigDecimal(record.getRevenue()).divide(new BigDecimal(1000000)).setScale(4, RoundingMode.HALF_EVEN); |
|
|
|
List<String> ratioList = JSONArray.parseArray(wxRentContract.getBusDiscountRatio(), String.class); |
|
|
|
|
|
|
|
for (String e:ratioList) { |
|
|
|
String[] array = e.split(":"); |
|
|
|
Integer ratio = Integer.parseInt(array[1]); |
|
|
|
|
|
|
|
if(e.indexOf("-") >= 0){ |
|
|
|
String[] revenueArray = array[0].split("-"); |
|
|
|
BigDecimal start = new BigDecimal(revenueArray[0]); |
|
|
|
BigDecimal end = new BigDecimal(revenueArray[1]); |
|
|
|
if (revenue.compareTo(start) >= 0 && revenue.compareTo(end)<= 0){ |
|
|
|
return ratio; |
|
|
|
} |
|
|
|
}if(e.indexOf(">") >= 0){ |
|
|
|
String[] revenueArray = array[0].split(">"); |
|
|
|
BigDecimal end = new BigDecimal(revenueArray[1]); |
|
|
|
if (revenue.compareTo(end) >= 0){ |
|
|
|
return ratio; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = {Exception.class}) |
|
|
|
@Override |
|
|
|
public ResultData updateRevenue(WxBillRent record, MallUserInfo user) { |
|
|
|
WxBillRent wxBillRent = wxBillRentMapper.selectByPrimaryKey(record.getId()); |
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getRentContractId()); |
|
|
|
SimpleDateFormat sdD = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
SimpleDateFormat sdM = new SimpleDateFormat("yyyy-MM"); |
|
|
|
Integer ratio = getPayRatio(record,wxRentContract); |
|
|
|
|
|
|
|
int startInt = Integer.parseInt(sdD.format(wxBillRent.getStarttime())); |
|
|
|
int endInt = Integer.parseInt(sdD.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))); |
|
|
|
int months = getMonths(sdM.format(wxBillRent.getStarttime())+"-01",sdM.format(DateUtils.getDaySet(wxBillRent.getEndtime(),Calendar.DATE,1))+"-01"); |
|
|
|
|
|
|
|
if(EnumBusRatioTime.YEAR.getCode().equals(wxRentContract.getBusDiscountTime())){ |
|
|
|
if(startInt == endInt && months == 12){ |
|
|
|
//刚好1年 |
|
|
|
BigDecimal hundred = new BigDecimal(100); |
|
|
|
BigDecimal revenue = new BigDecimal(record.getRevenue() == null ? 0 : record.getRevenue()).divide(hundred); |
|
|
|
BigDecimal payRatio = new BigDecimal(ratio).divide(new BigDecimal(10000)); |
|
|
|
BigDecimal price = revenue.multiply(payRatio).setScale(2, RoundingMode.HALF_EVEN); |
|
|
|
long newReceivePay = price.multiply(hundred).longValue(); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else if(EnumBusRatioTime.MONTH.getCode().equals(wxRentContract.getBusDiscountTime())){ |
|
|
|
if(startInt == endInt && months == 1){ |
|
|
|
//刚好1个月 |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Long oldPrice = wxBillRent.getReceivePay(); |
|
|
|
Long newPrice = record.getReceivePay(); |
|
|
|
wxBillRent.setRevenue(record.getRevenue()); |
|
|
|
|