Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
42c80f85
Commit
42c80f85
authored
Mar 14, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单换房接口
parent
057f8f2a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
0 deletions
+116
-0
SOrderController.java
...in/java/share/web/controller/system/SOrderController.java
+15
-0
SOrderDto.java
...ystem/src/main/java/share/system/domain/vo/SOrderDto.java
+6
-0
ISOrderService.java
...em/src/main/java/share/system/service/ISOrderService.java
+6
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+89
-0
No files found.
share-admin/src/main/java/share/web/controller/system/SOrderController.java
View file @
42c80f85
...
...
@@ -136,4 +136,19 @@ public class SOrderController extends BaseController
return
toAjax
(
sOrderService
.
refundOp
(
request
));
}
//查询当前门店可更换房间列表
@GetMapping
(
"/changeRoomList"
)
public
AjaxResult
changeRoomList
(
@PathVariable
(
"id"
)
Long
id
)
{
return
success
(
sOrderService
.
changeRoomList
(
id
));
}
/**
* 更换房间
*/
@PostMapping
(
"/changeRoom"
)
public
AjaxResult
changeRoom
(
@RequestBody
SOrderDto
dto
)
{
return
success
(
sOrderService
.
changeRoom
(
dto
));
}
}
share-system/src/main/java/share/system/domain/vo/SOrderDto.java
View file @
42c80f85
...
...
@@ -4,10 +4,16 @@ import lombok.Data;
@Data
public
class
SOrderDto
{
//订单ID
private
Long
id
;
//新房间id
private
Long
roomId
;
//订单滨海
private
String
orderNo
;
//是否消劵
private
Integer
isReverseconsume
;
//是否生成保洁
private
Integer
isClean
;
//备注
private
String
remark
;
}
share-system/src/main/java/share/system/service/ISOrderService.java
View file @
42c80f85
...
...
@@ -6,6 +6,7 @@ import share.system.domain.SConsumerCoupon;
import
share.system.domain.SOrder
;
import
share.system.domain.vo.SOrderDto
;
import
share.system.domain.vo.SOrderVo
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.request.AdminRefundRequest
;
import
share.system.request.CreateOrderRequest
;
import
share.system.request.OrderComputedPriceRequest
;
...
...
@@ -202,4 +203,9 @@ public interface ISOrderService extends IService<SOrder>
int
refundOp
(
AdminRefundRequest
request
);
List
<
SOrder
>
queryOrderList
(
SOrder
sOrder
);
List
<
SRoomVo
>
changeRoomList
(
Long
id
);
String
changeRoom
(
SOrderDto
dto
);
}
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
42c80f85
...
...
@@ -494,6 +494,95 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return
baseMapper
.
queryList
(
sOrder
.
getRoomId
());
}
@Override
public
List
<
SRoomVo
>
changeRoomList
(
Long
id
)
{
//查询订单
SOrder
sOrder
=
getById
(
id
);
//查询当前门店下所有的房间
LambdaQueryWrapper
<
SRoom
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
//当前门店
queryWrapper
.
eq
(
SRoom:
:
getStoreId
,
sOrder
.
getStoreId
());
//状态为空闲
queryWrapper
.
eq
(
SRoom:
:
getStatus
,
YesNoEnum
.
no
.
getIndex
());
//去除当前房间
queryWrapper
.
ne
(
SRoom:
:
getId
,
sOrder
.
getRoomId
());
//房间状态为上架
queryWrapper
.
eq
(
SRoom:
:
getRoomStat
,
YesNoEnum
.
yes
.
getIndex
());
List
<
SRoom
>
list
=
roomService
.
list
(
queryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
throw
new
BaseException
(
"当前门店没有空闲房间"
);
}
List
<
Long
>
roomIds
=
list
.
stream
().
map
(
SRoom:
:
getId
).
collect
(
Collectors
.
toList
());
//查询当前房间是否有保洁
LambdaQueryWrapper
<
SCleanRecords
>
cleanRecordsQueryWrapper
=
new
LambdaQueryWrapper
<>();
cleanRecordsQueryWrapper
.
in
(
SCleanRecords:
:
getRoomId
,
roomIds
);
cleanRecordsQueryWrapper
.
ne
(
SCleanRecords:
:
getStatus
,
CleaningStatusEnum
.
CLEANED
.
getCode
());
List
<
SCleanRecords
>
sCleanRecords
=
isCleanRecordsService
.
list
(
cleanRecordsQueryWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
sCleanRecords
))
{
//去掉保洁中的房间
List
<
Long
>
cleanRoomIds
=
Optional
.
ofNullable
(
sCleanRecords
).
orElse
(
new
ArrayList
<>()).
parallelStream
().
map
(
SCleanRecords:
:
getRoomId
).
collect
(
Collectors
.
toList
());
//获取不在保洁的房间
list
=
list
.
stream
().
filter
(
sRoom
->
!
cleanRoomIds
.
contains
(
sRoom
.
getId
())).
collect
(
Collectors
.
toList
());
}
if
(
CollectionUtils
.
isEmpty
(
list
))
{
throw
new
BaseException
(
"当前门店没有空闲房间"
);
}
//查询剩余房间的订单时段是否被占用
LambdaQueryWrapper
<
SOrder
>
sOrderLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sOrderLambdaQueryWrapper
.
notIn
(
SOrder:
:
getRefundStatus
,
RefundStatusEnum
.
getRefundedStatus
());
sOrderLambdaQueryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
getValidOrderStatus
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getStoreId
,
sOrder
.
getStoreId
());
sOrderLambdaQueryWrapper
.
in
(
SOrder:
:
getRoomId
,
list
.
stream
().
map
(
SRoom:
:
getId
).
collect
(
Collectors
.
toList
()));
queryWrapper
.
apply
(
"(IFNULL(start_date,pre_start_date) BETWEEN '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
sOrder
.
getPreStartDate
())
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
sOrder
.
getPreEndDate
(),
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' "
+
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
sOrder
.
getPreStartDate
(),
-
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
sOrder
.
getPreEndDate
())
+
"' )"
);
List
<
SOrder
>
orderList
=
list
(
sOrderLambdaQueryWrapper
);
if
(
CollectionUtils
.
isNotEmpty
(
orderList
))
{
//去掉被占用的房间
List
<
Long
>
orderRoomIds
=
Optional
.
ofNullable
(
orderList
).
orElse
(
new
ArrayList
<>()).
parallelStream
().
map
(
SOrder:
:
getRoomId
).
collect
(
Collectors
.
toList
());
list
=
list
.
stream
().
filter
(
sRoom
->
!
orderRoomIds
.
contains
(
sRoom
.
getId
())).
collect
(
Collectors
.
toList
());
}
return
list
.
stream
().
map
(
sRoom
->
{
SRoomVo
sRoomVo
=
new
SRoomVo
();
BeanUtils
.
copyProperties
(
sRoom
,
sRoomVo
);
return
sRoomVo
;
}).
collect
(
Collectors
.
toList
());
}
@Override
public
String
changeRoom
(
SOrderDto
dto
)
{
SOrder
sOrder
=
getById
(
dto
.
getId
());
// 判断原房间是否生成保洁
if
(
dto
.
getIsClean
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
//判断订单是否已经添加保洁记录
SCleanRecords
cleanRecords
=
isCleanRecordsService
.
lastCleanByRoomId
(
sOrder
.
getRoomId
());
if
(
ObjectUtil
.
isEmpty
(
cleanRecords
)
||
cleanRecords
.
getStatus
().
equals
(
CleaningStatusEnum
.
CLEANED
.
getCode
()))
{
//房间添加保洁记录
boolean
b
=
isCleanRecordsService
.
addSCleanRecords
(
sOrder
.
getStoreId
(),
sOrder
.
getRoomId
());
}
}
//原订单是否使用中
if
(
sOrder
.
getStatus
().
equals
(
OrderStatusEnum
.
INUSE
.
getCode
()))
{
// 使用中订单断电, 延时3分钟断电
deviceOpService
.
openOrCloseDevice
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
OpTypeEnum
.
CUT_ELECTRIC
.
getCode
(),
false
,
0
);
//修改原房间状态
SRoom
sRoom
=
new
SRoom
();
sRoom
.
setId
(
sOrder
.
getRoomId
());
sRoom
.
setStatus
(
RoomStatusEnum
.
FREE
.
getValue
());
roomService
.
updateById
(
sRoom
);
}
//发送短信
sOrder
.
setRoomId
(
dto
.
getRoomId
());
updateById
(
sOrder
);
return
null
;
}
/**
* 新增订单
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment