Просмотр исходного кода

Merge branch 'release_toaliyun_real' into release_toaliyun_real_offline_activity

release_toaliyun_real
winter 1 год назад
Родитель
Сommit
bb64aaaf67
16 измененных файлов: 709 добавлений и 110 удалений
  1. +0
    -51
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java
  2. +110
    -33
      mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java
  3. +3
    -3
      mallinkAdmin/src/main/resources/db/migration/V202408000000003.sql
  4. +10
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java
  5. +20
    -2
      mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java
  6. +28
    -2
      mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java
  7. +4
    -1
      mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java
  8. +16
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractRevenueSetSalesVo.java
  9. +36
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsSumVo.java
  10. +15
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsVo.java
  11. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumBillStatus.java
  12. +6
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxRentContractRevenueSalesMapper.java
  13. +10
    -0
      mallinkService/src/main/java/com/iformall/service/WxRentContractService.java
  14. +433
    -16
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  15. +2
    -0
      mallinkService/src/main/resources/mapper/WxAllBillMapper.xml
  16. +15
    -1
      mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml

+ 0
- 51
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java Просмотреть файл

@@ -100,57 +100,6 @@ public class WxPropertyContractController extends WxContractBaseController {
String floorName = "";
String buildingName = "";
String shopNumber = "";
// List<Long> floorIds = new ArrayList<Long>();
// List<Long> buildIds = new ArrayList<Long>();
// List<Long> shopIds = new ArrayList<Long>();
// for (int i = 0 ; i < arrays.size(); i ++) {
// JSONObject o = arrays.getJSONObject(i);
// try {
// floorIds.add(Long.parseLong(o.getString("floor")));
// }catch(Exception e) {
// floorName = floorName +","+o.getString("floor");
// }
// try {
// buildIds.add(Long.parseLong(o.getString("building")));
// }catch(Exception e) {
// buildingName = buildingName + ","+ o.getString("building");
// }
// try {
// shopIds.add(Long.parseLong(o.getString("id")));
// }catch(Exception e) {
// shopNumber = shopNumber +","+o.getString("id");
// }
//
//
// }
//
// WxMallBuilding bq = new WxMallBuilding();
// bq.setIds(buildIds);
// PageInfo<WxMallBuilding> bpage = buildingService.listAsPage(bq, 1, 1000);
// if (null != bpage && null != bpage.getList()) {
// for (WxMallBuilding wmb : bpage.getList()) {
// buildingName = buildingName +"," + wmb.getBuildingName();
// }
// }
//
// WxMallFloor fq = new WxMallFloor();
// fq.setIds(floorIds);
// PageInfo<WxMallFloor> fpage = floorService.listAsPage(fq, 1, 1000);
// if (null != fpage && null != fpage.getList()) {
// for (WxMallFloor wmf : fpage.getList()) {
// floorName = floorName +"," + wmf.getFloorName();
// }
// }
//
// WxShop ws = new WxShop();
// ws.setIds(shopIds);
// PageInfo<WxShop> spage = wxShopService.listAsPage(ws, 1, 1000);
// if (null != spage && null != spage.getList()) {
// for (WxShop shop : spage.getList()) {
// shopNumber = shopNumber+","+shop.getShopNumber();
// }
// }
wpc.setFloorName(floorName);
wpc.setBuildingName(buildingName);
wpc.setShopNumber(shopNumber);


+ 110
- 33
mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java Просмотреть файл

@@ -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;
@@ -810,54 +812,129 @@ public class WxRentContractController extends WxContractBaseController {
wxRentContract.setTypeList(typeList);
List<Integer> statusList = new ArrayList<Integer>();
statusList.add(EnumRentContractStatus.PAING.getCode());
statusList.add(EnumRentContractStatus.READY_FOR_PAING.getCode());
//statusList.add(EnumRentContractStatus.READY_FOR_PAING.getCode());
wxRentContract.setStatuss(statusList);
wxRentContract.setSortColumns(SortField.Createtime_DESC);
return new ResultData(wxRentContractService.getRentContractList(wxRentContract, pageNum, pageSize));
}
//查询联营扣点,联营取高的合同账单周期
@GetMapping("revenueBillTimes")
public ResultData revenueBillTimes(@ModelAttribute WxRentContractRevenueSales sales) {
if (null == sales) sales = new WxRentContractRevenueSales();
sales.updateTenantInfo(getTenantInfo());
WxAllBill bq = new WxAllBill();
bq.updateTenantInfo(sales);
bq.setRentContractId(sales.getRentContractId());
bq.setIsPreview(EnumYesOrNo.NO.getCode());
bq.setBillType(EnumBillAllType.RENT.getCode());
bq.setEnergyFeesId(EnumBillAllType.RENT.getEnergyFeesId());
bq.setSortColumn(" starttime asc");
List<WxAllBill> billList = wxAllBillService.list(bq);
WxRentContract rc = new WxRentContract();
rc.updateTenantInfo(sales);
rc.setId(sales.getRentContractId());
List<WxRentContractRevenueSales> salesList = wxRentContractService.getContractSales(rc);
if (null != salesList && salesList.size() > 0 && null != billList && billList.size() > 0 ) {
Map<Long,WxRentContractRevenueSales> billSalesMap = new HashMap<Long,WxRentContractRevenueSales>();
for (int i = 0 ; i < salesList.size() ; i ++ ) {
WxRentContractRevenueSales rs = salesList.get(i);
billSalesMap.put(rs.getBillId(), rs);
}
for (int i = 0 ; i < billList.size() ; i ++) {
WxAllBill bill = billList.get(i);
WxRentContractRevenueSales s = billSalesMap.get(bill.getId());
if (null != s) {
bill.setSales(s.getSaleMoney());
bill.setSalesTime(s.getUpdateTime());
}
}
}
return new ResultData(billList);
}
//查询商户计租合同列表
@GetMapping("revenuePropertyContract")
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());
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 ) {
return new ResultData(propertyList.get(0));
}
return new ResultData();
}
/**
* 扣点设置销售额重新计算
* @param wxRentContract
* @return
*/
@PostMapping("setRevenueSales")
public ResultData setRevenueSales(@RequestBody WxRentContract wxRentContract) {
WxRentContract rentContract = wxRentContractMapper.selectById(wxRentContract.getId());
if (null == rentContract) {
return new ResultData(Result.ERROR, "编号["+wxRentContract.getId()+"]未找到租金合同");
}
MallUserInfo user = getUser();
//查询是否有审批流程
if(!rentContractHasWorkFlow(rentContract)) {
return new ResultData(ErrorCode.FLOW_FAIL.getCode(),"租赁合同不存在工作流,不能提交审批。");
}
try {
validConfilit(rentContract);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
try {
validShop(rentContract);
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}
//如果是租金+物业合同,如果没有物业合同或者物业合同不是草稿状态,不能提交审核
if (rentContract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()) {
if (null == wxRentContract.getPropertyId()) {
return new ResultData(Result.ERROR,"未创建物业合同,请先完善。");
}
WxPropertyContract property = wxPropertyContractService.getSimpleDetail(wxRentContract.getPropertyId());
if (null == property) {
return new ResultData(Result.ERROR,"未创建物业合同,请先完善。");
}
if (property.getStatus().intValue() == EnumRentContractStatus.UNWRITE.getCode().intValue()) {
return new ResultData(Result.ERROR,"物业合同未完善,请先完善。");
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 ++) {
Date end = yearList.get(i);
Date realEnd = DateUtils.getDaySet(end, Calendar.SECOND, -1);
WxRentContractYearsVo vo = new WxRentContractYearsVo();
vo.setStart(begin);
vo.setEnd(realEnd);
vo.setRemark("第"+i+1+"年度");
retList.add(vo);
begin = end;
}
if (property.getStatus().intValue() != EnumRentContractStatus.DRAFT.getCode().intValue()) {
return new ResultData(Result.ERROR,"物业合同当前状态不能提交审批。");
}
return new ResultData(retList);
}
return wxRentContractService.apply(rentContract,user);
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));
}

}


