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
79fc9337
Commit
79fc9337
authored
Dec 02, 2020
by
刘鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
如果是明天的预约单,不做下单时间检查
parent
becd8e19
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
37 deletions
+17
-37
order-application-service/src/main/java/cn/freemud/service/order/impl/CocoOrderRelationServiceImpl.java
+17
-37
No files found.
order-application-service/src/main/java/cn/freemud/service/order/impl/CocoOrderRelationServiceImpl.java
View file @
79fc9337
...
...
@@ -18,6 +18,7 @@ import cn.freemud.entities.vo.CreateOrderVo;
import
cn.freemud.enums.CreateOrderType
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.impl.CheckOrder
;
import
cn.freemud.service.order.OrderRelationService
;
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
...
...
@@ -38,11 +39,25 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
@Autowired
private
StoreCenterService
storeCenterService
;
@Autowired
private
CheckOrder
checkOrder
;
@Override
public
void
createOrderTimeCheck
(
StoreResponse
.
BizVO
storeResponseDto
,
CreateOrderVo
createOrderVo
)
{
// 只有外卖单才做下单时间判断
if
(
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
())){
if
(!
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
())){
return
;
}
// 如果是明天的预约单,不做时间检查
// 设置预约时间
Date
takeMealDateTime
=
checkOrder
.
getOrderExpectTime
(
createOrderVo
.
getTakeMealFlag
(),
createOrderVo
.
getTakeMealTime
(),
createOrderVo
.
getExpectTime
(),
CreateOrderType
.
getByCode
(
createOrderVo
.
getOrderType
()),
storeResponseDto
.
getServiceTime
(),
storeResponseDto
);
Date
todayEnd
=
DateUtil
.
setEndDay
(
new
Date
());
if
(
todayEnd
.
before
(
takeMealDateTime
)){
return
;
}
...
...
@@ -53,7 +68,7 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
)
||
1
<
todayBusinessTimes
.
size
()
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
BusinessDate
businessDate
=
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
0
),
true
);
BusinessDate
businessDate
=
checkOrder
.
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
0
),
true
);
todayEndDate
=
businessDate
.
getEndDate
();
// 当前时间+15分钟 > 门店打烊时间,返回错误
...
...
@@ -63,39 +78,4 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
}
}
public
BusinessDate
getStoreBusinessDate
(
String
businessHoursDay
,
boolean
today
)
{
BusinessDate
businessDate
=
new
BusinessDate
();
//设置营业开始和结束时间
String
businessHourStr
=
businessHoursDay
.
replace
(
"-"
,
","
).
replace
(
"_"
,
","
);
String
[]
businessHours
=
businessHourStr
.
split
(
","
);
if
(
businessHours
.
length
!=
2
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_NOT_FOUND
);
}
Date
date
=
new
Date
();
if
(!
today
)
{
date
=
DateUtil
.
addDays
(
date
,
1
);
}
String
startDateTimeStr
=
DateUtil
.
convert2String
(
date
,
DateUtil
.
FORMAT_YMD
)
+
" "
+
businessHours
[
0
]
+
":00"
;
String
endDateTimeStr
=
DateUtil
.
convert2String
(
date
,
DateUtil
.
FORMAT_YMD
)
+
" "
+
businessHours
[
1
]
+
":00"
;
Date
startDateTime
;
Date
endDateTime
;
startDateTime
=
DateUtil
.
convert2Date
(
startDateTimeStr
,
DateUtil
.
FORMAT_YYYY_MM_DD_HHMMSS
);
SimpleDateFormat
hhmmss
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
try
{
endDateTime
=
hhmmss
.
parse
(
endDateTimeStr
);
}
catch
(
ParseException
e
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
//隔天营业时间处理
if
(
startDateTime
.
after
(
endDateTime
))
{
endDateTime
=
DateUtil
.
addDays
(
endDateTime
,
1
);
}
// 校验门店是否打烊,打烊了则不让操作
if
(
startDateTime
==
null
||
endDateTime
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_ITEM_STOP_BUSINESS
);
}
businessDate
.
setStartDate
(
startDateTime
);
businessDate
.
setEndDate
(
endDateTime
);
return
businessDate
;
}
}
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