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
e6315f9c
Commit
e6315f9c
authored
Jun 16, 2020
by
ping.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
隔日预约时间校验
parent
fc9684c2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
141 additions
and
35 deletions
+141
-35
order-application-service/pom.xml
+1
-2
order-application-service/src/main/java/cn/freemud/entities/dto/order/BusinessDate.java
+25
-0
order-application-service/src/main/java/cn/freemud/enums/ResponseResult.java
+1
-0
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
+108
-28
order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
+6
-5
No files found.
order-application-service/pom.xml
View file @
e6315f9c
...
...
@@ -93,7 +93,7 @@
<dependency>
<groupId>
com.freemud.application.service.sdk
</groupId>
<artifactId>
storecenter-sdk
</artifactId>
<version>
2.
6.4
-SNAPSHOT
</version>
<version>
2.
10.3
-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
cn.freemud
</groupId>
...
...
@@ -351,7 +351,6 @@
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
apm-toolkit-logback-1.x
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
...
...
order-application-service/src/main/java/cn/freemud/entities/dto/order/BusinessDate.java
0 → 100644
View file @
e6315f9c
package
cn
.
freemud
.
entities
.
dto
.
order
;
import
lombok.Data
;
import
java.util.Date
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: BusinessDate
* @Package cn.freemud.entities.dto.order
* @Description:
* @author: ping1.wu
* @date: 2020/6/16 23:09
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public
class
BusinessDate
{
private
Date
startDate
;
private
Date
endDate
;
}
order-application-service/src/main/java/cn/freemud/enums/ResponseResult.java
View file @
e6315f9c
...
...
@@ -141,6 +141,7 @@ public enum ResponseResult {
ORDER_HAS_PAID
(
"45057"
,
"订单已支付或已完成"
),
ORDER_PRE_PAYMENT_CLOSE_FAILED
(
"45058"
,
"关闭预支付订单失败"
),
ORDER_OWNER_ERROR
(
"45059"
,
"订单归属错误"
),
ORDER_TAKEMEALTIME_INVALID
(
"45060"
,
"你的隔日预约时间有误,请重新刷新后选择!"
),
/**
* 支付
...
...
order-application-service/src/main/java/cn/freemud/service/impl/CheckOrder.java
View file @
e6315f9c
...
...
@@ -19,6 +19,7 @@ import cn.freemud.entities.db.OpenPlatformIappWxappConfig;
import
cn.freemud.entities.db.OpenPlatformPartnerStoreDeliveryConfig
;
import
cn.freemud.entities.db.StoreTableNumber
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.order.BusinessDate
;
import
cn.freemud.entities.dto.shoppingCart.GetShoppingCartGoodsApportionDto
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.*
;
...
...
@@ -173,11 +174,28 @@ public class CheckOrder {
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
())))
{
throw
new
ServiceException
(
ResponseResult
.
PARAMETER_MISSING
);
}
//校验预约时间
Date
takeMealDateTime
=
checkOrderExpectTime
(
createOrderVo
,
storeResponseDto
);
//重新赋值为yyyy-MM-dd HH:mm:ss格式字符串时间
String
expectTime
=
takeMealDateTime
==
null
?
null
:
DateUtil
.
convert2String
(
takeMealDateTime
,
"yyyy-MM-dd HH:mm:ss"
);
createOrderVo
.
setExpectTime
(
expectTime
);
String
takeMealTimes
=
createOrderVo
.
getTakeMealTime
();
// TODO: 2020/6/16 门店校验处理
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
(
StringUtils
.
isNotBlank
(
takeMealTimes
)
||
StringUtils
.
isNotBlank
(
createOrderVo
.
getExpectTime
())){
// 设置预约时间
Date
takeMealDateTime
=
getOrderExpectTime
(
takeMealFlag
,
takeMealTimes
,
createOrderVo
.
getExpectTime
(),
CreateOrderType
.
getByCode
(
createOrderVo
.
getOrderType
()),
storeResponseDto
.
getServiceTime
());
if
(
takeMealDateTime
!=
null
){
//校验预约时间
takeMealDateTime
=
checkOrderExpectTime
(
createOrderVo
,
storeResponseDto
,
takeMealDateTime
);
//重新赋值为yyyy-MM-dd HH:mm:ss格式字符串时间
createOrderVo
.
setExpectTime
(
takeMealDateTime
==
null
?
null
:
DateUtil
.
convert2String
(
takeMealDateTime
,
"yyyy-MM-dd HH:mm:ss"
));
}
}
String
appId
=
userLoginInfoDto
.
getWxAppId
();
// 校验小程序是否支持到店或者外卖
OpenPlatformIappWxappConfig
config
=
openPlatformIappWxappConfigManager
.
selectIappWxappConfigByWxAppId
(
appId
);
...
...
@@ -221,29 +239,52 @@ public class CheckOrder {
return
pushOrderTime
;
}
public
Date
checkOrderExpectTime
(
CreateOrderVo
createOrderVo
,
StoreResponse
.
BizVO
storeResponseDto
){
String
takeMealTimes
=
createOrderVo
.
getTakeMealTime
();
String
takeMealFlag
=
createOrderVo
.
getTakeMealFlag
();
// 设置预约时间
Date
takeMealDateTime
=
getOrderExpectTime
(
takeMealFlag
,
takeMealTimes
,
createOrderVo
.
getExpectTime
(),
storeResponseDto
,
CreateOrderType
.
getByCode
(
createOrderVo
.
getOrderType
()));
//未营业无预约时间无法下单
if
(!
StoreConstant
.
BUSINESS
.
equals
(
storeResponseDto
.
getState
())
&&
StringUtils
.
isBlank
(
takeMealFlag
)
&&
"0"
.
equals
(
takeMealFlag
))
{
throw
new
ServiceException
(
ResponseResult
.
STORE_ITEM_CHECK_CLOSE
);
public
Date
checkOrderExpectTime
(
CreateOrderVo
createOrderVo
,
StoreResponse
.
BizVO
storeResponseDto
,
Date
takeMealDateTime
){
if
(
takeMealDateTime
==
null
){
return
takeMealDateTime
;
}
//当天营业时间结束 不校验预约时间
boolean
inBusinessTime
=
true
;
if
(
takeMealDateTime
!=
null
&&
takeMealDateTime
.
after
(
storeResponseDto
.
getBusinessHoursDayEndTime
())){
inBusinessTime
=
false
;
//获取门店当天营业时间
BusinessDate
storeBusinessDate
=
getStoreBusinessDate
(
storeResponseDto
.
getBusinessHoursDay
(),
true
);
Date
endDate
=
storeBusinessDate
.
getEndDate
();
Date
startDate
=
storeBusinessDate
.
getStartDate
();
storeResponseDto
.
setBusinessHoursDayStartTime
(
startDate
);
storeResponseDto
.
setBusinessHoursDayEndTime
(
endDate
);
//在当天营业时间内
boolean
inTodayBusinessTime
=
true
;
Date
date
=
new
Date
();
Date
newDate
=
DateUtil
.
convert2Date
(
date
,
DateUtil
.
FORMAT_yyyyMMdd_date
);
newDate
=
DateUtil
.
addDays
(
newDate
,
1
);
//隔天预约(在明日凌晨之后且在门店营业结束之后)
if
(
takeMealDateTime
.
after
(
newDate
)
&&
takeMealDateTime
.
after
(
endDate
)){
inTodayBusinessTime
=
false
;
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
()))
{
inNextDayBusinessTime
=
false
;
}
}
if
(
inNextDayBusinessTime
){
throw
new
ServiceException
(
ResponseResult
.
ORDER_TAKEMEALTIME_INVALID
);
}
}
//00:00-营业结束(隔天营业)
if
(
takeMealDateTime
.
after
(
newDate
)
&&
takeMealDateTime
.
before
(
endDate
)){
return
takeMealDateTime
;
}
//当前时间刚过凌晨-营业结束(隔天营业)
if
(
takeMealDateTime
.
after
(
date
)
&&
takeMealDateTime
.
before
(
startDate
)){
return
takeMealDateTime
;
}
//有预约时间,预约时间要在营业时间范围内
if
(
in
BusinessTime
&&
takeMealDateTime
!=
null
&&
(
takeMealDateTime
.
before
(
storeResponseDto
.
getBusinessHoursDayStartTime
())
if
(
in
TodayBusinessTime
&&
(
takeMealDateTime
.
before
(
storeResponseDto
.
getBusinessHoursDayStartTime
())
||
takeMealDateTime
.
after
(
storeResponseDto
.
getBusinessHoursDayEndTime
())))
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_TAKEMEALTIME_INVAILD
);
}
if
(
CreateOrderType
.
TAKE_OUT
.
getCode
().
equals
(
createOrderVo
.
getOrderType
())){
Date
date
=
new
Date
();
String
deliveryStr
=
storeResponseDto
.
getDeliveryHoursDay
().
replace
(
"-"
,
","
)
.
replace
(
"_"
,
","
);
String
[]
deliverys
=
deliveryStr
.
split
(
","
);
...
...
@@ -265,7 +306,13 @@ public class CheckOrder {
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
// 校验预约配送时间
if
(
inBusinessTime
&&
takeMealDateTime
!=
null
&&
(
takeMealDateTime
.
before
(
deliveryStartDate
)
||
takeMealDateTime
.
after
(
deliveryEndDate
)))
{
if
(
inTodayBusinessTime
&&
(
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
(!
inTodayBusinessTime
&&
(
takeMealDateTime
.
before
(
nextDeliveryStartDate
)
||
takeMealDateTime
.
after
(
nextDeliveryEndDate
)))
{
throw
new
ServiceException
(
ResponseResult
.
ORDER_CREATE_TIME_NOT_DELIVERY
);
}
}
...
...
@@ -274,7 +321,7 @@ public class CheckOrder {
public
Date
getOrderExpectTime
(
String
takeMealFlag
,
String
takeMealTimes
,
String
expectTime
,
StoreResponse
.
BizVO
storeResponseDto
,
CreateOrderType
createOrderTyp
e
){
CreateOrderType
createOrderType
,
Integer
serviceTim
e
){
Date
takeMealDateTime
=
null
;
//0=到店单我已到店、外卖单尽快送出
if
(
StringUtils
.
isNotBlank
(
takeMealFlag
)
&&
"0"
.
equals
(
takeMealFlag
))
{
...
...
@@ -289,11 +336,8 @@ public class CheckOrder {
takeMealTime
=
takeMealTime
.
append
(
DateUtil
.
convert2String
(
date
,
"yyyy-MM-dd"
))
.
append
(
" "
).
append
(
takeMealTimes
).
append
(
":00"
);
takeMealDateTime
=
DateUtil
.
convert2Date
(
takeMealTime
.
toString
(),
"yyyy-MM-dd HH:mm:ss"
);
//隔天预约时间处理 营业时间8:00-2:00 预约1:00
// 当前时间 2020-6-11 09:00:00 下单时间在02:00-24:00,计算预约时间2020-6-11 01:00:00 实际预约时间 2020-6-12 1:00:00
// 当前时间 2020-6-11 00:01:00 下单时间在00:00-02:00,计算预约时间2020-6-11 01:00:00 实际预约时间 2020-6-11 1:00:00
if
(
takeMealDateTime
!=
null
&&
takeMealDateTime
.
before
(
storeResponseDto
.
getBusinessHoursDayStartTime
())
&&
takeMealDateTime
.
before
(
DateUtil
.
addDays
(
DateUtil
.
convert2Date
(
storeResponseDto
.
getBusinessHoursDayStartTime
(),
"yyyy-MM-dd"
),
1
))){
//隔天营业的预约时间处理 计算出预约时间在当前时间之前,预约时间加1天
if
(
takeMealDateTime
!=
null
&&
takeMealDateTime
.
before
(
date
)){
takeMealDateTime
=
DateUtil
.
addDays
(
takeMealDateTime
,
1
);
}
}
...
...
@@ -306,12 +350,48 @@ public class CheckOrder {
}
//当顾客指定送达时间小于当前时间+提前预约时间时,订单记录类型为即时单
if
(
CreateOrderType
.
TAKE_OUT
.
equals
(
createOrderType
)
&&
takeMealDateTime
!=
null
&&
s
toreResponseDto
.
getServiceTime
()
!=
null
&&
takeMealDateTime
.
before
(
DateUtil
.
addMinutes
(
date
,
storeResponseDto
.
getServiceTime
()
)))
{
&&
s
erviceTime
!=
null
&&
takeMealDateTime
.
before
(
DateUtil
.
addMinutes
(
date
,
serviceTime
)))
{
takeMealDateTime
=
null
;
}
return
takeMealDateTime
;
}
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
;
}
public
ShoppingCartGoodsDto
getShoppingCartGoodsDto
(
CreateOrderVo
createOrderVo
)
{
ShoppingCartInfoRequestVo
.
BuyMemberCard
buyMemberCard
=
null
;
if
(
createOrderVo
.
getBuyMemberCard
()
!=
null
)
{
...
...
order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
View file @
e6315f9c
...
...
@@ -48,14 +48,17 @@ import cn.freemud.service.CouponActivityService;
import
cn.freemud.service.OrderAdapterService
;
import
cn.freemud.service.Orderservice
;
import
cn.freemud.service.thirdparty.*
;
import
cn.freemud.utils.*
;
import
cn.freemud.utils.BeanUtil
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.ResponseUtil
;
import
cn.freemud.utils.ValidationCode
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.api.assortment.datamanager.entity.db.*
;
import
com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentCloudPrinterManager
;
import
com.freemud.api.assortment.datamanager.enums.IappIdType
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentCloudPrinterManager
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformPartnerConfigManager
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappAuthorizerManager
;
import
com.freemud.api.assortment.datamanager.manager.AssortmentOpenPlatformWxappManager
;
...
...
@@ -93,7 +96,6 @@ import com.freemud.sdk.api.assortment.message.enums.MessageEventType;
import
com.freemud.sdk.api.assortment.message.request.MessagePushOrderTemplateRequest
;
import
com.freemud.sdk.api.assortment.message.request.MessageTemplateRequest
;
import
com.freemud.sdk.api.assortment.message.service.IMessageTemplatePushService
;
import
com.freemud.sdk.api.assortment.order.adapter.ActivitySdkAdapter
;
import
com.freemud.sdk.api.assortment.order.enums.OldOrderStatus
;
import
com.freemud.sdk.api.assortment.order.request.order.*
;
import
com.freemud.sdk.api.assortment.order.response.order.*
;
...
...
@@ -274,9 +276,8 @@ public class OrderServiceImpl implements Orderservice {
// 查询购物车(内部校验券点餐方式,券是否可用) 校验当前订单类型的下单参数
ShoppingCartGoodsDto
shoppingCartGoodsDto
=
checkOrder
.
getShoppingCartGoodsDto
(
createOrderVo
);
// 查询小程序自提外卖配置信息 校验当前订单类型的下单参数 校验外卖是否满足起送条件
Integer
pushOrderTime
=
checkOrder
.
checkOrderByOrderType
(
createOrderVo
,
userLoginInfoDto
,
storeResponseDto
,
1L
,
trackingNo
);
Integer
pushOrderTime
=
checkOrder
.
checkOrderByOrderType
(
createOrderVo
,
userLoginInfoDto
,
storeResponseDto
,
shoppingCartGoodsDto
.
getTotalAmount
()
,
trackingNo
);
OrderExtInfoDto
extInfo
=
getExtInfo
(
userLoginInfoDto
,
storeResponseDto
,
pushOrderTime
,
createOrderVo
);
//1.9.2套餐需求同步优化创建订单代码
BaseResponse
createOrderOperateDtoResponse
=
this
.
sdkCreateOrder
(
createOrderVo
,
storeResponseDto
,
shoppingCartGoodsDto
,
userLoginInfoDto
);
if
(
createOrderOperateDtoResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
createOrderOperateDtoResponse
.
getCode
())
||
createOrderOperateDtoResponse
.
getResult
()
==
null
)
{
...
...
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