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
8580f247
Commit
8580f247
authored
Jun 15, 2021
by
hanghang.wang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/qa' into qa
parents
5326727e
a696d78a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
349 additions
and
164 deletions
+349
-164
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
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/dto/ActivityCalculationDiscountResponseDto.java
+7
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ActivityList.java
+10
-1
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
+107
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
+0
-0
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/FreightCalculation.java
+54
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
+0
-66
shopping-cart-application-service/src/main/java/cn/freemud/utils/MoneyUtils.java
+20
-0
No files found.
assortment-ordercenter-sdk/src/main/java/com/freemud/sdk/api/assortment/order/adapter/OrderSdkAdapter.java
View file @
8580f247
...
@@ -3187,6 +3187,9 @@ public class OrderSdkAdapter {
...
@@ -3187,6 +3187,9 @@ public class OrderSdkAdapter {
if
(
null
!=
product
.
getProductGroupId
())
{
if
(
null
!=
product
.
getProductGroupId
())
{
extInfo
.
setProductGroupId
(
product
.
getProductGroupId
());
extInfo
.
setProductGroupId
(
product
.
getProductGroupId
());
}
}
if
(
null
!=
product
.
getIsSendGoods
()
&&
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 @
8580f247
...
@@ -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 @
8580f247
...
@@ -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 @
8580f247
...
@@ -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
);
...
@@ -161,6 +176,24 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -161,6 +176,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
.
clearMCCafeSendGoods
(
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
);
...
@@ -227,6 +260,7 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -227,6 +260,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
));
...
@@ -239,6 +273,17 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -239,6 +273,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
)
{
...
@@ -367,6 +412,10 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -367,6 +412,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 @
8580f247
...
@@ -2335,6 +2335,9 @@ public class OrderAdapter {
...
@@ -2335,6 +2335,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
());
...
@@ -2771,6 +2774,7 @@ public class OrderAdapter {
...
@@ -2771,6 +2774,7 @@ public class OrderAdapter {
createOrderProductDemoDto
.
setClassificationName
(
cartGoodsDetailDto
.
getClassificationName
());
createOrderProductDemoDto
.
setClassificationName
(
cartGoodsDetailDto
.
getClassificationName
());
createOrderProductDemoDto
.
setSplitIndex
(
cartGoodsDetailDto
.
getSplitIndex
());
createOrderProductDemoDto
.
setSplitIndex
(
cartGoodsDetailDto
.
getSplitIndex
());
createOrderProductDemoDto
.
setProductGroupId
(
cartGoodsDetailDto
.
getProductGroupId
());
createOrderProductDemoDto
.
setProductGroupId
(
cartGoodsDetailDto
.
getProductGroupId
());
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 @
8580f247
...
@@ -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
;
...
...
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartMccafeAdapter.java
View file @
8580f247
...
@@ -123,18 +123,16 @@ public class ShoppingCartMccafeAdapter {
...
@@ -123,18 +123,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
;
}
}
/**
/**
...
@@ -202,77 +200,18 @@ public class ShoppingCartMccafeAdapter {
...
@@ -202,77 +200,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 @
8580f247
...
@@ -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/dto/ActivityCalculationDiscountResponseDto.java
View file @
8580f247
...
@@ -169,6 +169,7 @@ public class ActivityCalculationDiscountResponseDto {
...
@@ -169,6 +169,7 @@ public class ActivityCalculationDiscountResponseDto {
* 已经优惠金额
* 已经优惠金额
*/
*/
private
Long
alreadyDiscountAmount
;
private
Long
alreadyDiscountAmount
;
private
Integer
alreadyDiscountThresholdAmount
;
private
Integer
activitySubType
;
private
Integer
activitySubType
;
private
List
<
SendGoods
>
sendGoods
;
private
List
<
SendGoods
>
sendGoods
;
}
}
...
@@ -256,6 +257,10 @@ public class ActivityCalculationDiscountResponseDto {
...
@@ -256,6 +257,10 @@ public class ActivityCalculationDiscountResponseDto {
*/
*/
private
String
goodsId
;
private
String
goodsId
;
/**
/**
* 0 原购物车商品 1 赠送商品 2 换购商品
*/
private
Integer
cartGoodType
;
/**
* 商品数量
* 商品数量
*/
*/
private
Integer
goodsQuantity
;
private
Integer
goodsQuantity
;
...
@@ -573,6 +578,8 @@ public class ActivityCalculationDiscountResponseDto {
...
@@ -573,6 +578,8 @@ public class ActivityCalculationDiscountResponseDto {
private
String
goodsId
;
private
String
goodsId
;
private
String
goodsName
;
private
String
goodsName
;
private
Integer
sendNumber
;
private
Integer
sendNumber
;
private
String
picture
;
private
Integer
originalPrice
;
}
}
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ActivityList.java
View file @
8580f247
...
@@ -43,7 +43,7 @@ public class ActivityList {
...
@@ -43,7 +43,7 @@ public class ActivityList {
private
String
deduct
;
private
String
deduct
;
//最高扣减金额
//最高扣减金额
private
String
maxDeduct
;
private
String
maxDeduct
;
//
最高扣减金额
//
已减
private
String
alreadyDecut
;
private
String
alreadyDecut
;
//还差
//还差
private
String
missing
;
private
String
missing
;
...
@@ -53,10 +53,19 @@ public class ActivityList {
...
@@ -53,10 +53,19 @@ 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
;
private
String
originalPriceStr
;
private
String
finalPriceStr
;
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
View file @
8580f247
...
@@ -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
getNowBuyShoppingCartSendGoods
(
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
.
getCartSendGoodsList
(
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 @
8580f247
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 @
8580f247
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
cn.freemud.utils.MoneyUtils
;
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
);
if
(
activityPrompt
.
getThresholdAmount
()
>
activityPrompt
.
getTotalAmount
())
{
return
;
}
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
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getThresholdAmount
()));
if
(
activityPrompt
.
getThresholdAmount
()
>
activityPrompt
.
getTotalAmount
())
{
activityList
.
setMissing
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getThresholdAmount
()
-
activityPrompt
.
getTotalAmount
()));
activityList
.
setAgainBuy
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getThresholdAmount
()
-
activityPrompt
.
getTotalAmount
()));
}
else
{
activityList
.
setMissing
(
"0"
);
activityList
.
setAgainBuy
(
"0"
);
}
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
());
mcCafeSendGoods
.
setPic
(
o
.
getPicture
());
mcCafeSendGoods
.
setOriginalPriceStr
(
MoneyUtils
.
parseFen2Yuan
(
o
.
getOriginalPrice
()));
mcCafeSendGoods
.
setFinalPriceStr
(
"0"
);
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
);
if
(
null
!=
cartGoodsDetailDto
)
{
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 @
8580f247
This diff is collapsed.
Click to expand it.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
8580f247
...
@@ -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/FreightCalculation.java
0 → 100644
View file @
8580f247
package
cn
.
freemud
.
service
.
impl
.
mcoffee
.
calculation
;
import
cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto
;
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
cn.freemud.utils.MoneyUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
public
class
FreightCalculation
{
public
void
updateBuySendActivityTip
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getActivityPrompts
()))
{
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ActivityPrompt
>
activityPromptList
=
calculationDiscountResult
.
getActivityPrompts
().
stream
().
filter
(
o
->
ActivityTypeEnum
.
TYPE_14
.
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
>());
}
if
(
activityPrompt
.
getAlreadyDiscountAmount
()
==
0
)
{
return
;
}
ActivityList
activityList
=
new
ActivityList
();
activityList
.
setTipType
(
activityPrompt
.
getActivityType
());
activityList
.
setSatisfy
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getAlreadyDiscountThresholdAmount
()));
activityList
.
setAlreadyDecut
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getAlreadyDiscountAmount
()));
activityList
.
setDeduct
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getAlreadyDiscountAmount
()));
activityList
.
setAgianDeduct
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getDiscountAmout
()
-
activityPrompt
.
getAlreadyDiscountAmount
()));
if
(
activityPrompt
.
getThresholdAmount
()
>
activityPrompt
.
getTotalAmount
())
{
activityList
.
setMissing
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getThresholdAmount
()
-
activityPrompt
.
getTotalAmount
()));
activityList
.
setAgainBuy
(
MoneyUtils
.
parseFen2Yuan
(
activityPrompt
.
getThresholdAmount
()
-
activityPrompt
.
getTotalAmount
()));
}
else
{
activityList
.
setMissing
(
"0"
);
activityList
.
setAgainBuy
(
"0"
);
}
activityTip
.
getActivityList
().
add
(
activityList
);
}
}
}
}
\ No newline at end of file
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
View file @
8580f247
...
@@ -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
()
+
"份优惠 超出按照原价计算哦"
;
}
}
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/utils/MoneyUtils.java
0 → 100644
View file @
8580f247
package
cn
.
freemud
.
utils
;
import
java.math.BigDecimal
;
public
class
MoneyUtils
{
public
static
String
parseFen2Yuan
(
Long
fen
)
{
if
(
null
==
fen
)
{
return
"0"
;
}
return
new
BigDecimal
(
fen
).
divide
(
new
BigDecimal
(
100
),
2
,
BigDecimal
.
ROUND_HALF_UP
).
toPlainString
();
}
public
static
String
parseFen2Yuan
(
Integer
fen
)
{
if
(
null
==
fen
)
{
return
"0"
;
}
return
new
BigDecimal
(
fen
).
divide
(
new
BigDecimal
(
100
),
2
,
BigDecimal
.
ROUND_HALF_UP
).
toPlainString
();
}
}
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