+ 3
- 3
mallinkAdmin/src/main/resources/db/migration/V202408000000003.sql Просмотреть файл

@@ -4,13 +4,13 @@ CREATE TABLE `wx_rent_contract_revenue_sales` (
`parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`rent_contract_id` bigint(20) NOT NULL COMMENT '合同编号',
`rent_contract_id` bigint(20) NOT NULL COMMENT '租金合同编号',
`bill_id` bigint(20) NOT NULL COMMENT '账单编号',
`bill_money` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '账单应付金额',
`sale_money` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '销售金额',
`remark` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '备注',
`calcute_money` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '计算之后的金额',
`property_contract_id` bigint(20) DEFAULT NULL COMMENT '物业合同',
PRIMARY KEY (`id`),
KEY `T_R_B` (`tenant_id`,`rent_contract_id`,`bill_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='租赁合同';

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='租赁合同';

+ 10
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java Просмотреть файл

@@ -114,6 +114,8 @@ public class WxAllBill extends TenantEntity {
}
return starttimeStr;
}
@TableField(exist = false)
private Date starttimeEqual;
@Excel(name = "周期结束时间", format = "yyyy-MM-dd", width = 20, orderNum = "5")
@io.swagger.annotations.ApiModelProperty(value="结束时间",name="endtime")
@@ -130,6 +132,8 @@ public class WxAllBill extends TenantEntity {
}
return endtimeStr;
}
@TableField(exist = false)
public Date endtimeEqual;

