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
1f8665dd
Commit
1f8665dd
authored
Nov 06, 2019
by
libin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/holiday-price' into holiday-price
parents
e5d49641
031d7ffc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
25 deletions
+105
-25
VehicleItemDTO.java
...va/com/xxfc/platform/order/pojo/order/VehicleItemDTO.java
+58
-9
OrderItemBiz.java
...c/main/java/com/xxfc/platform/order/biz/OrderItemBiz.java
+1
-0
OrderRentVehicleService.java
.../xxfc/platform/order/service/OrderRentVehicleService.java
+30
-16
VMCalendarPriceCostDTO.java
...atform/vehicle/pojo/dto/order/VMCalendarPriceCostDTO.java
+16
-0
No files found.
xx-order/xx-order-api/src/main/java/com/xxfc/platform/order/pojo/order/VehicleItemDTO.java
View file @
1f8665dd
package
com
.
xxfc
.
platform
.
order
.
pojo
.
order
;
package
com
.
xxfc
.
platform
.
order
.
pojo
.
order
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
...
@@ -18,6 +20,8 @@ import java.util.List;
...
@@ -18,6 +20,8 @@ import java.util.List;
@Data
@Data
public
class
VehicleItemDTO
extends
OrderItem
{
public
class
VehicleItemDTO
extends
OrderItem
{
public
static
final
int
topNum
=
2
;
public
static
final
int
topNum
=
2
;
//已抵消天数
private
Integer
offsetNum
;
public
BigDecimal
calculateVehicleUnitPrice
(
BigDecimal
vehicleAmount
,
BigDecimal
metaVehicleAmount
,
Boolean
isSetRealAmount
)
{
public
BigDecimal
calculateVehicleUnitPrice
(
BigDecimal
vehicleAmount
,
BigDecimal
metaVehicleAmount
,
Boolean
isSetRealAmount
)
{
if
(
isSetRealAmount
)
{
if
(
isSetRealAmount
)
{
setRealAmount
(
vehicleAmount
);
setRealAmount
(
vehicleAmount
);
...
@@ -38,45 +42,51 @@ public class VehicleItemDTO extends OrderItem {
...
@@ -38,45 +42,51 @@ public class VehicleItemDTO extends OrderItem {
}
}
public
BigDecimal
getCutAmount
()
{
public
BigDecimal
getCutAmount
()
{
List
<
V
ehicleModelCalendarPrice
DTO
>
vmcpds
=
getVehicleDetail
();
List
<
V
MCalendarPriceCost
DTO
>
vmcpds
=
getVehicleDetail
();
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
return
super
.
getCutAmount
();
return
super
.
getCutAmount
();
}
}
BigDecimal
cutAmount
=
BigDecimal
.
ZERO
;
BigDecimal
cutAmount
=
BigDecimal
.
ZERO
;
for
(
int
i
=
0
;
i
<
getCutNum
();
i
++)
{
// for(int i = 0; i < getCutNum(); i++) {
cutAmount
=
cutAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
for
(
VMCalendarPriceCostDTO
vmcpd
:
vmcpds
)
{
cutAmount
=
cutAmount
.
add
(
vmcpd
.
getFreeAmount
());
}
}
return
cutAmount
;
return
cutAmount
;
}
}
public
List
<
V
ehicleModelCalendarPrice
DTO
>
getVehicleDetail
()
{
public
List
<
V
MCalendarPriceCost
DTO
>
getVehicleDetail
()
{
if
(
StrUtil
.
isBlank
(
getDetail
()))
{
if
(
StrUtil
.
isBlank
(
getDetail
()))
{
return
CollUtil
.
newArrayList
();
return
CollUtil
.
newArrayList
();
}
}
return
JSONUtil
.
toList
(
JSONUtil
.
parseArray
(
getDetail
()),
V
ehicleModelCalendarPrice
DTO
.
class
);
return
JSONUtil
.
toList
(
JSONUtil
.
parseArray
(
getDetail
()),
V
MCalendarPriceCost
DTO
.
class
);
}
}
public
BigDecimal
getBuyAmount
()
{
public
BigDecimal
getBuyAmount
()
{
List
<
V
ehicleModelCalendarPrice
DTO
>
vmcpds
=
getVehicleDetail
();
List
<
V
MCalendarPriceCost
DTO
>
vmcpds
=
getVehicleDetail
();
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
return
super
.
getBuyAmount
();
return
super
.
getBuyAmount
();
}
}
BigDecimal
buyAmount
=
BigDecimal
.
ZERO
;
BigDecimal
buyAmount
=
BigDecimal
.
ZERO
;
for
(
int
i
=
0
;
i
<
getBuyNum
();
i
++)
{
for
(
int
i
=
0
;
i
<
getBuyNum
();
i
++)
{
//for(VMCalendarPriceCostDTO vmcpd : vmcpds) {
buyAmount
=
buyAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
buyAmount
=
buyAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
}
}
return
buyAmount
;
return
buyAmount
;
}
}
public
BigDecimal
getTopAmount
(
Integer
useDays
)
{
public
BigDecimal
getTopAmount
(
Integer
useDays
)
{
List
<
V
ehicleModelCalendarPrice
DTO
>
vmcpds
=
getVehicleDetail
();
List
<
V
MCalendarPriceCost
DTO
>
vmcpds
=
getVehicleDetail
();
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
return
getUnitPrice
().
multiply
(
new
BigDecimal
(
topNum
+
""
));
return
getUnitPrice
().
multiply
(
new
BigDecimal
(
topNum
+
""
));
}
}
BigDecimal
topAmount
=
BigDecimal
.
ZERO
;
BigDecimal
topAmount
=
BigDecimal
.
ZERO
;
for
(
int
i
=
useDays
;
i
<
getTotalNum
();
i
++)
{
for
(
int
i
=
useDays
;
i
<
getTotalNum
();
i
++)
{
if
((
i
-
useDays
)
>=
topNum
)
{
break
;
}
else
{
topAmount
=
topAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
topAmount
=
topAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
}
}
}
//未用天数 小于 topNum
//未用天数 小于 topNum
if
(
getTotalNum
()
-
useDays
<
topNum
)
{
if
(
getTotalNum
()
-
useDays
<
topNum
)
{
...
@@ -91,7 +101,7 @@ public class VehicleItemDTO extends OrderItem {
...
@@ -91,7 +101,7 @@ public class VehicleItemDTO extends OrderItem {
}
}
public
BigDecimal
getFreeAmount
(
Integer
freeDays
)
{
public
BigDecimal
getFreeAmount
(
Integer
freeDays
)
{
List
<
V
ehicleModelCalendarPrice
DTO
>
vmcpds
=
getVehicleDetail
();
List
<
V
MCalendarPriceCost
DTO
>
vmcpds
=
getVehicleDetail
();
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
if
(
CollUtil
.
isEmpty
(
vmcpds
)){
return
getUnitPrice
().
multiply
(
new
BigDecimal
(
freeDays
+
""
));
return
getUnitPrice
().
multiply
(
new
BigDecimal
(
freeDays
+
""
));
}
}
...
@@ -101,4 +111,43 @@ public class VehicleItemDTO extends OrderItem {
...
@@ -101,4 +111,43 @@ public class VehicleItemDTO extends OrderItem {
}
}
return
freeAmount
;
return
freeAmount
;
}
}
// public Integer getActualNum() {
//
// }
public
void
initDetail
(
Integer
ableFreeDays
)
{
if
(
StrUtil
.
isNotBlank
(
getDetail
()))
{
List
<
VehicleModelCalendarPriceDTO
>
metaList
=
JSONUtil
.
toList
(
JSONUtil
.
parseArray
(
getDetail
()),
VehicleModelCalendarPriceDTO
.
class
);
//计算消费金额
List
<
VMCalendarPriceCostDTO
>
list
=
Convert
.
toList
(
VMCalendarPriceCostDTO
.
class
,
metaList
);
//循环价格列表 获得对应消耗的免费天数
//循环已标记的已使用免费天数
Integer
cycleNum
=
0
;
for
(
VMCalendarPriceCostDTO
dto
:
list
)
{
if
(
ableFreeDays
>
cycleNum
&&
cycleNum
+
dto
.
getFreeDays
()
>
ableFreeDays
)
{
//本次累加天数 大于 可用免费天数
setCutNum
(
ableFreeDays
);
Integer
up
=
(
ableFreeDays
-
cycleNum
);
Integer
down
=
dto
.
getFreeDays
();
//根据百分比计算消费价格
dto
.
setFreeAndConsumeAmount
(
dto
.
getPrice
(),
dto
.
getPrice
().
multiply
(
new
BigDecimal
(
up
+
""
).
divide
(
new
BigDecimal
(
down
+
""
),
2
,
RoundingMode
.
HALF_UP
))
.
setScale
(
2
,
RoundingMode
.
HALF_UP
));
}
else
if
(
ableFreeDays
>
cycleNum
){
//本次累加天数 小于等于 可用免费天数
setCutNum
(
getCutNum
()+
dto
.
getFreeDays
());
//直接设置价格
dto
.
setFreeAndConsumeAmount
(
dto
.
getPrice
(),
BigDecimal
.
ZERO
);
this
.
offsetNum
+=
1
;
}
else
{
//上次累加天数 大于 可用天数
//直接设置价格
dto
.
setFreeAndConsumeAmount
(
dto
.
getPrice
(),
BigDecimal
.
ZERO
);
}
cycleNum
+=
dto
.
getFreeDays
();
}
setDetail
(
JSONUtil
.
parseArray
(
list
).
toString
());
}
}
}
}
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/biz/OrderItemBiz.java
View file @
1f8665dd
...
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
...
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.xxfc.platform.order.contant.enumerate.ItemTypeEnum
;
import
com.xxfc.platform.order.contant.enumerate.ItemTypeEnum
;
import
com.xxfc.platform.order.pojo.order.VehicleItemDTO
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO
;
...
...
xx-order/xx-order-server/src/main/java/com/xxfc/platform/order/service/OrderRentVehicleService.java
View file @
1f8665dd
...
@@ -39,6 +39,7 @@ import com.xxfc.platform.vehicle.entity.VehicleModel;
...
@@ -39,6 +39,7 @@ import com.xxfc.platform.vehicle.entity.VehicleModel;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
com.xxfc.platform.vehicle.feign.VehicleFeign
;
import
com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO
;
import
com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.order.VMCalendarPriceCostDTO
;
import
com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo
;
import
com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -229,7 +230,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
...
@@ -229,7 +230,8 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
String
couponDesc
=
""
;
String
couponDesc
=
""
;
Integer
vehicleDayNum
=
0
;
Integer
vehicleDayNum
=
0
;
Integer
freeDayNum
=
0
;
Integer
freeDayNum
=
0
;
Integer
cutDayNum
=
0
;
//抵消的天数
Integer
offsetNum
=
0
;
//当前用户
//当前用户
AppUserDTO
dto
=
detail
.
getAppUserDTO
();
AppUserDTO
dto
=
detail
.
getAppUserDTO
();
...
@@ -260,21 +262,25 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
...
@@ -260,21 +262,25 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}});
}});
}
}
//循环价格列表 获得对应消耗的免费天数
// //循环价格列表 获得对应消耗的免费天数
for
(
VehicleModelCalendarPriceDTO
vmcpd
:
vmcpds
)
{
// for(VehicleModelCalendarPriceDTO vmcpd : vmcpds) {
//如果新的相加消耗天数 大于 拥有天数
// //如果新的相加消耗天数 大于 拥有天数
if
(
freeDayNum
+
vmcpd
.
getFreeDays
()
>
dto
.
getRentFreeDays
())
{
// if(freeDayNum+ vmcpd.getFreeDays() > dto.getRentFreeDays()) {
//freeDayNum = dto.getRentFreeDays();
// //freeDayNum = dto.getRentFreeDays();
break
;
// break;
}
else
{
// }else {
freeDayNum
+=
detail
.
getDayNum
();
// freeDayNum += detail.getDayNum();
cutDayNum
+=
1
;
// cutDayNum += 1;
}
// }
}
// }
vehicleOrderItem
.
setCutNum
(
cutDayNum
);
// vehicleOrderItem.setCutNum(cutDayNum);
vehicleDayNum
=
detail
.
getDayNum
()
-
cutDayNum
;
freeDayNum
=
vehicleOrderItem
.
getCutNum
();
offsetNum
=
vehicleOrderItem
.
getOffsetNum
();
vehicleOrderItem
.
initDetail
(
dto
.
getRentFreeDays
());
vehicleDayNum
=
detail
.
getDayNum
()
-
offsetNum
;
detail
.
getOrder
().
setHasMemberRight
(
SYS_TRUE
);
detail
.
getOrder
().
setHasMemberRight
(
SYS_TRUE
);
}
else
{
}
else
{
vehicleOrderItem
.
initDetail
(
0
);
vehicleDayNum
=
detail
.
getDayNum
();
vehicleDayNum
=
detail
.
getDayNum
();
}
}
...
@@ -309,13 +315,21 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
...
@@ -309,13 +315,21 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
// default:
// default:
// break;
// break;
// }
// }
//设置是否使用会员权益
for
(
VMCalendarPriceCostDTO
vmcpcd
:
vehicleOrderItem
.
getVehicleDetail
())
{
if
(!
vmcpcd
.
getNo_discount_price
().
equals
(
vmcpcd
.
getPrice
()))
{
detail
.
getOrder
().
setHasMemberRight
(
SYS_TRUE
);
break
;
}
}
detail
.
setRebate
(
dto
.
getDiscount
());
detail
.
setRebate
(
dto
.
getDiscount
());
// vehicleOrderItem.setUnitPrice(handleDiscountDTO.getModelAmount());
// vehicleOrderItem.setUnitPrice(handleDiscountDTO.getModelAmount());
}
}
//计算价格
//计算价格
if
(
vehicleDayNum
>
0
)
{
if
(
vehicleDayNum
>
0
)
{
for
(
int
i
=
cutDay
Num
;
i
<
vmcpds
.
size
();
i
++)
{
for
(
int
i
=
offset
Num
;
i
<
vmcpds
.
size
();
i
++)
{
vehicleAmount
=
vehicleAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
vehicleAmount
=
vehicleAmount
.
add
(
vmcpds
.
get
(
i
).
getPrice
());
metaVehicleAmount
=
metaVehicleAmount
.
add
(
vmcpds
.
get
(
i
).
getNo_discount_price
());
metaVehicleAmount
=
metaVehicleAmount
.
add
(
vmcpds
.
get
(
i
).
getNo_discount_price
());
}
}
...
@@ -392,7 +406,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
...
@@ -392,7 +406,7 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
rvp
.
setVehicleDayNum
(
vehicleDayNum
);
rvp
.
setVehicleDayNum
(
vehicleDayNum
);
rvp
.
setFreeDayNum
(
freeDayNum
);
rvp
.
setFreeDayNum
(
freeDayNum
);
rvp
.
setCutDayNum
(
cutDay
Num
);
rvp
.
setCutDayNum
(
offset
Num
);
rvp
.
setFreeAmount
(
vehicleOrderItem
.
getCutAmount
());
rvp
.
setFreeAmount
(
vehicleOrderItem
.
getCutAmount
());
rvp
.
setBuyVehicleAmount
(
vehicleOrderItem
.
getBuyAmount
());
rvp
.
setBuyVehicleAmount
(
vehicleOrderItem
.
getBuyAmount
());
rvp
.
setRealVehicleAmount
(
vehicleOrderItem
.
getRealAmount
());
rvp
.
setRealVehicleAmount
(
vehicleOrderItem
.
getRealAmount
());
...
...
xx-vehicle/xx-vehicle-api/src/main/java/com/xxfc/platform/vehicle/pojo/dto/order/VMCalendarPriceCostDTO.java
View file @
1f8665dd
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO
;
import
com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO
;
import
lombok.Data
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.Date
;
@Data
@Data
...
@@ -11,4 +12,19 @@ public class VMCalendarPriceCostDTO extends VehicleModelCalendarPriceDTO {
...
@@ -11,4 +12,19 @@ public class VMCalendarPriceCostDTO extends VehicleModelCalendarPriceDTO {
@JsonFormat
(
locale
=
"zh"
,
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
locale
=
"zh"
,
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd"
)
private
Date
date
;
private
Date
date
;
/**
* 消费金额
*/
private
BigDecimal
consumeAmount
=
BigDecimal
.
ZERO
;
/**
* 免费金额
*/
private
BigDecimal
freeAmount
=
BigDecimal
.
ZERO
;
public
void
setFreeAndConsumeAmount
(
BigDecimal
realAmount
,
BigDecimal
freeAmount
)
{
setFreeAmount
(
freeAmount
);
setConsumeAmount
(
realAmount
.
subtract
(
freeAmount
));
}
}
}
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