@@ -214,9 +214,10 @@ public class WxRentContractServiceImpl implements WxRentContractService {
result.put("wxMerchant", null);
}
//关联的店铺
if (wxRentContract.getShopId() != null ) {
if (wxRentContract.shopIdsByRentInfo().size()> 0 ) {
WxShop record = new WxShop();
record.setId(wxRentContract.getShopId());
//record.setId(wxRentContract.getShopId());
record.setIds(wxRentContract.shopIdsByRentInfo());
List<Map<String, Object>> list = wxShopMapper.findListMap(record);
result.put("wxShops", list);
} else {
@@ -445,13 +446,14 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return new ResultData(ErrorCode.SHOP_NOT_SELECTED);
}
//查询rent_info 包括 shopId
String shopName = "";
for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.updateTenantInfo(record);
Long shopId = rentInfoObject.getLong("shopId");
//wxRentContract.setShopId(shopId);
int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContract);
int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContract.getTenantId(),wxRentContract.getParentTenantId(),shopId,wxRentContract.getId() );
String shopNumber = rentInfoObject.getString("shopNumber");
if (count > 0) {
return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shopNumber + " 已出租");
@@ -477,6 +479,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
if (!shopList.contains(shopId)) {
shopList.add(shopId);
shopName = shopName +","+ shopNumber;
}
}
@@ -485,6 +488,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
record.setStatus(EnumRentContractStatus.DRAFT.getCode());
Date tempDate = record.getRentalStartDate();
record.setRentalStartDate(oldRentStartDate);
record.setShopName(shopName);
wxRentContractMapper.insert(record);
wxRentContractShopMapper.deleteShops(record.getId());
record.setShopIdList(shopList);
@@ -519,26 +523,27 @@ public class WxRentContractServiceImpl implements WxRentContractService {
@Override
public List<Long> getShopIds(WxRentContract record) {
List<Long> shopList = Lists.newArrayList();
if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = record.getRentInfo();
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size();
//查询rent_info 包括 shopId
for (int i = 0; i < size; i++) {
JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.updateTenantInfo(record);
Long shopId = rentInfoObject.getLong("shopId");
shopList.add(shopId);
}
} else {
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.updateTenantInfo(record);
wxRentContract.setShopId(record.getShopId());
shopList.add(record.getShopId());
}
return shopList;
return record.shopIdsByRentInfo();
// List<Long> shopList = Lists.newArrayList();
// if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
// String rentInfo = record.getRentInfo();
// JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
// int size = rentInfoArray.size();
// //查询rent_info 包括 shopId
// for (int i = 0; i < size; i++) {
// JSONObject rentInfoObject = rentInfoArray.getJSONObject(i);
// WxRentContract wxRentContract = new WxRentContract();
// wxRentContract.updateTenantInfo(record);
// Long shopId = rentInfoObject.getLong("shopId");
// shopList.add(shopId);
// }
// } else {
// WxRentContract wxRentContract = new WxRentContract();
// wxRentContract.updateTenantInfo(record);
// wxRentContract.setShopId(record.getShopId());
// shopList.add(record.getShopId());
// }
// return shopList;
}
@Transactional(rollbackFor = {Exception.class})
@@ -586,6 +591,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
WxPayAccountBill wxPayAccountBill = wxPayAccountBillService.getByTenantInfo(record);
final IdWorker idWorker = IdWorker.get();
int count = 1;
List<Long> shopIds = record.shopIdsByRentInfo();
for (WxBillRent bill:record.getPreviewBillRentList()) {
bill.setId(idWorker.nextId());
Date date = new Date();
@@ -602,7 +608,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
bill.setLatePayRatio(0);
bill.setPay(0L);
bill.setIsDel(EnumDelStatus.NOT_DEL.getCode());
bill.setShopId(record.getShopId());
if (null != shopIds && shopIds.size() == 1) {
bill.setShopId(shopIds.get(0));
}
setExpiredDay(bill,Calendar.MONTH,record.getReceivePeriod());
if (bill.getReceivePay().equals(0L)) {
bill.setStatus(EnumBillRentStatus.PAID.getCode());
@@ -772,7 +780,9 @@ public class WxRentContractServiceImpl implements WxRentContractService {
wxBillDeposit.setIsDel(0);
wxBillDeposit.setMerchantId(wxRentContract.getMerchantId());
wxBillDeposit.setUserId(userId);
wxBillDeposit.setShopId(wxRentContract.getShopId());
if (wxRentContract.shopIdsByRentInfo().size()==1) {
wxBillDeposit.setShopId(wxRentContract.shopIdsByRentInfo().get(0));
}
wxBillDeposit.setCreatetime(date);
wxBillDeposit.setUpdatetime(date);
wxBillDeposit.setIsDel(EnumDelStatus.NOT_DEL.getCode());
@@ -855,8 +865,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
if (shopId == null) {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除");
}
wxRentContractQuery.setShopId(Long.valueOf(shopId));
int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContractQuery);
// wxRentContractQuery.setShopId(Long.valueOf(shopId));
int count = wxRentContractMapper.selectRentContractCountByShopId(wxRentContractQuery.getTenantId(),wxRentContractQuery.getParentTenantId(),Long.valueOf(shopId),wxRentContractQuery.getId() );
if (count > 0) {
return new ResultData(ErrorCode.SHOP_IS_RENT.getCode(), "店铺 " + shopNumber + " 已出租");
}
@@ -1694,23 +1704,26 @@ public class WxRentContractServiceImpl implements WxRentContractService {
result.put("buildArea", buildAreaStr);
result.put("operationArea", operationAreaStr);
} else {
WxShop record = new WxShop();
record.setId(wxRentContract.getShopId());
List<Map<String, Object>> wxShops = wxShopMapper.findListMap(record);
if (!wxShops.isEmpty()) {
//店铺信息
Map<String, Object> wxShop = wxShops.get(0);
result.put("shopNumber", wxShop.get("shopNumber"));
result.put("floorName", wxShop.get("floor"));
result.put("buildingName", wxShop.get("building"));
result.put("buildArea", wxShop.get("buildArea"));
result.put("operationArea", wxShop.get("operationArea"));
} else {
result.put("shopNumber", " ");
result.put("floorName", " ");
result.put("buildingName", " ");
result.put("buildArea", " ");
result.put("operationArea", " ");
//record.setId(wxRentContract.getShopId());
if (wxRentContract.shopIdsByRentInfo().size() == 0) {
result.put("shopNumber", " ");
result.put("floorName", " ");
result.put("buildingName", " ");
result.put("buildArea", " ");
result.put("operationArea", " ");
}else {
WxShop record = new WxShop();
record.setIds(wxRentContract.shopIdsByRentInfo());
List<Map<String, Object>> wxShops = wxShopMapper.findListMap(record);
if (!wxShops.isEmpty()) {
//店铺信息
Map<String, Object> wxShop = wxShops.get(0);
result.put("shopNumber", wxShop.get("shopNumber"));
result.put("floorName", wxShop.get("floor"));
result.put("buildingName", wxShop.get("building"));
result.put("buildArea", wxShop.get("buildArea"));
result.put("operationArea", wxShop.get("operationArea"));
}
}
}
//MALL信息
@@ -2511,7 +2524,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
record.setUpdatetime(date);
List<Long> shopList = Lists.newArrayList();
if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String shopName = "";
//if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = record.getRentInfo();
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size();
@@ -2529,17 +2543,21 @@ public class WxRentContractServiceImpl implements WxRentContractService {
if (wxShop == null) {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除");
}
shopList.add(shopId);
if (!shopList.contains(shopId)) {
shopList.add(shopId);
shopName = shopName+","+shopNumber;
}
}
} else {
shopList.add(record.getShopId());
}
// } else {
// shopList.add(record.getShopId());
// }
try {
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode());
record.setStatus(EnumRentContractStatus.DRAFT.getCode());
Date tempDate = record.getRentalStartDate();
record.setRentalStartDate(oldRentStartDate);
record.setShopName(shopName);
wxRentContractMapper.insert(record);
record.setRentalStartDate(tempDate);
} catch (Exception e) {
@@ -2548,14 +2566,15 @@ public class WxRentContractServiceImpl implements WxRentContractService {
}
//生成预览账单(补录第二步,第三步走编辑)
if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
wxBillRentMapper.deletePreviewBill(record);
//重新生成
List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true);
record.setPreviewBillRentList(resultList);
}
// if (record.getReceivePeriod() != null && record.getLease() != null && record.getPrice() != null
// && !record.getReceivePeriod().equals(0) && !record.getLease().equals(0) && !record.getPrice().equals(0l)) {
// wxBillRentMapper.deletePreviewBill(record);
// //重新生成
// List<WxBillRent> resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true);
// record.setPreviewBillRentList(resultList);
// }
List<WxBillRent> resultList = buildRent(null, record, EnumIsPreview.YES.getCode(),true);
record.setPreviewBillRentList(resultList);
EventUtil.publistRentEvent(this, record);
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", record);
}
@@ -2581,7 +2600,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
&& !record.getReceivePeriod().equals(0) && !record.getLease().equals(0)) {
//删除预账单,重新生成
wxBillRentMapper.deletePreviewBill(record);
resultList = buildRent(new WxMerchant(), null, record, EnumIsPreview.YES.getCode(),true);
resultList = buildRent( null, record, EnumIsPreview.YES.getCode(),true);
}
}
@@ -2637,7 +2656,7 @@ public class WxRentContractServiceImpl implements WxRentContractService {
record.setUpdatetime(new Date());
if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
// if (record.getRentShopType().equals(EnumRentShopType.SHOP.getCode())) {
String rentInfo = record.getRentInfo();
JSONArray rentInfoArray = JSONArray.parseArray(rentInfo);
int size = rentInfoArray.size();
@@ -2659,21 +2678,21 @@ public class WxRentContractServiceImpl implements WxRentContractService {
return new ResultData(ErrorCode.SHOP_IS_NOT_FOUND.getCode(), "店铺 " + shopNumber + " 已删除");
}
}
} else {
WxRentContract wxRentContractQuery = new WxRentContract();
wxRentContractQuery.updateTenantInfo(record);
wxRentContractQuery.setShopId(record.getShopId());
// long count = wxRentContractMapper.queryRentContractData(wxRentContract).stream().
// filter(rc -> rc.get("status").equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode())
// || rc.get("status").equals(EnumRentContractStatus.RENT_PAID.getCode())
// || rc.get("status").equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count();
long count = wxRentContractMapper.queryRentContractData(wxRentContract).stream().
filter(rc -> rc.get("status").equals(EnumRentContractStatus.READY_FOR_PAING.getCode())
|| rc.get("status").equals(EnumRentContractStatus.PAING.getCode())).count();
if (count > 0) {
return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND);
}
}
// } else {
// WxRentContract wxRentContractQuery = new WxRentContract();
// wxRentContractQuery.updateTenantInfo(record);
// wxRentContractQuery.setShopId(record.getShopId());
// // long count = wxRentContractMapper.queryRentContractData(wxRentContract).stream().
// // filter(rc -> rc.get("status").equals(EnumRentContractStatus.SIGNED_RENT_UNPAID.getCode())
// // || rc.get("status").equals(EnumRentContractStatus.RENT_PAID.getCode())
// // || rc.get("status").equals(EnumRentContractStatus.CONTRACT_END_SOON.getCode())).count();
// long count = wxRentContractMapper.queryRentContractData(wxRentContract).stream().
// filter(rc -> rc.get("status").equals(EnumRentContractStatus.READY_FOR_PAING.getCode())
// || rc.get("status").equals(EnumRentContractStatus.PAING.getCode())).count();
// if (count > 0) {
// return new ResultData(ErrorCode.RENT_CONTRACT_WITH_SHOP_IS_FOUND);
// }
// }
try {
Date tempDate = record.getRentalStartDate();
@@ -2764,17 +2783,17 @@ public class WxRentContractServiceImpl implements WxRentContractService {
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setTenantId(tenantId);
wxRentContract.setStatus(EnumRentContractStatus.OUT_DATE.getCode());
List<Map<String, Object>> rentContractData = wxRentContractMapper.queryRentContractData(wxRentContract);
for (int i = 0, size = rentContractData.size(); i < size; i++) {
Map<String, Object> contract = rentContractData.get(i);
Object merchantId = contract.get("merchantId");
if (merchantId != null) {
WxMerchant merchant = wxMerchantMapper.selectById((Long) merchantId);
Integer status = merchant.getStatus();
if (status.equals(EnumMerchantStatus.VALID.getCode())) {
wxMerchantService.disableMerchat((Long) merchantId);
}
}
}
// List<Map<String, Object>> rentContractData = wxRentContractMapper.queryRentContractData(wxRentContract);
// for (int i = 0, size = rentContractData.size(); i < size; i++) {
// Map<String, Object> contract = rentContractData.get(i);
// Object merchantId = contract.get("merchantId");
// if (merchantId != null) {
// WxMerchant merchant = wxMerchantMapper.selectById((Long) merchantId);
// Integer status = merchant.getStatus();
// if (status.equals(EnumMerchantStatus.VALID.getCode())) {
// wxMerchantService.disableMerchat((Long) merchantId);
// }
// }
// }
}
}