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
8c998050
Commit
8c998050
authored
Jul 14, 2020
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
当外卖订单的预约时间不在门店的外卖时间内时,不允许下单
parent
52ae5483
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
32 deletions
+51
-32
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
+51
-32
No files found.
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
View file @
8c998050
...
@@ -183,9 +183,17 @@ public class CheckOrder {
...
@@ -183,9 +183,17 @@ public class CheckOrder {
}
}
// TODO: 2020/6/16 门店校验处理
// TODO: 2020/6/16 门店校验处理
String
takeMealFlag
=
createOrderVo
.
getTakeMealFlag
();
String
takeMealFlag
=
createOrderVo
.
getTakeMealFlag
();
//未营业无预约时间无法下单
if
(!
StoreConstant
.
BUSINESS
.
equals
(
storeResponseDto
.
getState
())
&&
StringUtils
.
isBlank
(
takeMealFlag
)
&&
"0"
.
equals
(
takeMealFlag
))
{
//立即送达
throw
new
ServiceException
(
ResponseResult
.
STORE_ITEM_CHECK_CLOSE
);
if
(
"0"
.
equals
(
takeMealFlag
))
{
//未营业无预约时间无法下单
if
(!
StoreConstant
.
BUSINESS
.
equals
(
storeResponseDto
.
getState
()))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_ITEM_CHECK_CLOSE
);
}
// 外卖单选择立即送达的话,下单时间必须在店铺外卖时间内
if
(
createOrderVo
.
getOrderType
().
compareTo
(
CreateOrderType
.
TAKE_OUT
.
getCode
())
==
0
)
{
checkTakeOutTime
(
storeResponseDto
,
new
Date
(),
new
Date
(),
true
);
}
}
}
String
takeMealTimes
=
createOrderVo
.
getTakeMealTime
();
String
takeMealTimes
=
createOrderVo
.
getTakeMealTime
();
...
@@ -298,37 +306,48 @@ public class CheckOrder {
...
@@ -298,37 +306,48 @@ public class CheckOrder {
}
}
if
(
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
()))
{
if
(
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
()))
{
String
deliveryStr
=
storeResponseDto
.
getDeliveryHoursDay
().
replace
(
"-"
,
","
)
checkTakeOutTime
(
storeResponseDto
,
date
,
takeMealDateTime
,
expectTimeInTodayBusinessTime
);
.
replace
(
"_"
,
","
);
}
String
[]
deliverys
=
deliveryStr
.
split
(
","
);
}
Date
deliveryStartDate
=
null
;
Date
deliveryEndDate
=
null
;
/**
if
(
deliverys
.
length
==
2
)
{
* 检验订单是否在外卖时间内
SimpleDateFormat
hhmmss
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
* @param storeResponseDto 店铺信息
SimpleDateFormat
yyyyMMdd
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
* @param now 当前时间
String
startDateTimeStr
=
yyyyMMdd
.
format
(
date
)
+
" "
+
deliverys
[
0
]
+
":00"
;
* @param takeMealDateTime 预约单送达时间/即时单下单时间
String
endDateTimeStr
=
yyyyMMdd
.
format
(
date
)
+
" "
+
deliverys
[
1
]
+
":00"
;
* @param expectTimeInTodayBusinessTime 是否在当日营业时间内
try
{
*/
deliveryEndDate
=
hhmmss
.
parse
(
endDateTimeStr
);
private
void
checkTakeOutTime
(
StoreResponse
.
BizVO
storeResponseDto
,
Date
now
,
Date
takeMealDateTime
,
boolean
expectTimeInTodayBusinessTime
)
{
deliveryStartDate
=
hhmmss
.
parse
(
startDateTimeStr
);
String
deliveryStr
=
storeResponseDto
.
getDeliveryHoursDay
().
replace
(
"-"
,
","
)
}
catch
(
ParseException
e
)
{
.
replace
(
"_"
,
","
);
LogUtil
.
error
(
"getStoreDeliveryInfo_error"
,
endDateTimeStr
,
e
.
getMessage
());
String
[]
deliverys
=
deliveryStr
.
split
(
","
);
}
Date
deliveryStartDate
=
null
;
}
Date
deliveryEndDate
=
null
;
if
(
deliveryStartDate
==
null
||
deliveryEndDate
==
null
)
{
if
(
deliverys
.
length
==
2
)
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
SimpleDateFormat
hhmmss
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
}
SimpleDateFormat
yyyyMMdd
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// 校验预约配送时间
String
startDateTimeStr
=
yyyyMMdd
.
format
(
now
)
+
" "
+
deliverys
[
0
]
+
":00"
;
if
(
expectTimeInTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
deliveryStartDate
)
||
takeMealDateTime
.
after
(
deliveryEndDate
)))
{
String
endDateTimeStr
=
yyyyMMdd
.
format
(
now
)
+
" "
+
deliverys
[
1
]
+
":00"
;
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
try
{
}
deliveryStartDate
=
hhmmss
.
parse
(
startDateTimeStr
);
Date
nextDeliveryStartDate
=
DateUtil
.
addDays
(
deliveryStartDate
,
1
);
deliveryEndDate
=
hhmmss
.
parse
(
endDateTimeStr
);
Date
nextDeliveryEndDate
=
DateUtil
.
addDays
(
deliveryEndDate
,
1
);
}
catch
(
ParseException
e
)
{
// 隔日预约外卖校验预约配送时间
LogUtil
.
error
(
"getStoreDeliveryInfo_error"
,
endDateTimeStr
,
e
.
getMessage
());
if
(!
expectTimeInTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
nextDeliveryStartDate
)
||
takeMealDateTime
.
after
(
nextDeliveryEndDate
)))
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
}
}
}
if
(
deliveryStartDate
==
null
||
deliveryEndDate
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
// 校验预约配送时间
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
);
// 隔日预约外卖校验预约配送时间
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