From 6d7a201f2de0a1d82cb4063cda6b7500f0c708f0 Mon Sep 17 00:00:00 2001 From: winter Date: Sun, 11 Aug 2024 13:45:52 +0800 Subject: [PATCH] fix --- .../WxPropertyContractController.java | 51 --------- .../contract/WxRentContractController.java | 94 ++++++++++------ .../db/migration/V202408000000003.sql | 6 +- .../com/iformall/domain/po/WxAllBill.java | 10 ++ .../domain/po/WxPropertyContract.java | 22 +++- .../iformall/domain/po/WxRentContract.java | 26 ++++- .../domain/po/WxRentContractRevenueSales.java | 5 +- .../vo/WxRentContractRevenueSetSalesVo.java | 16 +++ .../com/iformall/enums/EnumBillStatus.java | 2 +- .../service/WxRentContractService.java | 6 ++ .../impl/WxRentContractServiceImpl.java | 102 +++++++++++++++++- .../main/resources/mapper/WxAllBillMapper.xml | 2 + .../WxRentContractRevenueSalesMapper.xml | 4 +- 13 files changed, 248 insertions(+), 98 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractRevenueSetSalesVo.java diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java index f97ae626b..07e430cef 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxPropertyContractController.java +++ b/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 floorIds = new ArrayList(); -// List buildIds = new ArrayList(); -// List shopIds = new ArrayList(); -// 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 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 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 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); diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java index 4fb14d140..261c2c338 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/contract/WxRentContractController.java @@ -810,52 +810,76 @@ public class WxRentContractController extends WxContractBaseController { wxRentContract.setTypeList(typeList); List statusList = new ArrayList(); 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 billList = wxAllBillService.list(bq); + + WxRentContract rc = new WxRentContract(); + rc.updateTenantInfo(sales); + rc.setId(sales.getRentContractId()); + List salesList = wxRentContractService.getContractSales(rc); + if (null != salesList && salesList.size() > 0 && null != billList && billList.size() > 0 ) { + Map billSalesMap = new HashMap(); + 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()); + + 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 propertyList = wxPropertyContractService.findList(bq); + return new ResultData(propertyList); + } + @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,"物业合同未完善,请先完善。"); - } - if (property.getStatus().intValue() != EnumRentContractStatus.DRAFT.getCode().intValue()) { - return new ResultData(Result.ERROR,"物业合同当前状态不能提交审批。"); - } - } - return wxRentContractService.apply(rentContract,user); + return new ResultData(wxRentContractService.setRevenueSales(rentContract,wxRentContract.getSalesMoney(),wxRentContract.getBillId(),wxRentContract.getPropertyContractId())); } diff --git a/mallinkAdmin/src/main/resources/db/migration/V202408000000003.sql b/mallinkAdmin/src/main/resources/db/migration/V202408000000003.sql index bddfebb9f..f0d21055a 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202408000000003.sql +++ b/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='租赁合同'; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java b/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java index 973588cb0..f148d2418 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxAllBill.java +++ b/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; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java index bb1a7e0bc..75356d07b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java +++ b/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 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; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java index 4ade46d3d..59fa73d04 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContract.java +++ b/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 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 freePeriods; public void setFreeVo(List freePeriods) { @@ -596,5 +614,9 @@ public class WxRentContract extends TenantEntity { } } + @TableField(exist = false) + private String salesMoney; + @TableField(exist = false) + private Long billId; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java b/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java index 9a285b396..1a7fbb1ca 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxRentContractRevenueSales.java +++ b/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; diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractRevenueSetSalesVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxRentContractRevenueSetSalesVo.java new file mode 100644 index 000000000..84caa789b --- /dev/null +++ b/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 billList; +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumBillStatus.java b/mallinkService/src/main/java/com/iformall/enums/EnumBillStatus.java index 5901b4e43..557ce0527 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumBillStatus.java +++ b/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,"预收待抵扣") ; diff --git a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java index b97e6d279..0f476e714 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxRentContractService.java @@ -7,8 +7,10 @@ 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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -154,4 +156,8 @@ public interface WxRentContractService { void saveFreePeriods(WxRentContract wxRentContract); + List getContractSales(WxRentContract wxRentContract); + + WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract,String sales,Long billId,Long propertyContractId); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 40d3aa41e..56b5889e2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -22,11 +22,13 @@ 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.WxRentContractRevenueSetSalesVo; import com.iformall.enums.EnumBillAllType; import com.iformall.enums.EnumBillStatus; import com.iformall.enums.EnumContractOperationType; @@ -146,6 +148,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { @Autowired WxBusinessMapper wxBusinessMapper; + @Lazy @Autowired WxMallService wxMallService; @@ -1057,7 +1060,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { resultList.addAll(billRentList); return resultList; } - + public List 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 +1459,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 +2313,100 @@ public class WxRentContractServiceImpl implements WxRentContractService { } } + + @Override + public List getContractSales(WxRentContract wxRentContract) { + WxRentContractRevenueSales sales = new WxRentContractRevenueSales(); + sales.updateTenantInfo(wxRentContract); + sales.setRentContractId(wxRentContract.getId()); + return wxRentContractRevenueSalesMapper.findList(sales); + } + + + @Override + public WxRentContractRevenueSetSalesVo setRevenueSales(WxRentContract rentcontract, String sales, Long billId, Long propertyContractId) { + WxAllBill rentBill = wxAllBillMapper.selectById(billId, rentcontract.getTenantId()); + BigDecimal price = 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 propertyBillList = wxAllBillMapper.findList(propertyBillq); + if (null != propertyBillList && propertyBillList.size() > 0) { + propertyBill = propertyBillList.get(0); + price = price.add(new BigDecimal(propertyBill.getReceivePay())); + } + } + + //免租期 + List freePeriods = getFreeDays(rentcontract); + String needpay = WxRentContractHelper.getNeedPayMoney(freePeriods,rentcontract, price.toPlainString(),rentBill.getStarttime(), + rentBill.getEndtime(),0,0,false,rentcontract.getReceivePeriodUnit(),rentcontract.getReceivePeriod()); + + //保存销售额 + WxRentContractRevenueSales rs = new WxRentContractRevenueSales(); + rs.updateTenantInfo(rentcontract); + rs.setRentContractId(rentcontract.getId()); + rs.setBillId(billId); + List 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 blist = new ArrayList(); + blist.add(rentBill); + if (null != propertyBill) { + blist.add(propertyBill); + } + vo.setBillList(blist);; + return vo; + } } diff --git a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml index d5d61ee65..fcb1471c6 100644 --- a/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxAllBillMapper.xml @@ -69,6 +69,8 @@ and `is_preview` = #{isPreview} and `starttime` >= #{starttime} and `endtime` <= #{endtime} + and `starttime` = #{starttimeEqual} + and `endtime` = #{endtimeEqual} and date_format(starttime,'%Y-%m') <= #{month} and date_format(endtime,'%Y-%m') >= #{month} diff --git a/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml b/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml index af991e549..7591717d9 100644 --- a/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxRentContractRevenueSalesMapper.xml @@ -8,6 +8,7 @@ + @@ -16,7 +17,7 @@ - `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` @@ -30,6 +31,7 @@ and `parent_tenant_id` = #{parentTenantId} and `rent_contract_id` = #{rentContractId} + and `property_contract_id` = #{propertyContractId} and `bill_id` = #{billId} and id in