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
d19d56aa
Commit
d19d56aa
authored
Sep 24, 2020
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
记录和读取上次使用的优惠券
parent
1a4e5269
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
13 deletions
+40
-13
order-application-service/src/test/java/cn/freemud/service/impl/MallOrderServiceImplTest.java
+17
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+22
-12
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+1
-1
No files found.
order-application-service/src/test/java/cn/freemud/service/impl/MallOrderServiceImplTest.java
View file @
d19d56aa
package
cn
.
freemud
.
service
.
impl
;
package
cn
.
freemud
.
service
.
impl
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.CreateOrderVo
;
import
cn.freemud.entities.vo.OrderAffirmRequestVO
;
import
cn.freemud.entities.vo.OrderAffirmRequestVO
;
import
cn.freemud.entities.vo.PaysuccessNoticeMessage
;
import
cn.freemud.entities.vo.PaysuccessNoticeMessage
;
import
cn.freemud.utils.ValidationCode
;
import
cn.freemud.utils.ValidationCode
;
import
com.alibaba.fastjson.JSON
;
import
com.freemud.application.sdk.api.ordercenter.enums.OrderClientType
;
import
com.freemud.application.sdk.api.ordercenter.request.OrderExtendedReq
;
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -24,6 +30,9 @@ public class MallOrderServiceImplTest {
...
@@ -24,6 +30,9 @@ public class MallOrderServiceImplTest {
@Autowired
@Autowired
private
MallOrderServiceImpl
mallOrderService
;
private
MallOrderServiceImpl
mallOrderService
;
@Autowired
private
MCCafeOrderServiceImpl
mcCafeOrderService
;
@Before
@Before
public
void
before
()
throws
Exception
{
public
void
before
()
throws
Exception
{
...
@@ -33,6 +42,14 @@ public class MallOrderServiceImplTest {
...
@@ -33,6 +42,14 @@ public class MallOrderServiceImplTest {
public
void
after
()
throws
Exception
{
public
void
after
()
throws
Exception
{
}
}
@Test
public
void
f1
()
{
mcCafeOrderService
.
createOrder
(
JSON
.
parseObject
(
"{\"channelType\":\"saas\",\"couponCode\":\"\",\"menuType\":\"saasdelivery\",\"needInvoice\":0,\"needTableware\":0,\"orderRemark\":\"\",\"orderType\":2,\"partnerId\":\"1206\",\"payChannelType\":1,\"receiveId\":\"3599568180562003060\",\"sessionId\":\"c4377678dbcbd6cdf6e7df86ea112b6f82723023\",\"shopId\":\"1450026\",\"takeMealFlag\":\"0\"}"
,
CreateOrderVo
.
class
),
new
StoreResponse
.
BizVO
(),
JSON
.
parseObject
(
"{\"activityDiscountsDtos\":[],\"deliveryAmount\":10,\"discountDeliveryAmount\":10,\"isDiscountDelivery\":false,\"originalTotalAmount\":4400,\"packageAmount\":0,\"products\":[{\"activityDiscountsDtos\":[],\"attributeNames\":\"{\\\"attributeNames\\\":\\\"\\\"}\",\"cartGoodsUid\":\"eb8c7260-8ecb-44d1-9234-8d8bed0b0875\",\"classificationId\":\"\",\"classificationName\":\"\",\"comboProducts\":[{\"attributeNames\":\"{\\\"attributeNames\\\":\\\"\\\"}\",\"customerCode\":\"501642\",\"extraList\":[],\"hasProductCoupon\":false,\"isFixedProduct\":false,\"materialList\":[],\"originalPrice\":1700,\"parentProductId\":\"184437853099519288\",\"picture\":\"https://picture.sandload.cn/1598678546485.png\",\"productType\":6,\"qty\":2,\"skuId\":\"184437494035639613\",\"skuName\":\"中杯热美式\",\"spuId\":\"184437494035639613\",\"spuName\":\"中杯热美式\",\"stockLimit\":false,\"tax\":0.01,\"taxId\":\"\",\"totalDiscountAmount\":0,\"unit\":\"\",\"weight\":0.0},{\"attributeNames\":\"{\\\"attributeNames\\\":\\\"\\\"}\",\"customerCode\":\"901290\",\"extraList\":[],\"hasProductCoupon\":false,\"isFixedProduct\":false,\"materialList\":[],\"originalPrice\":500,\"parentProductId\":\"184437853099519288\",\"picture\":\"https://picture.sandload.cn/1598677404074.png\",\"productType\":6,\"qty\":2,\"skuId\":\"184436294373469463\",\"skuName\":\"经典芝士蛋糕\",\"spuId\":\"184436294373469463\",\"spuName\":\"经典芝士蛋糕\",\"stockLimit\":false,\"tax\":0.01,\"taxId\":\"\",\"totalDiscountAmount\":0,\"unit\":\"\",\"weight\":0.0}],\"customerCode\":\"901280\",\"extraList\":[],\"hasProductCoupon\":false,\"materialList\":[],\"originalPrice\":4400,\"picture\":\"https://picture.sandload.cn/1598678861518.png\",\"productCode\":\"901280\",\"productType\":6,\"qty\":2,\"salePrice\":4400,\"skuId\":\"184437853099519288\",\"skuName\":\"早餐啡常搭\",\"spuId\":\"184437853099519288\",\"spuName\":\"早餐啡常搭\",\"stockLimit\":false,\"tax\":0.01,\"taxId\":\"\",\"totalDiscountAmount\":0,\"unit\":\"\",\"weight\":0.0}],\"shareDiscountActivityDtos\":[],\"totalAmount\":4400,\"totalDiscountAmount\":0}"
,
ShoppingCartGoodsDto
.
class
),
new
OrderExtendedReq
(),
OrderClientType
.
SAAS
,
"www"
);
}
@Test
@Test
public
void
testPaySuccess
()
{
public
void
testPaySuccess
()
{
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
d19d56aa
...
@@ -19,6 +19,7 @@ import cn.freemud.service.impl.FullSubtractionActivityServiceImpl;
...
@@ -19,6 +19,7 @@ import cn.freemud.service.impl.FullSubtractionActivityServiceImpl;
import
cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl
;
import
cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl
;
import
cn.freemud.service.impl.mcoffee.calculation.CouponDiscountCalculation
;
import
cn.freemud.service.impl.mcoffee.calculation.CouponDiscountCalculation
;
import
cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.CouponState
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo
;
import
cn.freemud.service.thirdparty.CustomerApplicationClient
;
import
cn.freemud.service.thirdparty.CustomerApplicationClient
;
...
@@ -37,6 +38,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
...
@@ -37,6 +38,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.ObjectUtils
;
...
@@ -297,6 +299,16 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -297,6 +299,16 @@ public class ShoppingCartMCoffeeServiceImpl {
Integer
orderType
=
shoppingCartInfoRequestVo
.
getOrderType
();
Integer
orderType
=
shoppingCartInfoRequestVo
.
getOrderType
();
String
receiveId
=
shoppingCartInfoRequestVo
.
getReceiveId
();
String
receiveId
=
shoppingCartInfoRequestVo
.
getReceiveId
();
// 获取购物车商品
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
sessionId
,
""
,
shoppingCartBaseService
);
// 如果购物车商品不为空, 则check购物车中所有商品
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
// check购物车中所有商品
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
cartGoodsList
);
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
}
/**
/**
* 如果couponCode为空,则从缓存里尝试获取
* 如果couponCode为空,则从缓存里尝试获取
...
@@ -304,25 +316,23 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -304,25 +316,23 @@ public class ShoppingCartMCoffeeServiceImpl {
*/
*/
if
(
StringUtils
.
isEmpty
(
couponCode
))
{
if
(
StringUtils
.
isEmpty
(
couponCode
))
{
couponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
);
couponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
);
//TODO 校验券是否可用,不可用要删除
if
(
StringUtils
.
isNotEmpty
(
couponCode
))
{
List
<
CouponState
>
couponStates
=
couponDiscountCalculation
.
buildAvailableCoupons
(
cartGoodsList
,
partnerId
,
storeId
,
Lists
.
newArrayList
(
couponCode
));
if
(
CollectionUtils
.
isNotEmpty
(
couponStates
))
{
if
(
Objects
.
equals
(
couponStates
.
get
(
0
).
getState
(),
CouponStateEnum
.
STATE_1
.
getCode
()))
{
couponCode
=
""
;
}
}
else
{
couponCode
=
""
;
}
}
}
else
{
}
else
{
if
(
"remove"
.
equals
(
couponCode
))
{
if
(
"remove"
.
equals
(
couponCode
))
{
couponCode
=
""
;
couponCode
=
""
;
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
""
,
shoppingCartBaseService
);
}
}
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
couponCode
,
shoppingCartBaseService
);
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
couponCode
,
shoppingCartBaseService
);
}
}
// 获取购物车商品
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
sessionId
,
""
,
shoppingCartBaseService
);
// 如果购物车商品不为空, 则check购物车中所有商品
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
// check购物车中所有商品
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
cartGoodsList
);
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
}
// 当couponCode不为空时,需参与价格计算
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
);
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
d19d56aa
...
@@ -279,7 +279,7 @@ public class CouponDiscountCalculation {
...
@@ -279,7 +279,7 @@ public class CouponDiscountCalculation {
p
rivate
List
<
CouponState
>
buildAvailableCoupons
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
storeId
,
List
<
String
>
couponCodes
)
{
p
ublic
List
<
CouponState
>
buildAvailableCoupons
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
storeId
,
List
<
String
>
couponCodes
)
{
// String appSecret = getAppSecret(partnerId);
// String appSecret = getAppSecret(partnerId);
// 最大15一提交
// 最大15一提交
int
maxNum
=
15
;
int
maxNum
=
15
;
...
...
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