Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
3f3973a0
Commit
3f3973a0
authored
Jun 22, 2020
by
ping.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
after时间相等问题比较修改
parent
b338ec89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
24 deletions
+26
-24
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
+26
-24
No files found.
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
View file @
3f3973a0
...
...
@@ -240,58 +240,60 @@ public class CheckOrder {
return
pushOrderTime
;
}
public
void
checkOrderExpectTime
(
CreateOrderVo
createOrderVo
,
StoreResponse
.
BizVO
storeResponseDto
,
Date
takeMealDateTime
)
{
if
(
takeMealDateTime
==
null
)
{
public
void
checkOrderExpectTime
(
CreateOrderVo
createOrderVo
,
StoreResponse
.
BizVO
storeResponseDto
,
Date
takeMealDateTime
)
{
if
(
takeMealDateTime
==
null
)
{
return
;
}
//获取门店当天营业时间
Date
todayEndDate
=
null
;
Date
todayEndDate
=
null
;
List
<
String
>
todayBusinessTimes
=
storeCenterService
.
getTodayBusinessTime
(
Integer
.
parseInt
(
storeResponseDto
.
getBusinessType
()),
storeResponseDto
.
getBusinessHoursDay
());
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
BusinessDate
businessDate
=
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
todayBusinessTimes
.
size
()
-
1
),
true
);
BusinessDate
businessDate
=
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
todayBusinessTimes
.
size
()
-
1
),
true
);
todayEndDate
=
businessDate
.
getEndDate
();
//在当天营业时间内
boolean
expectTimeInTodayBusinessTime
=
true
;
Date
date
=
new
Date
();
Date
newDate
=
DateUtil
.
convert2Date
(
date
,
DateUtil
.
FORMAT_yyyyMMdd_date
);
newDate
=
DateUtil
.
addDays
(
newDate
,
1
);
Date
newDate
=
DateUtil
.
convert2Date
(
date
,
DateUtil
.
FORMAT_yyyyMMdd_date
);
newDate
=
DateUtil
.
addDays
(
newDate
,
1
);
//隔天预约(在明日凌晨之后且在门店营业结束之后)
if
(
takeMealDateTime
.
after
(
newDate
)
&&
takeMealDateTime
.
after
(
todayEndDate
))
{
expectTimeInTodayBusinessTime
=
false
;
if
(
takeMealDateTime
.
after
(
todayEndDate
)
&&
takeMealDateTime
.
after
(
newDate
))
{
expectTimeInTodayBusinessTime
=
false
;
}
if
(
expectTimeInTodayBusinessTime
)
{
if
(
expectTimeInTodayBusinessTime
)
{
boolean
inTodayBusinessTime
=
true
;
for
(
String
todayTime
:
todayBusinessTimes
){
for
(
String
todayTime
:
todayBusinessTimes
)
{
//每段营业时间校验
BusinessDate
businessDate2
=
getStoreBusinessDate
(
todayTime
,
true
);
if
(
takeMealDateTime
.
after
(
businessDate2
.
getStartDate
())
&&
takeMealDateTime
.
before
(
businessDate2
.
getEndDate
()))
{
BusinessDate
businessDate2
=
getStoreBusinessDate
(
todayTime
,
true
);
if
(
takeMealDateTime
.
getTime
()
>=
businessDate2
.
getStartDate
().
getTime
()
&&
takeMealDateTime
.
getTime
()
<=
businessDate2
.
getEndDate
().
getTime
())
{
inTodayBusinessTime
=
false
;
break
;
}
}
if
(
inTodayBusinessTime
)
{
if
(
inTodayBusinessTime
)
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_TAKEMEALTIME_INVAILD
);
}
}
//隔天预约
if
(!
expectTimeInTodayBusinessTime
)
{
if
(!
expectTimeInTodayBusinessTime
)
{
List
<
String
>
nextDayBusinessTimes
=
storeCenterService
.
getNextDayBusinessTime
(
Integer
.
parseInt
(
storeResponseDto
.
getBusinessType
()),
storeResponseDto
.
getBusinessHoursDay
());
boolean
inNextDayBusinessTime
=
true
;
for
(
String
nextDayTime
:
nextDayBusinessTimes
){
BusinessDate
storeNextBusinessDate
=
getStoreBusinessDate
(
nextDayTime
,
false
);
if
(
takeMealDateTime
.
after
(
storeNextBusinessDate
.
getStartDate
())
&&
takeMealDateTime
.
before
(
storeNextBusinessDate
.
getEndDate
()))
{
for
(
String
nextDayTime
:
nextDayBusinessTimes
)
{
BusinessDate
storeNextBusinessDate
=
getStoreBusinessDate
(
nextDayTime
,
false
);
if
(
takeMealDateTime
.
getTime
()
>=
storeNextBusinessDate
.
getStartDate
().
getTime
()
&&
takeMealDateTime
.
getTime
()
<=
storeNextBusinessDate
.
getEndDate
().
getTime
())
{
inNextDayBusinessTime
=
false
;
break
;
}
}
if
(
inNextDayBusinessTime
)
{
if
(
inNextDayBusinessTime
)
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_TAKEMEALTIME_INVALID
);
}
}
if
(
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
()))
{
if
(
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
()))
{
String
deliveryStr
=
storeResponseDto
.
getDeliveryHoursDay
().
replace
(
"-"
,
","
)
.
replace
(
"_"
,
","
);
String
[]
deliverys
=
deliveryStr
.
split
(
","
);
...
...
@@ -313,13 +315,13 @@ public class CheckOrder {
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
// 校验预约配送时间
if
(
expectTimeInTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
deliveryStartDate
)
||
takeMealDateTime
.
after
(
deliveryEndDate
)))
{
if
(
expectTimeInTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
deliveryStartDate
)
||
takeMealDateTime
.
after
(
deliveryEndDate
)))
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
Date
nextDeliveryStartDate
=
DateUtil
.
addDays
(
deliveryStartDate
,
1
);
Date
nextDeliveryEndDate
=
DateUtil
.
addDays
(
deliveryEndDate
,
1
);
Date
nextDeliveryStartDate
=
DateUtil
.
addDays
(
deliveryStartDate
,
1
);
Date
nextDeliveryEndDate
=
DateUtil
.
addDays
(
deliveryEndDate
,
1
);
// 隔日预约外卖校验预约配送时间
if
(!
expectTimeInTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
nextDeliveryStartDate
)
||
takeMealDateTime
.
after
(
nextDeliveryEndDate
)))
{
if
(!
expectTimeInTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
nextDeliveryStartDate
)
||
takeMealDateTime
.
after
(
nextDeliveryEndDate
)))
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
}
...
...
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