Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
44e035a6
Commit
44e035a6
authored
Oct 22, 2019
by
libin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日历价格
parent
8b877207
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
26 deletions
+38
-26
VehicleModelCalendarPriceBiz.java
...fc/platform/vehicle/biz/VehicleModelCalendarPriceBiz.java
+38
-26
No files found.
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleModelCalendarPriceBiz.java
View file @
44e035a6
...
...
@@ -80,7 +80,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
List
<
Date
>
dateList
=
vehicleModelCalendarPrices
.
stream
().
peek
(
x
->
{
VehicleModelCalendarPrice
calendarPrice
=
new
VehicleModelCalendarPrice
();
BeanUtils
.
copyProperties
(
x
,
calendarPrice
);
Date
date
=
Date
.
from
(
LocalDate
.
parse
(
x
.
getDate
()).
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
(
));
Date
date
=
localDateToDate
(
LocalDate
.
parse
(
x
.
getDate
()
));
calendarPrice
.
setVehicleModelDay
(
date
);
calendarPrice
.
setCrtTime
(
new
Date
());
calendarPrice
.
setCrtUserId
(
userId
);
...
...
@@ -166,10 +166,10 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
List
<
VehicleModelCalendarPriceSaveDTO
>
vehicleModelCalendarPriceSaveDTOS
=
new
ArrayList
<>();
Example
example
=
new
Example
(
VehicleModelCalendarPrice
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
LocalDate
startLocalDate
=
currentDate
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
(
).
withDayOfMonth
(
1
);
Date
startDate
=
Date
.
from
(
startLocalDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()
);
LocalDate
startLocalDate
=
dateToLocalDate
(
currentDate
).
withDayOfMonth
(
1
);
Date
startDate
=
localDateToDate
(
startLocalDate
);
LocalDate
endLocalDate
=
startLocalDate
.
with
(
TemporalAdjusters
.
lastDayOfMonth
());
Date
endDate
=
Date
.
from
(
endLocalDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()
);
Date
endDate
=
localDateToDate
(
endLocalDate
);
criteria
.
andBetween
(
"vehicleModelDay"
,
startDate
,
endDate
);
criteria
.
andEqualTo
(
"isDel"
,
0
);
List
<
VehicleModelCalendarPrice
>
vehicleModelCalendarPriceList
=
mapper
.
selectByExample
(
example
);
...
...
@@ -224,7 +224,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
transformStartDateAndEndDate
(
startReference
,
endReference
);
List
<
VehicleModelCalendarPriceDTO
>
vehicleModelCalendarPrice
=
findVehicleModelCalendarPrice
(
startReference
.
get
(),
endReference
.
get
(),
vehicleModelId
,
userId
);
for
(
VehicleModelCalendarPriceDTO
vehicleModelCalendarPriceDTO
:
vehicleModelCalendarPrice
)
{
LocalDate
current_date
=
vehicleModelCalendarPriceDTO
.
getDate
().
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
(
);
LocalDate
current_date
=
dateToLocalDate
(
vehicleModelCalendarPriceDTO
.
getDate
()
);
boolean
isSelect
=
(
current_date
.
isAfter
(
startLocalDate
)
&&
current_date
.
isBefore
(
endLocalDate
))
||
current_date
.
isEqual
(
startLocalDate
)
||
current_date
.
isEqual
(
endLocalDate
);
vehicleModelCalendarPriceDTO
.
setIsSelect
(
isSelect
?
true
:
false
);
}
...
...
@@ -285,10 +285,11 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
switch
(
vehicleModelCalendarPrice
.
getType
())
{
case
VehicleModelPriceType
.
MULTIPLE
:
no_discount_price
=
vehicle_price
.
multiply
(
new
BigDecimal
(
vehicleModelCalendarPrice
.
getMultiple
().
doubleValue
()));
vehicle_price
=
no_discount_price
.
multiply
(
new
BigDecimal
(
discount
/
100.0
));
vehicle_price
=
no_discount_price
.
multiply
(
new
BigDecimal
(
discount
/
100.0
0
));
break
;
case
VehicleModelPriceType
.
ABS
:
vehicle_price
=
vehicleModelCalendarPrice
.
getPrice
().
multiply
(
new
BigDecimal
(
discount
/
100.00
));
no_discount_price
=
vehicleModelCalendarPrice
.
getPrice
();
vehicle_price
=
no_discount_price
.
multiply
(
new
BigDecimal
(
discount
/
100.00
));
break
;
case
VehicleModelPriceType
.
MEMBER
:
memberLevel
=
vehicleModelCalendarPrice
.
getLevel
()
>
memberLevel
?
vehicleModelCalendarPrice
.
getLevel
()
:
memberLevel
;
...
...
@@ -308,7 +309,7 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
free_days
=
(
Integer
)
price_freeDays_map
.
get
(
DAYS_VAL
);
}
vehicleModelCalendarPriceDTO
.
setNo_discount_price
(
no_discount_price
);
vehicleModelCalendarPriceDTO
.
setPrice
(
vehicle_price
.
setScale
(
2
,
RoundingMode
.
DOWN
));
vehicleModelCalendarPriceDTO
.
setPrice
(
vehicle_price
.
setScale
(
2
,
RoundingMode
.
HALF_UP
));
vehicleModelCalendarPriceDTO
.
setFreeDays
(
free_days
);
final_startLocalDate
=
final_startLocalDate
.
plusDays
(
1
);
vehicleModelCalendarPriceVos
.
add
(
vehicleModelCalendarPriceDTO
);
...
...
@@ -377,48 +378,59 @@ public class VehicleModelCalendarPriceBiz extends BaseBiz<VehicleModelCalendarPr
LocalDate
now
=
LocalDate
.
now
();
LocalDate
endLocalDate
=
now
.
with
(
TemporalAdjusters
.
lastDayOfMonth
());
LocalDate
startLocalDate
=
now
.
withDayOfMonth
(
1
);
startDate
=
Date
.
from
(
startLocalDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()
);
endDate
=
Date
.
from
(
endLocalDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()
);
startDate
=
localDateToDate
(
startLocalDate
);
endDate
=
localDateToDate
(
endLocalDate
);
}
else
{
int
days
=
0
;
/****************************************开始时间处理******************************************************/
LocalDate
startLocalDate
=
LocalDate
.
from
(
startDate
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
());
int
start_dayOfMonth
=
startLocalDate
.
getDayOfMonth
();
LocalDate
startLocalDate
=
dateToLocalDate
(
startDate
);
int
start_week
=
startLocalDate
.
getDayOfWeek
().
getValue
();
if
(
START_OF_WEEK
<
start_week
&&
start_week
<
END_OF_WEEK
)
{
start_dayOfMonth
=
start_dayOfMonth
-
(
start_week
-
START_OF_WEEK
)
;
days
=
start_week
-
START_OF_WEEK
;
}
else
{
if
(
END_OF_WEEK
==
start_week
)
{
start_dayOfMonth
=
start_dayOfMonth
-
END_OF_WEEK
+
1
;
days
=
END_OF_WEEK
-
1
;
}
}
start_dayOfMonth
=
start_dayOfMonth
>
0
?
start_dayOfMonth
:
1
;
LocalDate
start_startLocalDate
=
startLocalDate
.
withDayOfMonth
(
start_dayOfMonth
);
LocalDate
start_startLocalDate
=
startLocalDate
.
minusDays
(
days
);
/****************************************结束时间处理******************************************************/
LocalDate
endLocalDate
=
LocalDate
.
from
(
endDate
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
())
;
int
end_dayOfMonth
=
endLocalDate
.
getDayOfMonth
(
);
days
=
0
;
LocalDate
endLocalDate
=
dateToLocalDate
(
endDate
);
int
end_week
=
endLocalDate
.
getDayOfWeek
().
getValue
();
int
last_day
=
endLocalDate
.
with
(
TemporalAdjusters
.
lastDayOfMonth
()).
getDayOfMonth
();
if
(
START_OF_WEEK
<
end_week
&&
end_week
<
END_OF_WEEK
)
{
end_dayOfMonth
=
end_dayOfMonth
+
(
END_OF_WEEK
-
end_week
)
;
days
=
END_OF_WEEK
-
end_week
;
}
else
{
if
(
START_OF_WEEK
==
end_week
)
{
end_dayOfMonth
=
end_dayOfMonth
+
END_OF_WEEK
-
1
;
days
=
END_OF_WEEK
-
1
;
}
}
end_dayOfMonth
=
end_dayOfMonth
>
last_day
?
last_day
:
end_dayOfMonth
;
LocalDate
end_endLocalDate
=
endLocalDate
.
withDayOfMonth
(
end_dayOfMonth
);
LocalDate
end_endLocalDate
=
endLocalDate
.
plusDays
(
days
);
/****************************************时间转换******************************************************/
startDate
=
Date
.
from
(
start_startLocalDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()
);
endDate
=
Date
.
from
(
end_endLocalDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()
);
startDate
=
localDateToDate
(
start_startLocalDate
);
endDate
=
localDateToDate
(
end_endLocalDate
);
}
startDatee
.
set
(
startDate
);
endDatee
.
set
(
endDate
);
}
private
static
LocalDate
dateToLocalDate
(
Date
date
){
return
LocalDate
.
from
(
date
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
());
}
private
static
Date
localDateToDate
(
LocalDate
localDate
){
return
Date
.
from
(
localDate
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
public
static
void
main
(
String
[]
args
)
{
AtomicReference
<
Date
>
start
=
new
AtomicReference
<>(
Date
.
from
(
LocalDate
.
parse
(
"2019-10-03"
).
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()));
AtomicReference
<
Date
>
end
=
new
AtomicReference
<>(
Date
.
from
(
LocalDate
.
parse
(
"2019-10-29"
).
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
()));
transformStartDateAndEndDate
(
start
,
end
);
System
.
out
.
println
(
start
.
get
());
System
.
out
.
println
(
end
.
get
());
}
/**
...
...
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