|
|
|
@@ -248,11 +248,13 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<WxBillProperty> getWxBillPropertyPreview(TenantEntity tenantEntity,Long id) { |
|
|
|
//查询主账单列表,排除其他标砖费用,包括一次性费用,非一次性费用 |
|
|
|
WxBillProperty wxBillRent = new WxBillProperty(); |
|
|
|
wxBillRent.setPropertyContractId(id); |
|
|
|
wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); |
|
|
|
wxBillRent.updateTenantInfo(tenantEntity); |
|
|
|
return wxBillPropertyMapper.findList(wxBillRent); |
|
|
|
//TODO 111111111111 |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -301,152 +303,105 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
|
|
|
|
@Override |
|
|
|
//@Transactional(rollbackFor = {Exception.class}) |
|
|
|
public ResultData saveOrUpdate(WxPropertyContract record, Long userId, String userName,boolean writeComplate) { |
|
|
|
public ResultData save(WxPropertyContract record, Long userId, String userName,boolean writeComplate) { |
|
|
|
// 保存调整金额(预账单调整) |
|
|
|
boolean haspreview = false; |
|
|
|
if(!CollectionUtils.isEmpty(record.getPreviewBillRentList())){ |
|
|
|
savePreviewBill(record); |
|
|
|
haspreview = true; |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectById(record.getMerchantId()); |
|
|
|
if (merchant == null) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
// if (record.getRentShopType().equals(EnumRentShopType.POINT.getCode()) && null == record.getShopId()) { |
|
|
|
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "shopId不能为空"); |
|
|
|
// } |
|
|
|
WxRentContract wxRentContract = null; |
|
|
|
if (record.getCreateType().intValue() == EnumPropertyCreateType.BY_RENT.getCode().intValue()) { |
|
|
|
wxRentContract = wxRentContractMapper.selectById(record.getRentContractId()); |
|
|
|
if (wxRentContract != null) { |
|
|
|
if (wxRentContract.getStatus().equals(EnumRentContractStatus.OUT_DATE.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.TERMINATE.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())) { |
|
|
|
return new ResultData(ErrorCode.RENT_CONTRACT_IS_TERMINATED); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
}else { |
|
|
|
if (null == record.getRentalStartDate()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "起租开始时间不能为空"); |
|
|
|
} |
|
|
|
if (null == record.getRentalEndDate()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "起租结束时间不能为空"); |
|
|
|
} |
|
|
|
if (null == record.getStartDate()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "计租日不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (null == record.getMerchantId() && record.getOperationType().equals(EnumContractOperationType.PART.getCode())) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "merchantId不能为空"); |
|
|
|
} |
|
|
|
if (record.getOperationType().equals(EnumContractOperationType.PART.getCode())) { |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectById(record.getMerchantId()); |
|
|
|
if (merchant == null) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
} |
|
|
|
record.setBusinessId(merchant.getBusinessId()); |
|
|
|
record.setBrand(merchant.getBrand()); |
|
|
|
record.setMerchantName(merchant.getName()); |
|
|
|
record.setShopType(merchant.getShopType()); |
|
|
|
record.setLinkPerson(merchant.getLinkPerson()); |
|
|
|
record.setLinkPhone(merchant.getLinkPhone()); |
|
|
|
record.setRentShopType(merchant.getRentShopType()); |
|
|
|
|
|
|
|
//保存物业合同信息 |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
if (record.getCreateType().intValue() == EnumPropertyCreateType.BY_SHOP.getCode().intValue()) { |
|
|
|
record.setEndDate(setEndDate(record.getStartDate(),record.getRentalStartDate())); |
|
|
|
} |
|
|
|
if (null == record.getReceivePeriod()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "付款周期不能为空"); |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
record.setCreatetime(date); |
|
|
|
record.setUpdatetime(date); |
|
|
|
record.setStatus(EnumRentContractStatus.UNWRITE.getCode()); |
|
|
|
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); |
|
|
|
try { |
|
|
|
wxPropertyContractMapper.insert(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("保存物业合同信息失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
if (null == record.getLease()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "租期不能为空"); |
|
|
|
return new ResultData(Result.SUCCESS, "保存物业合同信息成功", record); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
//@Transactional(rollbackFor = {Exception.class}) |
|
|
|
public ResultData updateMoney(WxPropertyContract record, Long userId, String userName,boolean writeComplate) { |
|
|
|
//保存物业合同信息 |
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById(record.getId()); |
|
|
|
if (wxPropertyContract == null) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
if (null == record.getPrice()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "物业费不能为空"); |
|
|
|
record.setPrice(StringUtils.isNotBlank(record.getPrice()) ? record.getPrice() : "0"); |
|
|
|
record.setDeposit(StringUtils.isNotBlank(record.getDeposit()) ? record.getDeposit() : "0"); |
|
|
|
record.setUpdatetime(new Date()); |
|
|
|
|
|
|
|
//如果是合并合同 物业合同的状态为 意向 |
|
|
|
if (writeComplate) { |
|
|
|
record.setStatus(EnumRentContractStatus.DRAFT.getCode()); |
|
|
|
}else { |
|
|
|
record.setStatus(wxPropertyContract.getStatus()); |
|
|
|
} |
|
|
|
if (null == record.getDeposit()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "押金不能为空"); |
|
|
|
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); |
|
|
|
try { |
|
|
|
wxPropertyContractMapper.updateById(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("更新物业合同信息失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
//保存物业合同信息 |
|
|
|
String message; |
|
|
|
boolean hasFlow = true; |
|
|
|
if (record.getId() == null) { |
|
|
|
hasFlow = false; |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
if (record.getCreateType().intValue() == EnumPropertyCreateType.BY_RENT.getCode().intValue()) { |
|
|
|
record.setRentalStartDate(wxRentContract.getRentalStartDate()); |
|
|
|
record.setRentalEndDate(wxRentContract.getRentalEndDate()); |
|
|
|
record.setStartDate(wxRentContract.getStartDate()); |
|
|
|
record.setEndDate(wxRentContract.getEndDate()); |
|
|
|
}else { |
|
|
|
record.setEndDate(setEndDate(record.getStartDate(),record.getRentalStartDate())); |
|
|
|
} |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
record.setCreatetime(date); |
|
|
|
record.setUpdatetime(date); |
|
|
|
record.setStatus(EnumRentContractStatus.UNWRITE.getCode()); |
|
|
|
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); |
|
|
|
try { |
|
|
|
wxPropertyContractMapper.insert(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("保存物业合同信息失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
//生成预览账单 |
|
|
|
record.setFeeStandards(record.getFeesStardarsList()); |
|
|
|
|
|
|
|
//更新物业合同信息 |
|
|
|
if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null |
|
|
|
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals("0")) { |
|
|
|
//删除预账单,重新生成 |
|
|
|
wxBillPropertyMapper.deleteBillByContract(record); |
|
|
|
//重新生成 |
|
|
|
List<WxBillProperty> billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true); |
|
|
|
record.setPreviewBillRentList(billList); |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(Result.SUCCESS, "更新物业合同信息成功", record); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
//@Transactional(rollbackFor = {Exception.class}) |
|
|
|
public ResultData updateFile(WxPropertyContract record, Long userId, String userName,boolean writeComplate) { |
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById(record.getId()); |
|
|
|
if (wxPropertyContract == null) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
record.setUpdatetime(new Date()); |
|
|
|
|
|
|
|
message = "保存物业合同信息成功"; |
|
|
|
} else {//更新物业合同信息 |
|
|
|
//查询预账单用于展示 |
|
|
|
WxBillProperty wxBillRent = new WxBillProperty(); |
|
|
|
wxBillRent.setPropertyContractId(record.getId()); |
|
|
|
wxBillRent.setSortColumns(BaseEntity.SortField.Period_ASC); |
|
|
|
wxBillRent.setIsPreview(EnumIsPreview.YES.getCode()); |
|
|
|
wxBillRent.updateTenantInfo(record); |
|
|
|
List<WxBillProperty> billList = wxBillPropertyMapper.findList(wxBillRent); |
|
|
|
record.setPreviewBillRentList(billList); |
|
|
|
|
|
|
|
if(!haspreview){ |
|
|
|
if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null |
|
|
|
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals("0")) { |
|
|
|
//删除预账单,重新生成 |
|
|
|
wxBillPropertyMapper.deleteBillByContract(record); |
|
|
|
//重新生成 |
|
|
|
billList = buildProperty(new WxMerchant(),userId,record,EnumIsPreview.YES.getCode(),true); |
|
|
|
record.setPreviewBillRentList(billList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectById(record.getId()); |
|
|
|
if (wxPropertyContract == null) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
if (record.getCreateType().intValue() == EnumPropertyCreateType.BY_RENT.getCode().intValue()) { |
|
|
|
record.setRentalStartDate(wxRentContract.getRentalStartDate()); |
|
|
|
record.setRentalEndDate(wxRentContract.getRentalEndDate()); |
|
|
|
record.setStartDate(wxRentContract.getStartDate()); |
|
|
|
record.setEndDate(wxRentContract.getEndDate()); |
|
|
|
}else { |
|
|
|
record.setEndDate(setEndDate(record.getStartDate(),record.getRentalStartDate())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
record.setPrice(StringUtils.isNotBlank(record.getPrice()) ? record.getPrice() : "0"); |
|
|
|
record.setDeposit(StringUtils.isNotBlank(record.getDeposit()) ? record.getDeposit() : "0"); |
|
|
|
record.setUpdatetime(new Date()); |
|
|
|
|
|
|
|
//如果是合并合同 物业合同的状态为 意向 |
|
|
|
if (writeComplate) { |
|
|
|
record.setStatus(EnumRentContractStatus.DRAFT.getCode()); |
|
|
|
}else { |
|
|
|
record.setStatus(wxPropertyContract.getStatus()); |
|
|
|
} |
|
|
|
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); |
|
|
|
try { |
|
|
|
wxPropertyContractMapper.updateById(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("更新物业合同信息失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
message = "更新物业合同信息成功"; |
|
|
|
//如果是合并合同 物业合同的状态为 意向 |
|
|
|
if (writeComplate) { |
|
|
|
record.setStatus(EnumRentContractStatus.DRAFT.getCode()); |
|
|
|
}else { |
|
|
|
record.setStatus(wxPropertyContract.getStatus()); |
|
|
|
} |
|
|
|
record.setFeeStandards(record.getFeesStardarsList()); |
|
|
|
return new ResultData(Result.SUCCESS, message, record); |
|
|
|
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); |
|
|
|
try { |
|
|
|
wxPropertyContractMapper.updateById(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("更新物业合同信息失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "更新物业合同信息成功", record); |
|
|
|
} |
|
|
|
|
|
|
|
//跟租金合同保持逻辑一致 |
|
|
|
|