|
@@ -95,6 +95,9 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
95
|
95
|
@Autowired
|
96
|
96
|
private TaRaiseMapper taRaiseMapper;
|
97
|
97
|
|
|
98
|
+ @Autowired
|
|
99
|
+ private TaRaiseRecordMapper taRaiseRecordMapper;
|
|
100
|
+
|
98
|
101
|
/**
|
99
|
102
|
* 分页获取房源列表
|
100
|
103
|
*
|
|
@@ -277,74 +280,12 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
277
|
280
|
if (null == taRaise) {
|
278
|
281
|
resourcesPO.setRaiseBtn(false);
|
279
|
282
|
} else {
|
280
|
|
- //有认筹表的情况下判断是否认筹过这个房源
|
281
|
|
- boolean raiseBtnStatus = checkRaiseBtn(taRaise, salesBatchId, personId, houseId, orgId);
|
282
|
283
|
resourcesPO.setTaRaise(taRaise);
|
283
|
284
|
}
|
284
|
285
|
|
285
|
286
|
return resourcesPO;
|
286
|
287
|
}
|
287
|
288
|
|
288
|
|
- /**
|
289
|
|
- * 校验认筹状态的按钮
|
290
|
|
- *
|
291
|
|
- * @param taRaise
|
292
|
|
- * @param salesBatchId
|
293
|
|
- * @param personId
|
294
|
|
- * @param houseId
|
295
|
|
- * @param orgId
|
296
|
|
- * @return
|
297
|
|
- */
|
298
|
|
- private boolean checkRaiseBtn(TaRaise taRaise, Integer salesBatchId, String personId, Integer houseId, Integer orgId) {
|
299
|
|
- if (taRaise.getStatus() != CommConstant.STATUS_NORMAL) {
|
300
|
|
- return false;
|
301
|
|
- }
|
302
|
|
- if (taRaise.getNeedPreselection()) {
|
303
|
|
- //查看是否有当前房源的预选记录
|
304
|
|
- QueryWrapper<TaPreselectionRecord> preselectionRecordQueryWrapper = new QueryWrapper<>();
|
305
|
|
- preselectionRecordQueryWrapper.eq("sales_batch_id", salesBatchId);
|
306
|
|
- preselectionRecordQueryWrapper.eq("building_id", taRaise.getBuildingId());
|
307
|
|
- preselectionRecordQueryWrapper.eq("org_id", orgId);
|
308
|
|
- preselectionRecordQueryWrapper.eq("house_id", houseId);
|
309
|
|
- preselectionRecordQueryWrapper.eq("person_id", personId);
|
310
|
|
- TaPreselectionRecord taPreselectionRecord = taPreselectionRecordMapper.selectOne(preselectionRecordQueryWrapper);
|
311
|
|
- if (null == taPreselectionRecord) {
|
312
|
|
- return false;
|
313
|
|
- }
|
314
|
|
- }
|
315
|
|
- //判断是否在时间之内
|
316
|
|
-
|
317
|
|
- LocalDateTime raiseStartTime = taRaise.getRaiseStartTime();
|
318
|
|
- LocalDateTime raiseEndTime = taRaise.getRaiseEndTime();
|
319
|
|
- LocalDateTime now = LocalDateTime.now();
|
320
|
|
- if (now.isBefore(raiseStartTime) || now.isAfter(raiseEndTime)) {
|
321
|
|
- return false;
|
322
|
|
- }
|
323
|
|
- //销售批次校验
|
324
|
|
- TaSalesBatch taSalesBatch = taSalesBatchMapper.selectById(salesBatchId);
|
325
|
|
- if (taSalesBatch.getStatus() != CommConstant.STATUS_NORMAL) {
|
326
|
|
- return false;
|
327
|
|
- }
|
328
|
|
-
|
329
|
|
- //房源信息
|
330
|
|
- TaHousingResources taHousingResources = taHousingResourcesMapper.selectById(houseId);
|
331
|
|
- if (taHousingResources.getStatus() != CommConstant.STATUS_NORMAL || CommConstant.HOUSE_LOCKING_STATUS_LOCKED.equals(taHousingResources.getHouseLockingStatus())) {
|
332
|
|
- return false;
|
333
|
|
- }
|
334
|
|
-
|
335
|
|
- //查询我的认筹记录表
|
336
|
|
- QueryWrapper<TaRaiseHouse> taRaiseHouseQueryWrapper = new QueryWrapper<>();
|
337
|
|
- taRaiseHouseQueryWrapper.eq("org_id", orgId);
|
338
|
|
- taRaiseHouseQueryWrapper.eq("house_id", houseId);
|
339
|
|
- taRaiseHouseQueryWrapper.eq("person_id", personId);
|
340
|
|
- List<TaRaiseHouse> list = taRaiseHouseService.list(taRaiseHouseQueryWrapper);
|
341
|
|
- if (list.size() > 0) {
|
342
|
|
- return false;
|
343
|
|
- }
|
344
|
|
-
|
345
|
|
- return true;
|
346
|
|
- }
|
347
|
|
-
|
348
|
289
|
/**
|
349
|
290
|
* 校验楼栋信息存不存在
|
350
|
291
|
*
|
|
@@ -709,7 +650,7 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
709
|
650
|
}
|
710
|
651
|
|
711
|
652
|
@Override
|
712
|
|
- public ResponseBean updateLockingStatus(Integer houseId, String type, Integer orgId, Integer raiseHouseId, String personId) {
|
|
653
|
+ public ResponseBean updateLockingStatus(Integer houseId, String type, Integer orgId, Integer raiseHouseId, String personId, Integer raiseRecordId) {
|
713
|
654
|
logger.info("updateLockingStatus 接收参数:houseId:{},type:{},orgId:{},raiseHouseId:{},personId:{}",
|
714
|
655
|
houseId, type, orgId, raiseHouseId, personId);
|
715
|
656
|
ResponseBean responseBean = new ResponseBean();
|
|
@@ -721,56 +662,66 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
721
|
662
|
return responseBean;
|
722
|
663
|
}
|
723
|
664
|
|
724
|
|
- QueryWrapper<TaPerson> personQueryWrapper = new QueryWrapper<>();
|
725
|
|
- personQueryWrapper.eq("person_id", personId);
|
726
|
|
- TaPerson person = taPersonService.getOne(personQueryWrapper);
|
727
|
|
- if (person == null) {
|
728
|
|
- logger.info("updateLockingStatus 用户未找到");
|
729
|
|
- responseBean.addError("fail");
|
730
|
|
- return responseBean;
|
731
|
|
- }
|
|
665
|
+ QueryWrapper<TaRaiseHouse> taRaiseHouseQueryWrapper = new QueryWrapper<>();
|
|
666
|
+ taRaiseHouseQueryWrapper.eq("raise_record_id", raiseRecordId);
|
|
667
|
+ taRaiseHouseQueryWrapper.eq("raise_house_id", raiseHouseId);
|
|
668
|
+ TaRaiseHouse taRaiseHouse = taRaiseHouseService.getOne(taRaiseHouseQueryWrapper);
|
|
669
|
+
|
|
670
|
+ QueryWrapper<TaRaiseRecord> taRaiseRecordQueryWrapper = new QueryWrapper<>();
|
|
671
|
+ taRaiseRecordQueryWrapper.eq("raise_record_id", raiseRecordId);
|
|
672
|
+ TaRaiseRecord raiseRecord = taRaiseRecordMapper.selectOne(taRaiseRecordQueryWrapper);
|
732
|
673
|
|
733
|
674
|
// 更新为锁定状态
|
734
|
|
- if ("lock".equals(type)) {
|
|
675
|
+ if ("locked".equals(type)) {
|
|
676
|
+ // 校验当前房源状态
|
|
677
|
+ if ("locked".equals(po.getHouseLockingStatus())){
|
|
678
|
+ responseBean.addError("房源已被锁定");
|
|
679
|
+ return responseBean;
|
|
680
|
+ }
|
735
|
681
|
|
736
|
|
- // 校验当前房源状态
|
737
|
|
- if (!"locked".equals(po.getHouseLockingStatus())) {
|
738
|
|
- // 更行房源表状态
|
739
|
682
|
TaHousingResources housingResources = new TaHousingResources();
|
740
|
683
|
housingResources.setHouseId(po.getHouseId());
|
741
|
684
|
housingResources.setHouseLockingStatus("locked");
|
742
|
|
- housingResources.setHouseLockingPerson(personId);
|
743
|
|
- housingResources.setUpdateUser(person.getUserId());
|
|
685
|
+ housingResources.setHouseLockingPerson(taRaiseHouse.getPersonId());
|
744
|
686
|
housingResources.setUpdateDate(LocalDateTime.now());
|
|
687
|
+ housingResources.setHouseLockingPerson(raiseRecord.getPersonId());
|
745
|
688
|
updateById(housingResources);
|
746
|
689
|
|
|
690
|
+ //更新认筹单房源锁定状态
|
|
691
|
+ TaRaiseRecord taRaiseRecord = new TaRaiseRecord();
|
|
692
|
+ taRaiseRecord.setRaiseRecordId(raiseRecordId);
|
|
693
|
+ taRaiseRecord.setHouseLockingStatus("locked");
|
|
694
|
+ taRaiseRecordMapper.updateById(taRaiseRecord);
|
|
695
|
+
|
747
|
696
|
// 更新关联表状态
|
748
|
697
|
TaRaiseHouse raiseHouse = new TaRaiseHouse();
|
749
|
698
|
raiseHouse.setRaiseHouseId(raiseHouseId);
|
750
|
699
|
raiseHouse.setHouseLockingStatus("locked");
|
751
|
|
- raiseHouse.setPersonId(personId);
|
752
|
|
- raiseHouse.setPersonName(person.getName());
|
753
|
700
|
responseBean.addSuccess(taRaiseHouseService.updateById(raiseHouse));
|
754
|
701
|
return responseBean;
|
755
|
|
- }
|
756
|
|
- responseBean.addError("当前房源已为锁定状态");
|
757
|
|
- return responseBean;
|
758
|
702
|
}
|
759
|
703
|
|
760
|
704
|
// 更新为解锁状态
|
761
|
|
- if ("unlock".equals(type)) {
|
|
705
|
+ if ("unlocked".equals(type)) {
|
|
706
|
+ // 校验当前房源状态
|
|
707
|
+ if ("unlocked".equals(po.getHouseLockingStatus())){
|
|
708
|
+ responseBean.addError("房源已被解锁");
|
|
709
|
+ return responseBean;
|
|
710
|
+ }
|
762
|
711
|
|
763
|
|
- // 校验当前房源状态
|
764
|
|
- if ("locked".equals(po.getHouseLockingStatus())) {
|
765
|
|
- // 更新房源表状态
|
766
|
712
|
TaHousingResources housingResources = new TaHousingResources();
|
767
|
713
|
housingResources.setHouseId(po.getHouseId());
|
768
|
714
|
housingResources.setHouseLockingStatus("unlocked");
|
769
|
715
|
housingResources.setHouseLockingPerson("");
|
770
|
|
- housingResources.setUpdateUser(person.getUserId());
|
771
|
716
|
housingResources.setUpdateDate(LocalDateTime.now());
|
772
|
717
|
updateById(housingResources);
|
773
|
718
|
|
|
719
|
+ //更新认筹单房源锁定状态
|
|
720
|
+ TaRaiseRecord taRaiseRecord = new TaRaiseRecord();
|
|
721
|
+ taRaiseRecord.setRaiseRecordId(raiseRecordId);
|
|
722
|
+ taRaiseRecord.setHouseLockingStatus("unlocked");
|
|
723
|
+ taRaiseRecordMapper.updateById(taRaiseRecord);
|
|
724
|
+
|
774
|
725
|
// 更新关联表状态
|
775
|
726
|
TaRaiseHouse raiseHouse = new TaRaiseHouse();
|
776
|
727
|
raiseHouse.setRaiseHouseId(raiseHouseId);
|
|
@@ -779,14 +730,90 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
779
|
730
|
raiseHouse.setPersonName("");
|
780
|
731
|
responseBean.addSuccess(taRaiseHouseService.updateById(raiseHouse));
|
781
|
732
|
return responseBean;
|
782
|
|
- }
|
783
|
|
- responseBean.addError("当前房源已为解锁状态");
|
784
|
|
- return responseBean;
|
785
|
733
|
}
|
786
|
734
|
responseBean.addError("fail");
|
787
|
735
|
return responseBean;
|
788
|
736
|
}
|
789
|
737
|
|
|
738
|
+ /**
|
|
739
|
+ * 校验房源的认筹状态
|
|
740
|
+ *
|
|
741
|
+ * @param houseIds
|
|
742
|
+ * @param personId
|
|
743
|
+ * @param orgId
|
|
744
|
+ * @return
|
|
745
|
+ */
|
|
746
|
+ @Override
|
|
747
|
+ public boolean checkRaiseState(String houseIds, String personId, Integer orgId) throws Exception {
|
|
748
|
+ String[] houseIdArr = houseIds.split(",");
|
|
749
|
+ //房源信息
|
|
750
|
+ TaHousingResources taHousingResources = taHousingResourcesMapper.selectById(houseIdArr[0]);
|
|
751
|
+ //通过销售批次信息获取认筹信息
|
|
752
|
+ QueryWrapper<TaRaise> taRaiseQueryWrapper = new QueryWrapper<>();
|
|
753
|
+ taRaiseQueryWrapper.eq("org_id",orgId);
|
|
754
|
+ taRaiseQueryWrapper.eq("sales_batch_id",taHousingResources.getSalesBatchId());
|
|
755
|
+ taRaiseQueryWrapper.eq("building_id",taHousingResources.getBuildingId());
|
|
756
|
+ TaRaise taRaise = taRaiseMapper.selectOne(taRaiseQueryWrapper);
|
|
757
|
+ if (taRaise.getStatus() != CommConstant.STATUS_NORMAL) {
|
|
758
|
+ throw new Exception("认筹单已经作废");
|
|
759
|
+ }
|
|
760
|
+ //校验房源是否同一批次
|
|
761
|
+ for (String houseId : houseIdArr){
|
|
762
|
+ TaHousingResources taHousingResourcesChecked = taHousingResourcesMapper.selectById(houseId);
|
|
763
|
+ if (taHousingResources.getSalesBatchId() != taHousingResourcesChecked.getSalesBatchId()){
|
|
764
|
+ throw new Exception("非同一批次房源");
|
|
765
|
+ }
|
|
766
|
+ if (taRaise.getNeedPreselection()) {
|
|
767
|
+ //查看是否有当前房源的预选记录
|
|
768
|
+ QueryWrapper<TaPreselectionRecord> preselectionRecordQueryWrapper = new QueryWrapper<>();
|
|
769
|
+ preselectionRecordQueryWrapper.eq("sales_batch_id", taRaise.getSalesBatchId());
|
|
770
|
+ preselectionRecordQueryWrapper.eq("building_id", taRaise.getBuildingId());
|
|
771
|
+ preselectionRecordQueryWrapper.eq("org_id", orgId);
|
|
772
|
+ preselectionRecordQueryWrapper.eq("house_id", houseId);
|
|
773
|
+ preselectionRecordQueryWrapper.eq("person_id", personId);
|
|
774
|
+ TaPreselectionRecord taPreselectionRecord = taPreselectionRecordMapper.selectOne(preselectionRecordQueryWrapper);
|
|
775
|
+ if (null == taPreselectionRecord) {
|
|
776
|
+ throw new Exception("需要先预选才能认筹");
|
|
777
|
+ }
|
|
778
|
+ }
|
|
779
|
+ //查询我的认筹记录表
|
|
780
|
+ QueryWrapper<TaRaiseHouse> taRaiseHouseQueryWrapper = new QueryWrapper<>();
|
|
781
|
+ taRaiseHouseQueryWrapper.eq("org_id", orgId);
|
|
782
|
+ taRaiseHouseQueryWrapper.eq("house_id", houseId);
|
|
783
|
+ taRaiseHouseQueryWrapper.eq("person_id", personId);
|
|
784
|
+ List<TaRaiseHouse> list = taRaiseHouseService.list(taRaiseHouseQueryWrapper);
|
|
785
|
+ if (list.size() > 0) {
|
|
786
|
+ throw new Exception("您已有认筹单包含当前房源");
|
|
787
|
+ }
|
|
788
|
+
|
|
789
|
+ }
|
|
790
|
+ if (taHousingResources.getStatus() != CommConstant.STATUS_NORMAL) {
|
|
791
|
+ throw new Exception("房源已被取消发布");
|
|
792
|
+ }
|
|
793
|
+ if (CommConstant.HOUSE_LOCKING_STATUS_LOCKED.equals(taHousingResources.getHouseLockingStatus())){
|
|
794
|
+ throw new Exception("房源已被其他客户锁定");
|
|
795
|
+ }
|
|
796
|
+ //销售批次信息
|
|
797
|
+ TaSalesBatch taSalesBatch = taSalesBatchMapper.selectById(taHousingResources.getSalesBatchId());
|
|
798
|
+ //销售批次校验
|
|
799
|
+ if (null == taSalesBatch) {
|
|
800
|
+ throw new Exception("无销售批次无法认筹");
|
|
801
|
+ }
|
|
802
|
+ if (taSalesBatch.getStatus() != CommConstant.STATUS_NORMAL) {
|
|
803
|
+ throw new Exception("销售批次已被取消发布");
|
|
804
|
+ }
|
|
805
|
+
|
|
806
|
+ //判断是否在时间之内
|
|
807
|
+ LocalDateTime raiseStartTime = taRaise.getRaiseStartTime();
|
|
808
|
+ LocalDateTime raiseEndTime = taRaise.getRaiseEndTime();
|
|
809
|
+ LocalDateTime now = LocalDateTime.now();
|
|
810
|
+ if (now.isBefore(raiseStartTime) || now.isAfter(raiseEndTime)) {
|
|
811
|
+ throw new Exception("不在认筹时间内");
|
|
812
|
+ }
|
|
813
|
+
|
|
814
|
+ return true;
|
|
815
|
+ }
|
|
816
|
+
|
790
|
817
|
//更新房号
|
791
|
818
|
private void updateRoom(TaHousingResources taHousingResources) {
|
792
|
819
|
TaBuildingRoom taBuildingRoom = new TaBuildingRoom();
|