Browse Source

fix

release_toaliyun_real
winter 1 year ago
parent
commit
d950b8a17e
6 changed files with 284 additions and 20 deletions
  1. +51
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java
  2. +4
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java
  3. +26
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsSumVo.java
  4. +15
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsVo.java
  5. +4
    -0
      mallinkService/src/main/java/com/iformall/service/WxRentContractService.java
  6. +184
    -18
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java

+ 51
- 2
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java View File

@@ -1,5 +1,6 @@
package com.iformall.controller.contract;

import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
@@ -9,6 +10,7 @@ import com.iformall.common.ResultData;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.BaseEntity.SortField;
import com.iformall.domain.vo.WxRentContractYearsVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxRentContractMapper;
@@ -860,9 +862,11 @@ public class WxRentContractController extends WxContractBaseController {
public ResultData revenuePropertyContract(@ModelAttribute WxRentContract rentContract) {
if (null == rentContract) rentContract = new WxRentContract();
rentContract.updateTenantInfo(getTenantInfo());
WxRentContract contract = wxRentContractService.selectById(rentContract.getId());
//纯联营扣点方式,不能加物业费一起算
if (contract.getType().intValue() == EnumRentContractType.RENT_BY_JOINT.getCode()) {
return new ResultData();
}
WxPropertyContract bq = new WxPropertyContract();
bq.updateTenantInfo(rentContract);
bq.setMerchantId(contract.getMerchantId());
@@ -873,6 +877,11 @@ public class WxRentContractController extends WxContractBaseController {
return new ResultData(propertyList);
}
/**
* 扣点设置销售额重新计算
* @param wxRentContract
* @return
*/
@PostMapping("setRevenueSales")
public ResultData setRevenueSales(@RequestBody WxRentContract wxRentContract) {
WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId());
@@ -882,6 +891,46 @@ public class WxRentContractController extends WxContractBaseController {
return new ResultData(wxRentContractService.setRevenueSales(rentContract,wxRentContract.getSalesMoney(),wxRentContract.getBillId(),wxRentContract.getPropertyContractId()));
}
//查询合同年限
@GetMapping("getContractYears")
public ResultData getContractYears(@ModelAttribute WxRentContract wxRentContract) {
if (null == wxRentContract) wxRentContract = new WxRentContract();
WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId());
String adjustRatio = rentContract.getAdjustRatio();
List<Integer> integers = JSONArray.parseArray(adjustRatio, Integer.class);
integers.add(0, 0);
int years = integers.size();
List<Date> yearList = wxRentContractService.getYearList(years, 12, rentContract.getRentalStartDate());
if (null != yearList ) {
List<WxRentContractYearsVo> retList = new ArrayList<WxRentContractYearsVo>();
Date begin = rentContract.getRentalStartDate();
for (int i = 0 ; i < yearList.size() ; i ++) {
WxRentContractYearsVo vo = new WxRentContractYearsVo();
vo.setStart(begin);
vo.setEnd(yearList.get(i));
vo.setRemark("第"+i+1+"年度");
retList.add(vo);
begin = DateUtils.getDaySet(begin, Calendar.DATE, 1);
}
return new ResultData(retList);
}
return new ResultData();
}
/**
* 取高年度汇算计算
* @param wxRentContract
* @return
*/
@PostMapping("calcuteYearsRevenueRentUp")
public ResultData calcuteYearsRevenueRentUp(@RequestBody WxRentContract wxRentContract) {
WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId());
if (null == rentContract) {
return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同");
}
return new ResultData(wxRentContractService.calcuteYearsRevenueRentUp(rentContract));
}

}


+ 4
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java View File

@@ -618,5 +618,9 @@ public class WxRentContract extends TenantEntity {
private String salesMoney;
@TableField(exist = false)
private Long billId;
@TableField(exist = false)
private Date yearsBegin;
@TableField(exist = false)
private Long yearsEnd;
}


+ 26
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsSumVo.java View File

@@ -0,0 +1,26 @@
package com.iformall.domain.vo;

import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.iformall.domain.po.WxAllBill;
import com.iformall.utils.DateUtils;

@Data
public class WxRentContractYearsSumVo implements Serializable {

private static final long serialVersionUID = 1L;

//总计销售额
private String totalSales;
//总应收
private String receivePay;
//总冲抵
private String setoff;
//总实收
private String pay;
//总退回
private String returnPay;
}

+ 15
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsVo.java View File

@@ -0,0 +1,15 @@
package com.iformall.domain.vo;

