Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
e46a6f1a
Commit
e46a6f1a
authored
May 23, 2020
by
macro
Browse files
购物车支持选择商品下单
parent
13130811
Changes
3
Hide whitespace changes
Inline
Side-by-side
mall-portal/src/main/java/com/macro/mall/portal/controller/OmsCartItemController.java
View file @
e46a6f1a
...
...
@@ -49,8 +49,8 @@ public class OmsCartItemController {
@ApiOperation
(
"获取某个会员的购物车列表,包括促销信息"
)
@RequestMapping
(
value
=
"/list/promotion"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
CommonResult
<
List
<
CartPromotionItem
>>
listPromotion
()
{
List
<
CartPromotionItem
>
cartPromotionItemList
=
cartItemService
.
listPromotion
(
memberService
.
getCurrentMember
().
getId
());
public
CommonResult
<
List
<
CartPromotionItem
>>
listPromotion
(
@RequestParam
(
required
=
false
)
List
<
Long
>
cartIds
)
{
List
<
CartPromotionItem
>
cartPromotionItemList
=
cartItemService
.
listPromotion
(
memberService
.
getCurrentMember
().
getId
()
,
cartIds
);
return
CommonResult
.
success
(
cartPromotionItemList
);
}
...
...
mall-portal/src/main/java/com/macro/mall/portal/service/OmsCartItemService.java
View file @
e46a6f1a
...
...
@@ -26,7 +26,7 @@ public interface OmsCartItemService {
/**
* 获取包含促销活动信息的购物车列表
*/
List
<
CartPromotionItem
>
listPromotion
(
Long
memberId
);
List
<
CartPromotionItem
>
listPromotion
(
Long
memberId
,
List
<
Long
>
cartIds
);
/**
* 修改某个购物车商品的数量
...
...
mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsCartItemServiceImpl.java
View file @
e46a6f1a
package
com.macro.mall.portal.service.impl
;
import
cn.hutool.core.collection.CollUtil
;
import
com.macro.mall.mapper.OmsCartItemMapper
;
import
com.macro.mall.model.OmsCartItem
;
import
com.macro.mall.model.OmsCartItemExample
;
...
...
@@ -18,6 +19,7 @@ import org.springframework.util.StringUtils;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 购物车管理Service实现类
...
...
@@ -78,8 +80,11 @@ public class OmsCartItemServiceImpl implements OmsCartItemService {
}
@Override
public
List
<
CartPromotionItem
>
listPromotion
(
Long
memberId
)
{
public
List
<
CartPromotionItem
>
listPromotion
(
Long
memberId
,
List
<
Long
>
cartIds
)
{
List
<
OmsCartItem
>
cartItemList
=
list
(
memberId
);
if
(
CollUtil
.
isNotEmpty
(
cartIds
)){
cartItemList
=
cartItemList
.
stream
().
filter
(
item
->
cartIds
.
contains
(
item
.
getId
())).
collect
(
Collectors
.
toList
());
}
List
<
CartPromotionItem
>
cartPromotionItemList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
cartItemList
)){
cartPromotionItemList
=
promotionService
.
calcCartPromotion
(
cartItemList
);
...
...
Write
Preview
Supports
Markdown
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