|
|
|
@@ -68,14 +68,14 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData getById(Long id){ |
|
|
|
public ResultData getById(Long id) { |
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectByPrimaryKey(id); |
|
|
|
if(wxPropertyContract==null){ |
|
|
|
if (wxPropertyContract == null) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice(): 0); |
|
|
|
wxPropertyContract.setPrice(wxPropertyContract.getPrice() != null ? wxPropertyContract.getPrice() : 0); |
|
|
|
wxPropertyContract.setDeposit(wxPropertyContract.getDeposit() != null ? wxPropertyContract.getDeposit() : 0); |
|
|
|
|
|
|
|
result.put("wxPropertyContract", wxPropertyContract); |
|
|
|
@@ -102,42 +102,43 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
@Override |
|
|
|
public ResultData saveOrUpdate(WxPropertyContract record) { |
|
|
|
|
|
|
|
if(null==record.getShopId()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"shopId不能为空"); |
|
|
|
if (null == record.getShopId()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "shopId不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(record.getRentContractId()); |
|
|
|
if(wxRentContract!=null){ |
|
|
|
if(wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) || |
|
|
|
if (wxRentContract != null) { |
|
|
|
if (wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_END.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.WAIT_SIGN.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())){ |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())) { |
|
|
|
return new ResultData(ErrorCode.RENT_CONTRACT_IS_TERMINATED); |
|
|
|
} |
|
|
|
} |
|
|
|
if(null==record.getMerchantId()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"merchantId不能为空"); |
|
|
|
if (null == record.getMerchantId()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "merchantId不能为空"); |
|
|
|
} |
|
|
|
WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(record.getMerchantId()); |
|
|
|
if(merchant==null){ |
|
|
|
if (merchant == null) { |
|
|
|
return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); |
|
|
|
} |
|
|
|
if(null==record.getReceivePeriod()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"付款周期不能为空"); |
|
|
|
if (null == record.getReceivePeriod()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "付款周期不能为空"); |
|
|
|
} |
|
|
|
if(null==record.getLease()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"租期不能为空"); |
|
|
|
if (null == record.getLease()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "租期不能为空"); |
|
|
|
} |
|
|
|
if(null==record.getPrice()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"物业费不能为空"); |
|
|
|
if (null == record.getPrice()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "物业费不能为空"); |
|
|
|
} |
|
|
|
if(null==record.getDeposit()){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"押金不能为空"); |
|
|
|
if (null == record.getDeposit()) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "押金不能为空"); |
|
|
|
} |
|
|
|
if(record.getPrice().intValue()<=0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"物业费要大于0"); |
|
|
|
if (record.getPrice().intValue() <= 0) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "物业费要大于0"); |
|
|
|
} |
|
|
|
if(record.getDeposit().intValue()<=0){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"押金要大于0"); |
|
|
|
if (record.getDeposit().intValue() <= 0) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR, "押金要大于0"); |
|
|
|
} |
|
|
|
|
|
|
|
//保存物业合同信息 |
|
|
|
@@ -157,7 +158,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
wxPropertyContractMapper.insertSelective(record); |
|
|
|
//建立账单 |
|
|
|
if (record.getMerchantId() != null && record.getStatus().equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode()) |
|
|
|
&& record.getReceivePeriod() != null && record.getDeposit()>0 && record.getPrice()>0) { |
|
|
|
&& record.getReceivePeriod() != null && record.getDeposit() > 0 && record.getPrice() > 0) { |
|
|
|
WxBillProperty wxBillProperty = new WxBillProperty(); |
|
|
|
wxBillProperty.setMerchantId(record.getMerchantId()); |
|
|
|
List<Map<String, Object>> billPropertyList = wxBillPropertyMapper.queryBillPropertyList(wxBillProperty); |
|
|
|
@@ -178,7 +179,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
return new ResultData(Result.SUCCESS, "保存物业合同信息成功", record); |
|
|
|
} else {//更新物业合同信息 |
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectByPrimaryKey(record.getId()); |
|
|
|
if(wxPropertyContract==null){ |
|
|
|
if (wxPropertyContract == null) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
@@ -186,8 +187,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
instance.add(Calendar.MONTH, record.getLease()); |
|
|
|
instance.add(Calendar.DAY_OF_MONTH, -1); |
|
|
|
record.setRentalEndDate(instance.getTime()); |
|
|
|
record.setPrice(record.getPrice() != null ? record.getPrice(): 0); |
|
|
|
record.setDeposit(record.getDeposit() != null ? record.getDeposit(): 0); |
|
|
|
record.setPrice(record.getPrice() != null ? record.getPrice() : 0); |
|
|
|
record.setDeposit(record.getDeposit() != null ? record.getDeposit() : 0); |
|
|
|
record.setUpdatetime(new Date()); |
|
|
|
try { |
|
|
|
wxPropertyContractMapper.updateByPrimaryKeySelective(record); |
|
|
|
@@ -275,10 +276,10 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
wxPropertyContract = list.get(0); |
|
|
|
int receivePeriod = wxPropertyContract.getReceivePeriod().intValue(); |
|
|
|
Integer lease = wxPropertyContract.getLease(); |
|
|
|
int extralease =lease%receivePeriod; |
|
|
|
int extracount=extralease>0?1:0; |
|
|
|
int paycount = lease / receivePeriod+extracount; |
|
|
|
int index = paycount-1; |
|
|
|
int extralease = lease % receivePeriod; |
|
|
|
int extracount = extralease > 0 ? 1 : 0; |
|
|
|
int paycount = lease / receivePeriod + extracount; |
|
|
|
int index = paycount - 1; |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
for (int i = 0; i < paycount; i++) { |
|
|
|
WxBillProperty wxBillRent = new WxBillProperty(); |
|
|
|
@@ -306,7 +307,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
instance.add(Calendar.DAY_OF_MONTH, 1); |
|
|
|
instance.add(Calendar.MONTH, receivePeriod); |
|
|
|
wxBillRent.setEndtime(instance.getTime()); |
|
|
|
int needpay = wxPropertyContract.getPrice()*receivePeriod; |
|
|
|
int needpay = wxPropertyContract.getPrice() * receivePeriod; |
|
|
|
if (extracount > 0 && i == index) { |
|
|
|
//账单开始时间 |
|
|
|
instance.clear(); |
|
|
|
@@ -364,7 +365,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void deleteById(Long id) { |
|
|
|
wxPropertyContractMapper.deleteByPrimaryKey(id); |
|
|
|
@@ -416,11 +416,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
public ResultData endRentContract(Long id) { |
|
|
|
|
|
|
|
WxPropertyContract wxPropertyContract = wxPropertyContractMapper.selectByPrimaryKey(id); |
|
|
|
if(wxPropertyContract==null){ |
|
|
|
if (wxPropertyContract == null) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
wxPropertyContract.setStatus(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()); |
|
|
|
try { |
|
|
|
wxPropertyContract.setUpdatetime(new Date()); |
|
|
|
wxPropertyContractMapper.updateByPrimaryKeySelective(wxPropertyContract); |
|
|
|
} catch (MallinkException e) { |
|
|
|
logger.info("终止合同失败:" + e.getMessage()); |
|
|
|
@@ -432,8 +433,8 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object getRentContractList(String tenantId) { |
|
|
|
Map<String,Object> params =new HashMap<>(); |
|
|
|
params.put("tenantId",tenantId); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("tenantId", tenantId); |
|
|
|
return wxPropertyContractMapper.getRentContractList(params); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -442,7 +443,7 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
WxPropertyContract wxPropertyContractParam = new WxPropertyContract(); |
|
|
|
wxPropertyContractParam.setRentContractId(rentContractId); |
|
|
|
List<Map<String, Object>> contractData = wxPropertyContractMapper.queryPropertyContractData(wxPropertyContractParam); |
|
|
|
if(contractData.size()==0){ |
|
|
|
if (contractData.size() == 0) { |
|
|
|
return new ResultData(ErrorCode.PROPERTY_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
Map<String, Object> contractMap = contractData.get(0); |
|
|
|
@@ -459,21 +460,19 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData hasRentContract(Long rentContractId) { |
|
|
|
if(null==rentContractId){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"rentContractId不能为空"); |
|
|
|
if (null == rentContractId) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "rentContractId不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(rentContractId); |
|
|
|
if(null==wxRentContract){ |
|
|
|
return new ResultData(ErrorCode.RENT_CONTRACT_IS_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
if(wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.WAIT_SIGN.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())){ |
|
|
|
return new ResultData(true); |
|
|
|
if (wxRentContract != null) { |
|
|
|
if (wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_END.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.WAIT_SIGN.getCode()) || |
|
|
|
wxRentContract.getStatus().equals(EnumRentContractStatus.INVALID.getCode())) { |
|
|
|
return new ResultData(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new ResultData(false); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -580,9 +579,6 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |