zhengfangyuan 3 лет назад
Родитель
Сommit
6415902cf3
12 измененных файлов: 731 добавлений и 3 удалений
  1. +44
    -0
      mallinkAdmin/src/main/resources/db/migration/V202301200001__contract.sql
  2. +194
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxBillRentManage.java
  3. +5
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxBillAll.java
  4. +3
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumBillQueryType.java
  5. +37
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumRentContractManageFeeType.java
  6. +1
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxBillAllMapper.java
  7. +32
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxBillRentManageMapper.java
  8. +10
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java
  9. +168
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  10. +32
    -0
      mallinkService/src/main/resources/mapper/WxBillAllMapper.xml
  11. +1
    -0
      mallinkService/src/main/resources/mapper/WxBillDepositMapper.xml
  12. +204
    -0
      mallinkService/src/main/resources/mapper/WxBillRentManageMapper.xml

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

@@ -76,3 +76,47 @@ ADD COLUMN `out_date_notify_days` INT(3) NOT NULL DEFAULT 0 COMMENT '到期提
ALTER TABLE `mallink`.`wx_property_contract`
ADD COLUMN `out_date_notify_phone` varchar(30) COMMENT '到期提醒手机号' ;


CREATE TABLE `wx_bill_rent_manage` (
`id` bigint(20) NOT NULL COMMENT '主键ID',
`rent_contract_id` bigint(20) DEFAULT NULL COMMENT '租金合同ID',
`receive_pay` bigint(12) NOT NULL DEFAULT '0' COMMENT '实际应收',
`pay` bigint(12) NOT NULL DEFAULT '0' COMMENT '已付',
`receive_date` datetime DEFAULT NULL COMMENT '收款日期',
`pay_date` datetime DEFAULT NULL COMMENT '到账日期',
`createtime` datetime DEFAULT NULL COMMENT '创建时间',
`expired_day` int(5) DEFAULT NULL COMMENT '逾期天数',
`tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID',
`parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID',
`owe` bigint(12) NOT NULL DEFAULT '0' COMMENT '欠缴',
`status` smallint(2) DEFAULT '4' COMMENT '账单状态1欠缴2待缴3已结清4未到期5已退还6失效',
`is_del` smallint(2) DEFAULT NULL COMMENT '是否删除 是1否0 未到期不显示',
`need_pay` bigint(12) NOT NULL DEFAULT '0' COMMENT '应收',
`merchant_id` bigint(20) DEFAULT NULL COMMENT '商户ID',
`user_id` bigint(20) DEFAULT NULL COMMENT '账号ID',
`shop_id` bigint(20) DEFAULT NULL COMMENT '商铺ID',
`updatetime` datetime DEFAULT NULL COMMENT '更新时间',
`starttime` datetime DEFAULT NULL COMMENT '账单开始日期',
`endtime` datetime DEFAULT NULL COMMENT '账单结束日期',
`rent_shop_type` smallint(2) DEFAULT '1' COMMENT '租赁店铺类型1店铺2点位',
`late_pay_ratio` int(10) DEFAULT '0' COMMENT '滞纳金费率',
`late_pay_time` datetime DEFAULT NULL COMMENT '滞纳金时间',
`late_pay_price` bigint(12) DEFAULT NULL,
`period` int(10) DEFAULT '0' COMMENT '账期',
`apply_status` smallint(1) DEFAULT '0' COMMENT '审核状态0未审核1审核中2审核完成3驳回4合同作废5撤回',
`pay_way` smallint(2) DEFAULT '-1',
`late_pay_status` smallint(2) DEFAULT '2' COMMENT '滞纳金状态(使用账单的状态)',
`freeze` smallint(1) DEFAULT '0' COMMENT '0正常1冻结',
`service_charge_pay` bigint(12) DEFAULT '0' COMMENT '手续费费',
`apply_pay_img` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '付款截图',
`apply_update_time` datetime DEFAULT NULL COMMENT '审核更新时间',
`shop_info` json DEFAULT NULL COMMENT '商铺信息',
`manage_fee_type` int(1) NOT NULL COMMENT '管理费类型,EnumRentManageFeeType',
PRIMARY KEY (`id`),
KEY `st` (`rent_shop_type`),
KEY `sta` (`status`),
KEY `m` (`merchant_id`),
KEY `s_e` (`starttime`,`endtime`),
KEY `t_p_r_s_c` (`tenant_id`,`rent_shop_type`,`status`,`createtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='租金账单';


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

@@ -0,0 +1,194 @@
package com.iformall.domain.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.common.SortColumn;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;

/**
* @author gongbiao
*/
@TableName(value = "wx_bill_rent_manage")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxBillRentManage extends TenantEntity {

protected Long id;


@Excel(name = "商户名称", width = 20, orderNum = "2")
@TableField(exist = false)
private String merchantName;

@io.swagger.annotations.ApiModelProperty(value="租金合同ID",name="rentContractId")
private Long rentContractId;

@io.swagger.annotations.ApiModelProperty(value="应收金额",name="receivePay")
private Long receivePay;

public String getReceivePayStr() {
return new BigDecimal(receivePay == null ? 0 : receivePay).divide(new BigDecimal(100)).toPlainString();
}

@TableField(exist = false)
private String receivePayStr;

public String getPayStr() {
return new BigDecimal(pay == null ? 0 : pay).divide(new BigDecimal(100)).toPlainString();
}

@Excel(name = "实收账款(元)", width = 20, orderNum = "9")
@TableField(exist = false)
private String payStr;

@io.swagger.annotations.ApiModelProperty(value="实收金额",name="pay")
private Long pay;

@Excel(name = "缴款截止日期", format = "yyyy-MM-dd", width = 20, orderNum = "13")
@io.swagger.annotations.ApiModelProperty(value="收款日期",name="receiveDate")
private Date receiveDate;

@Excel(name = "收款日期", format = "yyyy-MM-dd", width = 20, orderNum = "12")
@io.swagger.annotations.ApiModelProperty(value="到账日期",name="payDate")
private Date payDate;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createtime")
private Date createtime;

@Excel(name = "逾期(天) ", width = 20, orderNum = "14")
@io.swagger.annotations.ApiModelProperty(value="逾期天数",name="expiredDay")
private Long expiredDay;

@io.swagger.annotations.ApiModelProperty(value="欠缴",name="owe")
private Long owe;

public String getOweStr() {
return new BigDecimal(owe == null ? 0 : owe).divide(new BigDecimal(100)).toPlainString();
}

@Excel(name = "欠缴金额(元)", width = 20, orderNum = "11")
@TableField(exist = false)
private String oweStr;

@Excel(name = "状态", replace = {"欠缴_1", "待缴_2", "已结清_3", "未到期_4", "已退还_5", "失效_6"}, width = 20, orderNum = "10")
@io.swagger.annotations.ApiModelProperty(value = "账单状态1欠缴2待缴3已结清4未到期", name = "status")
private Integer status;
@io.swagger.annotations.ApiModelProperty(value = "账单审核状态EnumBillRentApplyStatus", name = "applyStatus")
private Integer applyStatus;
@io.swagger.annotations.ApiModelProperty(value = "付款截图", name = "applyPayImg")
private String applyPayImg;
@io.swagger.annotations.ApiModelProperty(value = "付款截图", name = "applyUpdateTime")
private Date applyUpdateTime;

@io.swagger.annotations.ApiModelProperty(value="是否删除 是1否0 未到期不显示",name="isDel")
private Integer isDel;

@io.swagger.annotations.ApiModelProperty(value="应收金额",name="needPay")
private Long needPay;
@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
private Long merchantId;

@io.swagger.annotations.ApiModelProperty(value="账号ID",name="userId")
private Long userId;

@io.swagger.annotations.ApiModelProperty(value="商铺ID",name="shopId")
private Long shopId;

@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updatetime")
private Date updatetime;

@Excel(name = "周期开始时间", format = "yyyy-MM-dd", width = 20, orderNum = "4")
@io.swagger.annotations.ApiModelProperty(value="开始时间",name="starttime")
private Date starttime;

@Excel(name = "周期结束时间", format = "yyyy-MM-dd", width = 20, orderNum = "5")
@io.swagger.annotations.ApiModelProperty(value="结束时间",name="endtime")
private Date endtime;

@io.swagger.annotations.ApiModelProperty(value = "租赁商铺类型", name = "rentShopType")
private Integer rentShopType;

@io.swagger.annotations.ApiModelProperty(value = "滞纳金费率", name = "latePayRatio")
private Integer latePayRatio;

@io.swagger.annotations.ApiModelProperty(value = "滞纳金时间", name = "latePayTime")
private Date latePayTime;

@io.swagger.annotations.ApiModelProperty(value = "滞纳金总额", name = "latePayPrice")
private Long latePayPrice;

public String getLatePayPriceStr() {
return new BigDecimal(latePayPrice == null ? 0 : latePayPrice).divide(new BigDecimal(100)).toPlainString();
}

@Excel(name = "滞纳金(元)", width = 20, orderNum = "12")
@TableField(exist = false)
private String latePayPriceStr;

@SortColumn(column = "period")
@io.swagger.annotations.ApiModelProperty(value = "账期", name = "period")
private Integer period;

@io.swagger.annotations.ApiModelProperty(value = "商铺信息", name = "shopInfo")
private String shopInfo;

@io.swagger.annotations.ApiModelProperty(value = "支付方式:见枚举EnumBillPayWay", name = "payWay")
private Integer payWay;


@io.swagger.annotations.ApiModelProperty(value = "滞纳金状态", name = "latePayStatus")
private Integer latePayStatus;

@TableField(exist = false)
private Integer limitStart;
@TableField(exist = false)
private Integer limitEnd;

@TableField(exist = false)
private String latePayMoneyBefore;
@TableField(exist = false)
private String latePayMoneyUpdate;

@io.swagger.annotations.ApiModelProperty(value = "冻结状态,0正常1冻结", name = "freeze")
private Integer freeze;

@TableField(exist = false)
private String serviceChargePayBefore;
@TableField(exist = false)
private String serviceChargePayUpdate;

@io.swagger.annotations.ApiModelProperty(value = "手续费", name = "serviceChargePay")
private Integer serviceChargePay;

@io.swagger.annotations.ApiModelProperty(value="实际应收金额",name="realReceivePay")
@TableField(exist = false)
private Long realReceivePay;

@Excel(name = "实际应收总金额(元)", width = 20, orderNum = "8")
@TableField(exist = false)
private String realReceivePayStr;

public String getRealReceivePayStr() {
return new BigDecimal(realReceivePay == null ? 0 : realReceivePay).divide(new BigDecimal(100)).toPlainString();
}
@io.swagger.annotations.ApiModelProperty(value="管理费类型,EnumRentContractManageFeeType",name="manageFeeType")
private Integer manageFeeType;
private void initByBillRent(WxBillRent billRent) {
}

}

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

@@ -160,5 +160,10 @@ public class WxBillAll extends TenantEntity {
private Integer limitStart;
@TableField(exist = false)
private Integer limitEnd;
@TableField(exist = false)
private Integer manageFeeType;
@TableField(exist = false)
private String billTypeName;

}

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

@@ -14,7 +14,9 @@ public enum EnumBillQueryType {
WATER_POWER_AIR(5, "水电空调费"),
OTHER(7, "其他"),
OTHER_DEPOSIT(8, "其他押金"),
SETTLE(10, "结算单")
SETTLE(10, "结算单"),
RENT_BUSSINESS_MANAGE(11,"商业管理费"),
RENT_OPERATING_MANAGE(12,"营业管理费"),
;

public static Integer getRealType(Integer type) {


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

@@ -0,0 +1,37 @@
package com.iformall.enums;

/**
* Created by luozukai
* 预览账单0否1是
*/
public enum EnumRentContractManageFeeType {

RENT_BUSSINESS_MANAGE_FEE(1, "商业管理费"),
RENT_OPERATING_MANAGE_FEE(2, "营业管理费")
;

public static EnumRentContractManageFeeType getEnum(Integer code) {
for (EnumRentContractManageFeeType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumRentContractManageFeeType(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

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

@@ -26,6 +26,7 @@ public interface WxBillAllMapper {
List<WxBillAllVo> listDailyBill(WxBillAll record);
List<WxBillAllVo> listOtherBill(WxBillAll record);
List<WxBillAllVo> listOtherDepositBill(WxBillAll record);
List<WxBillAllVo> listRentManageBill(WxBillAll record);
Map<String,Object> queryOweInfo(WxBillAll record);



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

@@ -0,0 +1,32 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxBillRentManage;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

/**
* @author gongbiao
*/
public interface WxBillRentManageMapper extends CommonMapper<WxBillRentManage, Long> {
List<WxBillRentManage> findList(WxBillRentManage wxBillRentManage);
List<WxBillRentManage> queryBillManageList(WxBillRentManage wxBillRentManage);
Map<String,Object> queryPayInfoTotal(Map<String,Object> params);
void updateNotPaidStatus(Map<String,Object> params);
void updateWaitPayStatus(Map<String,Object> params);
void deletePreviewBill(WxBillRentManage wxBillRentManage);
long oweBillCount(@Param("contractId") Long contractId);
void insertBills(List<WxBillRentManage> resultList);
}

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

@@ -216,6 +216,16 @@ public class WxBillAllServiceImpl implements WxBillAllService {
} else if (wxBillAll.getBillTypeValue().equals(EnumBillQueryType.OTHER_DEPOSIT.getCode())) {
wxBillAll.setBillTypeValue(EnumBillQueryType.OTHER_DEPOSIT.getCode());
retList = wxBillAllMapper.listOtherDepositBill(wxBillAll);
}else if (wxBillAll.getBillTypeValue().equals(EnumBillQueryType.RENT_BUSSINESS_MANAGE.getCode())) {
wxBillAll.setBillTypeValue(EnumBillQueryType.RENT_BUSSINESS_MANAGE.getCode());
wxBillAll.setManageFeeType(EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode());
wxBillAll.setBillTypeName(EnumBillQueryType.RENT_BUSSINESS_MANAGE.getMessage());
retList = wxBillAllMapper.listRentManageBill(wxBillAll);
}else if (wxBillAll.getBillTypeValue().equals(EnumBillQueryType.RENT_OPERATING_MANAGE.getCode())) {
wxBillAll.setBillTypeValue(EnumBillQueryType.RENT_OPERATING_MANAGE.getCode());
wxBillAll.setManageFeeType(EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode());
wxBillAll.setBillTypeName(EnumBillQueryType.RENT_OPERATING_MANAGE.getMessage());
retList = wxBillAllMapper.listRentManageBill(wxBillAll);
} else {
logger.info("账单不存在");
}


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

@@ -127,6 +127,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
@Autowired
WxShopService wxShopService;
@Autowired
WxBillRentManageMapper wxBillRentManageMapper;
// @Override
// public Map<String, Object> listAsPage(WxRentContract record, Integer pageIndex, Integer pageSize) {
// //Object rentContractStatusInfo = getRentContractStatusInfo(record);
@@ -578,6 +581,16 @@ public class WxRentContractServiceImpl implements WxRentContractService {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) {
//删除预账单,重新生成
wxBillRentMapper.deletePreviewBill(record);
//删除商业管理费账单
WxBillRentManage wxBillRentManage = new WxBillRentManage();
wxBillRentManage.setRentContractId(record.getId());
wxBillRentManage.setManageFeeType(EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode());
wxBillRentManageMapper.deletePreviewBill(wxBillRentManage);
//删除营业管理费账单
wxBillRentManage.setManageFeeType(EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode());
wxBillRentManageMapper.deletePreviewBill(wxBillRentManage);
//联营扣点,不设置保底营业额,不生成账单
//if (EnumRentContractType.RENT_BY_JOINT.getCode().equals(record.getType()) && record.getRevenueRatio().equals(0)) {
@@ -592,6 +605,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
//保存调整金额(预账单调整)
//if (saveBill) {
savePreviewBill(record);
//保存商业管理费账单
savePreviewManageFeeBill(record,EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE);
//保存营业管理费账单
savePreviewManageFeeBill(record,EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE);
//}

WxRentContract wxRentContract = (WxRentContract)resultData.data;
@@ -646,6 +663,62 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
wxBillRentMapper.insertBills(record.getPreviewBillRentList());
}
/**
* 重新生成其他管理费用账单(预账单调整)
*/
private void savePreviewManageFeeBill(WxRentContract record,EnumRentContractManageFeeType feeType){
if(CollectionUtils.isEmpty(record.getPreviewBillRentList())){
return;
}
WxBillRentManage wxBillRentManage = new WxBillRentManage();
wxBillRentManage.setRentContractId(record.getId());
wxBillRentManage.setManageFeeType(feeType.getCode());
wxBillRentManageMapper.deletePreviewBill(wxBillRentManage);
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record);
final IdWorker idWorker = IdWorker.get();
int count = 1;
List<Long> shopIds = record.shopIdsByRentInfo();
List<WxBillRentManage> billList = new ArrayList<WxBillRentManage>();
for (WxBillRent _bi:record.getPreviewBillRentList()) {
WxBillRentManage bill = new WxBillRentManage();
bill.setId(idWorker.nextId());
Date date = new Date();
bill.setRentContractId(record.getId());
bill.setCreatetime(date);
bill.updateTenantInfo(record);
bill.setManageFeeType(feeType.getCode());
if (feeType.getCode() == EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE.getCode()) {
bill.setNeedPay(_bi.getBussinessManageFeeNeedPay());
}else if (feeType.getCode() == EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE.getCode()) {
bill.setNeedPay(_bi.getOperatingManageFeeNeedPay());
}
bill.setUpdatetime(date);
bill.setRentShopType(record.getRentShopType());
bill.setPeriod(count);
bill.setShopInfo(getShopInfoStr(record));
bill.setLatePayRatio(0);
bill.setPay(0L);
bill.setIsDel(EnumDelStatus.NOT_DEL.getCode());
if (null != shopIds && shopIds.size() == 1) {
bill.setShopId(shopIds.get(0));
}
setManageExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod());
if (bill.getReceivePay().equals(0L)) {
bill.setStatus(EnumBillRentStatus.PAID.getCode());
bill.setPayDate(date);
}
//计算手续费
BigDecimal servicePay = new BigDecimal(bill.getReceivePay()).multiply(new BigDecimal(wxPayAccountBill.getServiceChargeRate())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP);
bill.setServiceChargePay(servicePay.intValue());
bill.setOwe(bill.getReceivePay() + bill.getServiceChargePay());
count++;
billList.add(bill);
}
if (billList.size() > 0 ) {
wxBillRentManageMapper.insertBills(billList);
}
}

public ResultData getResultDataForUpdate(WxRentContract record, Long userId,int from,Date oldRentStartDate,boolean writeFinal) {
//更新租赁合同信息
@@ -841,6 +914,72 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
}
}
private void buildBussinessManagementFee( Long userId,WxRentContract wxRentContract) {
if (wxRentContract != null && wxRentContract.getBussinessManagementFee() > 0) {
final IdWorker idWorker = IdWorker.get();
WxBillDeposit wxBillDeposit = new WxBillDeposit();
wxBillDeposit.setId(idWorker.nextId());
wxBillDeposit.setRentContractId(wxRentContract.getId());
wxBillDeposit.setPay(0L);
long needpay = wxRentContract.getDeposit();
wxBillDeposit.setReceivePay(needpay);
wxBillDeposit.setNeedPay(needpay);
wxBillDeposit.setOwe(needpay);
//找到计租方式
int dayType = wxRentContract.getAdjustPeriod().equals(EnumRentContractAdjustPeriod.ADJUST_PERIOD_DAY.getCode()) ? Calendar.DAY_OF_MONTH : Calendar.MONTH;

Date date = new Date();
Calendar instance = Calendar.getInstance();
instance.setTime(wxRentContract.getRentalStartDate());
instance.add(Calendar.DAY_OF_MONTH, -1);
Date time = instance.getTime();
wxBillDeposit.setReceiveDate(time);

//账单开始时间
instance.clear();
instance.setTime(wxBillDeposit.getReceiveDate());
instance.add(Calendar.DAY_OF_MONTH, 1);
wxBillDeposit.setStarttime(instance.getTime());
//账单结束时间
instance.clear();
instance.setTime(wxBillDeposit.getReceiveDate());
instance.add(dayType, wxRentContract.getLease());
wxBillDeposit.setEndtime(instance.getTime());
wxBillDeposit.setStatus(EnumBillRentStatus.WAIT_PAY.getCode());
wxBillDeposit.setExpiredDay(0L);
wxBillDeposit.setReceiveDate(time);
wxBillDeposit.updateTenantInfo(wxRentContract);
wxBillDeposit.setIsDel(0);
wxBillDeposit.setMerchantId(wxRentContract.getMerchantId());
wxBillDeposit.setUserId(userId);
if (wxRentContract.shopIdsByRentInfo().size()==1) {
wxBillDeposit.setShopId(wxRentContract.shopIdsByRentInfo().get(0));
}
wxBillDeposit.setCreatetime(date);
wxBillDeposit.setUpdatetime(date);
wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode());
wxBillDeposit.setRentShopType(wxRentContract.getRentShopType());
if (wxRentContract.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = wxRentContract.getRentInfo();
if (rentInfo != null) {
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
Map<String, Object> shopInfo = new HashMap<>();
for (int i = 0, size = rentInfoArray.size(); i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
shopInfo.put(rentInfoObject.getString("shopNumber"), rentInfoObject.get("deposit"));
}
wxBillDeposit.setShopInfo(JSONObject.toJSONString(shopInfo));
}
}
try {
wxBillDepositMapper.insert(wxBillDeposit);
} catch (Exception e) {
logger.error("添加押金账单失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}
}
}

@Override
public Object getMerchants(WxRentContract wxRentContract) {
@@ -1449,7 +1588,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillRent.setRentPriceInfo(getRentPriceInfo(wxRentContract,needpay));
wxBillRent.setNeedPay(needpay);
wxBillRent.setOwe(needpay);
wxBillRent.setReceivePay(bussinessManageFeeNeedpay+operatingManageFeeNeedpay+needpay);
wxBillRent.setReceivePay(needpay);
//商业管理费
wxBillRent.setBussinessManageFeeNeedPay(bussinessManageFeeNeedpay);
//运营管理费
@@ -1511,6 +1650,29 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
}
}
public void setManageExpiredDay(WxBillRentManage wxBillRentManage,int dayType, int receivePeriod){
//截止收租日在当前时间之前
Date date = new Date();
wxBillRentManage.setExpiredDay(0L);
if (wxBillRentManage.getReceiveDate().before(date)) {
long day = (date.getTime() - wxBillRentManage.getReceiveDate().getTime()) / (24 * 60 * 60 * 1000);
wxBillRentManage.setStatus(EnumBillRentStatus.NOT_PAID.getCode());
if (day > 0) {
wxBillRentManage.setExpiredDay(day);
}
} else {//截止收租日在当前时间之后
Calendar now = Calendar.getInstance();
now.add(dayType, receivePeriod);
Date currenttime = now.getTime();
//当前日期加上周期后小于截止收租日就是没有到期,否则当前待缴
if (currenttime.before(wxBillRentManage.getReceiveDate())) {
wxBillRentManage.setStatus(EnumBillRentStatus.NOT_EXPIRED.getCode());
} else {
wxBillRentManage.setStatus(EnumBillRentStatus.WAIT_PAY.getCode());
}
}
}

@Transactional(rollbackFor = {Exception.class})
@Override
@@ -1722,6 +1884,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
// 保存调整金额(预账单调整)
if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){
savePreviewBill(record);
//保存商业管理费账单
savePreviewManageFeeBill(record,EnumRentContractManageFeeType.RENT_BUSSINESS_MANAGE_FEE);
//保存营业管理费账单
savePreviewManageFeeBill(record,EnumRentContractManageFeeType.RENT_OPERATING_MANAGE_FEE);
}
ResultData resultData = getResultDataForUpdate(record, userId,0,oldRentStartDate,writeComplate);
// if (resultData.code != Result.SUCCESS) {
@@ -1782,6 +1948,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
if (buildProperyBill) {
updatePropertyPreviewBill(record);
}
//作废合同
//updateInvalidContract(id);
}
@@ -2334,7 +2501,6 @@ public class WxRentContractServiceImpl implements WxRentContractService {

}
}else{
// TODO
//double adjustRatio = wxRentContract.getAdjustRatio() != null ? wxRentContract.getAdjustRatio() / 100.0 : 0;
result.put("adjustRatio", 0);
double priceRent = new BigDecimal(wxRentContract.getPrice())


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

@@ -74,6 +74,7 @@
<if test=" null != freeze ">and bill.freeze = #{freeze}</if>
<if test=" null != id ">and bill.id = #{id}</if>
<if test=" null != manageFeeType ">and bill.manage_fee_type = #{manageFeeType}</if>
<if test=" null != merchantIdList ">
and bill.`merchant_id` in
@@ -97,6 +98,17 @@
<include refid="billConditionSql"/>
</select>
<select id="listRentManageBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,#{billTypeName} as name,#{billTypeValue} as billTypeValue,#{billTypeName} as billType,
need_pay needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,
endtime,rent_shop_type rentShopType,
case when shop_info is null then '[]' else shop_info end shopInfo,
NULL comments,'' price_detail,updatetime,freeze,ifnull(late_pay_price,0) late_pay_price,service_charge_pay
from wx_bill_rent_manage bill
where bill.`tenant_id` = #{tenantId}
<include refid="billConditionSql"/>
</select>
<select id="listRentDepositBill" parameterType="com.iformall.domain.vo.WxBillAll" resultMap="allVoResultMap">
select id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
need_pay needPay,receive_pay receivePay,pay,owe,receive_date receiveDate,pay_date payDate,expired_day expiredDay,status,starttime,
@@ -314,6 +326,26 @@
<include refid="billSql"/>
</select>
<select id="listRentBussinessManageBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'商业管理费' name,11 billTypeValue,'商业管理费' billType,
bussiness_manage_fee_need_pay needPay,bussiness_manage_fee_need_pay receivePay,bussiness_manage_fee_need_pay pay,bussiness_manage_fee_need_pay owe,
receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,rent_shop_type rentShopType,'' priceDetail,
freeze,ifnull(late_pay_price,0) latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
from wx_bill_rent bill
where bill.is_preview = 0
and rent_contract_id in (select id from wx_rent_contract where status in (2,3,4))
select '' settle_number,id,merchant_id merchantId,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,
'商业管理费' name,11 billTypeValue,'商业管理费' billType, 0 as needPay,receive_pay receivePay,
pay,(receive_pay+service_charge_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,status,starttime,endtime,
rent_shop_type rentShopType,price_detail priceDetail,freeze,0 latePayPrice,service_charge_pay serviceChargePay,apply_status applyStatus,apply_pay_img applyPayImg,apply_update_time applyUpdateTime
from wx_bill_daily bill where bill.merchant_id=#{merchantId}
<include refid="billSql"/>
</select>
<select id="listRentDepositBillData" resultType="hashmap" parameterType="com.iformall.domain.vo.WxBillAll">
select '' settle_number,id,merchant_id merchant_id,shop_id shopId,tenant_id tenantId,parent_tenant_id parentTenantId,'租赁押金' name,2 billTypeValue,'租赁押金' billType,
need_pay needPay,receive_pay receivePay,pay,(receive_pay-pay) owe,receive_date receiveDate,pay_date payDate,DATEDIFF(now(),receive_date) expiredDay,


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

@@ -89,6 +89,7 @@
from wx_bill_rent_deposit br left join wx_merchant m on br.merchant_id=m.id
left join wx_shop s on br.shop_id=s.id
<where>
1 = 1
<if test=" null != id ">and br.`id` = #{id}</if>
<if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
<if test=" null != merchantName and ''!=merchantName ">and m.`name` like concat('%',#{merchantName},'%')</if>


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

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.WxBillRentManageMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBillRentManage">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
<result column="receive_pay" jdbcType="BIGINT" property="receivePay"/>
<result column="pay" jdbcType="BIGINT" property="pay"/>
<result column="receive_date" jdbcType="TIMESTAMP" property="receiveDate"/>
<result column="pay_date" jdbcType="TIMESTAMP" property="payDate"/>
<result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
<result column="expired_day" jdbcType="INTEGER" property="expiredDay"/>
<result column="owe" jdbcType="BIGINT" property="owe"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
<result column="apply_pay_img" jdbcType="INTEGER" property="applyPayImg"/>
<result column="apply_update_time" jdbcType="INTEGER" property="applyUpdateTime"/>
<result column="is_del" jdbcType="INTEGER" property="isDel"/>
<result column="need_pay" jdbcType="BIGINT" property="needPay"/>
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="shop_id" jdbcType="BIGINT" property="shopId"/>
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
<result column="rent_shop_type" jdbcType="INTEGER" property="rentShopType"/>
<result column="late_pay_ratio" jdbcType="INTEGER" property="latePayRatio"/>
<result column="late_pay_time" jdbcType="TIMESTAMP" property="latePayTime"/>
<result column="late_pay_price" jdbcType="BIGINT" property="latePayPrice"/>
<result column="period" jdbcType="INTEGER" property="period"/>
<result column="shop_info" jdbcType="VARCHAR" property="shopInfo"/>
<result column="pay_way" jdbcType="INTEGER" property="payWay"/>
<result column="late_pay_status" jdbcType="INTEGER" property="latePayStatus"/>
<result column="starttime" property="starttime"/>
<result column="endtime" property="endtime"/>
<result column="freeze" property="freeze"/>
<result column="service_charge_pay" property="serviceChargePay"/>
<result column="manage_fee_type" jdbcType="INTEGER" property="manageFeeType"/>
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`rent_contract_id`,`receive_pay`,`pay`,`receive_date`,`pay_date`,
`createtime`,`expired_day`,`owe`,`status`,`apply_status`,`apply_pay_img`,`apply_update_time`,`is_del`,`need_pay`,
`merchant_id`,`user_id`,`shop_id`,`updatetime`,`rent_shop_type`,`late_pay_ratio`,`late_pay_time`,`late_pay_price`,
`period`,`shop_info`,`pay_way`,`late_pay_status`,starttime,endtime,freeze,service_charge_pay,manage_fee_type
</sql>

<sql id="dynamicWhereConditions">
where 1=1
<if test=" null != id ">and `id` = #{id}</if>
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>
<if test=" null != rentContractId ">and `rent_contract_id` = #{rentContractId}</if>
<if test=" null != receivePay ">and `receive_pay` = #{receivePay}</if>
<if test=" null != pay ">and `pay` = #{pay}</if>
<if test=" null != receiveDate ">and `receive_date` = #{receiveDate}</if>
<if test=" null != payDate ">and `pay_date` = #{payDate}</if>
<if test=" null != createtime ">and `createtime` = #{createtime}</if>
<if test=" null != expiredDay ">and `expired_day` = #{expiredDay}</if>
<if test=" null != owe ">and `owe` = #{owe}</if>
<if test=" null != status ">and `status` = #{status}</if>
<if test=" null != applyStatus ">and `apply_status` = #{applyStatus}</if>
<if test=" null != isDel ">and `is_del` = #{isDel}</if>
<if test=" null != needPay ">and `need_pay` = #{needPay}</if>
<if test=" null != merchantId ">and `merchant_id` = #{merchantId}</if>
<if test=" null != userId ">and `user_id` = #{userId}</if>
<if test=" null != shopId ">and `shop_id` = #{shopId}</if>
<if test=" null != updatetime ">and `updatetime` = #{updatetime}</if>
<if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if>
<if test=" null != payWay ">and `pay_way` = #{payWay}</if>
<if test=" null != latePayStatus ">and `late_pay_status` = #{latePayStatus}</if>
<if test=" null != manageFeeType ">and `manage_fee_type` = #{manageFeeType}</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findList" parameterType="com.iformall.domain.po.WxBillRent" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_bill_rent_manage
<include refid="dynamicWhereConditions"/>
</select>

<select id="queryBillManageList" parameterType="com.iformall.domain.po.WxBillRentManage" resultMap="BaseResultMap">
select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`,
case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`need_pay`,
r.merchant_name,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,r.type as rent_type,br.`apply_status`,br.`apply_pay_img`,br.`apply_update_time`,
r.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`,
br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.starttime,br.endtime,
r.late_pay_ratio,br.freeze,br.service_charge_pay,br.manage_fee_type
from wx_bill_rent_manage br
left join wx_rent_contract r on br.rent_contract_id=r.id
<where>
1 = 1
<if test=" null != freeze ">and br.`freeze` = #{freeze}</if>
<if test=" null != rentShopType ">and br.`rent_shop_type` = #{rentShopType}</if>
<if test=" null != status ">and br.`status` = #{status}</if>
<if test=" null != applyStatus ">and br.`apply_status` = #{applyStatus}</if>
<if test=" null != id ">and br.`id` = #{id}</if>
<if test=" null != merchantId ">and br.`merchant_id` = #{merchantId}</if>
<if test=" null != merchantName and ''!=merchantName ">and r.merchant_name like
concat('%',#{merchantName},'%')
</if>
<if test=" null != isDel ">and br.`is_del` = #{isDel}</if>
<if test=" null != rentContractId ">and br.`rent_contract_id` = #{rentContractId}</if>
<if test=" null != payWay ">and br.`pay_way` = #{payWay}</if>
<if test=" null != latePayStatus ">and br.`late_pay_status` = #{latePayStatus}</if>
<if test=" null != starttime and null!=endtime ">and br.`receive_date` between #{starttime} and #{endtime}
</if>
<if test=" null != manageFeeType ">and br.`manage_fee_type` = #{manageFeeType}</if>
</where>
<if test=" null != sortColumns">order by ${sortColumns}</if>

<if test="null != limitStart and null != limitEnd">
limit #{limitStart},#{limitEnd}
</if>
</select>

<select id="queryPayInfoTotal" resultType="hashmap" parameterType="hashmap">
select IFNULL(sum(receive_pay),0) receivepay,IFNULL(sum(pay),0) pay,tenant_id from wx_bill_rent_manage
where status!=6
<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>
<if test=" null != startTime ">
and receive_date &gt;= #{startdate}
</if>
<if test=" null != endTime">
and receive_date &lt; #{enddate}
</if>
</select>

<update id="updateNotPaidStatus" parameterType="hashmap">
update wx_bill_rent_manage b set b.status=#{notPaid},b.expired_day=
DATEDIFF(now(), b.receive_date)
where b.status!=#{paid} and b.status!=6 and
DATEDIFF(now(), b.receive_date) >0
<if test=" null != tenantId and '' != tenantId">
and b.`tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and b.`parent_tenant_id` = #{parentTenantId}
</if>
</update>

<update id="updateWaitPayStatus" parameterType="hashmap">
update wx_bill_rent_manage set status=#{waitPay} where id in(
select a.id from (select br.id,rc.receive_period,br.rent_contract_id,br.receive_date from wx_bill_rent_manage br
left join wx_rent_contract rc on br.rent_contract_id=rc.id
where br.status!=#{paid}
<if test=" null != tenantId and '' != tenantId">
and br.`tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and br.`parent_tenant_id` = #{parentTenantId}
</if>
and br.status!=6 and now() &lt; br.receive_date
and DATE_ADD(now(),INTERVAL 1 MONTH)>br.receive_date) a)
</update>

<delete id="deletePreviewBill" parameterType="com.iformall.domain.po.WxBillRentManage">
delete from wx_bill_rent_manage where rent_contract_id = #{rentContractId} and manage_fee_type = #{manageFeeType}
</delete>

<select id="oweBillCount" parameterType="java.lang.Long" resultType="java.lang.Long">
select count(br.id) from wx_bill_rent_manage br,wx_rent_contract c where c.id = br.rent_contract_id
and br.status = 1 and c.id = #{contractId}
</select>
<insert id="insertBills" parameterType="java.util.List">
INSERT INTO wx_bill_rent_manage (id,tenant_id,parent_tenant_id,
rent_contract_id, receive_pay, pay, receive_date, pay_date, createtime, expired_day,
owe, status, is_del, need_pay, merchant_id, user_id, shop_id, updatetime, starttime, endtime,
rent_shop_type, late_pay_ratio, late_pay_time, late_pay_price, period, shop_info,
pay_way, late_pay_status, service_charge_pay,manage_fee_type)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id},#{item.tenantId},#{item.parentTenantId},
#{item.rentContractId},#{item.receivePay},#{item.pay},#{item.receiveDate},#{item.payDate},#{item.createtime},
#{item.expiredDay},#{item.owe},#{item.status},#{item.isDel},#{item.needPay},#{item.merchantId},
#{item.userId},#{item.shopId},#{item.updatetime},#{item.starttime},#{item.endtime},#{item.rentShopType},
#{item.latePayRatio},#{item.latePayTime},#{item.latePayPrice},#{item.period},#{item.shopInfo},
#{item.payWay},#{item.latePayStatus},#{item.serviceChargePay},#{manageFeeType}
)
</foreach>
</insert>

</mapper>


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