|
|
|
@@ -67,6 +67,12 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxRentContractMapper wxRentContractMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxContractCustomersMapper wxContractCustomersMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxContractShopMapper wxContractShopMapper; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
@@ -319,6 +325,22 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
if (record.getCreateType().intValue() == EnumPropertyCreateType.BY_SHOP.getCode().intValue()) { |
|
|
|
List<Long> shopIds = record.shopIdsByShop(); |
|
|
|
WxShop shopq = new WxShop(); |
|
|
|
shopq.updateTenantInfo(record); |
|
|
|
shopq.setIds(shopIds); |
|
|
|
List<WxShop> shlist = wxShopService.selectList(shopq); |
|
|
|
BigDecimal rentArea = new BigDecimal(0); |
|
|
|
for (int i = 0 ; i< shlist.size(); i ++) { |
|
|
|
rentArea = rentArea.add(new BigDecimal(shlist.get(i).getOperationArea())); |
|
|
|
} |
|
|
|
if (null != shlist) { |
|
|
|
record.setRentInfo(JSON.toJSONString(shlist)); |
|
|
|
} |
|
|
|
record.setRentArea(rentArea.toPlainString()); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
if (null == record.getId()) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
@@ -332,37 +354,80 @@ public class WxPropertyContractServiceImpl implements WxPropertyContractService |
|
|
|
record.setStatus(EnumRentContractStatus.UNWRITE.getCode()); |
|
|
|
record.setApplyStatus(EnumRentContractAppStatus.DEFAULT.getCode()); |
|
|
|
wxPropertyContractMapper.insert(record); |
|
|
|
|
|
|
|
setShops(record,record.shopIdsByShop()); |
|
|
|
//关联客户 |
|
|
|
setCustomers(record); |
|
|
|
//编辑 |
|
|
|
}else { |
|
|
|
record.setUpdatetime(date); |
|
|
|
record.setUpdateBy(user.getId()); |
|
|
|
record.setUpdateByName(user.getName()); |
|
|
|
wxPropertyContractMapper.updateById(record); |
|
|
|
|
|
|
|
setShops(record,record.shopIdsByShop()); |
|
|
|
//关联客户 |
|
|
|
setCustomers(record); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("保存物业合同信息失败,e:" + e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (record.getCreateType().intValue() == EnumPropertyCreateType.BY_SHOP.getCode().intValue()) { |
|
|
|
List<Long> shopIds = record.shopIdsByShop(); |
|
|
|
WxShop shopq = new WxShop(); |
|
|
|
shopq.updateTenantInfo(record); |
|
|
|
shopq.setIds(shopIds); |
|
|
|
List<WxShop> shlist = wxShopService.selectList(shopq); |
|
|
|
BigDecimal rentArea = new BigDecimal(0); |
|
|
|
for (int i = 0 ; i< shlist.size(); i ++) { |
|
|
|
rentArea = rentArea.add(new BigDecimal(shlist.get(i).getOperationArea())); |
|
|
|
} |
|
|
|
if (null != shlist) { |
|
|
|
record.setRentInfo(JSON.toJSONString(shlist)); |
|
|
|
} |
|
|
|
record.setRentArea(rentArea.toPlainString()); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "保存物业合同信息成功", record); |
|
|
|
} |
|
|
|
|
|
|
|
public void setCustomers(WxPropertyContract record) { |
|
|
|
WxContractCustomers cq = new WxContractCustomers(); |
|
|
|
cq.updateTenantInfo(record); |
|
|
|
cq.setPrincipalType(record.getCustomerType()); |
|
|
|
cq.setNameEqal(record.getCustomerName()); |
|
|
|
cq.setPhoneEqal(record.getCustomerPhone()); |
|
|
|
List<WxContractCustomers> list = wxContractCustomersMapper.findList(cq); |
|
|
|
WxContractCustomers cus = null; |
|
|
|
if (null != list && list.size() > 0 ){ |
|
|
|
cus = list.get(0); |
|
|
|
} |
|
|
|
if (null == cus) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
cus = new WxContractCustomers(); |
|
|
|
cus.updateTenantInfo(record); |
|
|
|
cus.setId(idWorker.nextId()); |
|
|
|
cus.setPrincipalType(record.getCustomerType()); |
|
|
|
cus.setName(record.getCustomerName()); |
|
|
|
cus.setPhone(record.getCustomerPhone()); |
|
|
|
cus.setLegalPerson(record.getCustomerLegalPerson()); |
|
|
|
cus.setLinkPerson(record.getCustomerLinkPerson()); |
|
|
|
cus.setCreateDate(new Date()); |
|
|
|
cus.setUpdateDate(new Date()); |
|
|
|
cus.setStatus(EnumContractCustomersStatus.TEMP.getCode()); |
|
|
|
wxContractCustomersMapper.insert(cus); |
|
|
|
} |
|
|
|
record.setCustomersId(cus.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
public void setShops(WxPropertyContract record,List<Long> shopIdList) { |
|
|
|
WxContractShop sdel = new WxContractShop(); |
|
|
|
sdel.updateTenantInfo(record); |
|
|
|
sdel.setContractId(record.getId()); |
|
|
|
wxContractShopMapper.deleteByCondition(sdel); |
|
|
|
|
|
|
|
if (null != shopIdList && shopIdList.size() > 0 ) { |
|
|
|
final IdWorker idWorker = IdWorker.get(); |
|
|
|
for ( int i = 0 ; i < shopIdList.size(); i ++) { |
|
|
|
WxContractShop s = new WxContractShop(); |
|
|
|
s.updateTenantInfo(record); |
|
|
|
s.setContractId(record.getId()); |
|
|
|
s.setShopId(shopIdList.get(i)); |
|
|
|
s.setCreateDate(new Date()); |
|
|
|
s.setUpdateDate(new Date()); |
|
|
|
s.setId(idWorker.nextId()); |
|
|
|
wxContractShopMapper.insert(s); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
//@Transactional(rollbackFor = {Exception.class}) |
|
|
|
|