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
7fb2bb35
Commit
7fb2bb35
authored
Dec 27, 2021
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预定单 预约单 预定时间校验模式修改
Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent
86605b2c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
66 deletions
+16
-66
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
+12
-26
order-application-service/src/main/java/cn/freemud/service/order/impl/CocoOrderRelationServiceImpl.java
+1
-39
order-application-service/src/main/java/cn/freemud/utils/DateUtils.java
+3
-1
No files found.
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
View file @
7fb2bb35
...
@@ -46,6 +46,7 @@ import cn.freemud.service.thirdparty.CustomerPropertyClient;
...
@@ -46,6 +46,7 @@ import cn.freemud.service.thirdparty.CustomerPropertyClient;
import
cn.freemud.service.thirdparty.ShoppingCartClient
;
import
cn.freemud.service.thirdparty.ShoppingCartClient
;
import
cn.freemud.service.thirdparty.StoreBaseApiClient
;
import
cn.freemud.service.thirdparty.StoreBaseApiClient
;
import
cn.freemud.utils.AppLogUtil
;
import
cn.freemud.utils.AppLogUtil
;
import
cn.freemud.utils.DateUtils
;
import
cn.freemud.utils.ResponseUtil
;
import
cn.freemud.utils.ResponseUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -505,9 +506,10 @@ public class CheckOrder {
...
@@ -505,9 +506,10 @@ public class CheckOrder {
}
}
Date
createOrder
=
DateUtil
.
addMinutes
(
new
Date
(),
10
);
Date
createOrder
=
DateUtil
.
addMinutes
(
new
Date
(),
10
);
int
diffDay
=
DateUtils
.
diffDay
(
new
Date
(),
takeMealDateTime
);
for
(
String
todayTime
:
todayBusinessTimes
)
{
for
(
String
todayTime
:
todayBusinessTimes
)
{
//每段营业时间校验
//每段营业时间校验
BusinessDate
businessDate2
=
this
.
getStoreBusinessDate
(
todayTime
,
true
);
BusinessDate
businessDate2
=
this
.
getStoreBusinessDate
(
todayTime
,
diffDay
);
if
(
createOrder
.
after
(
businessDate2
.
getEndDate
()))
{
if
(
createOrder
.
after
(
businessDate2
.
getEndDate
()))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_SELF_ERROR_10
);
throw
new
ServiceException
(
ResponseResult
.
STORE_SELF_ERROR_10
);
}
}
...
@@ -525,21 +527,6 @@ public class CheckOrder {
...
@@ -525,21 +527,6 @@ public class CheckOrder {
&&
BizTypeEnum
.
ADVANCE_ORDER
.
getBizType
().
compareTo
(
bizType
)
==
0
;
&&
BizTypeEnum
.
ADVANCE_ORDER
.
getBizType
().
compareTo
(
bizType
)
==
0
;
}
}
/**
* 获取门店营业时间
*
* @param storeResponseDto
* @param toDay true 今日,false 明天
* @return
*/
private
BusinessDate
getStoreBusinessDate
(
StoreResponseDto
storeResponseDto
,
boolean
toDay
)
{
List
<
String
>
todayBusinessTimes
=
storeCenterService
.
getTodayBusinessTime
(
Integer
.
parseInt
(
storeResponseDto
.
getBusinessType
()),
storeResponseDto
.
getBusinessHoursDay
());
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
BusinessDate
businessDate
=
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
todayBusinessTimes
.
size
()
-
1
),
toDay
);
return
businessDate
;
}
public
void
checkOrderExpectTime
(
CreateOrderVo
createOrderVo
,
StoreResponseDto
storeResponseDto
,
Date
takeMealDateTime
)
{
public
void
checkOrderExpectTime
(
CreateOrderVo
createOrderVo
,
StoreResponseDto
storeResponseDto
,
Date
takeMealDateTime
)
{
if
(
takeMealDateTime
==
null
)
{
if
(
takeMealDateTime
==
null
)
{
...
@@ -551,11 +538,12 @@ public class CheckOrder {
...
@@ -551,11 +538,12 @@ public class CheckOrder {
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
}
BusinessDate
businessDate
=
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
todayBusinessTimes
.
size
()
-
1
),
true
);
Date
date
=
new
Date
();
int
diffDay
=
DateUtils
.
diffDay
(
date
,
takeMealDateTime
);
BusinessDate
businessDate
=
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
todayBusinessTimes
.
size
()
-
1
),
diffDay
);
todayEndDate
=
businessDate
.
getEndDate
();
todayEndDate
=
businessDate
.
getEndDate
();
//在当天营业时间内
//在当天营业时间内
boolean
expectTimeInTodayBusinessTime
=
true
;
boolean
expectTimeInTodayBusinessTime
=
true
;
Date
date
=
new
Date
();
Date
newDate
=
DateUtil
.
convert2Date
(
date
,
DateUtil
.
FORMAT_yyyyMMdd_date
);
Date
newDate
=
DateUtil
.
convert2Date
(
date
,
DateUtil
.
FORMAT_yyyyMMdd_date
);
newDate
=
DateUtil
.
addDays
(
newDate
,
1
);
newDate
=
DateUtil
.
addDays
(
newDate
,
1
);
//隔天预约(在明日凌晨之后且在门店营业结束之后)
//隔天预约(在明日凌晨之后且在门店营业结束之后)
...
@@ -566,7 +554,7 @@ public class CheckOrder {
...
@@ -566,7 +554,7 @@ public class CheckOrder {
boolean
inTodayBusinessTime
=
true
;
boolean
inTodayBusinessTime
=
true
;
for
(
String
todayTime
:
todayBusinessTimes
)
{
for
(
String
todayTime
:
todayBusinessTimes
)
{
//每段营业时间校验
//每段营业时间校验
BusinessDate
businessDate2
=
getStoreBusinessDate
(
todayTime
,
true
);
BusinessDate
businessDate2
=
getStoreBusinessDate
(
todayTime
,
diffDay
);
if
(
takeMealDateTime
.
getTime
()
>=
businessDate2
.
getStartDate
().
getTime
()
if
(
takeMealDateTime
.
getTime
()
>=
businessDate2
.
getStartDate
().
getTime
()
&&
takeMealDateTime
.
getTime
()
<=
businessDate2
.
getEndDate
().
getTime
())
{
&&
takeMealDateTime
.
getTime
()
<=
businessDate2
.
getEndDate
().
getTime
())
{
inTodayBusinessTime
=
false
;
inTodayBusinessTime
=
false
;
...
@@ -582,7 +570,7 @@ public class CheckOrder {
...
@@ -582,7 +570,7 @@ public class CheckOrder {
List
<
String
>
nextDayBusinessTimes
=
storeCenterService
.
getNextDayBusinessTime
(
Integer
.
parseInt
(
storeResponseDto
.
getBusinessType
()),
storeResponseDto
.
getBusinessHoursDay
());
List
<
String
>
nextDayBusinessTimes
=
storeCenterService
.
getNextDayBusinessTime
(
Integer
.
parseInt
(
storeResponseDto
.
getBusinessType
()),
storeResponseDto
.
getBusinessHoursDay
());
boolean
inNextDayBusinessTime
=
true
;
boolean
inNextDayBusinessTime
=
true
;
for
(
String
nextDayTime
:
nextDayBusinessTimes
)
{
for
(
String
nextDayTime
:
nextDayBusinessTimes
)
{
BusinessDate
storeNextBusinessDate
=
getStoreBusinessDate
(
nextDayTime
,
false
);
BusinessDate
storeNextBusinessDate
=
getStoreBusinessDate
(
nextDayTime
,
diffDay
);
if
(
takeMealDateTime
.
getTime
()
>=
storeNextBusinessDate
.
getStartDate
().
getTime
()
if
(
takeMealDateTime
.
getTime
()
>=
storeNextBusinessDate
.
getStartDate
().
getTime
()
&&
takeMealDateTime
.
getTime
()
<=
storeNextBusinessDate
.
getEndDate
().
getTime
())
{
&&
takeMealDateTime
.
getTime
()
<=
storeNextBusinessDate
.
getEndDate
().
getTime
())
{
inNextDayBusinessTime
=
false
;
inNextDayBusinessTime
=
false
;
...
@@ -671,7 +659,7 @@ public class CheckOrder {
...
@@ -671,7 +659,7 @@ public class CheckOrder {
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
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
),
0
);
todayEndDate
=
businessDate
.
getEndDate
();
todayEndDate
=
businessDate
.
getEndDate
();
//隔天营业的预约时间处理 计算出预约时间在当前时间之前,预约时间加1天 newDate.before(todayEndDate)=隔天营业
//隔天营业的预约时间处理 计算出预约时间在当前时间之前,预约时间加1天 newDate.before(todayEndDate)=隔天营业
...
@@ -694,9 +682,6 @@ public class CheckOrder {
...
@@ -694,9 +682,6 @@ public class CheckOrder {
return
takeMealDateTime
;
return
takeMealDateTime
;
}
}
public
BusinessDate
getStoreBusinessDate
(
String
businessHoursDay
,
boolean
today
)
{
return
this
.
getStoreBusinessDate
(
businessHoursDay
,
today
?
0
:
1
);
}
public
ShoppingCartGoodsDto
getShoppingCartGoodsDto
(
CreateOrderVo
createOrderVo
)
{
public
ShoppingCartGoodsDto
getShoppingCartGoodsDto
(
CreateOrderVo
createOrderVo
)
{
// ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = null;
// ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = null;
...
@@ -1403,7 +1388,7 @@ public class CheckOrder {
...
@@ -1403,7 +1388,7 @@ public class CheckOrder {
}
}
}
}
p
rivate
BusinessDate
getStoreBusinessDate
(
String
businessHoursDay
,
int
today
)
{
p
ublic
BusinessDate
getStoreBusinessDate
(
String
businessHoursDay
,
int
today
)
{
BusinessDate
businessDate
=
new
BusinessDate
();
BusinessDate
businessDate
=
new
BusinessDate
();
//设置营业开始和结束时间
//设置营业开始和结束时间
String
businessHourStr
=
businessHoursDay
.
replace
(
"-"
,
","
).
replace
(
"_"
,
","
);
String
businessHourStr
=
businessHoursDay
.
replace
(
"-"
,
","
).
replace
(
"_"
,
","
);
...
@@ -1460,13 +1445,14 @@ public class CheckOrder {
...
@@ -1460,13 +1445,14 @@ public class CheckOrder {
private
void
getBusinessTimeByType1
(
String
businessHoursDay
,
Date
takeMealDateTime
)
{
private
void
getBusinessTimeByType1
(
String
businessHoursDay
,
Date
takeMealDateTime
)
{
String
[]
splitArr
=
businessHoursDay
.
split
(
";"
);
String
[]
splitArr
=
businessHoursDay
.
split
(
";"
);
boolean
isBusinessTime
=
false
;
boolean
isBusinessTime
=
false
;
int
diffDay
=
DateUtils
.
diffDay
(
new
Date
(),
takeMealDateTime
);
for
(
String
businessHours
:
splitArr
)
{
for
(
String
businessHours
:
splitArr
)
{
if
(
"00: 00-00: 00"
.
equals
(
businessHours
))
{
if
(
"00: 00-00: 00"
.
equals
(
businessHours
))
{
// 不在营业时间范围
// 不在营业时间范围
throw
new
ServiceException
(
ResponseResult
.
STORE_NO_OPEN
);
throw
new
ServiceException
(
ResponseResult
.
STORE_NO_OPEN
);
}
}
// 获取营业时间
// 获取营业时间
BusinessDate
storeBusinessDate
=
getStoreBusinessDate
(
businessHours
,
true
);
BusinessDate
storeBusinessDate
=
getStoreBusinessDate
(
businessHours
,
diffDay
);
// 检验 是否在营业时间 范围内
// 检验 是否在营业时间 范围内
if
(
takeMealDateTime
.
after
(
storeBusinessDate
.
getStartDate
())
&&
takeMealDateTime
.
before
(
storeBusinessDate
.
getEndDate
()))
{
if
(
takeMealDateTime
.
after
(
storeBusinessDate
.
getStartDate
())
&&
takeMealDateTime
.
before
(
storeBusinessDate
.
getEndDate
()))
{
// 在营业时间范围
// 在营业时间范围
...
...
order-application-service/src/main/java/cn/freemud/service/order/impl/CocoOrderRelationServiceImpl.java
View file @
7fb2bb35
...
@@ -16,7 +16,6 @@ import cn.freemud.base.util.DateUtil;
...
@@ -16,7 +16,6 @@ import cn.freemud.base.util.DateUtil;
import
cn.freemud.entities.dto.StoreResponseDto
;
import
cn.freemud.entities.dto.StoreResponseDto
;
import
cn.freemud.entities.dto.order.BusinessDate
;
import
cn.freemud.entities.dto.order.BusinessDate
;
import
cn.freemud.entities.vo.CreateOrderBaseVo
;
import
cn.freemud.entities.vo.CreateOrderBaseVo
;
import
cn.freemud.entities.vo.CreateOrderVo
;
import
cn.freemud.entities.vo.ProductVo
;
import
cn.freemud.entities.vo.ProductVo
;
import
cn.freemud.entities.vo.QueryOrderResponseVo
;
import
cn.freemud.entities.vo.QueryOrderResponseVo
;
import
cn.freemud.enums.CreateOrderType
;
import
cn.freemud.enums.CreateOrderType
;
...
@@ -28,7 +27,6 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -28,7 +27,6 @@ import com.alibaba.fastjson.JSONObject;
import
com.freemud.application.sdk.api.ordercenter.entities.v1.ProductBeanV1
;
import
com.freemud.application.sdk.api.ordercenter.entities.v1.ProductBeanV1
;
import
com.freemud.application.sdk.api.ordercenter.entities.v1.ProductDiscountV1
;
import
com.freemud.application.sdk.api.ordercenter.entities.v1.ProductDiscountV1
;
import
com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderSendCouponResp
;
import
com.freemud.application.sdk.api.ordercenter.response.orderInfo.OrderSendCouponResp
;
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
import
com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType
;
import
com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType
;
import
com.freemud.sdk.api.assortment.order.request.order.OrderProductAddInfoDto
;
import
com.freemud.sdk.api.assortment.order.request.order.OrderProductAddInfoDto
;
...
@@ -54,42 +52,6 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
...
@@ -54,42 +52,6 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
private
CheckOrder
checkOrder
;
private
CheckOrder
checkOrder
;
// @Override
// @Override
public
void
createOrderTimeCheck
(
StoreResponseDto
storeResponseDto
,
CreateOrderVo
createOrderVo
)
{
// 只有外卖单才做下单时间判断
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
(
takeMealDateTime
!=
null
&&
todayEnd
.
before
(
takeMealDateTime
)){
return
;
}
//获取门店当天营业时间
// coco只有一个营业时间,如果返回多个就报错
Date
todayEndDate
=
null
;
List
<
String
>
todayBusinessTimes
=
storeCenterService
.
getTodayBusinessTime
(
Integer
.
parseInt
(
storeResponseDto
.
getBusinessType
()),
storeResponseDto
.
getBusinessHoursDay
());
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
)
||
1
<
todayBusinessTimes
.
size
()
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
BusinessDate
businessDate
=
checkOrder
.
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
0
),
true
);
todayEndDate
=
businessDate
.
getEndDate
();
// 当前时间+15分钟 > 门店打烊时间,返回错误
Date
nowAddDate
=
DateUtil
.
addMinutes
(
new
Date
(),
15
);
if
(
nowAddDate
.
after
(
todayEndDate
)){
throw
new
ServiceException
(
ResponseResult
.
STORE_WILL_COLSE
);
}
}
// @Override
public
void
createOrderTimeCheck
(
StoreResponseDto
storeResponseDto
,
CreateOrderBaseVo
createOrderVo
)
{
public
void
createOrderTimeCheck
(
StoreResponseDto
storeResponseDto
,
CreateOrderBaseVo
createOrderVo
)
{
// 只有外卖单才做下单时间判断
// 只有外卖单才做下单时间判断
if
(!
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
())){
if
(!
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
())){
...
@@ -114,7 +76,7 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
...
@@ -114,7 +76,7 @@ public class CocoOrderRelationServiceImpl implements OrderRelationService {
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
)
||
1
<
todayBusinessTimes
.
size
()
)
{
if
(
CollectionUtils
.
isEmpty
(
todayBusinessTimes
)
||
1
<
todayBusinessTimes
.
size
()
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
throw
new
ServiceException
(
ResponseResult
.
STORE_BUSINESS_HOUR_ERROR
);
}
}
BusinessDate
businessDate
=
checkOrder
.
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
0
),
true
);
BusinessDate
businessDate
=
checkOrder
.
getStoreBusinessDate
(
todayBusinessTimes
.
get
(
0
),
0
);
todayEndDate
=
businessDate
.
getEndDate
();
todayEndDate
=
businessDate
.
getEndDate
();
// 当前时间+15分钟 > 门店打烊时间,返回错误
// 当前时间+15分钟 > 门店打烊时间,返回错误
...
...
order-application-service/src/main/java/cn/freemud/utils/DateUtils.java
View file @
7fb2bb35
...
@@ -44,6 +44,8 @@ public class DateUtils {
...
@@ -44,6 +44,8 @@ public class DateUtils {
}
}
}
}
public
static
int
diffDay
(
Date
before
,
Date
after
)
{
return
Integer
.
parseInt
(
String
.
valueOf
((
after
.
getTime
()
-
before
.
getTime
())
/
86400000L
));
}
}
}
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