import lombok.Data;
import java.io.Serializable;
import java.util.Date;

@Data
public class WxRentContractYearsVo implements Serializable {

private static final long serialVersionUID = 1L;

private String remark;
private Date start;
private Date end;
}

+ 4
- 0
mallinkService/src/main/java/com/iformall/service/WxRentContractService.java View File

@@ -11,6 +11,7 @@ import com.iformall.domain.po.WxRentContractRevenueSales;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.RentContractFreePeriodVo;
import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo;
import com.iformall.domain.vo.WxRentContractYearsSumVo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -83,6 +84,7 @@ public interface WxRentContractService {

void updateApplyStatus(WxRentContract wxRentContract);

public List<Date> getYearList(int years,int month,Date rentalStartDate );
List<WxAllBill> buildRent(MallUserInfo user,WxRentContract rentContract,Integer isPreview,boolean saveDb);

void buildDeposit( TenantEntity tenantEntity,MallUserInfo user,Long rentContractId);
@@ -160,4 +162,6 @@ public interface WxRentContractService {
WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract,String sales,Long billId,Long propertyContractId);
WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract);
}

+ 184
- 18
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java View File

@@ -29,6 +29,7 @@ import com.iformall.domain.vo.BillTimeVo;
import com.iformall.domain.vo.RatioVo;
import com.iformall.domain.vo.RentContractFreePeriodVo;
import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo;
import com.iformall.domain.vo.WxRentContractYearsSumVo;
import com.iformall.enums.EnumBillAllType;
import com.iformall.enums.EnumBillStatus;
import com.iformall.enums.EnumContractOperationType;
@@ -48,6 +49,7 @@ import com.iformall.enums.EnumRentContractAppStatus;
import com.iformall.enums.EnumRentContractManageFeeType;
import com.iformall.enums.EnumRentContractStatus;
import com.iformall.enums.EnumRentContractType;
import com.iformall.enums.EnumRentDayPriceCalcute;
import com.iformall.enums.EnumRentShopType;
import com.iformall.enums.EnumTradeDailyDateType;
import com.iformall.enums.EnumYesOrNo;
@@ -1019,20 +1021,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return rentList;
}
public List<WxAllBill> buildRentMonth(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate,Integer isPreview, boolean saveDb) {
int years = 0;
//计算租金每年的计费基数
String[] priceArrs = WxRentContractHelper.calcuteRentPrice(wxRentContract);
//计算商业管理费
String[] bussinessManagerPriceArrs = WxRentContractHelper.calcuteBussinessManagementFee(wxRentContract);
//计算运营管理费
String[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(wxRentContract);
int month = 12;
int billcount = 0;
List<WxAllBill> resultList = new ArrayList<WxAllBill>();
years = priceArrs.length;
@Override
public List<Date> getYearList(int years,int month,Date rentalStartDate ) {
List<Date> yearList = new ArrayList<>();
for (int i = 0; i < years; i++) {
Calendar instance = Calendar.getInstance();
@@ -1053,6 +1043,22 @@ public class WxRentContractServiceImpl implements WxRentContractService {
// }
yearList.add(startDate);
}
return yearList;
}
public List<WxAllBill> buildRentMonth(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate,Integer isPreview, boolean saveDb) {
int years = 0;
//计算租金每年的计费基数
String[] priceArrs = WxRentContractHelper.calcuteRentPrice(wxRentContract);
//计算商业管理费
String[] bussinessManagerPriceArrs = WxRentContractHelper.calcuteBussinessManagementFee(wxRentContract);
//计算运营管理费
String[] operationManagerPriceArrs = WxRentContractHelper.calcuteOperatingManagementFee(wxRentContract);
int month = 12;
int billcount = 0;
List<WxAllBill> resultList = new ArrayList<WxAllBill>();
years = priceArrs.length;
List<Date> yearList = getYearList(years,month,rentalStartDate);
String shopInfoStr = getShopInfoStr(wxRentContract);
Map<String, Object> resultMap = buildRent(receivePeriod, priceArrs,bussinessManagerPriceArrs,operationManagerPriceArrs, yearList, wxRentContract.getReceivePeriodUnit(), wxRentContract, user, billcount, isPreview, shopInfoStr,saveDb);
@@ -2322,11 +2328,126 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return wxRentContractRevenueSalesMapper.findList(sales);
}
private BigDecimal calcuteUnitPrice(Date startDate,Date endDate,BigDecimal salesDeciaml,Integer priceUnit,
Integer dayPriceCalcute,Integer mothAverageDays) {
BigDecimal unitPrice = new BigDecimal(0);
int[] diffs = DateUtils.getDiff(startDate, endDate);
if (priceUnit.equals(EnumPriceUnit.D.getCode())){
int allDays = 0;
if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
allDays = diffs[0]*mothAverageDays + diffs[1];
}else {
allDays = DateUtils.daysBetween(startDate, endDate)+1;
}
//每一天的单价
unitPrice = salesDeciaml.divide(new BigDecimal(allDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}else if(EnumPriceUnit.Y.getCode().equals(priceUnit)) {
//每一年的单价
BigDecimal years = new BigDecimal(diffs[0]/12);
int extraMonths = diffs[0]%12;
if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
int days = extraMonths*mothAverageDays + diffs[1];
years = years.add(new BigDecimal(days).divide(new BigDecimal(12*mothAverageDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP));
}else {
int days = DateUtils.daysBetween(startDate, endDate)+1;
years = years.add(new BigDecimal(days).divide(new BigDecimal(365),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP));
}
//每一天的单价
unitPrice = salesDeciaml.divide(years,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}else if(EnumPriceUnit.M.getCode().equals(priceUnit)) {
//每一月的单价
BigDecimal months = new BigDecimal(diffs[0]);
if (dayPriceCalcute.intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
months = months.add(new BigDecimal(diffs[1]).divide(new BigDecimal(mothAverageDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP));
}else {
Date extraStartDay = DateUtils.getTimeAfterMonths(diffs[0], startDate);
int extraDays = DateUtils.daysBetween(extraStartDay, endDate)+1;
Date extraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(extraStartDay);
Date extraStartDayMonthEnd = DateUtils.getLastDayForMonth(extraStartDay);
int monthDays = DateUtils.daysBetween(extraStartDayMonthStart, extraStartDayMonthEnd)+1;
months = months.add(new BigDecimal(extraDays).divide(new BigDecimal(monthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP));
}
//每一天的单价
unitPrice = salesDeciaml.divide(months,Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}
return unitPrice;
}
//根据租金合同来计算附加物业费
private BigDecimal calcuteRentPropertyPrice(WxRentContract rentcontract,WxPropertyContract propertyContract,Date startDate,Date endDate,BigDecimal money) {
//计算物业费的单价
BigDecimal unitPropertyPrice = calcuteUnitPrice(startDate, endDate,money,
propertyContract.getPriceUnit(),propertyContract.getDayPriceCalcute(),propertyContract.getMonthAverageDays());
//如果租金是按天计算
if (rentcontract.getPriceUnit().equals(EnumPriceUnit.D.getCode())){
//物业也是按天
if (propertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) {
return unitPropertyPrice;
}else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) {
if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
return unitPropertyPrice.divide(new BigDecimal(12*propertyContract.getMonthAverageDays()),
Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}else {
return unitPropertyPrice.divide(new BigDecimal(365),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}
}else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) {
if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
return unitPropertyPrice.divide(new BigDecimal(propertyContract.getMonthAverageDays()),
Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}else {
int allDays = DateUtils.daysBetween(startDate, endDate)+1;
return money.divide(new BigDecimal(allDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}
}
}else if (rentcontract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) {
if (propertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) {
if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
return unitPropertyPrice.multiply(new BigDecimal(12*propertyContract.getMonthAverageDays()));
}else {
return unitPropertyPrice.multiply(new BigDecimal(365));
}
}else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) {
return unitPropertyPrice;
}else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) {
return unitPropertyPrice.multiply(new BigDecimal(12));
}
}else if (rentcontract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) {
if (propertyContract.getPriceUnit().equals(EnumPriceUnit.D.getCode())) {
if (propertyContract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
return unitPropertyPrice.multiply(new BigDecimal(propertyContract.getMonthAverageDays()));
}else {
//此处就无法计算月了。
//计算月份值。
int[] diffs = DateUtils.getDiff(startDate, endDate);
BigDecimal months = new BigDecimal(diffs[0]);
Date extraStartDay = DateUtils.getTimeAfterMonths(diffs[0], startDate);
int extraDays = DateUtils.daysBetween(extraStartDay, endDate)+1;
Date extraStartDayMonthStart = DateUtils.getFirstDayForCurrMonth(extraStartDay);
Date extraStartDayMonthEnd = DateUtils.getLastDayForMonth(extraStartDay);
int monthDays = DateUtils.daysBetween(extraStartDayMonthStart, extraStartDayMonthEnd)+1;
months = months.add(new BigDecimal(extraDays).divide(new BigDecimal(monthDays),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP));
return unitPropertyPrice.multiply(months);
}
}else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.Y.getCode())) {
return unitPropertyPrice.divide(new BigDecimal(12),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}else if (propertyContract.getPriceUnit().equals(EnumPriceUnit.M.getCode())) {
return unitPropertyPrice;
}
}
return unitPropertyPrice;
}
private BigDecimal calcuteReveneuJump(BigDecimal sales,WxRentContract rentcontract) {
return null;
}
@Override
public WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract, String sales, Long billId, Long propertyContractId) {
WxAllBill rentBill = wxAllBillMapper.selectById(billId, rentcontract.getTenantId());
BigDecimal price = new BigDecimal(sales);
BigDecimal salesDeciaml = new BigDecimal(sales);
//加上物业
WxAllBill propertyBill = null;
if (null != propertyContractId) {
@@ -2341,15 +2462,54 @@ public class WxRentContractServiceImpl implements WxRentContractService {
List<WxAllBill> propertyBillList = wxAllBillMapper.findList(propertyBillq);
if (null != propertyBillList && propertyBillList.size() > 0) {
propertyBill = propertyBillList.get(0);
price = price.add(new BigDecimal(propertyBill.getReceivePay()));
}
}
//免租期
//根据销售额来计算价格均值
BigDecimal unitRevenuePrice = calcuteUnitPrice(rentBill.getStarttime(), rentBill.getEndtime(),salesDeciaml,
rentcontract.getPriceUnit(),rentcontract.getDayPriceCalcute(),rentcontract.getMonthAverageDays());
//设置保底营业额
rentcontract.setRevenue(unitRevenuePrice.toPlainString());
//联营扣点
if (rentcontract.getType().equals(EnumRentContractType.RENT_BY_JOINT.getCode())) {
rentcontract.setPrice(new BigDecimal(rentcontract.getPayRatio()).multiply(unitRevenuePrice).divide(new BigDecimal(100),
Constant.default_long_decimal_size,RoundingMode.HALF_UP).toPlainString());
}else if (rentcontract.getType().intValue() == EnumRentContractType.RENT_BY_AREA_AND_JOINT.getCode()) {
//取高才能加上物业费
if (null != propertyContractId && null != propertyBill) {
WxPropertyContract propertyContract = wxPropertyContractMapper.selectById(propertyContractId);
BigDecimal rentPrice = new BigDecimal(rentcontract.getPrice());
//有可能物业的单价时间跟租金的不一致,需要根据物业的单价重新计算
BigDecimal propertyPrice = calcuteRentPropertyPrice(rentcontract, propertyContract, rentBill.getStarttime(), rentBill.getEndtime(),
new BigDecimal(propertyBill.getReceivePay()));
rentcontract.setPrice(rentPrice.add(propertyPrice).toPlainString());;
}
}
//计算每一年的基数
String[] priceArrs = WxRentContractHelper.calcuteRentPrice(rentcontract);
List<Date> yearList = this.getYearList(priceArrs.length, 12, rentcontract.getRentalStartDate());
int yearIndex = 0;
for( int i = 0 ; i < yearList.size() ; i ++) {
Date yearEndDate = yearList.get(i);
if (rentBill.getEndtime().before(yearEndDate) || rentBill.getEndtime().equals(yearEndDate)) {
yearIndex = i;
break;
}
}
//免租期
List<Date> freePeriods = getFreeDays(rentcontract);
String needpay = WxRentContractHelper.getNeedPayMoney(freePeriods,rentcontract, price.toPlainString(),rentBill.getStarttime(),
//根据租金和扣点来计算
String needpay = WxRentContractHelper.getNeedPayMoney(freePeriods,rentcontract, priceArrs[yearIndex],rentBill.getStarttime(),
rentBill.getEndtime(),0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod());
//计算跳点。
BigDecimal jumppay = calcuteReveneuJump(salesDeciaml, rentcontract);
if (jumppay.compareTo(new BigDecimal(needpay)) > 0 ) {
needpay = jumppay.toPlainString();
}
//保存销售额
WxRentContractRevenueSales rs = new WxRentContractRevenueSales();
rs.updateTenantInfo(rentcontract);
@@ -2409,4 +2569,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
vo.setBillList(blist);;
return vo;
}
@Override
public WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract) {
//通过销售额汇总,查询跳点,计算扣点总应收
return null;
}
}

Loading…
Cancel
Save