Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
5e14d013
Commit
5e14d013
authored
May 14, 2021
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
问题修复
parent
afdbedbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
8 deletions
+71
-8
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+15
-8
shopping-cart-application-service/src/test/java/cn.freemud/service/ShoppingCartMCoffeeServiceTest.java
+56
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
5e14d013
...
...
@@ -1644,17 +1644,24 @@ public class ShoppingCartMCoffeeServiceImpl {
//套餐固定商品赋值
if
(
CollectionUtils
.
isNotEmpty
(
productBeanListSpuClass
.
get
(
0
).
getProductComboList
())
&&
CollectionUtils
.
isNotEmpty
(
cartGoods
.
getProductComboList
())){
Map
<
String
,
Integer
>
productMap
=
productBeanListSpuClass
.
get
(
0
).
getProductComboList
().
stream
()
.
collect
(
Collectors
.
toMap
(
ProductBeanDTO
.
ProductComboType
::
getProductId
,
ProductBeanDTO
.
ProductComboType
::
getQuantity
,
(
k1
,
k2
)
->
k1
+
k2
));
Map
<
String
,
Integer
>
cartGoodsMap
=
cartGoods
.
getProductComboList
().
stream
()
.
collect
(
Collectors
.
toMap
(
o
->
(
StringUtils
.
isBlank
(
o
.
getSpuId
())
||
"0"
.
equals
(
o
.
getSpuId
()))?
o
.
getSkuId
():
o
.
getSpuId
(),
CartGoods
.
ComboxGoods
::
getQty
,
(
k1
,
k2
)
->
k1
+
k2
));
if
(
productMap
.
entrySet
().
stream
().
filter
(
o
->
!
o
.
getValue
().
equals
(
cartGoodsMap
.
get
(
o
.
getKey
()))).
findFirst
().
isPresent
())
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_VERSION_ERROR
,
"加购套餐子商品数量异常"
);
if
(
StringUtils
.
isNotBlank
(
cartGoods
.
getCouponCode
()))
{
for
(
CartGoods
.
ComboxGoods
comboxGoods
:
cartGoods
.
getProductComboList
())
{
comboxGoods
.
setQty
(
productMap
.
get
(
comboxGoods
.
getGoodsId
()));
}
}
else
{
Map
<
String
,
Integer
>
cartGoodsMap
=
cartGoods
.
getProductComboList
().
stream
()
.
collect
(
Collectors
.
toMap
(
o
->
(
StringUtils
.
isBlank
(
o
.
getSpuId
())
||
"0"
.
equals
(
o
.
getSpuId
()))?
o
.
getSkuId
():
o
.
getSpuId
(),
CartGoods
.
ComboxGoods
::
getQty
,
(
k1
,
k2
)
->
k1
+
k2
));
if
(
productMap
.
entrySet
().
stream
().
filter
(
o
->
!
o
.
getValue
().
equals
(
cartGoodsMap
.
get
(
o
.
getKey
()))).
findFirst
().
isPresent
())
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_VERSION_ERROR
,
"加购套餐子商品数量异常"
);
}
}
}
...
...
shopping-cart-application-service/src/test/java/cn.freemud/service/ShoppingCartMCoffeeServiceTest.java
0 → 100644
View file @
5e14d013
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ShoppingCartNewServiceTest
* @Package cn.freemud.service
* @Description:
* @author: song.cai
* @date: 2019/1/23 16:56
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.service.impl.ShoppingCartMealServiceImpl
;
import
cn.freemud.service.impl.mcoffee.ShoppingCartMCoffeeServiceImpl
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.MealClearOperationEnum
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@EnableDiscoveryClient
@EnableFeignClients
@EnableAutoConfiguration
public
class
ShoppingCartMCoffeeServiceTest
{
@Autowired
private
ShoppingCartMCoffeeServiceImpl
shoppingCartMCoffeeService
;
@Test
public
void
f1
()
{
shoppingCartMCoffeeService
.
addGoods
(
JSON
.
parseObject
(
"{\"appId\":\"wx6816a0b007741702\",\"channelType\":\"saas\",\"couponCode\":\"601153527093109\",\"couponType\":0,\"extra\":[],\"isMonthCard\":0,\"isMonthCardGoods\":0,\"isSunnyCoupon\":0,\"menuType\":\"saas\",\"orderType\":1,\"partnerId\":\"1628\",\"productComboList\":[{\"extra\":[],\"productMaterialList\":[],\"skuId\":\"204903200109635372\"}],\"productGroupList\":[],\"qty\":1,\"receiveId\":\"\",\"sessionId\":\"408cc5c5ce3967f849859d1cd11000ab1cf34729\",\"shopId\":\"99998\",\"skuId\":\"204906489299783199\",\"spuId\":\"204906489299783199\"}"
,
MCoffeeAddGoodsRequestVo
.
class
));
}
}
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