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
faa278b6
Commit
faa278b6
authored
Jun 04, 2021
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
麦咖啡买赠
parent
840c4035
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
277 additions
and
215 deletions
+277
-215
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/adapter/OrderSdkAdapter.java
+3
-0
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/constant/RedisKeyConstant.java
+4
-0
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/ShoppingCartBaseService.java
+16
-0
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/impl/ShoppingCartBaseServiceImpl.java
+49
-0
order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
+4
-0
order-application-service/src/main/java/cn/freemud/entities/vo/ProductVo.java
+5
-0
order-application-service/src/main/java/cn/freemud/service/impl/MCCafeOrderServiceImpl.java
+0
-20
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartMccafeAdapter.java
+14
-75
shopping-cart-application-service/src/main/java/cn/freemud/controller/MCoffeeShoppingCartController.java
+9
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ActivityList.java
+7
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
+47
-2
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+0
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/BuySendCalculation.java
+95
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
+24
-32
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+0
-20
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
+0
-66
No files found.
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/adapter/OrderSdkAdapter.java
View file @
faa278b6
...
@@ -3162,6 +3162,9 @@ public class OrderSdkAdapter {
...
@@ -3162,6 +3162,9 @@ public class OrderSdkAdapter {
if
(
StringUtils
.
isNotBlank
(
product
.
getSplitIndex
())){
if
(
StringUtils
.
isNotBlank
(
product
.
getSplitIndex
())){
extInfo
.
setSplitIndex
(
product
.
getSplitIndex
());
extInfo
.
setSplitIndex
(
product
.
getSplitIndex
());
}
}
if
(
product
.
getIsSendGoods
()){
extInfo
.
setIsSendGoods
(
true
);
}
extInfo
.
setStapleFood
(
product
.
getStapleFood
());
extInfo
.
setStapleFood
(
product
.
getStapleFood
());
extInfo
.
setOriginalGoodsUid
(
product
.
getOriginalGoodsUid
());
extInfo
.
setOriginalGoodsUid
(
product
.
getOriginalGoodsUid
());
...
...
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/constant/RedisKeyConstant.java
View file @
faa278b6
...
@@ -21,6 +21,10 @@ public class RedisKeyConstant {
...
@@ -21,6 +21,10 @@ public class RedisKeyConstant {
/**
/**
* 用户购物车在redis的key前缀
* 用户购物车在redis的key前缀
*/
*/
public
final
static
String
SAAS_SHOPPINGCART_SENDGOODS_KEY_PREFIX
=
"saas:user:info:cart:sendgoods:"
;
/**
* 用户购物车在redis的key前缀
*/
public
final
static
String
SAAS_SHOPPINGCART_COUPON_KEY_PREFIX
=
"saas:user:info:cart:coupon:"
;
public
final
static
String
SAAS_SHOPPINGCART_COUPON_KEY_PREFIX
=
"saas:user:info:cart:coupon:"
;
/**
/**
* 用户购物车在redis的key前缀
* 用户购物车在redis的key前缀
...
...
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/ShoppingCartBaseService.java
View file @
faa278b6
...
@@ -82,6 +82,10 @@ public interface ShoppingCartBaseService {
...
@@ -82,6 +82,10 @@ public interface ShoppingCartBaseService {
*/
*/
BaseResponse
<
List
<
CartGoods
>>
getCartGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
);
BaseResponse
<
List
<
CartGoods
>>
getCartGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
);
default
BaseResponse
<
List
<
CartGoods
>>
getCartSendGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
return
null
;
}
/**
/**
* 设置购物车商品行集合信息
* 设置购物车商品行集合信息
*
*
...
@@ -100,6 +104,10 @@ public interface ShoppingCartBaseService {
...
@@ -100,6 +104,10 @@ public interface ShoppingCartBaseService {
return
null
;
return
null
;
}
}
default
BaseResponse
<
List
<
CartGoods
>>
setCartSendGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
,
long
expire
,
TimeUnit
timeUnit
)
{
return
null
;
}
/**
/**
* 设置购物车代金券信息
* 设置购物车代金券信息
*
*
...
@@ -140,6 +148,14 @@ public interface ShoppingCartBaseService {
...
@@ -140,6 +148,14 @@ public interface ShoppingCartBaseService {
default
BaseResponse
clearMCCafe
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
default
BaseResponse
clearMCCafe
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
return
null
;
return
null
;
}
}
/**
* 清除麦咖啡购物车赠送商品行信息
*
* @param cartParamDto
*/
default
BaseResponse
clearMCCafeSendGoods
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
return
null
;
}
/**
/**
...
...
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/impl/ShoppingCartBaseServiceImpl.java
View file @
faa278b6
...
@@ -111,6 +111,21 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -111,6 +111,21 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
}
}
@Override
@Override
public
BaseResponse
<
List
<
CartGoods
>>
getCartSendGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
String
redisKey
=
getShoppingCartSendGoodsKey
(
cartParamDto
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
List
<
CartGoods
>
cartGoodsList
=
operations
.
values
();
//对创建时间进行排序
cartGoodsList
.
sort
(
Comparator
.
comparingLong
(
CartGoods:
:
getCreateTimeMili
));
return
CartResponseUtil
.
success
(
cartGoodsList
);
}
catch
(
Exception
e
)
{
ErrorLog
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
trackingNo
,
e
.
getMessage
(),
"getCartGoodsList"
,
cartParamDto
,
e
,
Level
.
ERROR
);
return
null
;
}
}
@Override
public
BaseResponse
<
String
>
getCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
String
>
getCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
String
redisKey
=
getShoppingCartCouponCodeKey
(
cartParamDto
);
String
redisKey
=
getShoppingCartCouponCodeKey
(
cartParamDto
);
...
@@ -159,6 +174,24 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -159,6 +174,24 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
}
}
@Override
@Override
public
BaseResponse
<
List
<
CartGoods
>>
setCartSendGoodsList
(
CartParamDto
cartParamDto
,
String
trackingNo
,
long
expire
,
TimeUnit
timeUnit
)
{
try
{
String
redisKey
=
getShoppingCartSendGoodsKey
(
cartParamDto
);
BoundHashOperations
<
String
,
String
,
CartGoods
>
operations
=
redisTemplate
.
boundHashOps
(
redisKey
);
this
.
clear
(
cartParamDto
,
trackingNo
);
Map
<
String
,
CartGoods
>
cartGoodsMap
=
cartParamDto
.
getCartGoodsList
().
parallelStream
()
.
filter
(
k
->
StringUtils
.
isNotEmpty
(
k
.
getCartGoodsUid
()))
.
collect
(
Collectors
.
toMap
(
CartGoods:
:
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
operations
.
putAll
(
cartGoodsMap
);
operations
.
expire
(
expire
,
timeUnit
);
return
CartResponseUtil
.
success
();
}
catch
(
Exception
e
)
{
ErrorLog
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
trackingNo
,
e
.
getMessage
(),
"setCartSendGoodsList"
,
cartParamDto
,
e
,
Level
.
ERROR
);
return
null
;
}
}
@Override
public
BaseResponse
<
String
>
setCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
String
>
setCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
String
redisKey
=
getShoppingCartCouponCodeKey
(
cartParamDto
);
String
redisKey
=
getShoppingCartCouponCodeKey
(
cartParamDto
);
...
@@ -223,6 +256,7 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -223,6 +256,7 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
public
BaseResponse
clearMCCafe
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
clearMCCafe
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
redisTemplate
.
delete
(
this
.
getShoppingCartGoodsKey
(
cartParamDto
));
redisTemplate
.
delete
(
this
.
getShoppingCartGoodsKey
(
cartParamDto
));
redisTemplate
.
delete
(
this
.
getShoppingCartSendGoodsKey
(
cartParamDto
));
redisTemplate
.
delete
(
this
.
getShoppingCartGoodsAmountKey
(
cartParamDto
));
redisTemplate
.
delete
(
this
.
getShoppingCartGoodsAmountKey
(
cartParamDto
));
cartParamDto
.
setCouponType
(
SaveCouponType
.
COUPON
.
getCode
());
cartParamDto
.
setCouponType
(
SaveCouponType
.
COUPON
.
getCode
());
redisTemplate
.
delete
(
this
.
getShoppingCartCouponCodeKey
(
cartParamDto
));
redisTemplate
.
delete
(
this
.
getShoppingCartCouponCodeKey
(
cartParamDto
));
...
@@ -235,6 +269,17 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -235,6 +269,17 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
}
}
}
}
@Override
public
BaseResponse
clearMCCafeSendGoods
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
redisTemplate
.
delete
(
this
.
getShoppingCartSendGoodsKey
(
cartParamDto
));
return
new
BaseResponse
(
VersionUtils
.
VER_1
,
CartResponseConstant
.
SUCCESS
.
getCode
(),
CartResponseConstant
.
SUCCESS
.
getMessage
());
}
catch
(
Exception
e
)
{
ErrorLog
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
trackingNo
,
e
.
getMessage
(),
"clear"
,
cartParamDto
,
e
,
Level
.
ERROR
);
return
null
;
}
}
@Override
@Override
public
BaseResponse
clearMCCafeCouponByType
(
CartParamDto
cartParamDto
,
Integer
couponType
,
String
trackingNo
)
{
public
BaseResponse
clearMCCafeCouponByType
(
CartParamDto
cartParamDto
,
Integer
couponType
,
String
trackingNo
)
{
...
@@ -363,6 +408,10 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -363,6 +408,10 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
return
RedisKeyConstant
.
SAAS_SHOPPINGCART_KEY_PREFIX
+
cartParamDto
.
getPartnerId
()
+
"_"
+
cartParamDto
.
getStoreId
()
+
"_"
+
cartParamDto
.
getUserId
();
return
RedisKeyConstant
.
SAAS_SHOPPINGCART_KEY_PREFIX
+
cartParamDto
.
getPartnerId
()
+
"_"
+
cartParamDto
.
getStoreId
()
+
"_"
+
cartParamDto
.
getUserId
();
}
}
private
String
getShoppingCartSendGoodsKey
(
CartParamDto
cartParamDto
)
{
return
RedisKeyConstant
.
SAAS_SHOPPINGCART_SENDGOODS_KEY_PREFIX
+
cartParamDto
.
getPartnerId
()
+
"_"
+
cartParamDto
.
getStoreId
()
+
"_"
+
cartParamDto
.
getUserId
();
}
/**
/**
* 获取记录购物车coupon的key
* 获取记录购物车coupon的key
...
...
order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
View file @
faa278b6
...
@@ -2334,6 +2334,9 @@ public class OrderAdapter {
...
@@ -2334,6 +2334,9 @@ public class OrderAdapter {
if
(
StringUtils
.
isNotBlank
(
orderProductAddInfoDto
.
getSplitIndex
()))
{
if
(
StringUtils
.
isNotBlank
(
orderProductAddInfoDto
.
getSplitIndex
()))
{
productVo
.
setSplitIndex
(
orderProductAddInfoDto
.
getSplitIndex
());
productVo
.
setSplitIndex
(
orderProductAddInfoDto
.
getSplitIndex
());
}
}
if
(
null
!=
orderProductAddInfoDto
.
getIsSendGoods
()
&&
orderProductAddInfoDto
.
getIsSendGoods
())
{
productVo
.
setIsSendGoods
(
1
);
}
}
}
productVo
.
setOriginalPrice
(
productBean
.
getPrice
());
productVo
.
setOriginalPrice
(
productBean
.
getPrice
());
productVo
.
setFinalPrice
(
productBean
.
getSalePrice
());
productVo
.
setFinalPrice
(
productBean
.
getSalePrice
());
...
@@ -2769,6 +2772,7 @@ public class OrderAdapter {
...
@@ -2769,6 +2772,7 @@ public class OrderAdapter {
createOrderProductDemoDto
.
setClassificationId
(
cartGoodsDetailDto
.
getClassificationId
());
createOrderProductDemoDto
.
setClassificationId
(
cartGoodsDetailDto
.
getClassificationId
());
createOrderProductDemoDto
.
setClassificationName
(
cartGoodsDetailDto
.
getClassificationName
());
createOrderProductDemoDto
.
setClassificationName
(
cartGoodsDetailDto
.
getClassificationName
());
createOrderProductDemoDto
.
setSplitIndex
(
cartGoodsDetailDto
.
getSplitIndex
());
createOrderProductDemoDto
.
setSplitIndex
(
cartGoodsDetailDto
.
getSplitIndex
());
createOrderProductDemoDto
.
setIsSendGoods
(
cartGoodsDetailDto
.
getIsSendGoods
());
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsDetailDto
.
getSpecialExtra
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsDetailDto
.
getSpecialExtra
()))
{
createOrderProductDemoDto
.
setSpecialAttrs
(
new
ArrayList
<>());
createOrderProductDemoDto
.
setSpecialAttrs
(
new
ArrayList
<>());
cartGoodsDetailDto
.
getSpecialExtra
().
stream
().
forEach
(
o
->
{
cartGoodsDetailDto
.
getSpecialExtra
().
stream
().
forEach
(
o
->
{
...
...
order-application-service/src/main/java/cn/freemud/entities/vo/ProductVo.java
View file @
faa278b6
...
@@ -178,6 +178,11 @@ public class ProductVo {
...
@@ -178,6 +178,11 @@ public class ProductVo {
private
Boolean
isTableware
=
false
;
private
Boolean
isTableware
=
false
;
/**
/**
* 是否餐具商品
*/
private
Integer
isSendGoods
=
0
;
/**
* 商品单位
* 商品单位
*/
*/
private
String
unit
;
private
String
unit
;
...
...
order-application-service/src/main/java/cn/freemud/service/impl/MCCafeOrderServiceImpl.java
View file @
faa278b6
...
@@ -163,8 +163,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
...
@@ -163,8 +163,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
@Autowired
@Autowired
private
OrderServiceImpl
orderService
;
private
OrderServiceImpl
orderService
;
@Autowired
@Autowired
private
PromotionActivityClient
promotionActivityClient
;
@Autowired
private
ShoppingCartClient
shoppingCartClient
;
private
ShoppingCartClient
shoppingCartClient
;
@Autowired
@Autowired
private
CustomerApplicationClient
customerApplicationClient
;
private
CustomerApplicationClient
customerApplicationClient
;
...
@@ -173,17 +171,9 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
...
@@ -173,17 +171,9 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
@Autowired
@Autowired
private
BuriedPointService
buriedPointService
;
private
BuriedPointService
buriedPointService
;
@Autowired
@Autowired
private
CouponActivityService
couponActivityService
;
@Autowired
private
MessageNoticeAdapter
messageNoticeAdapter
;
private
MessageNoticeAdapter
messageNoticeAdapter
;
@Autowired
@Autowired
private
OrderAdapter
orderAdapter
;
private
OrderAdapter
orderAdapter
;
@Autowired
private
ActivityAdapter
activityAdapter
;
@Autowired
private
CouponAdapter
couponAdapter
;
@Autowired
private
MealCacheManager
mealCacheManager
;
//聚合订单服务
//聚合订单服务
@Autowired
@Autowired
private
OrderCenterSdkService
orderCenterSdkService
;
private
OrderCenterSdkService
orderCenterSdkService
;
...
@@ -195,8 +185,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
...
@@ -195,8 +185,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
@Autowired
@Autowired
private
StoreCenterService
storeCenterService
;
private
StoreCenterService
storeCenterService
;
@Autowired
@Autowired
private
DeliveryService
deliveryService
;
@Autowired
private
MQService
mqService
;
private
MQService
mqService
;
@Autowired
@Autowired
@Qualifier
(
"messageTemplatePushOrderService"
)
@Qualifier
(
"messageTemplatePushOrderService"
)
...
@@ -204,8 +192,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
...
@@ -204,8 +192,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
@Autowired
@Autowired
private
AssortmentOpenPlatformWxappManager
openPlatformWxappManager
;
private
AssortmentOpenPlatformWxappManager
openPlatformWxappManager
;
@Autowired
@Autowired
private
AssortmentOpenPlatformPartnerConfigManager
openPlatformPartnerConfigManager
;
@Autowired
private
AssortmentCustomerInfoManager
customerInfoManager
;
private
AssortmentCustomerInfoManager
customerInfoManager
;
@Autowired
@Autowired
private
CheckMCCafeOrder
checkMCCafeOrder
;
private
CheckMCCafeOrder
checkMCCafeOrder
;
...
@@ -216,12 +202,8 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
...
@@ -216,12 +202,8 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
@Autowired
@Autowired
private
PaymentNewService
paymentNewService
;
private
PaymentNewService
paymentNewService
;
@Autowired
@Autowired
private
ActivityApplicationClient
activityApplicationClient
;
@Autowired
private
AssortmentOpenPlatformWxappAuthorizerManager
wxappAuthorizerManager
;
private
AssortmentOpenPlatformWxappAuthorizerManager
wxappAuthorizerManager
;
@Autowired
@Autowired
private
CacheOpenPlatformPartnerWxappConfigManager
cacheOpenPlatformPartnerWxappConfigManager
;
@Autowired
private
OrderAdapterService
orderAdapterService
;
private
OrderAdapterService
orderAdapterService
;
@Autowired
@Autowired
private
AssortmentOpenPlatformPartnerManager
assortmentOpenPlatformPartnerManager
;
private
AssortmentOpenPlatformPartnerManager
assortmentOpenPlatformPartnerManager
;
...
@@ -237,8 +219,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
...
@@ -237,8 +219,6 @@ public class MCCafeOrderServiceImpl implements MCCafeOrderService {
private
OrderBaseService
orderBaseService
;
private
OrderBaseService
orderBaseService
;
@Autowired
@Autowired
private
CustomerExtendClient
customerExtendClient
;
private
CustomerExtendClient
customerExtendClient
;
@Autowired
private
CacheOpenApiEncryptManager
cacheOpenApiEncryptManager
;
private
static
MapperFacade
mapper
=
new
DefaultMapperFactory
.
Builder
().
build
().
getMapperFacade
();
private
static
MapperFacade
mapper
=
new
DefaultMapperFactory
.
Builder
().
build
().
getMapperFacade
();
...
...
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartMccafeAdapter.java
View file @
faa278b6
...
@@ -122,18 +122,16 @@ public class ShoppingCartMccafeAdapter {
...
@@ -122,18 +122,16 @@ public class ShoppingCartMccafeAdapter {
* @param cartGoods
* @param cartGoods
* @return
* @return
*/
*/
public
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
convertCartGoods2DetailGoodsList
(
CartGoods
cartGoods
,
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
>
apportionGoodsList
,
Map
<
String
,
String
>
duplicateGoodsMap
)
{
public
ShoppingCartGoodsDto
.
CartGoodsDetailDto
convertCartGoods2DetailGoodsList
(
CartGoods
cartGoods
,
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
>
apportionGoodsList
,
Map
<
String
,
String
>
duplicateGoodsMap
)
{
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
cartGoodsDetailDtos
=
new
ArrayList
<>();
if
(
StringUtils
.
isEmpty
(
cartGoods
.
getCouponCode
())
&&
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
().
equals
(
cartGoods
.
getGoodsType
()))
{
if
(
StringUtils
.
isEmpty
(
cartGoods
.
getCouponCode
())
&&
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
().
equals
(
cartGoods
.
getGoodsType
()))
{
return
cartGoodsDetailDtos
;
return
null
;
}
else
{
}
else
{
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
convertCartGoods2DetailGoods
(
cartGoods
,
apportionGoodsList
,
duplicateGoodsMap
);
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
convertCartGoods2DetailGoods
(
cartGoods
,
apportionGoodsList
,
duplicateGoodsMap
);
if
(
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
().
equals
(
cartGoods
.
getGoodsType
()))
{
if
(
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
().
equals
(
cartGoods
.
getGoodsType
()))
{
cartGoodsDetailDto
.
setComboProducts
(
this
.
convertComboxGoods2DetailGoods
(
cartGoods
,
cartGoodsDetailDto
.
getTotalDiscountAmount
()));
cartGoodsDetailDto
.
setComboProducts
(
this
.
convertComboxGoods2DetailGoods
(
cartGoods
,
cartGoodsDetailDto
.
getTotalDiscountAmount
()));
}
}
cartGoodsDetailDtos
.
add
(
cartGoodsDetailDto
)
;
return
cartGoodsDetailDto
;
}
}
return
cartGoodsDetailDtos
;
}
}
/**
/**
...
@@ -201,77 +199,18 @@ public class ShoppingCartMccafeAdapter {
...
@@ -201,77 +199,18 @@ public class ShoppingCartMccafeAdapter {
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
CartGoodsExtra
>
cartGoodsExtras
=
BeanUtil
.
convertBeans
(
cartGoods
.
getExtra
(),
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
CartGoodsExtra
::
new
);
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
CartGoodsExtra
>
cartGoodsExtras
=
BeanUtil
.
convertBeans
(
cartGoods
.
getExtra
(),
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
CartGoodsExtra
::
new
);
cartGoodsDetailDto
.
setExtraList
(
cartGoodsExtras
);
cartGoodsDetailDto
.
setExtraList
(
cartGoodsExtras
);
//61: 单品买M赠N \ 62:买赠 \ 6:买M赠N
//61: 单品买M赠N \ 62:买赠 \ 6:买M赠N
if
(
ObjectUtils
.
equals
(
ActivityTypeEnum
.
TYPE_61
.
getCode
(),
cartGoods
.
getActivityType
())
||
ObjectUtils
.
equals
(
ActivityTypeEnum
.
TYPE_6
.
getCode
(),
cartGoods
.
getActivityType
())
// if (ObjectUtils.equals(ActivityTypeEnum.TYPE_61.getCode(), cartGoods.getActivityType()) || ObjectUtils.equals(ActivityTypeEnum.TYPE_6.getCode(), cartGoods.getActivityType())
||
ObjectUtils
.
equals
(
ActivityTypeEnum
.
TYPE_62
.
getCode
(),
cartGoods
.
getActivityType
()))
{
// || ObjectUtils.equals(ActivityTypeEnum.TYPE_62.getCode(), cartGoods.getActivityType())) {
cartGoodsDetailDto
.
setTotalDiscountAmount
(
cartGoods
.
getOriginalAmount
().
intValue
()
-
cartGoods
.
getAmount
().
intValue
());
// cartGoodsDetailDto.setTotalDiscountAmount(cartGoods.getOriginalAmount().intValue() - cartGoods.getAmount().intValue());
}
else
{
// } else {
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
>
collect
=
apportionGoodsList
.
stream
().
filter
(
a
->
ObjectUtils
.
equals
(
cartGoods
.
getCartGoodsUid
(),
a
.
getCartGoodsUid
())).
collect
(
Collectors
.
toList
());
// List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods> collect = apportionGoodsList.stream().filter(a -> ObjectUtils.equals(cartGoods.getCartGoodsUid(), a.getCartGoodsUid())).collect(Collectors.toList());
//List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods> collect = apportionGoodsList.stream().filter(a -> ObjectUtils.equals(cartGoods.getSkuId(), a.getGoodsId()) || ObjectUtils.equals(cartGoods.getSpuId(), a.getGoodsId())).collect(Collectors.toList());
// //List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods> collect = apportionGoodsList.stream().filter(a -> ObjectUtils.equals(cartGoods.getSkuId(), a.getGoodsId()) || ObjectUtils.equals(cartGoods.getSpuId(), a.getGoodsId())).collect(Collectors.toList());
if
(
CollectionUtils
.
isNotEmpty
(
collect
))
{
// if (CollectionUtils.isNotEmpty(collect)) {
setTotalDiscountAndSalePrice
(
collect
,
cartGoodsDetailDto
,
duplicateGoodsMap
);
// setTotalDiscountAndSalePrice(collect, cartGoodsDetailDto, duplicateGoodsMap);
// 设置商品行,优惠活动均摊
// // 设置商品行,优惠活动均摊
setActivityDiscounts
(
collect
,
cartGoodsDetailDto
,
duplicateGoodsMap
);
// setActivityDiscounts(collect, cartGoodsDetailDto, duplicateGoodsMap);
}
// }
}
return
cartGoodsDetailDto
;
}
public
ShoppingCartGoodsDto
.
CartGoodsDetailDto
convertComboProduct2DetailGoods
(
CartGoods
.
ComboxGoods
cartGoods
)
{
// 设置基础信息
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
new
ShoppingCartGoodsDto
.
CartGoodsDetailDto
();
// cartGoodsDetailDto.setCartGoodsUid(cartGoods.getCartGoodsUid());
cartGoodsDetailDto
.
setTaxId
(
cartGoods
.
getTaxId
());
cartGoodsDetailDto
.
setTax
(
cartGoods
.
getTax
());
cartGoodsDetailDto
.
setSpuId
(
cartGoods
.
getSpuId
());
cartGoodsDetailDto
.
setSpuName
(
cartGoods
.
getSpuName
());
cartGoodsDetailDto
.
setSkuId
(
StringUtils
.
isEmpty
(
cartGoods
.
getSkuId
())
?
cartGoods
.
getSpuId
()
:
cartGoods
.
getSkuId
());
cartGoodsDetailDto
.
setSkuName
(
StringUtils
.
isEmpty
(
cartGoods
.
getSkuName
())
?
cartGoods
.
getSpuName
()
:
cartGoods
.
getSkuName
());
cartGoodsDetailDto
.
setOriginalPrice
(
cartGoods
.
getOriginalPrice
());
cartGoodsDetailDto
.
setSalePrice
(
cartGoods
.
getOriginalPrice
());
cartGoodsDetailDto
.
setPicture
(
cartGoods
.
getPic
());
cartGoodsDetailDto
.
setQty
(
cartGoods
.
getQty
());
// cartGoodsDetailDto.setActivityType(cartGoods.getActivityType());
// cartGoodsDetailDto.setNodeId(cartGoods.getNodeId());
// cartGoodsDetailDto.setCategoryName(cartGoods.getCategoryName());
// cartGoodsDetailDto.setCouponCode(cartGoods.getCouponCode());
// cartGoodsDetailDto.setStockLimit(cartGoods.isStockLimit());
cartGoodsDetailDto
.
setProductCode
(
cartGoods
.
getCustomerCode
());
cartGoodsDetailDto
.
setCustomerCode
(
cartGoods
.
getCustomerCode
());
cartGoodsDetailDto
.
setWeight
(
cartGoods
.
getWeight
());
cartGoodsDetailDto
.
setUnit
(
cartGoods
.
getUnit
());
cartGoodsDetailDto
.
setActivityDiscountsDtos
(
new
ArrayList
<>());
cartGoodsDetailDto
.
setTotalDiscountAmount
(
0
);
// cartGoodsDetailDto.setSpecialExtra(cartGoods.getSpecialExtra());
// cartGoodsDetailDto.setClassificationId(cartGoods.getClassificationId());
// cartGoodsDetailDto.setClassificationName(cartGoods.getClassificationName());
// if (GoodsTypeEnum.SET_MEAL_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
// cartGoodsDetailDto.setProductType(ProductType.SETMEAL.getCode());
// } else if (cartGoods.isWeightType()) {
// cartGoodsDetailDto.setProductType(ProductType.WEIGHT_PRODUCT.getCode());
// }
// }
//小料
if
(
CollectionUtils
.
isNotEmpty
(
cartGoods
.
getProductMaterialList
()))
{
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
MaterialGoods
>
materialList
=
new
ArrayList
<>(
0
);
for
(
CartGoods
.
MaterialGoods
materialGoods
:
cartGoods
.
getProductMaterialList
())
{
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
MaterialGoods
goods
=
new
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
MaterialGoods
();
goods
.
setSpuId
(
materialGoods
.
getSpuId
());
goods
.
setSpuName
(
materialGoods
.
getSpuName
());
goods
.
setOriginalPrice
(
materialGoods
.
getOriginalPrice
());
goods
.
setSalePrice
(
materialGoods
.
getFinalPrice
());
goods
.
setCustomerCode
(
materialGoods
.
getCustomerCode
());
goods
.
setProductCode
(
materialGoods
.
getCustomerCode
());
goods
.
setQty
(
cartGoods
.
getQty
());
goods
.
setTotalDiscountAmount
(
0
);
materialList
.
add
(
goods
);
}
cartGoodsDetailDto
.
setMaterialList
(
materialList
);
}
// 设置总优惠&售价
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
CartGoodsExtra
>
cartGoodsExtras
=
BeanUtil
.
convertBeans
(
cartGoods
.
getExtra
(),
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
CartGoodsExtra
::
new
);
cartGoodsDetailDto
.
setExtraList
(
cartGoodsExtras
);
return
cartGoodsDetailDto
;
return
cartGoodsDetailDto
;
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/controller/MCoffeeShoppingCartController.java
View file @
faa278b6
...
@@ -46,6 +46,15 @@ public class MCoffeeShoppingCartController {
...
@@ -46,6 +46,15 @@ public class MCoffeeShoppingCartController {
}
}
/**
/**
* 向购物车中添加商品
*/
@ApiAnnotation
(
logMessage
=
"selectSendGoods"
)
@PostMapping
(
value
=
"/selectSendGoods"
)
public
BaseResponse
selectSendGoods
(
@Validated
@LogParams
@RequestBody
MCoffeeAddGoodsRequestVo
request
)
{
return
shoppingCartMCoffeeService
.
selectSendGoods
(
request
);
}
/**
* 批量向购物车中添加商品
* 批量向购物车中添加商品
*/
*/
@ApiAnnotation
(
logMessage
=
"batchAddGoods"
)
@ApiAnnotation
(
logMessage
=
"batchAddGoods"
)
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ActivityList.java
View file @
faa278b6
...
@@ -53,10 +53,17 @@ public class ActivityList {
...
@@ -53,10 +53,17 @@ public class ActivityList {
private
String
agianDeduct
;
private
String
agianDeduct
;
private
List
<
SendGoods
>
sends
;
private
List
<
SendGoods
>
sends
;
private
List
<
McCafeSendGoods
>
mcCafeSendGoodsList
;
@Data
@Data
public
static
class
SendGoods
{
public
static
class
SendGoods
{
private
Integer
qty
;
private
Integer
qty
;
private
String
goodsName
;
private
String
goodsName
;
}
}
@Data
public
static
class
McCafeSendGoods
extends
CartGoods
{
private
Integer
isSelected
;
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
View file @
faa278b6
...
@@ -116,6 +116,11 @@ public class AssortmentSdkService {
...
@@ -116,6 +116,11 @@ public class AssortmentSdkService {
return
getNowBuyShoppingCart
(
buyType
,
partnerId
,
storeId
,
useId
,
sessionId
,
tableNumber
,
shoppingCartService
);
return
getNowBuyShoppingCart
(
buyType
,
partnerId
,
storeId
,
useId
,
sessionId
,
tableNumber
,
shoppingCartService
);
}
}
public
List
<
CartGoods
>
getShoppingCartSendGoods
(
String
partnerId
,
String
storeId
,
String
useId
,
String
sessionId
,
String
tableNumber
,
ShoppingCartBaseService
shoppingCartService
)
{
int
buyType
=
0
;
return
getNowBuyShoppingCart
(
buyType
,
partnerId
,
storeId
,
useId
,
sessionId
,
tableNumber
,
shoppingCartService
);
}
/**
/**
* 调用聚合sdk获取缓存中购物车信息
* 调用聚合sdk获取缓存中购物车信息
*
*
...
@@ -169,6 +174,12 @@ public class AssortmentSdkService {
...
@@ -169,6 +174,12 @@ public class AssortmentSdkService {
return
setNowBuyShoppingCart
(
buyType
,
partnerId
,
storeId
,
useId
,
cartGoodsList
,
sessionId
,
tableNumber
,
shoppingCartService
);
return
setNowBuyShoppingCart
(
buyType
,
partnerId
,
storeId
,
useId
,
cartGoodsList
,
sessionId
,
tableNumber
,
shoppingCartService
);
}
}
public
List
<
CartGoods
>
setShoppingCartSendGoods
(
String
partnerId
,
String
storeId
,
String
useId
,
List
<
CartGoods
>
cartGoodsList
,
String
sessionId
,
String
tableNumber
,
ShoppingCartBaseService
shoppingCartService
)
{
int
buyType
=
0
;
return
setNowBuyShoppingCartSendGoods
(
buyType
,
partnerId
,
storeId
,
useId
,
cartGoodsList
,
sessionId
,
tableNumber
,
shoppingCartService
);
}
/**
/**
* 调用聚合sdk设置缓存中购物车信息
* 调用聚合sdk设置缓存中购物车信息
*
*
...
@@ -200,6 +211,24 @@ public class AssortmentSdkService {
...
@@ -200,6 +211,24 @@ public class AssortmentSdkService {
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
}
}
public
List
<
CartGoods
>
setNowBuyShoppingCartSendGoods
(
int
buyType
,
String
partnerId
,
String
storeId
,
String
useId
,
List
<
CartGoods
>
cartGoodsList
,
String
sessionId
,
String
tableNumber
,
ShoppingCartBaseService
shoppingCartService
)
{
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartParamDto
cartParamDto
=
getCartParamDto
(
partnerId
,
storeId
,
useId
);
cartParamDto
.
setSessionId
(
sessionId
);
cartParamDto
.
setTableNumber
(
tableNumber
);
cartParamDto
.
setUserId
(
useId
);
//立即购买==1 ,设置新的缓存key
if
(
buyType
==
ShoppingCartConstant
.
NOW_BUY_TYPE
)
{
cartParamDto
.
setBuyType
(
buyType
);
}
cartParamDto
.
setCartGoodsList
(
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
cartGoodsList
),
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
class
));
BaseResponse
<
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
>>
baseResponse
=
shoppingCartService
.
setCartSendGoodsList
(
cartParamDto
,
LogThreadLocal
.
getTrackingNo
(),
3
,
TimeUnit
.
DAYS
);
if
(
baseResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
baseResponse
.
getCode
()))
{
return
null
;
}
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
}
/**
/**
* 调用聚合sdk设置缓存中购物车代金券
* 调用聚合sdk设置缓存中购物车代金券
*
*
...
@@ -208,7 +237,7 @@ public class AssortmentSdkService {
...
@@ -208,7 +237,7 @@ public class AssortmentSdkService {
* @param useId
* @param useId
* @return
* @return
*/
*/
public
List
<
CartGoods
>
setShoppingCartCouponCode
(
String
partnerId
,
String
storeId
,
String
useId
,
String
couponCode
,
ShoppingCartBaseService
shoppingCartService
,
Integer
type
)
{
public
String
setShoppingCartCouponCode
(
String
partnerId
,
String
storeId
,
String
useId
,
String
couponCode
,
ShoppingCartBaseService
shoppingCartService
,
Integer
type
)
{
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartParamDto
cartParamDto
=
getCartParamDto
(
partnerId
,
storeId
,
useId
);
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartParamDto
cartParamDto
=
getCartParamDto
(
partnerId
,
storeId
,
useId
);
cartParamDto
.
setCouponCode
(
couponCode
);
cartParamDto
.
setCouponCode
(
couponCode
);
cartParamDto
.
setCouponType
(
type
);
cartParamDto
.
setCouponType
(
type
);
...
@@ -217,7 +246,7 @@ public class AssortmentSdkService {
...
@@ -217,7 +246,7 @@ public class AssortmentSdkService {
return
null
;
return
null
;
}
}
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
return
baseResponse
.
getResult
(
);
}
}
/**
/**
...
@@ -337,6 +366,22 @@ public class AssortmentSdkService {
...
@@ -337,6 +366,22 @@ public class AssortmentSdkService {
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
}
}
public
List
<
CartGoods
>
getNowBuyShoppingCartSendGoods
(
int
buyType
,
String
partnerId
,
String
storeId
,
String
useId
,
String
sessionId
,
String
tableNumber
,
ShoppingCartBaseService
shoppingCartService
)
{
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartParamDto
cartParamDto
=
getCartParamDto
(
partnerId
,
storeId
,
useId
);
cartParamDto
.
setSessionId
(
sessionId
);
cartParamDto
.
setTableNumber
(
tableNumber
);
cartParamDto
.
setUserId
(
useId
);
if
(
buyType
==
ShoppingCartConstant
.
NOW_BUY_TYPE
)
{
cartParamDto
.
setBuyType
(
buyType
);
}
// 根据不同点餐类型获取不同购物车实例
BaseResponse
<
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
>>
baseResponse
=
shoppingCartService
.
getCartGoodsList
(
cartParamDto
,
LogThreadLocal
.
getTrackingNo
());
if
(
baseResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
baseResponse
.
getCode
())
||
CollectionUtils
.
isEmpty
(
baseResponse
.
getResult
()))
{
return
new
ArrayList
<>();
}
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CartGoods
.
class
);
}
/**
/**
* 调用聚合sdk更新商品行数量信息
* 调用聚合sdk更新商品行数量信息
*
*
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
faa278b6
This diff is collapsed.
Click to expand it.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/BuySendCalculation.java
0 → 100644
View file @
faa278b6
package
cn
.
freemud
.
service
.
impl
.
mcoffee
.
calculation
;
import
cn.freemud.adapter.ShoppingCartMccafeAdapter
;
import
cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.ActivityList
;
import
cn.freemud.entities.vo.ActivityTip
;
import
cn.freemud.entities.vo.CartGoods
;
import
cn.freemud.entities.vo.ShoppingCartGoodsResponseVo
;
import
cn.freemud.enums.ActivityTypeEnum
;
import
com.google.common.base.Functions
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Service
public
class
BuySendCalculation
{
@Autowired
private
ShoppingCartMccafeAdapter
shoppingCartMccafeAdapter
;
public
void
updateBuySendActivityTip
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
List
<
CartGoods
>
cartSendGoodsList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getActivityPrompts
()))
{
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ActivityPrompt
>
activityPromptList
=
calculationDiscountResult
.
getActivityPrompts
().
stream
().
filter
(
o
->
ActivityTypeEnum
.
TYPE_230
.
getCode
().
equals
(
o
.
getActivityType
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
activityPromptList
))
{
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ActivityPrompt
activityPrompt
=
activityPromptList
.
get
(
0
);
ActivityTip
activityTip
=
shoppingCartGoodsResponseVo
.
getActivityTip
();
if
(
activityTip
==
null
)
{
activityTip
=
new
ActivityTip
();
shoppingCartGoodsResponseVo
.
setActivityTip
(
activityTip
);
}
if
(
CollectionUtils
.
isEmpty
(
activityTip
.
getActivityList
()))
{
activityTip
.
setActivityList
(
new
ArrayList
<
ActivityList
>());
}
ActivityList
activityList
=
new
ActivityList
();
activityList
.
setTipType
(
activityPrompt
.
getActivityType
());
activityList
.
setSatisfy
(
activityPrompt
.
getThresholdAmount
().
toString
());
if
(
activityPrompt
.
getThresholdAmount
()
>
activityPrompt
.
getTotalAmount
())
{
activityList
.
setMissing
(
String
.
valueOf
(
activityPrompt
.
getThresholdAmount
()
-
activityPrompt
.
getTotalAmount
()));
activityList
.
setAgainBuy
(
String
.
valueOf
(
activityPrompt
.
getThresholdAmount
()
-
activityPrompt
.
getTotalAmount
()));
}
if
(
CollectionUtils
.
isNotEmpty
(
activityPrompt
.
getSendGoods
()))
{
if
(
CollectionUtils
.
isEmpty
(
cartSendGoodsList
))
{
cartSendGoodsList
=
new
ArrayList
<>();
}
Map
<
String
,
CartGoods
>
map
=
cartSendGoodsList
.
stream
().
collect
(
Collectors
.
toMap
(
CartGoods:
:
getSpuId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
List
<
ActivityList
.
McCafeSendGoods
>
mcCafeSendGoodsList
=
activityPrompt
.
getSendGoods
().
stream
().
map
(
o
->
{
ActivityList
.
McCafeSendGoods
mcCafeSendGoods
=
new
ActivityList
.
McCafeSendGoods
();
mcCafeSendGoods
.
setGoodsId
(
o
.
getGoodsId
());
mcCafeSendGoods
.
setSpuName
(
o
.
getGoodsName
());
mcCafeSendGoods
.
setQty
(
o
.
getSendNumber
());
if
(
map
.
get
(
o
.
getGoodsId
())
!=
null
)
{
mcCafeSendGoods
.
setIsSelected
(
1
);
}
return
mcCafeSendGoods
;
}).
collect
(
Collectors
.
toList
());
activityList
.
setMcCafeSendGoodsList
(
mcCafeSendGoodsList
);
}
else
{
activityList
.
setMcCafeSendGoodsList
(
new
ArrayList
<
ActivityList
.
McCafeSendGoods
>());
}
activityTip
.
getActivityList
().
add
(
activityList
);
}
}
}
public
void
updateBuySendGoods
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
ShoppingCartGoodsDto
shoppingCartGoodsDto
,
List
<
CartGoods
>
cartSendGoodsList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getSendGoods
()))
{
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendActivityList
=
calculationDiscountResult
.
getSendGoods
().
stream
().
filter
(
o
->
ActivityTypeEnum
.
TYPE_230
.
getCode
().
equals
(
o
.
getActivityType
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
sendActivityList
))
{
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
sendActivity
=
sendActivityList
.
get
(
0
);
if
(
CollectionUtils
.
isNotEmpty
(
sendActivity
.
getSendGoods
())
&&
CollectionUtils
.
isNotEmpty
(
cartSendGoodsList
))
{
Map
<
String
,
CartGoods
>
map
=
cartSendGoodsList
.
stream
().
collect
(
Collectors
.
toMap
(
CartGoods:
:
getSpuId
,
Functions
.
identity
(),
(
k1
,
k2
)
->
k1
));
sendActivity
.
getSendGoods
().
forEach
(
o
->
{
CartGoods
cartGoods
=
map
.
get
(
o
.
getGoodsId
());
if
(
null
!=
cartGoods
)
{
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
shoppingCartMccafeAdapter
.
convertCartGoods2DetailGoodsList
(
cartGoods
,
null
,
null
);
cartGoodsDetailDto
.
setOriginalPrice
(
0
l
);
cartGoodsDetailDto
.
setSalePrice
(
0
l
);
cartGoodsDetailDto
.
setIsSendGoods
(
true
);
shoppingCartGoodsDto
.
getProducts
().
add
(
cartGoodsDetailDto
);
}
});
}
}
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
View file @
faa278b6
...
@@ -19,9 +19,11 @@ import cn.freemud.interceptor.ServiceException;
...
@@ -19,9 +19,11 @@ import cn.freemud.interceptor.ServiceException;
import
cn.freemud.service.CommonService
;
import
cn.freemud.service.CommonService
;
import
cn.freemud.service.impl.ItemServiceImpl
;
import
cn.freemud.service.impl.ItemServiceImpl
;
import
cn.freemud.service.thirdparty.ActivityClient
;
import
cn.freemud.service.thirdparty.ActivityClient
;
import
cn.freemud.utils.ExceptionUtils
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.PropertyConvertUtil
;
import
cn.freemud.utils.PropertyConvertUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.freemud.application.sdk.api.log.
Error
Log
;
import
com.freemud.application.sdk.api.log.
Api
Log
;
import
com.freemud.application.sdk.api.log.LogThreadLocal
;
import
com.freemud.application.sdk.api.log.LogThreadLocal
;
import
com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest
;
import
com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest
;
import
com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse
;
import
com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse
;
...
@@ -32,11 +34,13 @@ import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailRe
...
@@ -32,11 +34,13 @@ import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailRe
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -55,6 +59,7 @@ import java.util.stream.Collectors;
...
@@ -55,6 +59,7 @@ import java.util.stream.Collectors;
*/
*/
@Service
@Service
@Slf4j
public
class
CalculationServiceImpl
{
public
class
CalculationServiceImpl
{
...
@@ -67,11 +72,8 @@ public class CalculationServiceImpl {
...
@@ -67,11 +72,8 @@ public class CalculationServiceImpl {
@Autowired
@Autowired
private
ActivityClient
activityClient
;
private
ActivityClient
activityClient
;
@Autowired
@Autowired
private
ActivityAdapter
activityAdapter
;
@Autowired
private
ItemServiceImpl
itemService
;
private
ItemServiceImpl
itemService
;
@Autowired
@Autowired
private
TimeSaleCalculation
timeSaleCalculation
;
private
TimeSaleCalculation
timeSaleCalculation
;
@Autowired
@Autowired
...
@@ -85,6 +87,8 @@ public class CalculationServiceImpl {
...
@@ -85,6 +87,8 @@ public class CalculationServiceImpl {
private
MaterialCalculation
materialCalculation
;
private
MaterialCalculation
materialCalculation
;
@Autowired
@Autowired
private
ShoppingCartMccafeAdapter
shoppingCartMccafeAdapter
;
private
ShoppingCartMccafeAdapter
shoppingCartMccafeAdapter
;
@Autowired
private
BuySendCalculation
buySendCalculation
;
/**
/**
* 更新购物车行优惠信息
* 更新购物车行优惠信息
...
@@ -93,7 +97,7 @@ public class CalculationServiceImpl {
...
@@ -93,7 +97,7 @@ public class CalculationServiceImpl {
boolean
isMember
,
String
menuType
,
String
receiveId
,
String
couponCode
,
boolean
isMember
,
String
menuType
,
String
receiveId
,
String
couponCode
,
List
<
CartGoods
>
cartGoodsList
,
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
,
List
<
CartGoods
>
cartGoodsList
,
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
,
List
<
ShoppingCartInfoRequestVo
.
SendGoods
>
sendGoodsList
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
List
<
ShoppingCartInfoRequestVo
.
SendGoods
>
sendGoodsList
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
Long
payCardFee
)
{
Long
payCardFee
,
List
<
CartGoods
>
cartSendGoodsList
)
{
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
menuType
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
menuType
);
...
@@ -116,6 +120,10 @@ public class CalculationServiceImpl {
...
@@ -116,6 +120,10 @@ public class CalculationServiceImpl {
//加料
//加料
materialCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscount
,
cartGoodsList
);
materialCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscount
,
cartGoodsList
);
//买赠
buySendCalculation
.
updateBuySendActivityTip
(
calculationDiscount
,
shoppingCartGoodsResponseVo
,
cartSendGoodsList
);
return
calculationDiscount
;
return
calculationDiscount
;
}
}
...
@@ -157,7 +165,7 @@ public class CalculationServiceImpl {
...
@@ -157,7 +165,7 @@ public class CalculationServiceImpl {
try
{
try
{
activityCalculationDiscountResponseDto
=
activityClient
.
calculationDiscountSharing
(
discountRequest
);
activityCalculationDiscountResponseDto
=
activityClient
.
calculationDiscountSharing
(
discountRequest
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
ErrorLog
.
printErrorLog
(
"calculation_discount_error"
,
"/calculation/discount/sharding"
,
discountRequest
,
ex
);
log
.
error
(
"calculation_discount_error "
+
"/calculation/discount/sharding "
+
JSON
.
toJSONString
(
discountRequest
)
+
" "
+
ExceptionUtils
.
getExceptionInfo
(
ex
)
);
throw
new
ServiceException
(
ResponseResult
.
OPERATE_TOO_OFTEN
);
throw
new
ServiceException
(
ResponseResult
.
OPERATE_TOO_OFTEN
);
}
}
//优惠券互斥
//优惠券互斥
...
@@ -172,7 +180,9 @@ public class CalculationServiceImpl {
...
@@ -172,7 +180,9 @@ public class CalculationServiceImpl {
}
}
public
void
updateShoppingCartGoodsApportion
(
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
ShoppingCartGoodsDto
shoppingCartGoodsDto
,
CreateOrderVo
.
PremiumExchangeActivity
premiumExchangeActivity
,
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
){
public
void
updateShoppingCartGoodsApportion
(
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
ShoppingCartGoodsDto
shoppingCartGoodsDto
,
CreateOrderVo
.
PremiumExchangeActivity
premiumExchangeActivity
,
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
,
List
<
CartGoods
>
cartSendGoodsList
){
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
cartGoodsDetailDtoList
=
CollectionUtils
.
isEmpty
(
shoppingCartGoodsDto
.
getProducts
())
?
new
ArrayList
<>()
:
shoppingCartGoodsDto
.
getProducts
();
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
cartGoodsDetailDtoList
=
CollectionUtils
.
isEmpty
(
shoppingCartGoodsDto
.
getProducts
())
?
new
ArrayList
<>()
:
shoppingCartGoodsDto
.
getProducts
();
List
<
ShareDiscountActivityDto
>
shareDiscountActivityDtoList
=
CollectionUtils
.
isEmpty
(
shoppingCartGoodsDto
.
getShareDiscountActivityDtos
())
?
new
ArrayList
<>()
:
shoppingCartGoodsDto
.
getShareDiscountActivityDtos
();
List
<
ShareDiscountActivityDto
>
shareDiscountActivityDtoList
=
CollectionUtils
.
isEmpty
(
shoppingCartGoodsDto
.
getShareDiscountActivityDtos
())
?
new
ArrayList
<>()
:
shoppingCartGoodsDto
.
getShareDiscountActivityDtos
();
...
@@ -198,13 +208,14 @@ public class CalculationServiceImpl {
...
@@ -198,13 +208,14 @@ public class CalculationServiceImpl {
calculationDiscountResult
==
null
?
new
ArrayList
<>()
:
calculationDiscountResult
.
getApportionGoods
();
calculationDiscountResult
==
null
?
new
ArrayList
<>()
:
calculationDiscountResult
.
getApportionGoods
();
Map
<
String
,
String
>
duplicateGoodsMap
=
new
HashMap
<>();
Map
<
String
,
String
>
duplicateGoodsMap
=
new
HashMap
<>();
cartGoodsList
.
stream
().
filter
(
cartGoods
->
!
StringUtils
.
equals
(
cartGoods
.
getSkuId
(),
"9999"
)).
collect
(
Collectors
.
groupingBy
(
CartGoods:
:
getGoodsId
,
Collectors
.
counting
())).
forEach
((
goodsId
,
count
)
->
{
cartGoodsList
.
stream
().
filter
(
cartGoods
->
!
StringUtils
.
equals
(
cartGoods
.
getSkuId
(),
"9999"
))
duplicateGoodsMap
.
put
(
goodsId
,
String
.
format
(
"%s,0"
,
count
));
.
collect
(
Collectors
.
groupingBy
(
CartGoods:
:
getGoodsId
,
Collectors
.
counting
()))
});
.
forEach
((
goodsId
,
count
)
->
{
duplicateGoodsMap
.
put
(
goodsId
,
String
.
format
(
"%s,0"
,
count
));
});
for
(
int
i
=
0
,
len
=
cartGoodsList
.
size
();
i
<
len
;
i
++)
{
for
(
int
i
=
0
,
len
=
cartGoodsList
.
size
();
i
<
len
;
i
++)
{
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
cartGoodsDetailDtos
=
shoppingCartMccafeAdapter
.
convertCartGoods2DetailGoodsList
(
cartGoods
,
apportionGoodsList
,
duplicateGoodsMap
);
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
shoppingCartMccafeAdapter
.
convertCartGoods2DetailGoodsList
(
cartGoods
,
apportionGoodsList
,
duplicateGoodsMap
);
cartGoodsDetailDtoList
.
add
All
(
cartGoodsDetailDtos
);
cartGoodsDetailDtoList
.
add
(
cartGoodsDetailDto
);
}
}
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
=
calculationDiscountResult
==
null
?
new
ArrayList
<>()
:
calculationDiscountResult
.
getDiscounts
();
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
=
calculationDiscountResult
==
null
?
new
ArrayList
<>()
:
calculationDiscountResult
.
getDiscounts
();
List
<
ActivityDiscountsDto
>
activityDiscountsDtos
=
shoppingCartGoodsDto
.
getActivityDiscountsDtos
()
==
null
?
new
ArrayList
<>()
:
shoppingCartGoodsDto
.
getActivityDiscountsDtos
();
List
<
ActivityDiscountsDto
>
activityDiscountsDtos
=
shoppingCartGoodsDto
.
getActivityDiscountsDtos
()
==
null
?
new
ArrayList
<>()
:
shoppingCartGoodsDto
.
getActivityDiscountsDtos
();
...
@@ -225,19 +236,6 @@ public class CalculationServiceImpl {
...
@@ -225,19 +236,6 @@ public class CalculationServiceImpl {
}
}
}
}
//订单级别券优惠
// for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults discount : calculationDiscountResult.getCouponDiscounts()) {
// int discountAmount = (discount.getDiscountAmount() == null) ? 0 : discount.getDiscountAmount();
// Integer discountType = discount.getActivityType();
// if (discountType != null && discountAmount > 0) {
// ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
// activityDiscountsDto.setActivityCode(discount.getCouponCode());
// activityDiscountsDto.setActivityName(discount.getActivityName());
// activityDiscountsDto.setActivityType(discountType);
// activityDiscountsDto.setDiscountAmount(0 - discountAmount);
// activityDiscountsDtos.add(activityDiscountsDto);
// }
// }
//过滤出加价购
//过滤出加价购
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
addMoneyDiscounts
=
discounts
.
stream
().
filter
(
discount
->
ActivityTypeEnum
.
TYPE_81
.
getCode
().
equals
(
discount
.
getType
())).
collect
(
Collectors
.
toList
());
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
addMoneyDiscounts
=
discounts
.
stream
().
filter
(
discount
->
ActivityTypeEnum
.
TYPE_81
.
getCode
().
equals
(
discount
.
getType
())).
collect
(
Collectors
.
toList
());
...
@@ -268,18 +266,12 @@ public class CalculationServiceImpl {
...
@@ -268,18 +266,12 @@ public class CalculationServiceImpl {
//限时特价
//限时特价
timeSaleCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscountResult
,
shoppingCartGoodsDto
);
timeSaleCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscountResult
,
shoppingCartGoodsDto
);
CouponPromotionVO
couponPromotionVO
=
new
CouponPromotionVO
();
// couponPromotionVO.setPartnerId("1206");
// couponPromotionVO.setUserId(userId);
// couponPromotionVO.setStoreId(storeId);
// couponPromotionVO.setCouponCode(null);
// couponPromotionVO.setOrderType(orderType);
// couponPromotionVO.setFlg(CouponFlag.YES.getCode());
//优惠券
//优惠券
couponDiscountCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscountResult
,
shoppingCartGoodsDto
,
shoppingCartInfoRequestVo
);
couponDiscountCalculation
.
updateShoppingCartGoodsApportion
(
calculationDiscountResult
,
shoppingCartGoodsDto
,
shoppingCartInfoRequestVo
);
setMealCalculation
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
);
setMealCalculation
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
);
buySendCalculation
.
updateBuySendGoods
(
calculationDiscountResult
,
shoppingCartGoodsDto
,
cartSendGoodsList
);
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
faa278b6
...
@@ -302,28 +302,8 @@ public class CouponDiscountCalculation {
...
@@ -302,28 +302,8 @@ public class CouponDiscountCalculation {
}
}
}
}
}
}
}
}
// public void getCoupon(CouponPromotionVO couponPromotionVO, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
// // 用户选择了查询优惠券信息
// if (couponPromotionVO != null && ObjectUtils.equals(CouponFlag.YES.getCode(), couponPromotionVO.getFlg())) {
// // 构建可用不可用优惠券
// ActivityClassifyCouponBean activityClassifyCouponBean = availableCoupon(couponPromotionVO.getPartnerId()
// , couponPromotionVO.getUserId(), couponPromotionVO.getStoreId(), couponPromotionVO.getCouponCode(), couponPromotionVO.getOrderType(),cartGoodsList);
// if (Objects.equals(activityClassifyCouponBean, null)) {
// // 构建一个空得订单券信息
// activityClassifyCouponBean = new ActivityClassifyCouponBean();
// activityClassifyCouponBean.setCouponNum(0);
// activityClassifyCouponBean.setDisableCouponNum(0);
// activityClassifyCouponBean.setUsableCouponNum(0);
// activityClassifyCouponBean.setDisableCoupons(Lists.newArrayList());
// activityClassifyCouponBean.setUsableCoupons(Lists.newArrayList());
// }
// shoppingCartGoodsResponseVo.setAvailableCoupon(activityClassifyCouponBean);
// }
// }
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
View file @
faa278b6
...
@@ -102,23 +102,8 @@ public class SetMealCalculation {
...
@@ -102,23 +102,8 @@ public class SetMealCalculation {
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalAmount
()
+
materialPrice
);
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalAmount
()
+
materialPrice
);
}
}
// 套餐(固定商品)现价
// String toastMsg = getTotalAmount(cartGoods, productGroupAmount, numberMap, goodsMap);
// if (StringUtils.isNotEmpty(toastMsg)) {
// shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
// }
}
}
// long totalFinalPrice = setMealProducts.stream().mapToLong(product -> product.getFinalPrice() * product.getQty()).sum();
// long totalOriginalPrice = setMealProducts.stream().mapToLong(product -> product.getOriginalPrice() * product.getQty()).sum();
//总原价=促销优惠 - 套餐finalPrice + 套餐原价
// shoppingCartGoodsResponseVo.setOriginalTotalAmount(shoppingCartGoodsResponseVo.getOriginalTotalAmount() - totalFinalPrice + totalOriginalPrice);
//总现价=促销现总价 + 可选商品现总价
// shoppingCartGoodsResponseVo.setTotalAmount(shoppingCartGoodsResponseVo.getTotalAmount() + productGroupTotalAmount);
//总优惠=促销总优惠 + (套餐总原件 - 套餐总finalPrice - 可选商品总售价)
// shoppingCartGoodsResponseVo.setTotalDiscountAmount(shoppingCartGoodsResponseVo.getTotalDiscountAmount() + totalOriginalPrice - totalFinalPrice - productGroupTotalAmount);
}
}
...
@@ -144,57 +129,6 @@ public class SetMealCalculation {
...
@@ -144,57 +129,6 @@ public class SetMealCalculation {
cartGoodsDetailDtos
.
add
(
parentCartGoods
);
cartGoodsDetailDtos
.
add
(
parentCartGoods
);
}
}
}
}
// //订单级别,套餐优惠活动
// if (totalDiscountAmount > 0) {
// shoppingCartGoodsDto.getActivityDiscountsDtos().add(getActivityDiscountsDto(-totalDiscountAmount));
// }
}
private
ActivityDiscountsDto
getActivityDiscountsDto
(
Integer
totalDiscountAmount
)
{
ActivityDiscountsDto
activityDiscountsDto
=
new
ActivityDiscountsDto
();
activityDiscountsDto
.
setActivityCode
(
"setMeal"
);
activityDiscountsDto
.
setActivityName
(
"套餐商品优惠"
);
activityDiscountsDto
.
setActivityType
(
211
);
activityDiscountsDto
.
setDiscountAmount
(
totalDiscountAmount
);
return
activityDiscountsDto
;
}
/**
* 促销活动有份数限制时,计算当前商品行总现价
* 当超出份数限制,提示:该商品限 N 份优惠 超出按照原价计算哦
*
* @param cartGoods
* @param productGroupAmount
* @param numberMap
* @param goodsMap
* @return
*/
private
String
getTotalAmount
(
CartGoods
cartGoods
,
long
productGroupAmount
,
Map
<
String
,
Integer
>
numberMap
,
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsMap
)
{
if
(
goodsMap
.
isEmpty
()||
goodsMap
.
get
(
cartGoods
.
getGoodsId
()).
getDiscountAmount
()
==
0
)
{
cartGoods
.
setAmount
((
cartGoods
.
getFinalPrice
()
+
productGroupAmount
)
*
cartGoods
.
getQty
());
return
""
;
}
if
(
numberMap
.
get
(
cartGoods
.
getGoodsId
())
==
null
)
{
int
actualGoodsNumber
=
goodsMap
.
get
(
cartGoods
.
getGoodsId
()).
getDiscounts
().
stream
().
mapToInt
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
::
getActualGoodsNumber
)
.
min
().
orElse
(
goodsMap
.
get
(
cartGoods
.
getGoodsId
()).
getGoodsQuantity
());
numberMap
.
put
(
cartGoods
.
getGoodsId
(),
actualGoodsNumber
);
}
// 可优惠数量
Integer
number
=
numberMap
.
get
(
cartGoods
.
getGoodsId
());
if
(
number
>
0
)
{
Long
nowPrice
=
goodsMap
.
get
(
cartGoods
.
getGoodsId
()).
getNowPrice
();
//套餐固定商品价格
long
productComboxAmount
=
cartGoods
.
getQty
()
>
number
?
number
*
nowPrice
+
(
cartGoods
.
getQty
()
-
number
)
*
cartGoods
.
getFinalPrice
()
:
cartGoods
.
getQty
()
*
nowPrice
;
cartGoods
.
setAmount
(
productComboxAmount
+
productGroupAmount
*
cartGoods
.
getQty
());
//设置剩余优惠数量
numberMap
.
put
(
cartGoods
.
getGoodsId
(),
number
-
cartGoods
.
getQty
());
return
number
-
cartGoods
.
getQty
()
<
0
?
"该商品限"
+
goodsMap
.
get
(
cartGoods
.
getGoodsId
()).
getActualGoodsNumber
()
+
"份优惠 超出按照原价计算哦"
:
""
;
}
else
{
cartGoods
.
setAmount
((
cartGoods
.
getFinalPrice
()
+
productGroupAmount
)
*
cartGoods
.
getQty
());
return
"该商品限"
+
goodsMap
.
get
(
cartGoods
.
getGoodsId
()).
getActualGoodsNumber
()
+
"份优惠 超出按照原价计算哦"
;
}
}
}
}
}
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