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
9bbd1877
Commit
9bbd1877
authored
Dec 10, 2021
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
额外配送费逻辑开发
Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent
2cdc02ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
10 deletions
+49
-10
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/console/NightDeliveryuInfo.java
+2
-4
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/DeliveryService.java
+18
-6
shopping-cart-application-service/src/main/java/cn/freemud/utils/DateTimeUtil.java
+29
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/console/NightDeliveryuInfo.java
View file @
9bbd1877
...
@@ -2,8 +2,6 @@ package cn.freemud.entities.dto.console;
...
@@ -2,8 +2,6 @@ package cn.freemud.entities.dto.console;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Date
;
/**
/**
* @author : xh.Z
* @author : xh.Z
* @email : fisherman0510@163.com
* @email : fisherman0510@163.com
...
@@ -25,12 +23,12 @@ public class NightDeliveryuInfo {
...
@@ -25,12 +23,12 @@ public class NightDeliveryuInfo {
/**
/**
* 开始时间
* 开始时间
*/
*/
private
Date
startTime
;
private
String
startTime
;
/**
/**
* 结束时间
* 结束时间
*/
*/
private
Date
endTime
;
private
String
endTime
;
/**
/**
* 是否开启 1开启 0关闭
* 是否开启 1开启 0关闭
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/DeliveryService.java
View file @
9bbd1877
...
@@ -13,14 +13,18 @@
...
@@ -13,14 +13,18 @@
package
cn
.
freemud
.
service
.
delivery
;
package
cn
.
freemud
.
service
.
delivery
;
import
cn.freemud.base.util.DateUtil
;
import
cn.freemud.entities.ExtraDeliveryDto
;
import
cn.freemud.entities.ExtraDeliveryDto
;
import
cn.freemud.entities.dto.console.DeliveryInfoExpandFieldDTO
;
import
cn.freemud.entities.dto.console.DeliveryInfoExpandFieldDTO
;
import
cn.freemud.entities.dto.console.NightDeliveryuInfo
;
import
cn.freemud.entities.dto.console.NightDeliveryuInfo
;
import
cn.freemud.entities.vo.ShoppingCartGoodsResponseVo
;
import
cn.freemud.entities.vo.ShoppingCartGoodsResponseVo
;
import
cn.freemud.utils.DateTimeUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -56,16 +60,24 @@ public interface DeliveryService {
...
@@ -56,16 +60,24 @@ public interface DeliveryService {
if
(
StringUtils
.
isNotBlank
(
expandFields
))
{
if
(
StringUtils
.
isNotBlank
(
expandFields
))
{
DeliveryInfoExpandFieldDTO
expandField
=
JSON
.
parseObject
(
expandFields
,
DeliveryInfoExpandFieldDTO
.
class
);
DeliveryInfoExpandFieldDTO
expandField
=
JSON
.
parseObject
(
expandFields
,
DeliveryInfoExpandFieldDTO
.
class
);
if
(
Objects
.
nonNull
(
expandField
)
&&
CollectionUtils
.
isNotEmpty
(
expandField
.
getNightDeliveryInfo
()))
{
if
(
Objects
.
nonNull
(
expandField
)
&&
CollectionUtils
.
isNotEmpty
(
expandField
.
getNightDeliveryInfo
()))
{
Date
currentDate
=
new
Date
();
for
(
NightDeliveryuInfo
info
:
expandField
.
getNightDeliveryInfo
())
{
for
(
NightDeliveryuInfo
info
:
expandField
.
getNightDeliveryInfo
())
{
if
(
info
.
getStatus
()
==
NightDeliveryuInfo
.
COMMON_STATUS_OPEN
)
{
if
(
info
.
getStatus
()
==
NightDeliveryuInfo
.
COMMON_STATUS_OPEN
)
{
// 当前时间在区间内
// 当前时间在区间内
if
(
currentDate
.
after
(
info
.
getStartTime
())
&&
currentDate
.
before
(
info
.
getEndTime
()))
{
try
{
ExtraDeliveryDto
extraDeliveryDto
=
new
ExtraDeliveryDto
(
info
.
getType
(),
amount
);
Date
nowTime
=
new
SimpleDateFormat
(
DateUtil
.
FORMAT_time
).
parse
(
DateTimeUtil
.
getCurrentTimeStr
());
list
.
add
(
extraDeliveryDto
);
Date
startTime
=
new
SimpleDateFormat
(
DateUtil
.
FORMAT_time
).
parse
(
info
.
getStartTime
());
// 金额 增加
Date
endTime
=
new
SimpleDateFormat
(
DateUtil
.
FORMAT_time
).
parse
(
info
.
getEndTime
());
amount
+=
info
.
getPrice
();
if
(
DateTimeUtil
.
isEffectiveDate
(
nowTime
,
startTime
,
endTime
))
{
ExtraDeliveryDto
extraDeliveryDto
=
new
ExtraDeliveryDto
(
info
.
getType
(),
amount
);
list
.
add
(
extraDeliveryDto
);
// 金额 增加
amount
+=
info
.
getPrice
();
}
}
catch
(
ParseException
e
)
{
// 报错表示 时间格式设置错误, 默认当做不计算
e
.
printStackTrace
();
}
}
}
}
}
}
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/utils/DateTimeUtil.java
View file @
9bbd1877
...
@@ -6,6 +6,7 @@ import java.time.format.DateTimeParseException;
...
@@ -6,6 +6,7 @@ import java.time.format.DateTimeParseException;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.Temporal
;
import
java.time.temporal.Temporal
;
import
java.time.temporal.TemporalAdjusters
;
import
java.time.temporal.TemporalAdjusters
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
...
@@ -281,4 +282,32 @@ public class DateTimeUtil {
...
@@ -281,4 +282,32 @@ public class DateTimeUtil {
return
getCurrentLocalDate
().
plus
(
2
,
ChronoUnit
.
DECADES
).
format
(
DATE_FORMATTER
);
return
getCurrentLocalDate
().
plus
(
2
,
ChronoUnit
.
DECADES
).
format
(
DATE_FORMATTER
);
}
}
/**
* 是否在这个时间范围内
* @param nowTime
* @param startTime
* @param endTime
* @return
*/
public
static
boolean
isEffectiveDate
(
Date
nowTime
,
Date
startTime
,
Date
endTime
)
{
if
(
nowTime
.
getTime
()
==
startTime
.
getTime
()
||
nowTime
.
getTime
()
==
endTime
.
getTime
())
{
return
true
;
}
Calendar
date
=
Calendar
.
getInstance
();
date
.
setTime
(
nowTime
);
Calendar
begin
=
Calendar
.
getInstance
();
begin
.
setTime
(
startTime
);
Calendar
end
=
Calendar
.
getInstance
();
end
.
setTime
(
endTime
);
if
(
date
.
after
(
begin
)
&&
date
.
before
(
end
))
{
return
true
;
}
else
{
return
false
;
}
}
}
}
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