|
|
|
@@ -28,6 +28,7 @@ import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.BillTimeVo;
|
|
|
|
import com.iformall.domain.vo.RatioVo;
|
|
|
|
import com.iformall.domain.vo.RentContractFreePeriodVo;
|
|
|
|
import com.iformall.domain.vo.WxBillSum;
|
|
|
|
import com.iformall.domain.vo.WxRentContractRevenueSetSalesVo;
|
|
|
|
import com.iformall.domain.vo.WxRentContractYearsSumVo;
|
|
|
|
import com.iformall.enums.EnumBillAllType;
|
|
|
|
@@ -1045,7 +1046,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
}
|
|
|
|
return yearList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<WxAllBill> buildRentMonth(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate,Integer isPreview, boolean saveDb) {
|
|
|
|
int years = 0;
|
|
|
|
//计算租金每年的计费基数
|
|
|
|
@@ -2438,8 +2439,45 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private BigDecimal calcuteReveneuJump(BigDecimal sales,WxRentContract rentcontract) {
|
|
|
|
return null;
|
|
|
|
private BigDecimal[] calcuteReveneuJump(BigDecimal sales,WxRentContract rentcontract,Date startDate,Date endDate,List<Date> freePeriods) {
|
|
|
|
WxRentContractRevenueJump jq = new WxRentContractRevenueJump();
|
|
|
|
jq.updateTenantInfo(rentcontract);
|
|
|
|
jq.setRentContractId(rentcontract.getId());
|
|
|
|
jq.setSortColumn(" minMoney asc");
|
|
|
|
BigDecimal revenueDecimal = new BigDecimal(0);
|
|
|
|
BigDecimal rentDecimal = new BigDecimal(0);
|
|
|
|
List<WxRentContractRevenueJump> jumpList = wxRentContractRevenueJumpMapper.findList(jq);
|
|
|
|
if (null != jumpList && jumpList.size() > 0 ) {
|
|
|
|
for (int i = 0 ; i< jumpList.size() ; i ++) {
|
|
|
|
WxRentContractRevenueJump rj = jumpList.get(i);
|
|
|
|
String minMoney = rj.getMinMoney();
|
|
|
|
String maxMoney = rj.getMaxMoney();
|
|
|
|
if (StringUtils.isNotBlank(maxMoney)) {
|
|
|
|
if (sales.compareTo(new BigDecimal(maxMoney)) <= 0 ) {
|
|
|
|
revenueDecimal = sales.multiply(new BigDecimal(rj.getRate()));
|
|
|
|
if (StringUtils.isNotBlank(rj.getRentMoney())) {
|
|
|
|
rentDecimal = new BigDecimal(rj.getRentMoney());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
if (sales.compareTo(new BigDecimal(minMoney)) > 0 ) {
|
|
|
|
revenueDecimal = sales.multiply(new BigDecimal(rj.getRate()));
|
|
|
|
if (StringUtils.isNotBlank(rj.getRentMoney())) {
|
|
|
|
rentDecimal = new BigDecimal(rj.getRentMoney());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//根据时间区间计算
|
|
|
|
//固定租金需要再计算,因为跳点设置的租金是单价
|
|
|
|
String rentNeedpay = WxRentContractHelper.getNeedPayMoney(freePeriods,rentcontract, rentDecimal.toPlainString(),startDate,
|
|
|
|
endDate,0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod());
|
|
|
|
rentDecimal = new BigDecimal(rentNeedpay);
|
|
|
|
BigDecimal[] bs = new BigDecimal[] {revenueDecimal,rentDecimal};
|
|
|
|
return bs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2504,7 +2542,15 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
rentBill.getEndtime(),0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod());
|
|
|
|
|
|
|
|
//计算跳点。
|
|
|
|
BigDecimal jumppay = calcuteReveneuJump(salesDeciaml, rentcontract);
|
|
|
|
BigDecimal[] jumppays = calcuteReveneuJump(salesDeciaml, rentcontract,rentBill.getStarttime(), rentBill.getEndtime(),freePeriods);
|
|
|
|
BigDecimal jumpRevenuePay = jumppays[0];
|
|
|
|
BigDecimal jumpRentPay = jumppays[1];
|
|
|
|
BigDecimal jumppay = new BigDecimal(0);
|
|
|
|
if (jumpRevenuePay.compareTo(jumpRentPay) > 0 ) {
|
|
|
|
jumppay = jumppay.add(jumpRevenuePay);
|
|
|
|
}else {
|
|
|
|
jumppay = jumppay.add(jumpRentPay);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (jumppay.compareTo(new BigDecimal(needpay)) > 0 ) {
|
|
|
|
needpay = jumppay.toPlainString();
|
|
|
|
@@ -2542,7 +2588,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
if (new BigDecimal(rentBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
|
|
|
|
rentBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
|
|
|
|
}else {
|
|
|
|
rentBill.setStatus(EnumBillStatus.PAID.getCode());
|
|
|
|
//rentBill.setStatus(EnumBillStatus.PAID.getCode());
|
|
|
|
}
|
|
|
|
wxAllBillMapper.updateById(rentBill);
|
|
|
|
//物业账单应收就改为0,因为金额已经合并了
|
|
|
|
@@ -2553,7 +2599,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
if (new BigDecimal(propertyBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
|
|
|
|
propertyBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
|
|
|
|
}else {
|
|
|
|
propertyBill.setStatus(EnumBillStatus.PAID.getCode());
|
|
|
|
//propertyBill.setStatus(EnumBillStatus.PAID.getCode());
|
|
|
|
}
|
|
|
|
propertyBill.setUpdatetime(new Date());
|
|
|
|
wxAllBillMapper.updateById(propertyBill);
|
|
|
|
@@ -2572,7 +2618,84 @@ public class WxRentContractServiceImpl implements WxRentContractService { |
|
|
|
|
|
|
|
@Override
|
|
|
|
public WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract) {
|
|
|
|
//通过销售额汇总,查询跳点,计算扣点总应收
|
|
|
|
return null;
|
|
|
|
//查询销售总数
|
|
|
|
WxRentContractRevenueSales rsq = new WxRentContractRevenueSales();
|
|
|
|
rsq.updateTenantInfo(rentcontract);
|
|
|
|
rsq.setRentContractId(rentcontract.getId());
|
|
|
|
BigDecimal sum = wxRentContractRevenueSalesMapper.findSumSalesMoney(rsq);
|
|
|
|
//计算跳点。
|
|
|
|
BigDecimal[] jumppays = calcuteReveneuJump(sum, rentcontract,rentcontract.getYearsBegin(), rentcontract.getYearsEnd(),null);
|
|
|
|
BigDecimal jumpRevenuePay = jumppays[0];
|
|
|
|
//BigDecimal jumpRentPay = jumppays[1];
|
|
|
|
|
|
|
|
BigDecimal receivepay = new BigDecimal(0);
|
|
|
|
//查询所有租金和物业账单的信息
|
|
|
|
WxAllBill rentBillq = new WxAllBill();
|
|
|
|
rentBillq.updateTenantInfo(rentcontract);
|
|
|
|
rentBillq.setRentContractId(rentcontract.getId());
|
|
|
|
rentBillq.setBillType(EnumBillAllType.RENT.getCode());
|
|
|
|
rentBillq.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId());
|
|
|
|
rentBillq.setIsPreview(EnumYesOrNo.NO.getCode());
|
|
|
|
rentBillq.setStarttimeEqual(rentcontract.getYearsBegin());
|
|
|
|
rentBillq.setEndtimeEqual(rentcontract.getYearsEnd());
|
|
|
|
WxBillSum rentBillSum = wxAllBillMapper.getBillMonthSum(rentBillq);
|
|
|
|
if (null != rentBillSum) {
|
|
|
|
receivepay = receivepay.add(rentBillSum.getNeedPayNumber());
|
|
|
|
}
|
|
|
|
|
|
|
|
WxPropertyContract bq = new WxPropertyContract();
|
|
|
|
bq.updateTenantInfo(rentcontract);
|
|
|
|
bq.setMerchantId(rentcontract.getMerchantId());
|
|
|
|
bq.setRentContractId(rentcontract.getId());
|
|
|
|
bq.setOperationType(EnumContractOperationType.WHOLE.getCode());
|
|
|
|
bq.setStatus(EnumRentContractStatus.PAING.getCode());
|
|
|
|
List<WxPropertyContract> propertyList = wxPropertyContractService.findList(bq);
|
|
|
|
if (null != propertyList && propertyList.size() > 0 ) {
|
|
|
|
WxPropertyContract pc = propertyList.get(0);
|
|
|
|
WxAllBill propertyBillq = new WxAllBill();
|
|
|
|
propertyBillq.updateTenantInfo(rentcontract);
|
|
|
|
propertyBillq.setPropertyContractId(pc.getId());
|
|
|
|
propertyBillq.setBillType(EnumBillAllType.PROPERTY.getCode());
|
|
|
|
propertyBillq.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId());
|
|
|
|
propertyBillq.setIsPreview(EnumYesOrNo.NO.getCode());
|
|
|
|
propertyBillq.setStarttimeEqual(rentcontract.getYearsBegin());
|
|
|
|
propertyBillq.setEndtimeEqual(rentcontract.getYearsEnd());
|
|
|
|
WxBillSum propertyBillSum = wxAllBillMapper.getBillMonthSum(rentBillq);
|
|
|
|
if (null != propertyBillSum) {
|
|
|
|
receivepay = receivepay.add(propertyBillSum.getNeedPayNumber());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WxRentContractYearsSumVo vo = new WxRentContractYearsSumVo();
|
|
|
|
vo.setTotalSales(sum.toPlainString());
|
|
|
|
vo.setTotalRevenue(jumpRevenuePay.toPlainString());
|
|
|
|
vo.setBillReceivePay(receivepay.toPlainString());
|
|
|
|
|
|
|
|
if ( new BigDecimal(vo.getOwe()).compareTo(new BigDecimal(0)) > 0) {
|
|
|
|
//增加一个账单
|
|
|
|
WxAllBill createBillq = new WxAllBill();
|
|
|
|
createBillq.updateTenantInfo(rentcontract);
|
|
|
|
final IdWorker idWorker = IdWorker.get();
|
|
|
|
createBillq.setId(idWorker.nextId());
|
|
|
|
createBillq.setMerchantId(rentcontract.getMerchantId());
|
|
|
|
createBillq.setRentShopType(rentcontract.getRentShopType());
|
|
|
|
createBillq.setCreatetime(new Date());
|
|
|
|
createBillq.setUpdatetime(new Date());
|
|
|
|
createBillq.setPriceDetail("年度汇算销售额:"+sum.toPlainString()+",应扣点金额:"+jumpRevenuePay.toPlainString()+",账单总金额:"+receivepay.toPlainString()+".差额:"+vo.getOwe());
|
|
|
|
createBillq.setNeedPay(vo.getOwe());
|
|
|
|
createBillq.setReceivePay(vo.getOwe());
|
|
|
|
createBillq.setPay("0");
|
|
|
|
createBillq.setBillType(EnumBillAllType.RENT.getCode());
|
|
|
|
createBillq.setStarttime(rentcontract.getYearsBegin());
|
|
|
|
createBillq.setEndtime(rentcontract.getYearsEnd());
|
|
|
|
createBillq.setStatus(EnumBillStatus.WAIT_PAY.getCode());
|
|
|
|
createBillq.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId());
|
|
|
|
createBillq.setBillRemark("扣点年度汇算自动生成");
|
|
|
|
createBillq.setIsPreview(EnumYesOrNo.NO.getCode());
|
|
|
|
createBillq.setRentContractId(rentcontract.getId());
|
|
|
|
wxAllBillMapper.insert(createBillq);
|
|
|
|
}
|
|
|
|
|
|
|
|
return vo;
|
|
|
|
}
|
|
|
|
}
|