@Excel(name = "欠缴金额(元)", width = 20, orderNum = "11")
@TableField(exist = false)
@@ -344,4 +348,10 @@ public class WxAllBill extends TenantEntity {
private Long feesStandarsId;
@TableField(exist = false)
public Integer toPayMerchant;
@TableField(exist = false)
public String sales;
@TableField(exist = false)
public Date salesTime;
@TableField(exist = false)
public String moneyChangeDetail;
}

+ 20
- 2
mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java Просмотреть файл

@@ -10,6 +10,7 @@ import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumPriceUnit;
import com.iformall.enums.EnumPropertyCreateType;
import com.iformall.enums.EnumRentContractAdjustPeriod;
import com.iformall.enums.EnumRentContractStatus;
import com.iformall.enums.EnumYesOrNo;

import lombok.Data;
@@ -77,10 +78,19 @@ public class WxPropertyContract extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="合同文件路径",name="filepath")
private String filepath;

@io.swagger.annotations.ApiModelProperty(value="合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期",name="status")
@io.swagger.annotations.ApiModelProperty(value="合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期EnumRentContractStatus",name="status")
private Integer status;
@TableField(exist = false)
private List<Integer> statuss;
@TableField(exist = false)
private String statusName;
public String getStatusName() {
if (null != status) {
return EnumRentContractStatus.getEnum(status).getMessage();
}
return null;
}
@io.swagger.annotations.ApiModelProperty(value="是否固定价格",name="0:按面积计算,1:固定价格")
private Integer fixedPrice;
@@ -192,8 +202,16 @@ public class WxPropertyContract extends TenantEntity {
@TableField(exist = false)
private String buildingName;

@io.swagger.annotations.ApiModelProperty(value = "租金单位1日2月3年", name = "priceUnit")
@io.swagger.annotations.ApiModelProperty(value = "租金单位1日2月3年EnumPriceUnit", name = "priceUnit")
private Integer priceUnit;
@TableField(exist = false)
private String priceUnitName;
public String getPriceUnitName() {
if (null != priceUnit) {
return EnumPriceUnit.getEnum(priceUnit).getMessage();
}
return null;
}

@io.swagger.annotations.ApiModelProperty(value = "多径租赁单价(其他放rentInfo)", name = "priceUnit")
private String rentPrice;


+ 28
- 2
mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java Просмотреть файл

@@ -9,6 +9,7 @@ import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.RentContractFreePeriodVo;
import com.iformall.enums.EnumPriceUnit;
import com.iformall.enums.EnumRentContractAdjustPeriod;
import com.iformall.enums.EnumRentContractStatus;
import com.iformall.enums.EnumRentContractType;
import com.iformall.utils.Constant;

@@ -243,10 +244,18 @@ public class WxRentContract extends TenantEntity {
private Integer receivePeriodUnit;
@io.swagger.annotations.ApiModelProperty(value = "合同文件路径", name = "filepath")
private String filepath;
@io.swagger.annotations.ApiModelProperty(value = "合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期", name = "status")
@io.swagger.annotations.ApiModelProperty(value = "合同进度状态1待签约2已签约未记租3计租中4提前终止5合同到期EnumRentContractStatus", name = "status")
private Integer status;
@TableField(exist = false)
private List<Integer> statuss;
@TableField(exist = false)
private String statusName;
public String getStatusName() {
if (null != status) {
return EnumRentContractStatus.getEnum(status).getMessage();
}
return null;
}

@io.swagger.annotations.ApiModelProperty(value = "押金", name = "deposit")
private String deposit;
@@ -374,8 +383,16 @@ public class WxRentContract extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value = "上传文件名", name = "fileNames")
private String fileNames;

@io.swagger.annotations.ApiModelProperty(value = "租金单位1日2月3年", name = "priceUnit")
@io.swagger.annotations.ApiModelProperty(value = "租金单位1日2月3年EnumPriceUnit", name = "priceUnit")
private Integer priceUnit;
@TableField(exist = false)
private String priceUnitName;
public String getPriceUnitName() {
if (null != priceUnit) {
return EnumPriceUnit.getEnum(priceUnit).getMessage();
}
return null;
}

@io.swagger.annotations.ApiModelProperty(value = "租金租赁单价(其他放rentInfo)", name = "priceUnit")
private String rentPrice;
@@ -572,6 +589,7 @@ public class WxRentContract extends TenantEntity {
@TableField(exist = false)
private Long propertyContractId;
@TableField(exist = false)
private List<RentContractFreePeriodVo> freePeriods;
public void setFreeVo(List<WxRentContractFreePeriod> freePeriods) {
@@ -596,5 +614,13 @@ public class WxRentContract extends TenantEntity {
}
}
@TableField(exist = false)
private String salesMoney;
@TableField(exist = false)
private Long billId;
@TableField(exist = false)
private Date yearsBegin;
@TableField(exist = false)
private Date yearsEnd;
}


+ 4
- 1
mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java Просмотреть файл

@@ -26,9 +26,12 @@ public class WxRentContractRevenueSales extends TenantEntity {
@io.swagger.annotations.ApiModelProperty(value="updateTime",name="updateTime")
private Date updateTime;
@io.swagger.annotations.ApiModelProperty(value = "合同编号", name = "rentContractId")
@io.swagger.annotations.ApiModelProperty(value = "租金合同编号", name = "rentContractId")
private Long rentContractId;
@io.swagger.annotations.ApiModelProperty(value = "物业合同编号", name = "propertyContractId")
private Long propertyContractId;
@io.swagger.annotations.ApiModelProperty(value = "账单编号", name = "billId")
private Long billId;


+ 16
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractRevenueSetSalesVo.java Просмотреть файл

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

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

import com.iformall.domain.po.WxAllBill;

@Data
public class WxRentContractRevenueSetSalesVo implements Serializable {

private static final long serialVersionUID = 1L;

private String total;
private List<WxAllBill> billList;
}

+ 36
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsSumVo.java Просмотреть файл

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

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

import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;
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 totalRevenue;
//账单总应收
private String billReceivePay;
//差额
private String owe;
public String getOwe() {
if (StringUtils.isBlank(totalRevenue)) {
totalRevenue = "0";
}
if (StringUtils.isBlank(billReceivePay)) {
billReceivePay = "0";
}
owe = new BigDecimal(totalRevenue).subtract(new BigDecimal(billReceivePay)).toPlainString();
return owe;
}
}

+ 15
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractYearsVo.java Просмотреть файл

@@ -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;
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/enums/EnumBillStatus.java Просмотреть файл

@@ -13,7 +13,7 @@ public enum EnumBillStatus {
PAID(3, "已结清"),
INVALID(6, "失效"),
BAD(7, "坏账"),
STOP_TO_SETTLE(8,"退租待结算"),
STOP_TO_SETTLE(8,"待结算"),
SET_OFF(9,"预收待抵扣")
;



+ 6
- 0
mallinkService/src/main/java/com/iformall/mapper/WxRentContractRevenueSalesMapper.java Просмотреть файл

@@ -4,6 +4,8 @@ import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxRentContractRevenueSales;

import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
@@ -13,5 +15,9 @@ public interface WxRentContractRevenueSalesMapper extends CommonMapper<WxRentCon
List<WxRentContractRevenueSales> findList(WxRentContractRevenueSales wxBillRent);

WxRentContractRevenueSales selectById(@Param("id")Long id,@Param("tenantId")String tenantId);
BigDecimal findSumSalesMoney(WxRentContractRevenueSales wxBillRent);
List<Long> findBillId(WxRentContractRevenueSales wxBillRent);
}

+ 10
- 0
mallinkService/src/main/java/com/iformall/service/WxRentContractService.java Просмотреть файл

@@ -7,8 +7,11 @@ import com.iformall.domain.po.WxAllBill;
import com.iformall.domain.po.WxMall;
import com.iformall.domain.po.WxRentContract;
import com.iformall.domain.po.WxRentContractFreePeriod;
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;
@@ -81,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);
@@ -154,4 +158,10 @@ public interface WxRentContractService {
void saveFreePeriods(WxRentContract wxRentContract);
List<WxRentContractRevenueSales> getContractSales(WxRentContract wxRentContract);
WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract,String sales,Long billId,Long propertyContractId);
WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract);
}

+ 433
- 16
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java Просмотреть файл

@@ -22,11 +22,15 @@ import com.iformall.domain.po.WxPropertyContract;
import com.iformall.domain.po.WxRentContract;
import com.iformall.domain.po.WxRentContractFreePeriod;
import com.iformall.domain.po.WxRentContractRevenueJump;
import com.iformall.domain.po.WxRentContractRevenueSales;
import com.iformall.domain.po.WxShop;
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;
import com.iformall.enums.EnumBillStatus;
import com.iformall.enums.EnumContractOperationType;
@@ -46,6 +50,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;
@@ -146,6 +151,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
@Autowired
WxBusinessMapper wxBusinessMapper;
@Lazy
@Autowired
WxMallService wxMallService;
@@ -1016,20 +1022,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();
@@ -1050,6 +1044,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);
@@ -1057,7 +1067,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
resultList.addAll(billRentList);
return resultList;
}
public List<WxAllBill> buildRentJinmao(MallUserInfo user, WxRentContract wxRentContract, int receivePeriod, Integer lease, Date rentalStartDate, String price, Integer isPreview, boolean saveDb) {
int size = 0;
String[] priceArrs = null;
@@ -1456,7 +1466,6 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return resultMap;
}
private WxAllBill setManageRent(Integer decimalSize,WxAllBill wxBillRent,EnumRentContractManageFeeType feeType,String needPay,Integer serviceChargeRate,int dayType,int receivePeriod) {
WxAllBill manage = new WxAllBill();
manage.setRentContractId(wxBillRent.getRentContractId());
@@ -2311,4 +2320,412 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
}
@Override
public List<WxRentContractRevenueSales> getContractSales(WxRentContract wxRentContract) {
WxRentContractRevenueSales sales = new WxRentContractRevenueSales();
sales.updateTenantInfo(wxRentContract);
sales.setRentContractId(wxRentContract.getId());
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,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;
}
@Override
public WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract, String sales, Long billId, Long propertyContractId) {
WxAllBill rentBill = wxAllBillMapper.selectById(billId, rentcontract.getTenantId());
BigDecimal salesDeciaml = new BigDecimal(sales);
//加上物业
WxAllBill propertyBill = null;
if (null != propertyContractId) {
WxAllBill propertyBillq = new WxAllBill();
propertyBillq.updateTenantInfo(rentcontract);
propertyBillq.setPropertyContractId(propertyContractId);
propertyBillq.setBillType(EnumBillAllType.PROPERTY.getCode());
propertyBillq.setEnergyFeesId(EnumBillAllType.PROPERTY.getEnergyFeesId());
propertyBillq.setIsPreview(EnumYesOrNo.NO.getCode());
propertyBillq.setStarttimeEqual(rentBill.getStarttime());
propertyBillq.setStarttimeEqual(rentBill.getEndtime());
List<WxAllBill> propertyBillList = wxAllBillMapper.findList(propertyBillq);
if (null != propertyBillList && propertyBillList.size() > 0) {
propertyBill = propertyBillList.get(0);
}
}
//根据销售额来计算价格均值
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, priceArrs[yearIndex],rentBill.getStarttime(),
rentBill.getEndtime(),0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod());
//计算跳点。
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();
}
//保存销售额
WxRentContractRevenueSales rs = new WxRentContractRevenueSales();
rs.updateTenantInfo(rentcontract);
rs.setRentContractId(rentcontract.getId());
rs.setBillId(billId);
List<WxRentContractRevenueSales> saleList = wxRentContractRevenueSalesMapper.findList(rs);
if (null != saleList && saleList.size() > 0 ) { WxRentContractRevenueSales sale = saleList.get(0);
sale.setSaleMoney(sales);
sale.setUpdateTime(new Date());
wxRentContractRevenueSalesMapper.updateById(sale);
}else {
WxRentContractRevenueSales sale = new WxRentContractRevenueSales();
sale.updateTenantInfo(rentcontract);
sale.setBillId(billId);
sale.setRentContractId(rentcontract.getId());
sale.setBillMoney(rentBill.getReceivePay());
sale.setSaleMoney(sales);
sale.setCalcuteMoney(needpay);
sale.setPropertyContractId(propertyContractId);
sale.setCreateTime(new Date());
sale.setUpdateTime(new Date());
wxRentContractRevenueSalesMapper.insert(sale);
}
//更新账单费用
rentBill.setMoneyChangeDetail("原合同租金金额:"+rentBill.getReceivePay()+"元,计算之后为:"+needpay+"元。");
rentBill.setReceivePay(needpay);
rentBill.setBillRemark("设置销售额,自动计算");
rentBill.setUpdatetime(new Date());
if (new BigDecimal(rentBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
rentBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
}else {
//rentBill.setStatus(EnumBillStatus.PAID.getCode());
}
wxAllBillMapper.updateById(rentBill);
//物业账单应收就改为0,因为金额已经合并了
if (null != propertyBill) {
propertyBill.setMoneyChangeDetail("原合同物业金额:"+propertyBill.getReceivePay()+"元,已合并到租金,调整为:0元。");
propertyBill.setReceivePay("0");
propertyBill.setBillRemark("设置销售额,已自动计算合并到租金");
if (new BigDecimal(propertyBill.getOwe()).compareTo(new BigDecimal(0)) < 0 ) {
propertyBill.setStatus(EnumBillStatus.STOP_TO_SETTLE.getCode());
}else {
//propertyBill.setStatus(EnumBillStatus.PAID.getCode());
}
propertyBill.setUpdatetime(new Date());
wxAllBillMapper.updateById(propertyBill);
}
WxRentContractRevenueSetSalesVo vo = new WxRentContractRevenueSetSalesVo();
vo.setTotal(needpay);
List<WxAllBill> blist = new ArrayList<WxAllBill>();
blist.add(rentBill);
if (null != propertyBill) {
blist.add(propertyBill);
}
vo.setBillList(blist);;
return vo;
}
@Override
public WxRentContractYearsSumVo calcuteYearsRevenueRentUp(WxRentContract rentcontract) {
//查询销售总数
WxRentContractRevenueSales rsq = new WxRentContractRevenueSales();
rsq.updateTenantInfo(rentcontract);
rsq.setRentContractId(rentcontract.getId());
//BigDecimal sum = wxRentContractRevenueSalesMapper.findSumSalesMoney(rsq);
List<Long> billIdList = wxRentContractRevenueSalesMapper.findBillId(rsq);
Date realStartTime = null;
Date realEndTime = null;
if (null != billIdList || billIdList.size() > 0 ) {
WxAllBill abq = new WxAllBill();
abq.updateTenantInfo(rentcontract);
abq.setIds(billIdList);
abq.setStarttimeEqual(rentcontract.getYearsBegin());
abq.setStarttimeEqual(rentcontract.getYearsEnd());
abq.setSortColumn(" starttime asc");
List<WxAllBill> billList = wxAllBillMapper.findList(abq);
if (null == billList || billList.size() <= 0 ){
return null;
}
realStartTime = billList.get(0).getStarttime();
realEndTime = billList.get(billList.size()-1).getEndtime();
}
BigDecimal sum = new BigDecimal(0);
//计算跳点。
BigDecimal[] jumppays = calcuteReveneuJump(sum, rentcontract,rentcontract.getYearsBegin(), rentcontract.getYearsEnd(),null);
BigDecimal jumpRevenuePay = jumppays[0];
//BigDecimal jumpRentPay = jumppays[1];
//销售收入不满足一年怎么算。
if (realStartTime.equals(rentcontract.getYearsBegin()) && realEndTime.equals(rentcontract.getYearsEnd())) {
}else {
int days = DateUtils.daysBetween(realStartTime, realEndTime)+1;
if (rentcontract.getDayPriceCalcute().intValue() == EnumRentDayPriceCalcute.AVERAGE_DAYS.getCode()) {
jumpRevenuePay = jumpRevenuePay.multiply(new BigDecimal(days)).divide(new BigDecimal(12*rentcontract.getMonthAverageDays()),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}else {
jumpRevenuePay = jumpRevenuePay.multiply(new BigDecimal(days)).divide(new BigDecimal(365),Constant.default_long_decimal_size,BigDecimal.ROUND_HALF_UP);
}
}
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;
}
}

