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
8e265172
Commit
8e265172
authored
Mar 16, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
long 序列化
parent
3ad9aa82
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
295 additions
and
84 deletions
+295
-84
CouponCustomerRelevanceServiceImpl.java
...ation/market/impl/CouponCustomerRelevanceServiceImpl.java
+14
-3
CouponServiceImpl.java
...com/gogirl/application/market/impl/CouponServiceImpl.java
+3
-0
MarketServiceImpl.java
...com/gogirl/application/market/impl/MarketServiceImpl.java
+129
-77
MallShoppingCartQryServiceImpl.java
...ion/product/mall/impl/MallShoppingCartQryServiceImpl.java
+25
-1
BaseQuestionServiceImpl.java
...tion/user/investigation/impl/BaseQuestionServiceImpl.java
+0
-1
MallProductDTOAssembler.java
...in/java/com/gogirl/assembler/MallProductDTOAssembler.java
+24
-0
MallShoppingCartDTOAssembler.java
...va/com/gogirl/assembler/MallShoppingCartDTOAssembler.java
+41
-0
Coupon.java
src/main/java/com/gogirl/domain/market/coupon/Coupon.java
+4
-0
CouponCustomerRelevance.java
.../gogirl/domain/market/coupon/CouponCustomerRelevance.java
+24
-0
TimesCardCustomerRelevance.java
...l/domain/market/timescard/TimesCardCustomerRelevance.java
+4
-0
MallShoppingCart.java
...n/java/com/gogirl/domain/order/mall/MallShoppingCart.java
+6
-0
TimesCardController.java
.../java/com/gogirl/interfaces/user/TimesCardController.java
+18
-1
OrderServeDTO.java
...ared/order/serve/query/dto/ordermanage/OrderServeDTO.java
+2
-0
MyMallShoppingCartDTO.java
...ogirl/shared/product/query/dto/MyMallShoppingCartDTO.java
+1
-1
No files found.
src/main/java/com/gogirl/application/market/impl/CouponCustomerRelevanceServiceImpl.java
View file @
8e265172
...
...
@@ -20,6 +20,7 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper;
import
com.gogirl.shared.market.command.SetUpOuterCouponCommand
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.Date
;
...
...
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
@Service
@Slf4j
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
CouponCustomerRelevanceServiceImpl
extends
ServiceImpl
<
CouponCustomerRelevanceMapper
,
CouponCustomerRelevance
>
implements
CouponCustomerRelevanceService
{
@Resource
...
...
@@ -65,6 +67,15 @@ public class CouponCustomerRelevanceServiceImpl extends ServiceImpl<CouponCustom
List
<
Integer
>
freeCouponIds
=
discountConfigMapper
.
selectList
(
new
LambdaQueryWrapper
<>()).
stream
().
map
(
DiscountConfig:
:
getCouponId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
canUserServeIds
.
retainAll
(
orderServeList
.
stream
()
.
map
(
OrderServe:
:
getServeId
)
.
collect
(
Collectors
.
toList
()));
return
ListUtil
.
isNotEmpty
(
canUserServeIds
);
})
.
peek
(
couponCustomerRelevance
->
{
List
<
Integer
>
canUserServeIds
=
couponCustomerRelevanceMapper
.
queryCouponCustomerServeRelevance
(
couponCustomerRelevance
.
getCouponId
());
List
<
Integer
>
freeCouponIds
=
discountConfigMapper
.
selectList
(
new
LambdaQueryWrapper
<>()).
stream
().
map
(
DiscountConfig:
:
getCouponId
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
if
(
freeCouponIds
.
contains
(
couponCustomerRelevance
.
getCouponId
()))
{
canUserServeIds
.
retainAll
(
orderServeList
.
stream
()
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
==
2
)
...
...
@@ -73,13 +84,13 @@ public class CouponCustomerRelevanceServiceImpl extends ServiceImpl<CouponCustom
}
else
{
canUserServeIds
.
retainAll
(
orderServeList
.
stream
()
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
==
2
)
.
filter
(
orderServe
->
orderServe
.
getProduceCurrentPrice
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getProduceCurrentPrice
()
.
compareTo
(
orderServe
.
getProduceBargainPrice
())
>
-
1
)
.
filter
(
orderServe
->
orderServe
.
getProducePromotionTimeId
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getLeisureDiscountConfigId
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getLeisureDiscountConfigId
()
==
null
||
orderServe
.
getLeisureDiscountConfigId
()
==
0
)
.
map
(
OrderServe:
:
getServeId
)
.
collect
(
Collectors
.
toList
()));
}
return
ListUtil
.
isNotEmpty
(
canUserServeIds
);
couponCustomerRelevance
.
setCanBeUse
(
ListUtil
.
isNotEmpty
(
canUserServeIds
)
);
})
//过滤可用
.
filter
(
CouponCustomerRelevance:
:
isValid
)
...
...
src/main/java/com/gogirl/application/market/impl/CouponServiceImpl.java
View file @
8e265172
...
...
@@ -223,6 +223,9 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
canUserServeIds
.
retainAll
(
orderServeList
.
stream
().
map
(
OrderServe:
:
getServeId
).
collect
(
Collectors
.
toList
()));
return
ListUtil
.
isNotEmpty
(
canUserServeIds
);
})
.
peek
(
coupon
->
{
})
//过滤达到可用金额
.
filter
(
coupon
->
coupon
.
getReachingAmount
().
compareTo
(
orderManage
.
getTotalPrice
())
<
0
)
.
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/gogirl/application/market/impl/MarketServiceImpl.java
View file @
8e265172
...
...
@@ -6,6 +6,7 @@ import com.gogirl.application.order.serve.OrderServeService;
import
com.gogirl.domain.market.coupon.Coupon
;
import
com.gogirl.domain.market.coupon.CouponCustomerRelevance
;
import
com.gogirl.domain.market.coupon.CouponOrderRelevance
;
import
com.gogirl.domain.market.discount.DiscountConfig
;
import
com.gogirl.domain.market.timescard.TimesCardCustomerRelevance
;
import
com.gogirl.domain.market.timescard.TimesCardOrderServeDetail
;
import
com.gogirl.domain.market.timescard.TimesCardUsedRecord
;
...
...
@@ -15,6 +16,7 @@ import com.gogirl.infrastructure.common.exception.RRException;
import
com.gogirl.infrastructure.common.util.ListUtil
;
import
com.gogirl.infrastructure.mapper.market.coupon.CouponCustomerRelevanceMapper
;
import
com.gogirl.infrastructure.mapper.market.coupon.CouponMapper
;
import
com.gogirl.infrastructure.mapper.market.discount.DiscountConfigMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardCustomerRelevanceMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardOrderServeDetailMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardUsedRecordMapper
;
...
...
@@ -23,15 +25,14 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper;
import
com.gogirl.shared.market.command.SetTimesCardCommand
;
import
com.gogirl.shared.market.command.SetUpInnerCouponCommand
;
import
com.gogirl.shared.market.command.SetUpOuterCouponCommand
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -64,6 +65,8 @@ public class MarketServiceImpl implements MarketService {
@Resource
private
TimesCardCustomerRelevanceService
timesCardCustomerRelevanceService
;
@Resource
private
DiscountConfigMapper
discountConfigMapper
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
...
...
@@ -96,14 +99,15 @@ public class MarketServiceImpl implements MarketService {
//设置卡券关联
if
(
ListUtil
.
isNotEmpty
(
cmd
.
getInnerCouponCustomerRelevanceIds
()))
{
List
<
CouponCustomerRelevance
>
couponCustomerRelevanceList
=
(
List
<
CouponCustomerRelevance
>)
couponCustomerRelevanceService
.
listByIds
(
cmd
.
getInnerCouponCustomerRelevanceIds
());
List
<
CouponCustomerRelevance
>
couponCustomerRelevanceList
=
(
List
<
CouponCustomerRelevance
>)
couponCustomerRelevanceService
.
listByIds
(
cmd
.
getInnerCouponCustomerRelevanceIds
());
if
(
ListUtil
.
isNotEmpty
(
couponCustomerRelevanceList
))
{
couponCustomerRelevanceList
.
forEach
(
couponCustomerRelevance
->
{
couponCustomerRelevance
.
setOrderId
(
cmd
.
getOrderId
());
//选择使用
couponCustomerRelevance
.
setState
(
CouponCustomerRelevance
.
STATE_CHOSE
);
couponCustomerRelevanceMapper
.
updateById
(
couponCustomerRelevance
);
});
couponCustomerRelevanceService
.
updateBatchById
(
couponCustomerRelevanceList
);
}
}
}
...
...
@@ -265,14 +269,14 @@ public class MarketServiceImpl implements MarketService {
.
list
(
new
LambdaQueryWrapper
<
CouponCustomerRelevance
>()
.
eq
(
CouponCustomerRelevance:
:
getOrderId
,
orderId
)
.
eq
(
CouponCustomerRelevance:
:
getState
,
1
)
.
eq
(
CouponCustomerRelevance:
:
getType
,
0
));
.
eq
(
CouponCustomerRelevance:
:
get
Source
Type
,
0
));
//订单使用的外部券
List
<
CouponCustomerRelevance
>
outerCouponCustomerRelevanceServiceList
=
couponCustomerRelevanceService
.
list
(
new
LambdaQueryWrapper
<
CouponCustomerRelevance
>()
.
eq
(
CouponCustomerRelevance:
:
getOrderId
,
orderId
)
.
eq
(
CouponCustomerRelevance:
:
getState
,
1
)
.
eq
(
CouponCustomerRelevance:
:
getType
,
1
));
.
eq
(
CouponCustomerRelevance:
:
get
Source
Type
,
1
));
//订单使用的次卡
...
...
@@ -336,6 +340,7 @@ public class MarketServiceImpl implements MarketService {
//如果有属于这个服务的辅助服务 就查出来一起折扣
OrderServe
supportServe
=
this
.
querySupportServe
(
orderManage
,
orderServe
);
BigDecimal
actualDiscountAmount
=
orderServe
.
getPayPrice
().
min
(
timesCardUsedRecord
.
getDiscountAmount
());
//更新次卡记录 已使用
timesCardUsedRecord
.
setStatus
(
TimesCardUsedRecord
.
STATUS_USED
);
//次卡对应订单服务的美甲师
...
...
@@ -348,12 +353,13 @@ public class MarketServiceImpl implements MarketService {
timesCardUsedRecord
.
setServeName
(
orderServe
.
getServeName
());
//次卡作用的服务id
timesCardUsedRecord
.
setOrderServeId
(
orderServe
.
getServeId
());
timesCardUsedRecord
.
setOrderId
(
orderId
);
timesCardUsedRecord
.
setActualDiscountAmount
(
actualDiscountAmount
);
timesCardUsedRecordService
.
updateById
(
timesCardUsedRecord
);
//在主服务上折扣的钱
TimesCardOrderServeDetail
timesCardOrderServeDetail
=
new
TimesCardOrderServeDetail
();
BigDecimal
serveDiscountAmount
=
orderServe
.
getPayPrice
().
min
(
timesCardUsedRecord
.
getDiscountAmount
());
timesCardOrderServeDetail
.
setDiscountAmount
(
serveDiscountAmount
);
timesCardOrderServeDetail
.
setDiscountAmount
(
actualDiscountAmount
);
timesCardOrderServeDetail
.
setOrderServeId
(
orderServe
.
getId
());
timesCardOrderServeDetail
.
setOrderId
(
orderId
);
timesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getOrderServeId
());
...
...
@@ -363,28 +369,27 @@ public class MarketServiceImpl implements MarketService {
//订单折扣金额更新
orderServe
.
setBindCoupon
(
1
);
orderServe
.
addDiscountPrice
(
serveDiscountAmount
);
orderManage
.
addDiscountPrice
(
serveDiscountAmount
);
//在从服务上折扣的钱
BigDecimal
leftServeDiscountAmount
=
timesCardUsedRecord
.
getDiscountAmount
().
subtract
(
serveDiscountAmount
);
if
(
supportServe
!=
null
&&
leftServeDiscountAmount
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
BigDecimal
actualSupportServeDiscountAmount
=
leftServeDiscountAmount
.
min
(
supportServe
.
getPayPrice
());
TimesCardOrderServeDetail
supportTimesCardOrderServeDetail
=
new
TimesCardOrderServeDetail
();
supportTimesCardOrderServeDetail
.
setDiscountAmount
(
actualSupportServeDiscountAmount
);
supportTimesCardOrderServeDetail
.
setOrderServeId
(
supportServe
.
getId
());
supportTimesCardOrderServeDetail
.
setOrderId
(
orderId
);
supportTimesCardOrderServeDetail
.
setTimesCardUserRecordId
(
timesCardUsedRecord
.
getOrderServeId
());
//业绩
supportTimesCardOrderServeDetail
.
setAchievement
(
BigDecimal
.
ZERO
);
timesCardOrderServeDetailMapper
.
insert
(
supportTimesCardOrderServeDetail
);
//订单折扣金额更新
supportServe
.
setBindCoupon
(
1
);
supportServe
.
addDiscountPrice
(
actualSupportServeDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualSupportServeDiscountAmount
);
}
orderServe
.
addDiscountPrice
(
actualDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualDiscountAmount
);
// 在从服务上折扣的钱
// BigDecimal leftServeDiscountAmount = timesCardUsedRecord.getDiscountAmount().subtract(serveDiscountAmount);
// if (supportServe != null && leftServeDiscountAmount.compareTo(BigDecimal.ZERO) > 0) {
//
// BigDecimal actualSupportServeDiscountAmount = leftServeDiscountAmount.min(supportServe.getPayPrice());
// TimesCardOrderServeDetail supportTimesCardOrderServeDetail = new TimesCardOrderServeDetail();
// supportTimesCardOrderServeDetail.setDiscountAmount(actualSupportServeDiscountAmount);
// supportTimesCardOrderServeDetail.setOrderServeId(supportServe.getId());
// supportTimesCardOrderServeDetail.setOrderId(orderId);
// supportTimesCardOrderServeDetail.setTimesCardUserRecordId(timesCardUsedRecord.getOrderServeId());
// //业绩
// supportTimesCardOrderServeDetail.setAchievement(BigDecimal.ZERO);
// timesCardOrderServeDetailMapper.insert(supportTimesCardOrderServeDetail);
//
// //订单折扣金额更新
// supportServe.setBindCoupon(1);
// supportServe.addDiscountPrice(actualSupportServeDiscountAmount);
// orderManage.addDiscountPrice(actualSupportServeDiscountAmount);
// }
//更新使用次数
TimesCardCustomerRelevance
timesCardCustomerRelevance
=
timesCardCustomerRelevanceService
.
getById
(
timesCardUsedRecord
.
getCardRelevanceCustomerId
());
...
...
@@ -395,8 +400,9 @@ public class MarketServiceImpl implements MarketService {
}
timesCardCustomerRelevanceService
.
updateById
(
timesCardCustomerRelevance
);
}
else
{
timesCardUsedRecord
.
setOrderId
(
null
);
timesCardUsedRecordMapper
.
updateById
(
timesCardUsedRecord
);
throw
new
RRException
(
"次卡冲突"
);
// timesCardUsedRecord.setOrderId(null);
// timesCardUsedRecordMapper.updateById(timesCardUsedRecord);
}
});
...
...
@@ -431,7 +437,7 @@ public class MarketServiceImpl implements MarketService {
//如果有属于这个服务的辅助服务 就查出来一起折扣
OrderServe
supportServe
=
this
.
querySupportServe
(
orderManage
,
orderServe
);
BigDecimal
serve
DiscountAmount
=
orderServe
.
getPayPrice
().
min
(
couponCustomerRelevance
.
getDiscountAmount
());
BigDecimal
actual
DiscountAmount
=
orderServe
.
getPayPrice
().
min
(
couponCustomerRelevance
.
getDiscountAmount
());
//新增外部券抵扣情况记录
CouponOrderRelevance
couponOrderRelevance
=
CouponOrderRelevance
.
builder
()
...
...
@@ -444,7 +450,7 @@ public class MarketServiceImpl implements MarketService {
//支付金额
.
payForOrderServe
(
couponCustomerRelevance
.
getPayAmount
())
//折扣金额
.
discountAmount
(
serve
DiscountAmount
)
.
discountAmount
(
actual
DiscountAmount
)
.
createTime
(
new
Date
())
.
confirmTime
(
new
Date
())
.
message
(
orderServe
.
getServeName
())
...
...
@@ -457,44 +463,44 @@ public class MarketServiceImpl implements MarketService {
}
else
{
couponOrderRelevance
.
setAchievement
(
couponOrderRelevance
.
getDiscountAmount
());
}
orderServe
.
addDiscountPrice
(
serve
DiscountAmount
);
orderManage
.
addDiscountPrice
(
serve
DiscountAmount
);
orderServe
.
addDiscountPrice
(
actual
DiscountAmount
);
orderManage
.
addDiscountPrice
(
actual
DiscountAmount
);
orderServe
.
setBindCoupon
(
1
);
couponOrderRelevanceService
.
save
(
couponOrderRelevance
);
//在从服务上折扣的钱
BigDecimal
leftServeDiscountAmount
=
couponCustomerRelevance
.
getDiscountAmount
().
subtract
(
serve
DiscountAmount
);
if
(
supportServe
!=
null
&&
leftServeDiscountAmount
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
BigDecimal
actualSupportServeDiscountAmount
=
leftServeDiscountAmount
.
min
(
supportServe
.
getPayPrice
());
//新增外部券抵扣情况记录
CouponOrderRelevance
supportCouponOrderRelevance
=
CouponOrderRelevance
.
builder
()
.
couponCustomerRelevanceId
(
couponCustomerRelevance
.
getId
())
.
couponId
(
couponCustomerRelevance
.
getCouponId
())
.
couponName
(
couponCustomerRelevance
.
getCouponName
())
.
orderServeId
(
supportServe
.
getId
())
.
serveName
(
supportServe
.
getServeName
())
.
orderId
(
orderManage
.
getId
())
//支付金额
.
payForOrderServe
(
BigDecimal
.
ZERO
)
//折扣金额
.
discountAmount
(
actualSupportServeDiscountAmount
)
.
createTime
(
new
Date
())
.
confirmTime
(
new
Date
())
.
message
(
supportServe
.
getServeName
())
.
customerId
(
orderManage
.
getOrderUser
())
.
achievement
(
BigDecimal
.
ZERO
)
//确认可用
.
status
(
2
)
.
build
();
couponOrderRelevanceService
.
save
(
supportCouponOrderRelevance
);
supportServe
.
addDiscountPrice
(
actualSupportServeDiscountAmount
);
orderManage
.
addDiscountPrice
(
actualSupportServeDiscountAmount
);
orderServe
.
setBindCoupon
(
1
);
}
// BigDecimal leftServeDiscountAmount = couponCustomerRelevance.getDiscountAmount().subtract(actual
DiscountAmount);
//
if (supportServe != null && leftServeDiscountAmount.compareTo(BigDecimal.ZERO) > 0) {
//
BigDecimal actualSupportServeDiscountAmount = leftServeDiscountAmount.min(supportServe.getPayPrice());
//
//新增外部券抵扣情况记录
//
CouponOrderRelevance supportCouponOrderRelevance = CouponOrderRelevance.builder()
//
.couponCustomerRelevanceId(couponCustomerRelevance.getId())
//
.couponId(couponCustomerRelevance.getCouponId())
//
.couponName(couponCustomerRelevance.getCouponName())
//
.orderServeId(supportServe.getId())
//
.serveName(supportServe.getServeName())
//
.orderId(orderManage.getId())
//
//支付金额
//
.payForOrderServe(BigDecimal.ZERO)
//
//折扣金额
//
.discountAmount(actualSupportServeDiscountAmount)
//
.createTime(new Date())
//
.confirmTime(new Date())
//
.message(supportServe.getServeName())
//
.customerId(orderManage.getOrderUser())
//
.achievement(BigDecimal.ZERO)
//
//确认可用
//
.status(2)
//
.build();
//
couponOrderRelevanceService.save(supportCouponOrderRelevance);
//
//
supportServe.addDiscountPrice(actualSupportServeDiscountAmount);
//
orderManage.addDiscountPrice(actualSupportServeDiscountAmount);
//
orderServe.setBindCoupon(1);
//
}
}
else
{
couponCustomerRelevance
.
setOrderId
(
null
);
couponCustomerRelevanceMapper
.
updateById
(
couponCustomerRelevance
);
throw
new
RRException
(
"外部券冲突"
);
// couponCustomerRelevance.setOrderId(null);
// couponCustomerRelevanceMapper.updateById(couponCustomerRelevance);
}
});
...
...
@@ -513,7 +519,7 @@ public class MarketServiceImpl implements MarketService {
List
<
Integer
>
serveIds
=
couponCustomerRelevanceMapper
.
queryCouponCustomerServeRelevance
(
couponCustomerRelevance
.
getCouponId
());
//作用的服务id
List
<
OrderServe
>
canUserOrderServeList
=
orderManage
.
getListOrderServer
().
stream
().
filter
(
dto
->
serveIds
.
contains
(
dto
.
getServeId
())).
collect
(
Collectors
.
toList
());
List
<
OrderServe
>
canUserOrderServeList
=
this
.
queryCanDiscount
(
orderManage
,
serveIds
,
couponCustomerRelevance
.
getCouponId
());
//打折订单项总支付金额
BigDecimal
total
=
canUserOrderServeList
.
stream
().
map
(
OrderServe:
:
getPayPrice
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
...
...
@@ -571,16 +577,17 @@ public class MarketServiceImpl implements MarketService {
orderServe
.
addDiscountPrice
(
discountAmount
);
orderManage
.
addDiscountPrice
(
discountAmount
);
orderServe
.
setBindCoupon
(
1
);
discountCalc
=
discountCalc
.
add
(
discountAmount
);
payCalc
=
payCalc
.
add
(
payAmount
);
}
}
//内部券抵扣不了
else
{
couponCustomerRelevance
.
setState
(
null
);
couponCustomerRelevance
.
setOrderId
(
null
);
couponCustomerRelevanceService
.
updateById
(
couponCustomerRelevance
);
// couponCustomerRelevance.setState(null);
// couponCustomerRelevance.setOrderId(null);
// couponCustomerRelevanceService.updateById(couponCustomerRelevance);
throw
new
RRException
(
"内部券冲突"
);
}
});
}
...
...
@@ -590,6 +597,51 @@ public class MarketServiceImpl implements MarketService {
}
private
List
<
OrderServe
>
queryCanDiscount
(
OrderManage
orderManage
,
List
<
Integer
>
serveIds
,
Integer
counponId
)
{
List
<
Integer
>
freeCouponIds
=
discountConfigMapper
.
selectList
(
new
LambdaQueryWrapper
<>()).
stream
().
map
(
DiscountConfig:
:
getCouponId
)
.
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
if
(
freeCouponIds
.
contains
(
counponId
))
{
Set
<
OrderServe
>
set
=
new
HashSet
<>();
List
<
String
>
meijia
=
Lists
.
newArrayList
(
"全手光疗延长"
,
"单指光疗延长"
,
"精细日式卸甲(手部)"
,
"精细日式卸甲(脚部)"
,
"单指跳色"
);
List
<
String
>
meijie
=
Lists
.
newArrayList
(
"睫毛(卸除)"
,
"加彩色睫毛"
,
"加种睫毛"
,
"加彩色睫毛"
,
"下睫毛"
);
OrderServe
maxOrderServe
=
orderManage
.
getListOrderServer
()
.
stream
()
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
==
2
)
.
filter
(
orderServe
->
serveIds
.
contains
(
orderServe
.
getServeId
()))
.
max
(
Comparator
.
comparing
(
OrderServe:
:
getPayPrice
))
.
orElse
(
null
);
set
.
add
(
maxOrderServe
);
if
(
maxOrderServe
!=
null
)
{
if
(
maxOrderServe
.
getServeType
().
equals
(
"美甲"
))
{
set
.
addAll
(
orderManage
.
getListOrderServer
().
stream
()
.
filter
(
orderServe
->
meijia
.
contains
(
orderServe
.
getServeName
()))
.
collect
(
Collectors
.
toList
()));
}
if
(
maxOrderServe
.
getServeType
().
equals
(
"美睫"
))
{
set
.
addAll
(
orderManage
.
getListOrderServer
().
stream
()
.
filter
(
orderServe
->
meijie
.
contains
(
orderServe
.
getServeName
()))
.
collect
(
Collectors
.
toList
()));
}
}
return
new
ArrayList
<>(
set
).
stream
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
}
else
{
return
orderManage
.
getListOrderServer
()
.
stream
()
.
filter
(
orderServe
->
serveIds
.
contains
(
orderServe
.
getServeId
()))
.
filter
(
orderServe
->
orderServe
.
getLeisureDiscountConfigId
()
==
null
||
orderServe
.
getLeisureDiscountConfigId
()
==
0
)
.
filter
(
orderServe
->
orderServe
.
getProducePromotionTimeId
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getProduceCurrentPrice
().
compareTo
(
orderServe
.
getProduceBargainPrice
())
>
-
1
)
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
==
2
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
}
}
private
OrderServe
querySupportServe
(
OrderManage
orderManage
,
OrderServe
orderServe
)
{
return
null
;
}
...
...
@@ -605,10 +657,10 @@ public class MarketServiceImpl implements MarketService {
return
orderManage
.
getListOrderServer
()
.
stream
()
.
filter
(
orderServe
->
serveIds
.
contains
(
orderServe
.
getServeId
()))
.
filter
(
orderServe
->
orderServe
.
getLeisureDiscountConfigId
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getLeisureDiscountConfigId
()
==
null
||
orderServe
.
getLeisureDiscountConfigId
()
==
0
)
.
filter
(
orderServe
->
orderServe
.
getProducePromotionTimeId
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getProduceCurrentPrice
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
!=
1
)
.
filter
(
orderServe
->
orderServe
.
getProduceCurrentPrice
()
.
compareTo
(
orderServe
.
getProduceBargainPrice
())
>
-
1
)
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
==
2
)
.
max
(
Comparator
.
comparing
(
OrderServe:
:
getPayPrice
))
.
orElse
(
null
);
}
...
...
src/main/java/com/gogirl/application/product/mall/impl/MallShoppingCartQryServiceImpl.java
View file @
8e265172
...
...
@@ -2,29 +2,53 @@ package com.gogirl.application.product.mall.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.gogirl.application.product.mall.MallShoppingCartQryService
;
import
com.gogirl.assembler.MallShoppingCartDTOAssembler
;
import
com.gogirl.domain.order.mall.MallShoppingCart
;
import
com.gogirl.domain.product.mall.MallProduct
;
import
com.gogirl.infrastructure.common.util.ListUtil
;
import
com.gogirl.infrastructure.mapper.order.mall.MallShoppingCartMapper
;
import
com.gogirl.infrastructure.mapper.product.mall.MallProductMapper
;
import
com.gogirl.shared.product.query.dto.MallShoppingCartDTO
;
import
com.gogirl.shared.product.query.dto.MyMallShoppingCartDTO
;
import
com.gogirl.shared.product.query.qry.MyShoppingCartQuery
;
import
lombok.AllArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Service
@AllArgsConstructor
public
class
MallShoppingCartQryServiceImpl
implements
MallShoppingCartQryService
{
private
final
MallShoppingCartMapper
mallShoppingCartMapper
;
private
final
MallShoppingCartDTOAssembler
mallShoppingCartDTOAssembler
;
private
final
MallProductMapper
mallProductMapper
;
@Override
public
MyMallShoppingCartDTO
queryMyShoppingCart
(
MyShoppingCartQuery
qry
)
{
List
<
MallShoppingCart
>
mallShoppingCartList
=
mallShoppingCartMapper
.
selectList
(
new
LambdaQueryWrapper
<
MallShoppingCart
>().
eq
(
MallShoppingCart:
:
getCustomerId
,
qry
.
getCustomerId
())
);
List
<
Long
>
productIds
=
mallShoppingCartList
.
stream
().
map
(
MallShoppingCart:
:
getProductId
)
.
collect
(
Collectors
.
toList
());
if
(
ListUtil
.
isNotEmpty
(
productIds
))
{
Map
<
Long
,
List
<
MallProduct
>>
map
=
mallProductMapper
.
selectBatchIds
(
productIds
)
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
MallProduct:
:
getId
));
mallShoppingCartList
.
forEach
(
mallShoppingCart
->
{
List
<
MallProduct
>
mallProductList
=
map
.
get
(
mallShoppingCart
.
getProductId
());
if
(
ListUtil
.
isNotEmpty
(
mallProductList
))
{
mallShoppingCart
.
setMallProduct
(
mallProductList
.
stream
().
findAny
().
orElse
(
null
));
}
});
}
List
<
MallShoppingCartDTO
>
mallShoppingCartDTOList
=
mallShoppingCartList
.
stream
().
map
(
mallShoppingCartDTOAssembler
).
collect
(
Collectors
.
toList
());
MyMallShoppingCartDTO
data
=
new
MyMallShoppingCartDTO
();
data
.
setMallShoppingCartDTOList
(
mallShoppingCartList
);
data
.
setMallShoppingCartDTOList
(
mallShoppingCart
DTO
List
);
data
.
setItemSum
(
mallShoppingCartList
.
stream
()
.
map
(
MallShoppingCart:
:
getNum
)
...
...
src/main/java/com/gogirl/application/user/investigation/impl/BaseQuestionServiceImpl.java
View file @
8e265172
...
...
@@ -75,7 +75,6 @@ public class BaseQuestionServiceImpl extends ServiceImpl<BaseQuestionMapper, Bas
complaintMainService
.
saveComplainsByOrderQuestion
(
list
);
Coupon
coupon
=
couponService
.
getOne
(
new
LambdaQueryWrapper
<
Coupon
>().
eq
(
Coupon:
:
getName
,
"问卷调查礼券"
));
if
(
coupon
!=
null
)
{
couponService
.
sendCoupon
(
coupon
.
getId
(),
currentCustomerId
);
...
...
src/main/java/com/gogirl/assembler/MallProductDTOAssembler.java
0 → 100644
View file @
8e265172
package
com
.
gogirl
.
assembler
;
import
com.gogirl.domain.product.mall.MallProduct
;
import
com.gogirl.shared.product.query.dto.MallProductDTO
;
import
lombok.AllArgsConstructor
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Component
;
import
java.util.function.Function
;
@Component
@AllArgsConstructor
public
class
MallProductDTOAssembler
implements
Function
<
MallProduct
,
MallProductDTO
>
{
private
final
MallShoppingCartDTOAssembler
.
PurchaseSkuDTOAssembler
purchaseSkuDTOAssembler
;
@Override
public
MallProductDTO
apply
(
MallProduct
mallProduct
)
{
MallProductDTO
mallProductDTO
=
new
MallProductDTO
();
BeanUtils
.
copyProperties
(
mallProduct
,
mallProductDTO
);
return
mallProductDTO
;
}
}
src/main/java/com/gogirl/assembler/MallShoppingCartDTOAssembler.java
0 → 100644
View file @
8e265172
package
com
.
gogirl
.
assembler
;
import
com.gogirl.domain.order.mall.MallShoppingCart
;
import
com.gogirl.domain.product.purchase.PurchaseSku
;
import
com.gogirl.shared.product.query.dto.MallShoppingCartDTO
;
import
com.gogirl.shared.product.query.dto.PurchaseSkuDTO
;
import
lombok.AllArgsConstructor
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Component
;
import
java.util.function.Function
;
@Component
@AllArgsConstructor
public
class
MallShoppingCartDTOAssembler
implements
Function
<
MallShoppingCart
,
MallShoppingCartDTO
>
{
private
final
MallProductDTOAssembler
mallProductDTOAssembler
;
@Override
public
MallShoppingCartDTO
apply
(
MallShoppingCart
mallShoppingCart
)
{
MallShoppingCartDTO
mallShoppingCartDTO
=
new
MallShoppingCartDTO
();
BeanUtils
.
copyProperties
(
mallShoppingCart
,
mallShoppingCartDTO
);
if
(
mallShoppingCart
.
getMallProduct
()
!=
null
)
{
mallShoppingCartDTO
.
setMallProductDTO
(
mallProductDTOAssembler
.
apply
(
mallShoppingCart
.
getMallProduct
()));
}
return
mallShoppingCartDTO
;
}
@Component
static
class
PurchaseSkuDTOAssembler
implements
Function
<
PurchaseSku
,
PurchaseSkuDTO
>
{
@Override
public
PurchaseSkuDTO
apply
(
PurchaseSku
purchaseSku
)
{
PurchaseSkuDTO
purchaseSkuDTO
=
new
PurchaseSkuDTO
();
BeanUtils
.
copyProperties
(
purchaseSku
,
purchaseSkuDTO
);
return
purchaseSkuDTO
;
}
}
}
src/main/java/com/gogirl/domain/market/coupon/Coupon.java
View file @
8e265172
package
com
.
gogirl
.
domain
.
market
.
coupon
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
@@ -69,4 +70,7 @@ public class Coupon {
@ApiModelProperty
(
"1-计算 2-不计算"
)
private
Integer
isCalcAchievement
;
@TableField
(
exist
=
false
)
private
Integer
canBeUse
;
}
src/main/java/com/gogirl/domain/market/coupon/CouponCustomerRelevance.java
View file @
8e265172
...
...
@@ -31,6 +31,7 @@ public class CouponCustomerRelevance implements Serializable {
private
Integer
id
;
@ApiModelProperty
(
"顾客Id"
)
private
Integer
customerId
;
@ApiModelProperty
(
"卡券id"
)
private
Integer
couponId
;
...
...
@@ -39,43 +40,66 @@ public class CouponCustomerRelevance implements Serializable {
@ApiModelProperty
(
"领奖码"
)
private
String
code
;
@ApiModelProperty
(
"领券时间"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
receiveTime
;
@ApiModelProperty
(
"可用开始日期"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
validStartTime
;
@ApiModelProperty
(
"可用截止日期"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
validEndTime
;
@ApiModelProperty
(
"使用日期"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
useDate
;
//冗余coupon字段
@ApiModelProperty
(
"卡券配置备注"
)
private
String
remark
;
@ApiModelProperty
(
"能否使用"
)
@TableField
(
exist
=
false
)
private
Boolean
canBeUse
;
@TableField
(
exist
=
false
)
private
Coupon
coupon
;
@TableField
(
exist
=
false
)
private
Customer
customer
;
@ApiModelProperty
(
"卡券名称"
)
private
String
couponName
;
@ApiModelProperty
(
"优惠金额"
)
private
BigDecimal
discountAmount
;
@ApiModelProperty
(
"满这个金额才能减"
)
private
BigDecimal
reachingAmount
;
@ApiModelProperty
(
"优惠折扣"
)
private
BigDecimal
discountPercent
;
@ApiModelProperty
(
"优惠券类型:1.现金抵扣券;2.免单券;3满减券;4卸甲券"
)
private
Integer
type
;
@ApiModelProperty
(
"0 = 内部券 1 = 外部券"
)
private
Integer
sourceType
;
@ApiModelProperty
(
"使用条件:1.重叠使用"
)
private
String
condition1
;
@ApiModelProperty
(
"客户购买该券时,实际支付的金额(用该金额算业绩)"
)
private
BigDecimal
payAmount
;
@ApiModelProperty
(
"卡券来源"
)
private
String
sourceFrom
;
@ApiModelProperty
(
"卡券来源id"
)
...
...
src/main/java/com/gogirl/domain/market/timescard/TimesCardCustomerRelevance.java
View file @
8e265172
...
...
@@ -74,6 +74,9 @@ public class TimesCardCustomerRelevance {
//状态-已过期
public
static
Integer
STATUS_OVER_TIME
=
3
;
@TableField
(
exist
=
false
)
private
Boolean
canBeUse
;
/**
* 次卡是否可用
*
...
...
@@ -83,4 +86,5 @@ public class TimesCardCustomerRelevance {
return
validStartTime
.
getTime
()
<
System
.
currentTimeMillis
()
&&
validEndTime
.
getTime
()
>
System
.
currentTimeMillis
();
}
}
src/main/java/com/gogirl/domain/order/mall/MallShoppingCart.java
View file @
8e265172
package
com
.
gogirl
.
domain
.
order
.
mall
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
com.fasterxml.jackson.databind.ser.std.ToStringSerializer
;
import
com.gogirl.domain.product.mall.MallProduct
;
import
com.gogirl.domain.product.purchase.PurchaseSku
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -37,4 +39,8 @@ public class MallShoppingCart {
private
Long
lastUpdateTime
;
@TableField
(
exist
=
false
)
private
MallProduct
mallProduct
;
}
src/main/java/com/gogirl/interfaces/user/TimesCardController.java
View file @
8e265172
...
...
@@ -20,6 +20,7 @@ import com.gogirl.infrastructure.common.exception.RRException;
import
com.gogirl.infrastructure.common.util.ListUtil
;
import
com.gogirl.infrastructure.config.GogirlProperties
;
import
com.gogirl.infrastructure.feign.wx.WxPayControllerFeign
;
import
com.gogirl.infrastructure.mapper.market.discount.DiscountConfigMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardCustomerRelevanceMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardTypeContentMapper
;
import
com.gogirl.infrastructure.mapper.market.timescard.TimesCardTypeMapper
;
...
...
@@ -150,6 +151,8 @@ public class TimesCardController {
return
JsonResult
.
success
(
timesCardCustomerRelevance
);
}
private
final
DiscountConfigMapper
discountConfigMapper
;
@ApiOperation
(
value
=
"根据订单号查询我的可用的次卡"
)
@GetMapping
(
"/customer/timescard/getMyTimesCardByOrderId"
)
public
JsonResult
<
List
<
TimesCardCustomerRelevance
>>
getMyTimesCardByOrderId
(
@RequestHeader
String
token
,
...
...
@@ -169,10 +172,24 @@ public class TimesCardController {
//次卡可以作用的服务
List
<
Integer
>
canUserServeIds
=
timesCardCustomerRelevanceMapper
.
queryTimesCardServeIds
(
timesCardCustomerRelevance
.
getCardTypeId
());
//可用服务与当前服务交集
canUserServeIds
.
retainAll
(
orderServeList
.
stream
().
map
(
OrderServe:
:
getServeId
).
collect
(
Collectors
.
toList
()));
canUserServeIds
.
retainAll
(
orderServeList
.
stream
()
.
map
(
OrderServe:
:
getServeId
)
.
collect
(
Collectors
.
toList
()));
//不为空
return
ListUtil
.
isNotEmpty
(
canUserServeIds
);
})
.
peek
(
timesCardCustomerRelevance
->
{
List
<
Integer
>
canUserServeIds
=
timesCardCustomerRelevanceMapper
.
queryTimesCardServeIds
(
timesCardCustomerRelevance
.
getCardTypeId
());
canUserServeIds
.
retainAll
(
orderServeList
.
stream
()
.
filter
(
orderServe
->
orderServe
.
getBindCoupon
()
==
2
)
.
filter
(
orderServe
->
orderServe
.
getProduceCurrentPrice
().
compareTo
(
orderServe
.
getProduceBargainPrice
())
>
-
1
)
.
filter
(
orderServe
->
orderServe
.
getProducePromotionTimeId
()
==
null
)
.
filter
(
orderServe
->
orderServe
.
getLeisureDiscountConfigId
()
==
null
||
orderServe
.
getLeisureDiscountConfigId
()
==
0
)
.
map
(
OrderServe:
:
getServeId
)
.
collect
(
Collectors
.
toList
()));
timesCardCustomerRelevance
.
setCanBeUse
(
ListUtil
.
isNotEmpty
(
canUserServeIds
));
})
.
collect
(
Collectors
.
toList
());
return
JsonResult
.
success
(
timesCardCustomerRelevanceList
);
}
...
...
src/main/java/com/gogirl/shared/order/serve/query/dto/ordermanage/OrderServeDTO.java
View file @
8e265172
...
...
@@ -108,4 +108,6 @@ public class OrderServeDTO {
private
Integer
actualServeDuration
;
private
Integer
bindCoupon
;
}
src/main/java/com/gogirl/shared/product/query/dto/MyMallShoppingCartDTO.java
View file @
8e265172
...
...
@@ -14,5 +14,5 @@ public class MyMallShoppingCartDTO {
private
Integer
itemSum
;
private
List
<
MallShoppingCart
>
mallShoppingCartDTOList
;
private
List
<
MallShoppingCart
DTO
>
mallShoppingCartDTOList
;
}
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