Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
fda2520d
Commit
fda2520d
authored
Jul 01, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改计算订单价格,增加用户钱包计算
parent
5f97e321
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
6 deletions
+74
-6
ComputedOrderPriceResponse.java
...ava/share/system/response/ComputedOrderPriceResponse.java
+16
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+58
-6
No files found.
share-system/src/main/java/share/system/response/ComputedOrderPriceResponse.java
View file @
fda2520d
...
@@ -36,5 +36,21 @@ public class ComputedOrderPriceResponse implements Serializable {
...
@@ -36,5 +36,21 @@ public class ComputedOrderPriceResponse implements Serializable {
@ApiModelProperty
(
value
=
"折扣比例"
)
@ApiModelProperty
(
value
=
"折扣比例"
)
private
BigDecimal
discountRatio
;
private
BigDecimal
discountRatio
;
//使用时长
@ApiModelProperty
(
value
=
"使用时长"
)
private
BigDecimal
duration
;
//剩余时长
@ApiModelProperty
(
value
=
"剩余时长"
)
private
BigDecimal
remainingDuration
;
//使用余额
@ApiModelProperty
(
value
=
"使用余额"
)
private
BigDecimal
balance
;
//剩余余额
@ApiModelProperty
(
value
=
"剩余余额"
)
private
BigDecimal
remainingBalance
;
}
}
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
fda2520d
...
@@ -149,6 +149,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -149,6 +149,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
@Autowired
private
ActivityService
activityService
;
private
ActivityService
activityService
;
@Autowired
private
ConsumerWalletService
consumerWalletService
;
private
final
static
Long
FIVE
=
5L
;
private
final
static
Long
FIVE
=
5L
;
...
@@ -1851,12 +1854,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1851,12 +1854,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private
ComputedOrderPriceResponse
computedPrice
(
OrderComputedPriceRequest
request
,
SConsumer
user
)
{
private
ComputedOrderPriceResponse
computedPrice
(
OrderComputedPriceRequest
request
,
SConsumer
user
)
{
BigDecimal
timeLong
=
DateUtils
.
differentHour
(
request
.
getPreStartDate
(),
request
.
getPreEndDate
());
// 计算各种价格
// 计算各种价格
ComputedOrderPriceResponse
priceResponse
=
new
ComputedOrderPriceResponse
();
ComputedOrderPriceResponse
priceResponse
=
new
ComputedOrderPriceResponse
();
Activity
activity
;
Activity
activity
;
ConsumerMember
consumerMember
=
null
;
ConsumerMember
consumerMember
=
null
;
ConsumerWallet
consumerWallet
=
null
;
LambdaQueryWrapper
<
Activity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
Activity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
if
(
ObjectUtil
.
isNotEmpty
(
user
))
{
if
(
ObjectUtil
.
isNotEmpty
(
user
))
{
consumerWallet
=
consumerWalletService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerWallet
>().
eq
(
ConsumerWallet:
:
getConsumerId
,
user
.
getId
()));
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
user
.
getId
()));
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
user
.
getId
()));
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
queryWrapper
.
eq
(
Activity:
:
getIsOpen
,
YesNoEnum
.
yes
.
getIndex
());
queryWrapper
.
eq
(
Activity:
:
getIsOpen
,
YesNoEnum
.
yes
.
getIndex
());
...
@@ -1877,6 +1883,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1877,6 +1883,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity
=
activityService
.
getOne
(
queryWrapper
);
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
}
}
totalFee
=
getBigDecimal
(
consumerWallet
,
timeLong
,
priceResponse
,
totalFee
,
room
);
}
else
{
}
else
{
SPack
byId
=
packService
.
getById
(
roomLabel
.
getPackId
());
SPack
byId
=
packService
.
getById
(
roomLabel
.
getPackId
());
if
(!
ObjectUtils
.
isEmpty
(
byId
)
&&
byId
.
getIsOpen
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
if
(!
ObjectUtils
.
isEmpty
(
byId
)
&&
byId
.
getIsOpen
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
...
@@ -1887,6 +1894,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1887,6 +1894,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity
=
activityService
.
getOne
(
queryWrapper
);
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
}
}
totalFee
=
getBigDecimal
(
consumerWallet
,
timeLong
,
priceResponse
,
totalFee
,
byId
);
}
else
{
}
else
{
payPrice
=
totalPrice
;
payPrice
=
totalPrice
;
request
.
setBuyType
(
BuyTypeEnum
.
TIME
.
getCode
());
request
.
setBuyType
(
BuyTypeEnum
.
TIME
.
getCode
());
...
@@ -1895,9 +1903,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1895,9 +1903,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity
=
activityService
.
getOne
(
queryWrapper
);
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
}
}
totalFee
=
getBigDecimal
(
consumerWallet
,
timeLong
,
priceResponse
,
totalFee
,
room
);
}
}
}
}
}
else
if
(!
ObjectUtils
.
isEmpty
(
request
.
getPackId
()))
{
}
else
if
(!
ObjectUtils
.
isEmpty
(
request
.
getPackId
()))
{
SPack
byId
=
packService
.
getById
(
request
.
getPackId
());
payPrice
=
computeTotalPrice
(
request
.
getPackId
(),
totalPrice
);
payPrice
=
computeTotalPrice
(
request
.
getPackId
(),
totalPrice
);
request
.
setBuyType
(
BuyTypeEnum
.
PACK
.
getCode
());
request
.
setBuyType
(
BuyTypeEnum
.
PACK
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
...
@@ -1905,9 +1915,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1905,9 +1915,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
activity
=
activityService
.
getOne
(
queryWrapper
);
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
}
}
totalFee
=
getBigDecimal
(
consumerWallet
,
timeLong
,
priceResponse
,
totalFee
,
byId
);
}
}
priceResponse
.
setTotalFee
(
payPrice
);
priceResponse
.
setTotalFee
(
payPrice
);
if
(
totalFee
.
compareTo
(
new
BigDecimal
(
0
))
==
0
)
{
if
(
ObjectUtil
.
isEmpty
(
consumerWallet
)
&&
totalFee
.
compareTo
(
new
BigDecimal
(
0
))
==
0
)
{
priceResponse
.
setPayFee
(
payPrice
);
priceResponse
.
setPayFee
(
payPrice
);
}
else
{
}
else
{
priceResponse
.
setPayFee
(
totalFee
);
priceResponse
.
setPayFee
(
totalFee
);
...
@@ -1915,11 +1926,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1915,11 +1926,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 计算优惠券金额
// 计算优惠券金额
if
(
ObjectUtil
.
isNull
(
request
.
getCouponId
())
||
request
.
getCouponId
()
<=
0
)
{
if
(
ObjectUtil
.
isNull
(
request
.
getCouponId
())
||
request
.
getCouponId
()
<=
0
)
{
priceResponse
.
setCouponFee
(
BigDecimal
.
ZERO
);
priceResponse
.
setCouponFee
(
BigDecimal
.
ZERO
);
if
(
totalFee
.
compareTo
(
new
BigDecimal
(
0
))
==
0
)
{
priceResponse
.
setPayFee
(
payPrice
);
}
else
{
priceResponse
.
setPayFee
(
totalFee
);
}
priceResponse
.
setDiscountFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
priceResponse
.
setDiscountFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
priceResponse
.
setDiscountRatio
(
priceResponse
.
getDiscountFee
().
divide
(
priceResponse
.
getTotalFee
()).
multiply
(
new
BigDecimal
(
100
)));
priceResponse
.
setDiscountRatio
(
priceResponse
.
getDiscountFee
().
divide
(
priceResponse
.
getTotalFee
()).
multiply
(
new
BigDecimal
(
100
)));
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
...
@@ -1945,6 +1951,52 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1945,6 +1951,52 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return
priceResponse
;
return
priceResponse
;
}
}
private
BigDecimal
getBigDecimal
(
ConsumerWallet
consumerWallet
,
BigDecimal
timeLong
,
ComputedOrderPriceResponse
priceResponse
,
BigDecimal
totalFee
,
SRoom
room
)
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
>=
0
)
{
priceResponse
.
setDuration
(
timeLong
);
priceResponse
.
setRemainingDuration
(
consumerWallet
.
getRemainingDuration
().
subtract
(
timeLong
));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
<
0
)
{
priceResponse
.
setDuration
(
consumerWallet
.
getRemainingDuration
());
priceResponse
.
setRemainingDuration
(
new
BigDecimal
(
0
));
BigDecimal
remainingBalance
=
timeLong
.
subtract
(
consumerWallet
.
getRemainingDuration
()).
multiply
(
room
.
getPrice
());
if
(
consumerWallet
.
getBalance
().
compareTo
(
remainingBalance
)
>=
0
)
{
priceResponse
.
setBalance
(
remainingBalance
);
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
remainingBalance
));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
remainingBalance
)
<
0
)
{
priceResponse
.
setBalance
(
remainingBalance
.
subtract
(
consumerWallet
.
getBalance
()));
priceResponse
.
setTotalFee
(
remainingBalance
.
subtract
(
consumerWallet
.
getBalance
()));
priceResponse
.
setPayFee
(
remainingBalance
.
subtract
(
consumerWallet
.
getBalance
()));
totalFee
=
remainingBalance
.
subtract
(
consumerWallet
.
getBalance
());
}
}
}
return
totalFee
;
}
private
BigDecimal
getBigDecimal
(
ConsumerWallet
consumerWallet
,
BigDecimal
timeLong
,
ComputedOrderPriceResponse
priceResponse
,
BigDecimal
totalFee
,
SPack
byId
)
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
>=
0
)
{
priceResponse
.
setDuration
(
timeLong
);
priceResponse
.
setRemainingDuration
(
consumerWallet
.
getRemainingDuration
().
subtract
(
timeLong
));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
<
0
)
{
if
(
consumerWallet
.
getBalance
().
compareTo
(
byId
.
getPrice
())
>=
0
)
{
priceResponse
.
setBalance
(
byId
.
getPrice
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
byId
.
getPrice
()));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
byId
.
getPrice
())
<
0
)
{
priceResponse
.
setBalance
(
consumerWallet
.
getBalance
());
priceResponse
.
setRemainingBalance
(
new
BigDecimal
(
0
));
totalFee
=
byId
.
getPrice
().
subtract
(
consumerWallet
.
getBalance
());
}
}
}
return
totalFee
;
}
private
BigDecimal
getBigDecimal
(
OrderComputedPriceRequest
request
,
Activity
activity
,
BigDecimal
payPrice
,
SConsumer
user
)
{
private
BigDecimal
getBigDecimal
(
OrderComputedPriceRequest
request
,
Activity
activity
,
BigDecimal
payPrice
,
SConsumer
user
)
{
if
(
ObjectUtil
.
isNotEmpty
(
activity
)
&&
ObjectUtil
.
isNotEmpty
(
user
))
{
if
(
ObjectUtil
.
isNotEmpty
(
activity
)
&&
ObjectUtil
.
isNotEmpty
(
user
))
{
CronParser
cronParser
=
new
CronParser
(
CronDefinitionBuilder
.
instanceDefinitionFor
(
CronType
.
QUARTZ
));
CronParser
cronParser
=
new
CronParser
(
CronDefinitionBuilder
.
instanceDefinitionFor
(
CronType
.
QUARTZ
));
...
...
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