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
c042d5b2
Commit
c042d5b2
authored
Sep 22, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
次卡id的set
parent
1ce7c5ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
51 deletions
+89
-51
MarketServiceImpl.java
...irl/application/market/coupon/impl/MarketServiceImpl.java
+19
-51
OrderManageServiceImplTest.java
...lication/order/serve/impl/OrderManageServiceImplTest.java
+70
-0
No files found.
src/main/java/com/gogirl/application/market/coupon/impl/MarketServiceImpl.java
View file @
c042d5b2
...
...
@@ -434,23 +434,24 @@ public class MarketServiceImpl implements MarketService {
timesCardUsedRecord
.
setDepartmentId
(
orderManage
.
getDepartmentId
());
//次卡折扣的
timesCardUsedRecord
.
setServeName
(
orderServe
.
getServeName
());
//次卡作用的订单详情id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getId
());
//次卡作用的服务id
timesCardUsedRecord
.
set
OrderServeId
(
orderServe
.
getServeId
());
timesCardUsedRecord
.
set
ServeName
(
orderServe
.
getServeName
());
//次卡作用的订单id
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
.
get
OrderServe
Id
());
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getId
());
//业绩
timesCardOrderServeDetail
.
setAchievement
(
timesCardUsedRecord
.
getPayAmount
());
// timesCardOrderServeDetailMapper.insert(timesCardOrderServeDetail);
//订单折扣金额更新
orderServe
.
setBindTimesCard
(
1
);
...
...
@@ -459,15 +460,7 @@ public class MarketServiceImpl implements MarketService {
//业绩
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
(
"次卡冲突"
);
}
...
...
@@ -475,17 +468,9 @@ public class MarketServiceImpl implements MarketService {
});
}
//卡券之前删除订单服务和卡券关联
// 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
())
...
...
@@ -543,8 +528,6 @@ public class MarketServiceImpl implements MarketService {
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
orderServe
.
setBindOuterCoupon
(
1
);
// couponOrderRelevanceService.save(couponOrderRelevance);
}
else
{
throw
new
RRException
(
"%s与其他卡券冲突"
,
couponCustomerRelevance
.
getCouponName
());
}
...
...
@@ -554,11 +537,6 @@ public class MarketServiceImpl implements MarketService {
//4、内部券
if
(
ListUtil
.
isNotEmpty
(
innerCouponCustomerRelevanceServiceList
))
{
//删除之前的内部券抵扣情况记录
// couponOrderRelevanceService.remove(new LambdaQueryWrapper<CouponOrderRelevance>()
// .eq(CouponOrderRelevance::getOrderId, orderId)
// .in(CouponOrderRelevance::getCouponCustomerRelevanceId, innerCouponCustomerRelevanceServiceList.stream().map(CouponCustomerRelevance::getId).collect(Collectors.toList())));
//免单券Id
List
<
Integer
>
discountConfigListCouponId
=
discountConfigMapper
.
selectList
(
new
QueryWrapper
<>()).
stream
().
map
(
DiscountConfig:
:
getCouponId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
...
...
@@ -621,9 +599,6 @@ public class MarketServiceImpl implements MarketService {
}
else
{
couponOrderRelevance
.
setAchievement
(
couponOrderRelevance
.
getDiscountAmount
());
}
//保存卡券在订单服务上的使用情况
// couponOrderRelevanceService.save(couponOrderRelevance);
System
.
out
.
println
(
orderServe
.
getAchievement
());
//如果不是免单券 业绩就要扣除实际折扣金额
if
(!
discountConfigListCouponId
.
contains
(
couponCustomerRelevance
.
getCouponId
()))
{
...
...
@@ -921,8 +896,12 @@ public class MarketServiceImpl implements MarketService {
//次卡折扣的
timesCardUsedRecord
.
setServeName
(
orderServe
.
getServeName
());
//次卡作用的服务id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getServeId
());
timesCardUsedRecord
.
setServeId
(
orderServe
.
getServeId
());
//次卡作用的订单服务详情id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getId
());
//次卡作用的订单id
timesCardUsedRecord
.
setOrderId
(
orderId
);
//
timesCardUsedRecord
.
setActualDiscountAmount
(
actualDiscountAmount
);
timesCardUsedRecordService
.
updateById
(
timesCardUsedRecord
);
...
...
@@ -931,7 +910,7 @@ public class MarketServiceImpl implements MarketService {
timesCardOrderServeDetail
.
setDiscountAmount
(
actualDiscountAmount
);
timesCardOrderServeDetail
.
setOrderServeId
(
orderServe
.
getId
());
timesCardOrderServeDetail
.
setOrderId
(
orderId
);
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
get
OrderServe
Id
());
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getId
());
//业绩
timesCardOrderServeDetail
.
setAchievement
(
timesCardUsedRecord
.
getPayAmount
());
timesCardOrderServeDetailMapper
.
insert
(
timesCardOrderServeDetail
);
...
...
@@ -944,14 +923,6 @@ public class MarketServiceImpl implements MarketService {
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
(
"次卡冲突"
);
}
...
...
@@ -1263,8 +1234,12 @@ public class MarketServiceImpl implements MarketService {
//次卡折扣的
timesCardUsedRecord
.
setServeName
(
orderServe
.
getServeName
());
//次卡作用的服务id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getServeId
());
timesCardUsedRecord
.
setServeId
(
orderServe
.
getServeId
());
//次卡作用的服务id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getId
());
//
timesCardUsedRecord
.
setOrderId
(
orderId
);
//
timesCardUsedRecord
.
setActualDiscountAmount
(
actualDiscountAmount
);
timesCardUsedRecordService
.
updateById
(
timesCardUsedRecord
);
...
...
@@ -1273,7 +1248,8 @@ public class MarketServiceImpl implements MarketService {
timesCardOrderServeDetail
.
setDiscountAmount
(
actualDiscountAmount
);
timesCardOrderServeDetail
.
setOrderServeId
(
orderServe
.
getId
());
timesCardOrderServeDetail
.
setOrderId
(
orderId
);
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getOrderServeId
());
//
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getId
());
//业绩
timesCardOrderServeDetail
.
setAchievement
(
timesCardUsedRecord
.
getPayAmount
());
timesCardOrderServeDetailMapper
.
insert
(
timesCardOrderServeDetail
);
...
...
@@ -1286,14 +1262,6 @@ public class MarketServiceImpl implements MarketService {
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
(
"次卡冲突"
);
}
...
...
src/test/java/com/gogirl/application/order/serve/impl/OrderManageServiceImplTest.java
0 → 100644
View file @
c042d5b2
package
com
.
gogirl
.
application
.
order
.
serve
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.gogirl.domain.order.serve.MultiPaymentType
;
import
com.gogirl.domain.order.serve.OrderManage
;
import
com.gogirl.domain.user.customer.CustomerBalanceRecord
;
import
com.gogirl.infrastructure.common.util.JsonUtilByFsJson
;
import
com.gogirl.infrastructure.mapper.order.serve.OrderManageMapper
;
import
com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMapper
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.List
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/9/21 4:05 下午
*/
@ActiveProfiles
(
"prod"
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@Slf4j
public
class
OrderManageServiceImplTest
{
@Resource
OrderManageMapper
orderManageMapper
;
@Resource
CustomerBalanceRecordMapper
customerBalanceRecordMapper
;
@Test
public
void
test1
()
{
List
<
OrderManage
>
orderManageList
=
orderManageMapper
.
selectList
(
new
LambdaQueryWrapper
<
OrderManage
>()
.
eq
(
OrderManage:
:
getPaymentType
,
12
)
.
isNull
(
OrderManage:
:
getMultiplePaymentType
));
orderManageList
.
forEach
(
orderManage
->
{
CustomerBalanceRecord
customerBalanceRecord
=
customerBalanceRecordMapper
.
selectOne
(
new
LambdaQueryWrapper
<
CustomerBalanceRecord
>()
.
eq
(
CustomerBalanceRecord:
:
getOrderId
,
orderManage
.
getId
()));
BigDecimal
cardAmount
=
new
BigDecimal
(
customerBalanceRecord
.
getOrderAmount
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_DOWN
);
BigDecimal
wxAmount
=
orderManage
.
getTotalPaymentAmount
().
subtract
(
cardAmount
);
orderManage
.
setMultiplePaymentType
(
JsonUtilByFsJson
.
beanToJson
(
Lists
.
newArrayList
(
MultiPaymentType
.
builder
()
.
type
(
1
)
.
price
(
wxAmount
)
.
build
(),
MultiPaymentType
.
builder
()
.
type
(
2
)
.
price
(
cardAmount
)
.
build
()
)));
orderManageMapper
.
updateById
(
orderManage
);
});
}
}
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