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
5ae7bd84
Commit
5ae7bd84
authored
Mar 20, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改订单开放接口
parent
ca03eca2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
7 deletions
+68
-7
OpenInterfaceServiceImpl.java
...a/share/system/service/impl/OpenInterfaceServiceImpl.java
+68
-7
No files found.
share-system/src/main/java/share/system/service/impl/OpenInterfaceServiceImpl.java
View file @
5ae7bd84
package
share
.
system
.
service
.
impl
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.enums.DeviceOpSourceEnum
;
import
share.common.enums.DeviceType
;
import
share.common.enums.RoomType
;
import
share.common.constant.Constants
;
import
share.common.enums.*
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.DateUtils
;
import
share.common.utils.bean.BeanUtils
;
import
share.system.domain.*
;
import
share.system.domain.vo.OrderVo
;
import
share.system.domain.vo.SRoomVo
;
import
share.system.service.*
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
...
...
@@ -42,6 +46,11 @@ public class OpenInterfaceServiceImpl implements OpenInterfaceService {
@Autowired
private
DeviceOpService
deviceOpService
;
@Autowired
private
ISCleanRecordsService
cleanRecordsService
;
@Override
public
OrderVo
orderInfo
(
String
orderNo
)
{
SOrder
en
=
orderService
.
getByOrderNo
(
orderNo
);
...
...
@@ -61,10 +70,7 @@ public class OpenInterfaceServiceImpl implements OpenInterfaceService {
SConsumerCoupon
consumerCoupon
=
consumerCouponService
.
getById
(
en
.
getCouponId
());
vo
.
setCouponName
(
consumerCoupon
.
getName
());
// 判断是否可以退款
vo
.
setIsRefund
(
orderService
.
isRefund
(
en
,
consumerCoupon
));
}
else
{
// 判断是否可以退款
vo
.
setIsRefund
(
orderService
.
isRefund
(
en
,
null
));
vo
.
setIsRefund
(
Boolean
.
FALSE
);
}
if
(
ObjectUtil
.
isNotEmpty
(
en
.
getPackId
()))
{
SPack
byId
=
packService
.
getById
(
en
.
getPackId
());
...
...
@@ -102,7 +108,62 @@ public class OpenInterfaceServiceImpl implements OpenInterfaceService {
).
collect
(
Collectors
.
toList
()).
isEmpty
())
{
throw
new
BaseException
(
"房间取电设备不存在!"
);
}
if
(
sOrder
.
getStatus
().
equals
(
OrderStatusEnum
.
UNUSED
.
getCode
()))
{
if
(
RoomStatusEnum
.
HOLD
.
getValue
().
compareTo
(
sRoomVo
.
getStatus
())
==
0
||
!
checkOrderOpenDoor
(
sOrder
))
{
throw
new
BaseException
(
"房间当前时段已被占用不可开门!"
);
}
//判断预约时间是否到达,可提前一个小时开门
if
(
DateUtils
.
addHours
(
sOrder
.
getPreStartDate
(),
Constants
.
OPEN_DOOR_AHEAD_HOUR_MINUS
).
compareTo
(
new
Date
())
>
0
)
{
throw
new
BaseException
(
"预约时间未到达,可提前"
+
Constants
.
OPEN_DOOR_AHEAD_HOUR
+
"小时进场,请耐心等候!"
);
}
// 判断房间是否脏房中
// if (sRoomVo.getIsDirtyRoom() > 0) {
// throw new BaseException("当前房间未保洁,请等待!");
// }
// 55分钟内是否有保洁记录
LambdaQueryWrapper
<
SCleanRecords
>
recordsQueryWrapper
=
new
LambdaQueryWrapper
<>();
recordsQueryWrapper
.
eq
(
SCleanRecords:
:
getRoomId
,
sOrder
.
getRoomId
());
recordsQueryWrapper
.
ge
(
SCleanRecords:
:
getCreateTime
,
cn
.
hutool
.
core
.
date
.
DateUtil
.
offset
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
date
(),
DateField
.
MINUTE
,
-
60
));
List
<
SCleanRecords
>
recordsList
=
cleanRecordsService
.
list
(
recordsQueryWrapper
);
if
(
recordsList
!=
null
&&
recordsList
.
size
()
>
0
)
{
SCleanRecords
records
=
recordsList
.
get
(
0
);
if
(
CleaningStatusEnum
.
CLEANED
.
getCode
().
equals
(
records
.
getStatus
()))
{
// 如果保洁状态未不是保洁中
throw
new
BaseException
(
"当前房间待保洁中,请等待!"
);
}
}
}
deviceOpService
.
openDoor
(
sRoomVo
.
getId
(),
sOrder
.
getConsumerPhone
(),
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
return
"开锁成功"
;
}
/**
* 查询非当前用户,预约时间或使用时间为当前时间的订单,如果存在,房间不可开门
*
* @return
*/
private
boolean
checkOrderOpenDoor
(
SOrder
order
)
{
LambdaQueryWrapper
<
SOrder
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
ne
(
SOrder:
:
getOrderNo
,
order
.
getOrderNo
());
queryWrapper
.
eq
(
SOrder:
:
getStoreId
,
order
.
getStoreId
());
queryWrapper
.
eq
(
SOrder:
:
getRoomId
,
order
.
getRoomId
());
queryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
YesNoEnum
.
yes
.
getIndex
());
queryWrapper
.
notIn
(
SOrder:
:
getStatus
,
new
ArrayList
<
Integer
>()
{{
add
(
OrderStatusEnum
.
USED
.
getCode
());
add
(
OrderStatusEnum
.
CANCEL
.
getCode
());
add
(
OrderStatusEnum
.
REFUNDING
.
getCode
());
add
(
OrderStatusEnum
.
REFUNDED
.
getCode
());
}});
queryWrapper
.
notIn
(
SOrder:
:
getRefundStatus
,
new
ArrayList
<
Integer
>()
{{
add
(
RefundStatusEnum
.
INREFUND
.
getCode
());
add
(
RefundStatusEnum
.
REFUNDED
.
getCode
());
}});
//订单开始时间大于等于当前时间 并且 订单开始时间小于等于当前订单实际结束时间+30分钟保洁
BigDecimal
bigDecimal
=
DateUtils
.
differentHour
(
order
.
getPreStartDate
(),
order
.
getPreEndDate
());
Date
orderEndDate
=
DateUtils
.
addMinutes
(
DateUtils
.
addHours
(
new
Date
(),
bigDecimal
.
intValue
()),
Constants
.
ROOM_LOCK_DELAY_MINUTE
);
queryWrapper
.
apply
(
"IFNULL(start_date,pre_start_date) >= '"
+
DateUtils
.
getTime
()
+
"' "
+
" AND IFNULL(start_date,pre_start_date) <= '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
orderEndDate
)
+
"'"
);
return
orderService
.
count
(
queryWrapper
)
==
0
;
}
}
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