From 4b3bf67505b0ecd38c432dc0fb2036fdd4d3c1e4 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 05 十二月 2024 18:49:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java | 205 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 147 insertions(+), 58 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
index 4683542..0b19f67 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwContractServiceImpl.java
@@ -91,6 +91,7 @@
}
private void dealRoomsForContract(YwContract model) {
+ this.dealRoomsValid(model);
List<YwContractRoom> list = new ArrayList<>();
for(YwRoom room :model.getRoomList()){
YwContractRoom t = new YwContractRoom();
@@ -106,6 +107,46 @@
}
ywContractRoomMapper.insert(list);
}
+
+ private void dealRoomsValid(YwContract model){
+ List<Integer> roomIds = model.getRoomList().stream().map(i->i.getId()).collect(Collectors.toList());
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(roomIds)){
+ if(ywContractMapper.selectJoinCount(new MPJLambdaWrapper<YwContract>()
+ .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId)
+ .eq(YwContractRoom::getType,Constants.ZERO)
+ .in(YwContractRoom::getRoomId,roomIds)
+ .in(YwContract::getStatus,Constants.ZERO,Constants.ONE,Constants.TWO)
+ .apply(" (" +
+ " ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " +
+ "or " +
+ " ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' and t.END_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " +
+ " ) ")
+
+ )>Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎴挎簮宸茶鍗犵敤璇峰埛鏂伴噸璇�");
+ };
+
+ if(ywContractMapper.selectJoinCount(new MPJLambdaWrapper<YwContract>()
+ .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId)
+ .eq(YwContractRoom::getType,Constants.ZERO)
+ .in(YwContractRoom::getRoomId,roomIds)
+ .in(YwContract::getStatus,Constants.THREE)
+ .apply(" ( t.START_DATE < '"+DateUtil.getFomartDate(model.getEndDate(),"yyyy-MM-dd HH:mm:ss")+"' " +
+ " and t.BT_DATE > '"+DateUtil.getFomartDate(model.getStartDate(),"yyyy-MM-dd HH:mm:ss")+"' ) " )
+ )>Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎴挎簮宸茶鍗犵敤璇峰埛鏂伴噸璇�");
+ };
+
+
+
+ }
+
+
+
+
+
+ }
+
@Override
public List<YwContractBill> getBillList(YwContract model){
@@ -262,9 +303,10 @@
BigDecimal fee = Constants.formatBigdecimal(model.getBtFee());
String str = "閫�绉熸憳瑕侊細鍓╀綑鏈粨娓呰处鍗晎param1}浠斤紝鍏抽棴璐﹀崟{param2}浠姐�愰��绉熸棩{param3}锛岄��绉熻垂鐢ㄥ悎璁¢渶{param4}{param5}鍏冦�傘��";
str = str.replace("{param1}",model.getBtWaitBill()+"")
- .replace("{param2}",DateUtil.getDateLongSlash(model.getBtDate()))
- .replace("{param3}",fee.compareTo(new BigDecimal(0)) >=0?"鏀�":"浠�")
- .replace("{param4}",(fee.compareTo(new BigDecimal(0)) >=0?
+ .replace("{param2}",model.getBtCLoseBill()+"")
+ .replace("{param3}",DateUtil.getDateLongSlash(model.getBtDate()))
+ .replace("{param4}",fee.compareTo(new BigDecimal(0)) >=0?"鏀�":"浠�")
+ .replace("{param5}",(fee.compareTo(new BigDecimal(0)) >=0?
Constants.formatBigdecimal(model.getBtFee()).intValue()
:(Constants.formatBigdecimal(model.getBtFee()).intValue() * -1))+"" );
return str;
@@ -1168,87 +1210,100 @@
}
@Override
public YwContract findById(Integer id) {
+
+ YwContract model =queryDetailInfoById(id);
+ //鏌ヨ鎿嶄綔鏃ュ織璁板綍
+ YwWorkorderLog log = new YwWorkorderLog();
+ log.setJobId(model.getId());
+ log.setIsdeleted(Constants.ZERO);
+ model.setLogList(ywWorkorderLogMapper.selectList(new QueryWrapper<YwWorkorderLog>(log)
+ .lambda()
+ .in(YwWorkorderLog::getObjType,Constants.YwLogType.CONTRACT_BACK.getKey()
+ ,Constants.YwLogType.CONTRACT_CREATE.getKey()
+ ,Constants.YwLogType.CONTRACT_UPDATE.getKey())
+ .orderByAsc(YwWorkorderLog::getCreateDate)));
+
+ //鏌ヨ璐﹀崟闆嗗悎
+ queryBillListByModel(model,new Date());
+ return model;
+ }
+ private YwContract queryDetailInfoById(Integer id) {
MPJLambdaWrapper<YwContract> queryWrapper = new MPJLambdaWrapper<>();
- queryWrapper.selectAll(YwContract.class )
- .selectAs(Company::getName,YwContract::getCompanyName )
- .selectAs(SystemUser::getRealname,YwContract::getUserName )
- .selectAs(YwCustomer::getName,YwContract::getRenterName )
- .selectAs(YwProject::getName,YwContract::getProjectName )
- .select("t3.realname",YwContract::getCreatorName )
- .select("(select sum(r.area) from yw_contract_room cr left join yw_room r on r.id = cr.room_id where r.isdeleted=0 and cr.contract_id =t.id)",YwContract::getTotalArea )
- .leftJoin(Company.class,Company::getId,YwContract::getCompanyId)
- .leftJoin(SystemUser.class,SystemUser::getId,YwContract::getUserId)
- .leftJoin(SystemUser.class,SystemUser::getId,YwContract::getCreator)
- .leftJoin(YwProject.class,YwProject::getId,YwContract::getProjectId)
- .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
- .eq( YwContract::getId,id);
- YwContract model = ywContractMapper.selectJoinOne(YwContract.class,queryWrapper);
- if(model != null){
+ queryWrapper.selectAll(YwContract.class)
+ .selectAs(Company::getName, YwContract::getCompanyName)
+ .selectAs(SystemUser::getRealname, YwContract::getUserName)
+ .selectAs(YwCustomer::getName, YwContract::getRenterName)
+ .selectAs(YwProject::getName, YwContract::getProjectName)
+ .select("t3.realname", YwContract::getCreatorName)
+ .select("(select sum(r.area) from yw_contract_room cr left join yw_room r on r.id = cr.room_id where r.isdeleted=0 and cr.contract_id =t.id)", YwContract::getTotalArea)
+ .leftJoin(Company.class, Company::getId, YwContract::getCompanyId)
+ .leftJoin(SystemUser.class, SystemUser::getId, YwContract::getUserId)
+ .leftJoin(SystemUser.class, SystemUser::getId, YwContract::getCreator)
+ .leftJoin(YwProject.class, YwProject::getId, YwContract::getProjectId)
+ .leftJoin(YwCustomer.class, YwCustomer::getId, YwContract::getRenterId)
+ .eq(YwContract::getId, id);
+ YwContract model = ywContractMapper.selectJoinOne(YwContract.class, queryWrapper);
+ if (model == null) {
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
//鍚堝悓闄勪欢
initFiles(model);
//鏌ヨ鎴挎簮淇℃伅鏁版嵁
MPJLambdaWrapper<YwRoom> rw = new MPJLambdaWrapper<>();
- rw.selectAll(YwRoom.class )
- .selectAs(YwProject::getName,YwRoom::getProjectName)
- .selectAs(YwFloor::getName,YwRoom::getFloorName)
- .selectAs(YwBuilding::getName,YwRoom::getBuildingName)
- .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
- .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
- .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
- .eq(YwRoom::getIsdeleted,Constants.ZERO)
- .exists("(select a.id from yw_contract_room a where a.isdeleted=0 and a.type=0 and a.room_id=t.id and a.contract_id="+model.getId()+")");
- model.setRoomList(roomMapper.selectJoinList(YwRoom.class,rw));
+ rw.selectAll(YwRoom.class)
+ .selectAs(YwProject::getName, YwRoom::getProjectName)
+ .selectAs(YwFloor::getName, YwRoom::getFloorName)
+ .selectAs(YwBuilding::getName, YwRoom::getBuildingName)
+ .leftJoin(YwProject.class, YwProject::getId, YwRoom::getProjectId)
+ .leftJoin(YwBuilding.class, YwBuilding::getId, YwRoom::getBuildingId)
+ .leftJoin(YwFloor.class, YwFloor::getId, YwRoom::getFloor)
+ .eq(YwRoom::getIsdeleted, Constants.ZERO)
+ .exists("(select a.id from yw_contract_room a where a.isdeleted=0 and a.type=0 and a.room_id=t.id and a.contract_id=" + model.getId() + ")");
+ model.setRoomList(roomMapper.selectJoinList(YwRoom.class, rw));
model.setWyFirstCircleStr(Constants.getUnitTypeByNum(model.getWyFirstCircle()));
model.setZlFirstCircleStr(Constants.getUnitTypeByNum(model.getZlFirstCircle()));
//鏌ヨ绉熻硟鏉℃淇℃伅
MPJLambdaWrapper<YwContractDetail> dw = new MPJLambdaWrapper<>();
- dw.selectAll(YwContractDetail.class )
- .eq(YwContractDetail::getIsdeleted,Constants.ZERO)
- .eq(YwContractDetail::getContractId,model.getId())
- .in(YwContractDetail::getType,Constants.ZERO,Constants.TWO)
+ dw.selectAll(YwContractDetail.class)
+ .eq(YwContractDetail::getIsdeleted, Constants.ZERO)
+ .eq(YwContractDetail::getContractId, model.getId())
+ .in(YwContractDetail::getType, Constants.ZERO, Constants.TWO)
.orderByAsc(YwContractDetail::getSortnum);
- model.setZlDetailList(ywContractDetailMapper.selectJoinList(YwContractDetail.class,dw));
+ model.setZlDetailList(ywContractDetailMapper.selectJoinList(YwContractDetail.class, dw));
//鏌ヨ鐗╂キ鏉℃淇℃伅
dw = new MPJLambdaWrapper<>();
- dw.selectAll(YwContractDetail.class )
- .eq(YwContractDetail::getIsdeleted,Constants.ZERO)
- .eq(YwContractDetail::getContractId,model.getId())
- .in(YwContractDetail::getType,Constants.ONE,Constants.THREE)
+ dw.selectAll(YwContractDetail.class)
+ .eq(YwContractDetail::getIsdeleted, Constants.ZERO)
+ .eq(YwContractDetail::getContractId, model.getId())
+ .in(YwContractDetail::getType, Constants.ONE, Constants.THREE)
.orderByAsc(YwContractDetail::getSortnum);
- model.setWyDetailList(ywContractDetailMapper.selectJoinList(YwContractDetail.class,dw));
+ model.setWyDetailList(ywContractDetailMapper.selectJoinList(YwContractDetail.class, dw));
- //鏌ヨ鎿嶄綔鏃ュ織璁板綍
- YwWorkorderLog log = new YwWorkorderLog();
- log.setJobId(model.getId());
- log.setIsdeleted(Constants.ZERO);
- model.setLogList(ywWorkorderLogMapper.selectList(new QueryWrapper<YwWorkorderLog>(log)
- .lambda()
- .in(YwWorkorderLog::getObjType,Constants.YwLogType.CONTRACT_BACK.getKey()
- ,Constants.YwLogType.CONTRACT_CREATE.getKey()
- ,Constants.YwLogType.CONTRACT_UPDATE.getKey())
- .orderByAsc(YwWorkorderLog::getCreateDate)));
-
- queryBillListByModel(model,new Date());
- }
return model;
}
- @Override
- public YwContract findForBills(YwContract model) {
- queryBillListByModel(model,model.getBtDate());
+
+ @Override
+ public YwContract findForBills(YwContract param) {
+ YwContract model = queryDetailInfoById(param.getId());
+ queryBillListByModel(model,param.getBtDate());
return model;
}
private void queryBillListByModel(YwContract model,Date date) {
+ if(date ==null){
+ date = new Date();
+ }
//鏌ヨ璐﹀崟闆嗗悎
model.setBillList(ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>()
.selectAll(YwContractBill.class )
- .select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ")
+ //.select(" ( select ifnull(sum(case when yw.REVENUE_TYPE = 0 then yw.ACT_RECEIVABLE_FEE else -yw.ACT_RECEIVABLE_FEE end),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ")
+ .select(" ( select ifnull( sum( CASE WHEN t.bill_type = 0 and yw.REVENUE_TYPE = 0 THEN yw.ACT_RECEIVABLE_FEE when t.bill_type = 0 and yw.REVENUE_TYPE = 1 then -yw.ACT_RECEIVABLE_FEE when t.bill_type = 1 and yw.REVENUE_TYPE = 0 then -yw.ACT_RECEIVABLE_FEE else yw.ACT_RECEIVABLE_FEE END),0) from yw_contract_revenue yw where yw.bill_id = t.id and yw.status = 0 and yw.isdeleted = 0 ) as actReceivableFee ")
.eq( YwContractBill::getContractId,model.getId())
.eq(YwContractBill::getIsdeleted,Constants.ZERO)
.orderByAsc(YwContractBill::getSortnum,YwContractBill::getCreateDate)));
-
for (YwContractBill ywContractBill:model.getBillList()) {
- ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
+ ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee());
+// ywContractBill.setNeedReceivableFee(ywContractBill.getReceivableFee().subtract(ywContractBill.getActReceivableFee()));
}
model.setCanBackRentBills(new ArrayList<>());
long nowStart = Utils.Date.getStart(date).getTime();
@@ -1263,7 +1318,6 @@
continue;
}
model.getCanBackRentBills().add(bill);
-
}else if(Constants.equalsInteger(bill.getPayStatus(),Constants.ONE) ){
if(bill.getEndDate().getTime()<nowStart){
//濡傛灉宸茬粨娓咃紝璐﹀崟鐩存帴鍏抽棴
@@ -1274,9 +1328,44 @@
model.getCanBackRentBills().add(bill);
}
}
+ for(YwContractBill bill : model.getCanBackRentBills()){
+ YwContractDetail detail = null;
+ if(Constants.equalsInteger(bill.getCostType(),Constants.ZERO)){
+ detail = getDetailByIdFromList(bill.getDetailId(),model.getZlDetailList());
+ if(detail!=null&& bill.getStartDate()!=null && bill.getEndDate()!=null
+ &&(date.getTime() <= bill.getStartDate().getTime() || (date.getTime() >= bill.getStartDate().getTime() && date.getTime()<= bill.getEndDate().getTime()))){
+ Date odate = bill.getEndDate();
+ bill.setEndDate(date);
+ BigDecimal actFee = getTotalFeeByStartEnd(model,detail,bill,model.getZlFreeStartDate(),model.getZlFreeEndDate());
+ bill.setEndDate(odate);
+ bill.setNeedReceivableFee(actFee);
+ }
+ }else if(Constants.equalsInteger(bill.getCostType(),Constants.ONE)){
+ detail = getDetailByIdFromList(bill.getDetailId(),model.getWyDetailList());
+ if(detail!=null&& bill.getStartDate()!=null && bill.getEndDate()!=null
+ &&(date.getTime() <= bill.getStartDate().getTime() || (date.getTime() >= bill.getStartDate().getTime() && date.getTime()<= bill.getEndDate().getTime()))){
+ Date odate = bill.getEndDate();
+ bill.setEndDate(date);
+ BigDecimal actFee = getTotalFeeByStartEnd(model,detail,bill,model.getWyFreeStartDate(),model.getWyFreeEndDate());
+ bill.setEndDate(odate);
+ bill.setNeedReceivableFee(actFee);
+ }
+ }
+ }
}
}
+ private YwContractDetail getDetailByIdFromList(Integer detailId, List<YwContractDetail> list) {
+ if(list!=null){
+ for(YwContractDetail d : list){
+ if(Constants.equalsInteger(detailId,d.getId())){
+ return d;
+ }
+ }
+ }
+ return null;
+ }
+
@Override
public YwContract findOne(YwContract ywContract) {
QueryWrapper<YwContract> wrapper = new QueryWrapper<>(ywContract);
--
Gitblit v1.9.3