Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
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
huluobin
gogirl-miniapp-backend
Commits
1009a97e
Commit
1009a97e
authored
Jul 10, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
75467fae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
136 deletions
+136
-136
MarketServiceImpl.java
...irl/application/market/coupon/impl/MarketServiceImpl.java
+136
-136
No files found.
src/main/java/com/gogirl/application/market/coupon/impl/MarketServiceImpl.java
View file @
1009a97e
...
...
@@ -1050,6 +1050,7 @@ public class MarketServiceImpl implements MarketService {
//查询订单聚合
OrderManage
orderManage
=
orderManageMapper
.
selectById
(
orderId
);
List
<
OrderServe
>
orderServeList
=
orderServeMapper
.
selectList
(
new
LambdaQueryWrapper
<
OrderServe
>().
eq
(
OrderServe:
:
getOrderId
,
orderId
));
orderManage
.
setListOrderServer
(
orderServeList
);
...
...
@@ -1080,11 +1081,144 @@ public class MarketServiceImpl implements MarketService {
}
});
//2、次卡
if
(
ListUtil
.
isNotEmpty
(
timesCardUsedRecordList
))
{
//次卡使用记录
timesCardUsedRecordList
.
forEach
(
timesCardUsedRecord
->
timesCardUsedRecord
.
setStatus
(
TimesCardUsedRecord
.
STATUS_CHOSE
));
timesCardUsedRecordList
.
stream
()
.
sorted
(
Comparator
.
comparing
(
TimesCardUsedRecord:
:
getDiscountAmount
))
.
forEach
(
timesCardUsedRecord
->
{
timesCardOrderServeDetailMapper
.
delete
(
new
LambdaQueryWrapper
<
TimesCardOrderServeDetail
>().
eq
(
TimesCardOrderServeDetail:
:
getOrderId
,
orderId
));
//次卡能用的服务id
List
<
Integer
>
serveIds
=
timesCardCustomerRelevanceMapper
.
queryTimesCardServeIds
(
timesCardUsedRecord
.
getCardTypeId
());
//抵扣的服务为 作用范围内支付金额最高的服务
OrderServe
orderServe
=
this
.
queryMaxPayPrice
(
orderManage
,
serveIds
);
if
(
orderServe
!=
null
)
{
BigDecimal
actualDiscountAmount
=
orderServe
.
getPayPrice
().
min
(
timesCardUsedRecord
.
getDiscountAmount
());
//更新次卡记录 已使用
timesCardUsedRecord
.
setStatus
(
TimesCardUsedRecord
.
STATUS_USED
);
//次卡对应订单服务的美甲师
timesCardUsedRecord
.
setTechnicianName
(
orderServe
.
getTechnicianName
());
//次卡店铺名称
timesCardUsedRecord
.
setDepartmentName
(
orderManage
.
getDepartmentName
());
//次卡店铺id
timesCardUsedRecord
.
setDepartmentId
(
orderManage
.
getDepartmentId
());
//次卡折扣的
timesCardUsedRecord
.
setServeName
(
orderServe
.
getServeName
());
//次卡作用的服务id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getServeId
());
timesCardUsedRecord
.
setOrderId
(
orderId
);
timesCardUsedRecord
.
setActualDiscountAmount
(
actualDiscountAmount
);
timesCardUsedRecordService
.
updateById
(
timesCardUsedRecord
);
//在主服务上折扣的钱
TimesCardOrderServeDetail
timesCardOrderServeDetail
=
new
TimesCardOrderServeDetail
();
timesCardOrderServeDetail
.
setDiscountAmount
(
actualDiscountAmount
);
timesCardOrderServeDetail
.
setOrderServeId
(
orderServe
.
getId
());
timesCardOrderServeDetail
.
setOrderId
(
orderId
);
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getOrderServeId
());
//业绩
timesCardOrderServeDetail
.
setAchievement
(
timesCardUsedRecord
.
getPayAmount
());
timesCardOrderServeDetailMapper
.
insert
(
timesCardOrderServeDetail
);
//订单折扣金额更新
orderServe
.
setBindTimesCard
(
1
);
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
//业绩
orderServe
.
setAchievement
(
orderServe
.
getAchievement
().
subtract
(
actualDiscountAmount
).
add
(
timesCardUsedRecord
.
getPayAmount
()));
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
}
else
{
throw
new
RRException
(
"次卡冲突"
);
}
});
}
//卡券之前删除订单服务和卡券关联
couponOrderRelevanceService
.
remove
(
new
LambdaQueryWrapper
<
CouponOrderRelevance
>()
.
eq
(
CouponOrderRelevance:
:
getOrderId
,
orderId
));
couponOrderRelevanceService
.
remove
(
new
LambdaQueryWrapper
<
CouponOrderRelevance
>().
eq
(
CouponOrderRelevance:
:
getOrderId
,
orderId
));
//3、外部券
if
(
ListUtil
.
isNotEmpty
(
outerCouponCustomerRelevanceServiceList
))
{
//删除之前的外部券抵扣情况记录
couponOrderRelevanceService
.
remove
(
new
LambdaQueryWrapper
<
CouponOrderRelevance
>()
.
eq
(
CouponOrderRelevance:
:
getOrderId
,
orderId
)
.
in
(
CouponOrderRelevance:
:
getCouponCustomerRelevanceId
,
outerCouponCustomerRelevanceServiceList
.
stream
().
map
(
CouponCustomerRelevance:
:
getId
).
collect
(
Collectors
.
toList
())));
outerCouponCustomerRelevanceServiceList
.
stream
()
.
sorted
(
Comparator
.
comparing
(
CouponCustomerRelevance:
:
getDiscountAmount
).
reversed
())
.
forEach
(
couponCustomerRelevance
->
{
//外部券能用的服务id
List
<
Integer
>
serveIds
=
couponCustomerRelevanceMapper
.
queryCouponCustomerServeRelevance
(
couponCustomerRelevance
.
getCouponId
());
//抵扣的服务为 作用范围内支付金额最高的服务
OrderServe
orderServe
=
this
.
queryMaxPayPrice
(
orderManage
,
serveIds
);
if
(
orderServe
!=
null
)
{
BigDecimal
discountAmount
=
couponCustomerRelevance
.
getDiscountAmount
();
if
(
couponCustomerRelevance
.
getType
()
==
5
)
{
discountAmount
=
orderServe
.
getPrice
().
multiply
(
BigDecimal
.
ONE
.
subtract
(
couponCustomerRelevance
.
getDiscountPercent
()));
}
BigDecimal
actualDiscountAmount
=
orderServe
.
getPayPrice
().
min
(
discountAmount
);
//新增外部券抵扣情况记录
CouponOrderRelevance
couponOrderRelevance
=
CouponOrderRelevance
.
builder
()
.
couponCustomerRelevanceId
(
couponCustomerRelevance
.
getId
())
.
couponId
(
couponCustomerRelevance
.
getCouponId
())
.
couponName
(
couponCustomerRelevance
.
getCouponName
())
.
orderServeId
(
orderServe
.
getId
())
.
serveName
(
orderServe
.
getServeName
())
.
orderId
(
orderManage
.
getId
())
//支付金额
.
payForOrderServe
(
couponCustomerRelevance
.
getPayAmount
())
//折扣金额
.
discountAmount
(
actualDiscountAmount
)
.
createTime
(
new
Date
())
.
confirmTime
(
new
Date
())
.
message
(
orderServe
.
getServeName
())
.
customerId
(
orderManage
.
getOrderUser
())
.
status
(
2
)
.
build
();
//如果计算业绩
if
(
couponCustomerRelevance
.
getIsCalcAchievement
()
==
1
)
{
couponOrderRelevance
.
setAchievement
(
couponCustomerRelevance
.
getPayAmount
());
}
else
{
couponOrderRelevance
.
setAchievement
(
couponOrderRelevance
.
getDiscountAmount
());
}
//业绩
orderServe
.
setAchievement
(
orderServe
.
getAchievement
().
subtract
(
actualDiscountAmount
).
add
(
couponCustomerRelevance
.
getPayAmount
()));
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
orderServe
.
setBindOuterCoupon
(
1
);
couponOrderRelevanceService
.
save
(
couponOrderRelevance
);
}
else
{
throw
new
RRException
(
"%s与其他卡券冲突"
,
couponCustomerRelevance
.
getCouponName
());
}
});
}
//4、内部券
if
(
ListUtil
.
isNotEmpty
(
innerCouponCustomerRelevanceServiceList
))
{
...
...
@@ -1218,143 +1352,9 @@ public class MarketServiceImpl implements MarketService {
}
//2、次卡
if
(
ListUtil
.
isNotEmpty
(
timesCardUsedRecordList
))
{
//次卡使用记录
timesCardUsedRecordList
.
forEach
(
timesCardUsedRecord
->
timesCardUsedRecord
.
setStatus
(
TimesCardUsedRecord
.
STATUS_CHOSE
));
timesCardUsedRecordList
.
stream
()
.
sorted
(
Comparator
.
comparing
(
TimesCardUsedRecord:
:
getDiscountAmount
))
.
forEach
(
timesCardUsedRecord
->
{
timesCardOrderServeDetailMapper
.
delete
(
new
LambdaQueryWrapper
<
TimesCardOrderServeDetail
>().
eq
(
TimesCardOrderServeDetail:
:
getOrderId
,
orderId
));
//次卡能用的服务id
List
<
Integer
>
serveIds
=
timesCardCustomerRelevanceMapper
.
queryTimesCardServeIds
(
timesCardUsedRecord
.
getCardTypeId
());
//抵扣的服务为 作用范围内支付金额最高的服务
OrderServe
orderServe
=
this
.
queryMaxPayPrice
(
orderManage
,
serveIds
);
if
(
orderServe
!=
null
)
{
BigDecimal
actualDiscountAmount
=
orderServe
.
getPayPrice
().
min
(
timesCardUsedRecord
.
getDiscountAmount
());
//更新次卡记录 已使用
timesCardUsedRecord
.
setStatus
(
TimesCardUsedRecord
.
STATUS_USED
);
//次卡对应订单服务的美甲师
timesCardUsedRecord
.
setTechnicianName
(
orderServe
.
getTechnicianName
());
//次卡店铺名称
timesCardUsedRecord
.
setDepartmentName
(
orderManage
.
getDepartmentName
());
//次卡店铺id
timesCardUsedRecord
.
setDepartmentId
(
orderManage
.
getDepartmentId
());
//次卡折扣的
timesCardUsedRecord
.
setServeName
(
orderServe
.
getServeName
());
//次卡作用的服务id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getServeId
());
timesCardUsedRecord
.
setOrderId
(
orderId
);
timesCardUsedRecord
.
setActualDiscountAmount
(
actualDiscountAmount
);
timesCardUsedRecordService
.
updateById
(
timesCardUsedRecord
);
//在主服务上折扣的钱
TimesCardOrderServeDetail
timesCardOrderServeDetail
=
new
TimesCardOrderServeDetail
();
timesCardOrderServeDetail
.
setDiscountAmount
(
actualDiscountAmount
);
timesCardOrderServeDetail
.
setOrderServeId
(
orderServe
.
getId
());
timesCardOrderServeDetail
.
setOrderId
(
orderId
);
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getOrderServeId
());
//业绩
timesCardOrderServeDetail
.
setAchievement
(
timesCardUsedRecord
.
getPayAmount
());
timesCardOrderServeDetailMapper
.
insert
(
timesCardOrderServeDetail
);
//订单折扣金额更新
orderServe
.
setBindTimesCard
(
1
);
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
//业绩
orderServe
.
setAchievement
(
orderServe
.
getAchievement
().
subtract
(
actualDiscountAmount
).
add
(
timesCardUsedRecord
.
getPayAmount
()));
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
// //更新使用次数
// TimesCardCustomerRelevance timesCardCustomerRelevance = timesCardCustomerRelevanceService.getById(timesCardUsedRecord.getCardRelevanceCustomerId());
// timesCardCustomerRelevance.setUsedTimes(timesCardCustomerRelevance.getUsedTimes() + 1);
// if (timesCardCustomerRelevance.getUsedTimes().equals(timesCardCustomerRelevance.getSumTimes())) {
// //次数用完
// timesCardCustomerRelevance.setStatus(2);
// }
// timesCardCustomerRelevanceService.updateById(timesCardCustomerRelevance);
}
else
{
throw
new
RRException
(
"次卡冲突"
);
}
});
}
}
//3、外部券
if
(
ListUtil
.
isNotEmpty
(
outerCouponCustomerRelevanceServiceList
))
{
//删除之前的外部券抵扣情况记录
couponOrderRelevanceService
.
remove
(
new
LambdaQueryWrapper
<
CouponOrderRelevance
>()
.
eq
(
CouponOrderRelevance:
:
getOrderId
,
orderId
)
.
in
(
CouponOrderRelevance:
:
getCouponCustomerRelevanceId
,
outerCouponCustomerRelevanceServiceList
.
stream
().
map
(
CouponCustomerRelevance:
:
getId
).
collect
(
Collectors
.
toList
())));
outerCouponCustomerRelevanceServiceList
.
stream
()
.
sorted
(
Comparator
.
comparing
(
CouponCustomerRelevance:
:
getDiscountAmount
).
reversed
())
.
forEach
(
couponCustomerRelevance
->
{
//外部券能用的服务id
List
<
Integer
>
serveIds
=
couponCustomerRelevanceMapper
.
queryCouponCustomerServeRelevance
(
couponCustomerRelevance
.
getCouponId
());
//抵扣的服务为 作用范围内支付金额最高的服务
OrderServe
orderServe
=
this
.
queryMaxPayPrice
(
orderManage
,
serveIds
);
if
(
orderServe
!=
null
)
{
BigDecimal
discountAmount
=
couponCustomerRelevance
.
getDiscountAmount
();
if
(
couponCustomerRelevance
.
getType
()
==
5
)
{
discountAmount
=
orderServe
.
getPrice
().
multiply
(
BigDecimal
.
ONE
.
subtract
(
couponCustomerRelevance
.
getDiscountPercent
()));
}
BigDecimal
actualDiscountAmount
=
orderServe
.
getPayPrice
().
min
(
discountAmount
);
//新增外部券抵扣情况记录
CouponOrderRelevance
couponOrderRelevance
=
CouponOrderRelevance
.
builder
()
.
couponCustomerRelevanceId
(
couponCustomerRelevance
.
getId
())
.
couponId
(
couponCustomerRelevance
.
getCouponId
())
.
couponName
(
couponCustomerRelevance
.
getCouponName
())
.
orderServeId
(
orderServe
.
getId
())
.
serveName
(
orderServe
.
getServeName
())
.
orderId
(
orderManage
.
getId
())
//支付金额
.
payForOrderServe
(
couponCustomerRelevance
.
getPayAmount
())
//折扣金额
.
discountAmount
(
actualDiscountAmount
)
.
createTime
(
new
Date
())
.
confirmTime
(
new
Date
())
.
message
(
orderServe
.
getServeName
())
.
customerId
(
orderManage
.
getOrderUser
())
.
status
(
2
)
.
build
();
//如果计算业绩
if
(
couponCustomerRelevance
.
getIsCalcAchievement
()
==
1
)
{
couponOrderRelevance
.
setAchievement
(
couponCustomerRelevance
.
getPayAmount
());
}
else
{
couponOrderRelevance
.
setAchievement
(
couponOrderRelevance
.
getDiscountAmount
());
}
//业绩
orderServe
.
setAchievement
(
orderServe
.
getAchievement
().
subtract
(
actualDiscountAmount
).
add
(
couponCustomerRelevance
.
getPayAmount
()));
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
orderServe
.
setBindOuterCoupon
(
1
);
couponOrderRelevanceService
.
save
(
couponOrderRelevance
);
}
else
{
throw
new
RRException
(
"%s与其他卡券冲突"
,
couponCustomerRelevance
.
getCouponName
());
}
});
}
orderManageMapper
.
updateById
(
orderManage
);
orderServeService
.
updateBatchById
(
orderServeList
);
}
...
...
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