+ 2
- 0
mallinkService/src/main/resources/mapper/WxAllBillMapper.xml Просмотреть файл

@@ -69,6 +69,8 @@
<if test=" null != isPreview ">and `is_preview` = #{isPreview}</if>
<if test=" null != starttime">and `starttime` &gt;= #{starttime}</if>
<if test=" null != endtime">and `endtime` &lt;= #{endtime}</if>
<if test=" null != starttimeEqual">and `starttime` = #{starttimeEqual}</if>
<if test=" null != endtimeEqual">and `endtime` = #{endtimeEqual}</if>
<if test=" null != month and '' != month">
and date_format(starttime,'%Y-%m') &lt;= #{month} and date_format(endtime,'%Y-%m') &gt;= #{month}
</if>


+ 15
- 1
mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml Просмотреть файл

@@ -8,6 +8,7 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
<result column="property_contract_id" jdbcType="BIGINT" property="propertyContractId"/>
<result column="bill_id" jdbcType="BIGINT" property="billId"/>
<result column="bill_money" jdbcType="VARCHAR" property="billMoney"/>
<result column="sale_money" jdbcType="VARCHAR" property="saleMoney"/>
@@ -16,7 +17,7 @@
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`rent_contract_id`,`bill_id`,`bill_money`,
`id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`rent_contract_id`,`property_contract_id`,`bill_id`,`bill_money`,
`sale_money`,`calcute_money`,`remark`
</sql>

@@ -30,6 +31,7 @@
and `parent_tenant_id` = #{parentTenantId}
</if>
<if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
<if test=" null != propertyContractId ">and `property_contract_id` = #{propertyContractId}</if>
<if test=" null != billId ">and `bill_id` = #{billId}</if>
<if test=" null != ids ">
and id in
@@ -53,5 +55,17 @@
from wx_rent_contract_revenue_sales where id = #{id} and `tenant_id` = #{tenantId}
</select>
<select id="findSumSalesMoney" parameterType="com.iformall.domain.po.WxRentContractRevenueSales" resultType="BigDecimal">
select sum(CAST(sale_money AS DECIMAL(20,2))) receive_pay
from wx_rent_contract_revenue_sales
<include refid="dynamicWhereConditions"/>
</select>
<select id="findBillId" parameterType="com.iformall.domain.po.WxRentContractRevenueSales" resultType="Long">
select distinct bill_id
from wx_rent_contract_revenue_sales
<include refid="dynamicWhereConditions"/>
</select>
</mapper>


Загрузка…
Отмена
Сохранить