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
ea26e3f0
Commit
ea26e3f0
authored
Oct 09, 2020
by
刘鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车添加创单时调用的接口
parent
f4e45717
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
264 additions
and
6 deletions
+264
-6
shopping-cart-application-service/src/main/java/cn/freemud/controller/ShoppingCartCollageController.java
+20
-0
shopping-cart-application-service/src/main/java/cn/freemud/factory/AbstractShoppingCartImpl.java
+133
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartCollageServiceImpl.java
+111
-6
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/controller/ShoppingCartCollageController.java
View file @
ea26e3f0
...
...
@@ -14,7 +14,10 @@ package cn.freemud.controller;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.service.impl.ShoppingCartCollageServiceImpl
;
import
cn.freemud.service.impl.ShoppingCartMallServiceImpl
;
import
cn.freemud.utils.ResponseUtil
;
import
com.freemud.application.sdk.api.base.SDKCommonBaseContextWare
;
import
com.freemud.application.sdk.api.log.ApiAnnotation
;
import
com.freemud.application.sdk.api.log.LogParams
;
...
...
@@ -77,4 +80,21 @@ public class ShoppingCartCollageController {
public
BaseResponse
clearCartGoods
(
@Validated
@LogParams
@RequestBody
ShoppingCartClearRequestVo
request
)
{
return
SDKCommonBaseContextWare
.
getBean
(
ShoppingCartCollageServiceImpl
.
class
).
clear
(
request
);
}
/**
* 获取购物车均摊详情,点 "去支付" 时调用
*
* @param getShoppingCartGoodsApportionRequestVo
* @return
*/
@ApiAnnotation
(
logMessage
=
"getShoppingCartGoodsApportion"
)
@PostMapping
(
value
=
"/getShoppingCartGoodsApportion"
)
public
BaseResponse
getShoppingCartGoodsApportion
(
@Validated
@LogParams
@RequestBody
GetShoppingCartGoodsApportionRequestVo
getShoppingCartGoodsApportionRequestVo
)
{
if
(
getShoppingCartGoodsApportionRequestVo
==
null
||
getShoppingCartGoodsApportionRequestVo
.
getShoppingCartInfoRequestVo
()
==
null
)
{
return
ResponseUtil
.
error
(
ResponseResult
.
NOT_LOGIN
);
}
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
=
getShoppingCartGoodsApportionRequestVo
.
getShoppingCartInfoRequestVo
();
return
SDKCommonBaseContextWare
.
getBean
(
ShoppingCartCollageServiceImpl
.
class
).
getShoppingCartGoods
(
shoppingCartInfoRequestVo
,
getShoppingCartGoodsApportionRequestVo
.
getPremiumExchangeActivity
());
}
}
shopping-cart-application-service/src/main/java/cn/freemud/factory/AbstractShoppingCartImpl.java
View file @
ea26e3f0
...
...
@@ -8,6 +8,7 @@ import cn.freemud.constant.ShoppingCartConstant;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.activity.ActivityQueryDto
;
import
cn.freemud.entities.dto.activity.ActivityQueryResponseDto
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.dto.user.GetSessionUserInfoDto
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.*
;
...
...
@@ -35,6 +36,7 @@ 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.service.StoreCenterService
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
...
...
@@ -46,6 +48,8 @@ import org.springframework.beans.factory.annotation.Value;
import
java.awt.geom.Point2D
;
import
java.text.DecimalFormat
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
static
cn
.
freemud
.
constant
.
ApplicationConstant
.*;
import
static
cn
.
freemud
.
constant
.
ShoppingCartConstant
.
SHOPPING_CART_EMPTY_GOODS_LIST
;
...
...
@@ -93,6 +97,9 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
@Autowired
private
ItemService
itemService
;
@Autowired
private
AssortmentSdkService
assortmentSdkService
;
// 配送费逻辑是否使用旧的
@Value
(
"${store.delivery.use.old:true}"
)
private
boolean
storeDeliveryUseOld
;
...
...
@@ -663,4 +670,130 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
shoppingCartGoodsResponseVo
.
setCardDiscountAmount
(
firstCouponAmount
);
}
/**
* 处理加价购商品
*
* @param sendGoodsList
* @param partnerId
* @param storeId
*/
public
void
processSendGoods
(
List
<
ShoppingCartInfoRequestVo
.
SendGoods
>
sendGoodsList
,
String
partnerId
,
String
storeId
,
String
menuType
,
ShoppingCartBaseService
shoppingCartService
)
{
List
<
String
>
goodsIds
=
sendGoodsList
.
parallelStream
().
map
(
ShoppingCartInfoRequestVo
.
SendGoods
::
getGoodsId
).
collect
(
Collectors
.
toList
());
List
<
ProductBeanDTO
>
productBeanList
=
assortmentSdkService
.
getProductsInfoSdk
(
partnerId
,
storeId
,
goodsIds
,
menuType
,
shoppingCartService
);
// 将productBeanList转换为Map,key为pid,即goodsId
Map
<
String
,
ProductBeanDTO
>
productBeanMap
=
productBeanList
.
parallelStream
()
.
collect
(
Collectors
.
toMap
(
ProductBeanDTO:
:
getPid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
// 遍历购物车进行加个更新
for
(
ShoppingCartInfoRequestVo
.
SendGoods
sendGoods
:
sendGoodsList
)
{
ProductBeanDTO
productBean
;
if
((
productBean
=
productBeanMap
.
get
(
sendGoods
.
getGoodsId
()))
!=
null
)
{
// 设置加价购商品原价
sendGoods
.
setOriginalPrice
(
productBean
.
getFinalPrice
());
}
else
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SENDGOODS_NOT_EXIST
);
}
}
}
public
void
packgeAdditional
(
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
,
CreateOrderVo
.
PremiumExchangeActivity
premiumExchangeActivity
)
{
ArrayList
<
ShoppingCartInfoRequestVo
.
SendGoods
>
senGoods
=
new
ArrayList
<>();
if
(
premiumExchangeActivity
!=
null
&&
CollectionUtils
.
isNotEmpty
(
premiumExchangeActivity
.
getProducts
()))
{
for
(
CreateOrderVo
.
PremiumExchangeActivity
.
Product
product
:
premiumExchangeActivity
.
getProducts
())
{
ShoppingCartInfoRequestVo
.
SendGoods
sendGoods
=
new
ShoppingCartInfoRequestVo
.
SendGoods
();
sendGoods
.
setQty
(
product
.
getQty
());
sendGoods
.
setGoodsId
(
StringUtils
.
isEmpty
(
product
.
getSkuId
())
?
product
.
getSpuId
()
:
product
.
getSkuId
());
senGoods
.
add
(
sendGoods
);
}
}
shoppingCartInfoRequestVo
.
setSendGoods
(
senGoods
);
}
/**
* 促销均摊计算
*
* @param shoppingCartGoodsResponseVo
* @param calculationDiscountResult
* @param shoppingCartGoodsDto
* @param premiumExchangeActivity
* @param shoppingCartInfoRequestVo
*/
public
void
updateShoppingCartGoodsApportion
(
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
ShoppingCartGoodsDto
shoppingCartGoodsDto
,
CreateOrderVo
.
PremiumExchangeActivity
premiumExchangeActivity
,
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
)
{
DefaultPromotionService
defaultPromotionService
=
(
DefaultPromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
DEFAULT_PROMOTION
);
defaultPromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
// 优惠券
CouponPromotionService
couponPromotionService
=
(
CouponPromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
COUPON_DISCOUNT
);
couponPromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
// 买赠
BuySendPromotionService
buySendPromotionService
=
(
BuySendPromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
BUY_ONE_SEND
);
buySendPromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
// 加价购
AdditionalPromotionService
additionalPromotionService
=
(
AdditionalPromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
ADDITIONAL_BUY
);
additionalPromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
// 限时特价
TimeSalePromotionService
timeSalePromotionService
=
(
TimeSalePromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
TIME_SALE
);
timeSalePromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
//套餐
SetMealServiceImpl
setMealService
=
(
SetMealServiceImpl
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
SET_MEAL
);
setMealService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
//积分兑换
CustomerScoreService
customerScoreService
=
(
CustomerScoreService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
CUSTOMER_SCORE
);
customerScoreService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
//xy折
XyDiscountServiceImpl
xyDiscountService
=
(
XyDiscountServiceImpl
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
XY_DISCOUNT
);
xyDiscountService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
//xy折
BuyAndGiftsPromotionService
buyAndGiftsPromotionService
=
(
BuyAndGiftsPromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
BUY_GIFTS
);
buyAndGiftsPromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
/**
* 设置加料商品行记录
*/
MaterialPromotionService
materialPromotionService
=
(
MaterialPromotionService
)
PromotionFactory
.
getPromotionService
(
ShoppingCartPromotionEnum
.
Material
);
materialPromotionService
.
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
}
/**
* 计算第一次使用会员卡需多支付的金额 单位:分
*
* @param shoppingCartInfoRequestVo
* @param shoppingCartGoodsDto
* @return
*/
public
void
getNeedCardAmount
(
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
,
ShoppingCartGoodsDto
shoppingCartGoodsDto
)
{
ShoppingCartInfoRequestVo
.
BuyMemberCard
buyMemberCard
=
shoppingCartInfoRequestVo
.
getBuyMemberCard
();
if
(
buyMemberCard
!=
null
&&
StringUtils
.
isNotEmpty
(
buyMemberCard
.
getPaidId
())
&&
StringUtils
.
isNotEmpty
(
buyMemberCard
.
getRuleId
()))
{
GetPaidRuleRequestDto
getPaidRuleRequestDto
=
new
GetPaidRuleRequestDto
();
getPaidRuleRequestDto
.
setPartnerId
(
shoppingCartInfoRequestVo
.
getPartnerId
());
getPaidRuleRequestDto
.
setPaidId
(
buyMemberCard
.
getPaidId
());
getPaidRuleRequestDto
.
setRuleId
(
buyMemberCard
.
getRuleId
());
BaseResponse
<
GetPaidRuleResponseDto
>
baseResponse
=
customerApplicationClient
.
getPaidRule
(
getPaidRuleRequestDto
);
if
(
baseResponse
==
null
||
baseResponse
.
getResult
()
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
baseResponse
.
getCode
())
||
baseResponse
.
getResult
().
getActivityPrice
()
==
null
)
{
return
;
}
Integer
activityPrice
=
baseResponse
.
getResult
().
getActivityPrice
();
Integer
firstCouponAmount
=
baseResponse
.
getResult
().
getFirstCouponAmount
()==
null
?
0
:
baseResponse
.
getResult
().
getFirstCouponAmount
();
Integer
needCardAmount
=
activityPrice
-
firstCouponAmount
;
shoppingCartGoodsDto
.
setMemberCardAmount
(
needCardAmount
);
shoppingCartGoodsDto
.
setCardOriginalAmount
(
baseResponse
.
getResult
().
getActivityPrice
());
shoppingCartGoodsDto
.
setCardDiscountAmount
(
firstCouponAmount
);
shoppingCartGoodsDto
.
setOriginalTotalAmount
(
shoppingCartGoodsDto
.
getOriginalTotalAmount
()
+
activityPrice
);
shoppingCartGoodsDto
.
setTotalAmount
(
shoppingCartGoodsDto
.
getTotalAmount
()
+
needCardAmount
);
shoppingCartGoodsDto
.
setTotalDiscountAmount
(
shoppingCartGoodsDto
.
getTotalDiscountAmount
()
+
firstCouponAmount
);
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartCollageServiceImpl.java
View file @
ea26e3f0
...
...
@@ -16,10 +16,7 @@ import cn.freemud.enums.ResponseResult;
import
cn.freemud.factory.AbstractShoppingCartImpl
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.service.CommonService
;
import
cn.freemud.service.CouponService
;
import
cn.freemud.service.ShoppingCartCollageService
;
import
cn.freemud.service.ShoppingCartNewService
;
import
cn.freemud.service.*
;
import
cn.freemud.service.thirdparty.ActivityClient
;
import
cn.freemud.utils.PropertyConvertUtil
;
import
cn.freemud.utils.RedisLock
;
...
...
@@ -35,6 +32,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.RedisKeyConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.domain.CollageOrder
;
import
com.freemud.sdk.api.assortment.shoppingcart.domain.CollageOrderDto
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.CollageCartBaseServiceImpl
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
...
...
@@ -51,10 +49,12 @@ import java.util.function.Function;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
import
static
java
.
util
.
stream
.
Collectors
.
toList
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @version V1.0
assortmentSdkService
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
...
...
@@ -94,6 +94,9 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
@Autowired
private
CouponAdapter
couponAdapter
;
@Autowired
private
ProductService
productService
;
@Override
...
...
@@ -498,7 +501,109 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
@Override
public
BaseResponse
<
ShoppingCartGoodsDto
>
getShoppingCartGoods
(
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
,
CreateOrderVo
.
PremiumExchangeActivity
premiumExchangeActivity
)
{
return
null
;
ShoppingCartGoodsDto
shoppingCartGoodsDto
=
new
ShoppingCartGoodsDto
();
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
=
new
ShoppingCartGoodsResponseVo
();
// 获取用户信息,只有创单发起人才会进行创单,所以当前登陆的用户为拼单的发起人
CustomerInfoVo
assortmentCustomerInfoVo
=
getCustomerInfoVo
(
shoppingCartInfoRequestVo
.
getSessionId
());
UserLoginInfoDto
userLoginInfoDto
=
convert2UserLoginInfoDto
(
assortmentCustomerInfoVo
);
String
userId
=
userLoginInfoDto
.
getMemberId
();
String
partnerId
=
shoppingCartInfoRequestVo
.
getPartnerId
();
String
storeId
=
shoppingCartInfoRequestVo
.
getShopId
();
String
appId
=
StringUtils
.
isEmpty
(
shoppingCartInfoRequestVo
.
getAppId
())?
userLoginInfoDto
.
getWxAppid
():
shoppingCartInfoRequestVo
.
getAppId
();
String
couponCode
=
shoppingCartInfoRequestVo
.
getCouponCode
();
String
activityCode
=
shoppingCartInfoRequestVo
.
getActivityCode
();
String
tableNumber
=
assortmentCustomerInfoVo
.
getTableNumber
();
String
menuType
=
shoppingCartInfoRequestVo
.
getMenuType
();
Integer
orderType
=
shoppingCartInfoRequestVo
.
getOrderType
();
String
receiveId
=
shoppingCartInfoRequestVo
.
getReceiveId
();
// 加价购商品
List
<
ShoppingCartInfoRequestVo
.
SendGoods
>
sendGoodsList
=
shoppingCartInfoRequestVo
.
getSendGoods
();
// 获取购物车商品
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
null
,
tableNumber
,
collageCartBaseService
);
if
(
cartGoodsList
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_GETINFO_INVAILD
);
}
/**
* 校验该门店是否有必选商品
* 1. 调用商品服务拿到该门店是否有必选商品
* 2. 如果有,则和购物车的商品对比
*/
if
(
productService
.
hasRequiredProducts
(
partnerId
,
storeId
,
cartGoodsList
,
BusinessTypeEnum
.
getByType
(
shoppingCartInfoRequestVo
.
getMenuType
()).
getCode
()))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_REQUIRED_PRODUCT_NOT_EXIST
);
}
// check购物车中所有商品(商品是否存在,价格变动,券是否支持当前点餐方式)
CheckCartRequest
checkCartRequest
=
assortmentSdkService
.
checkShoppingCartSdk
(
cartGoodsList
,
partnerId
,
storeId
,
shoppingCartGoodsResponseVo
,
shoppingCartInfoRequestVo
.
getOrderType
(),
tableNumber
,
shoppingCartInfoRequestVo
.
getMenuType
()
,
shoppingCartBaseService
);
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
ShoppingCartGoodsResponseVo
cartGoodsResponseVo
=
checkCartRequest
.
getShoppingCartGoodsResponseVo
();
//商品不再售卖状态或价格变动,直接返回报错
if
(
cartGoodsResponseVo
!=
null
)
{
if
(
cartGoodsResponseVo
.
getCartGoodsStates
()
!=
null
&&
cartGoodsResponseVo
.
getCartGoodsStates
().
isHasInvalidGoods
())
{
return
ResponseUtil
.
error
(
ResponseResult
.
STORE_ITEM_CHECK_INVAILD
);
}
if
(
cartGoodsResponseVo
.
getCartGoodsStates
()
!=
null
&&
cartGoodsResponseVo
.
getCartGoodsStates
().
isPriceChanged
())
{
return
ResponseUtil
.
error
(
ResponseResult
.
SHOPPING_CART_ACTIVITY_CHANGE
);
}
shoppingCartGoodsResponseVo
.
setToastMsg
(
cartGoodsResponseVo
.
getToastMsg
());
}
cartGoodsList
=
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
checkCartRequest
.
getCartGoodsList
()),
CartGoods
.
class
);
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
assortmentCustomerInfoVo
.
getSessionId
(),
tableNumber
,
this
.
shoppingCartBaseService
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
new
ArrayList
<>();
// 当couponCode不为空时,需参与价格计算
if
(
StringUtils
.
isNotEmpty
(
couponCode
))
{
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
coupon
=
new
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
();
coupon
.
setCode
(
couponCode
);
coupon
.
setActivityCode
(
activityCode
);
coupons
.
add
(
coupon
);
}
if
(
CollectionUtils
.
isNotEmpty
(
sendGoodsList
))
{
processSendGoods
(
sendGoodsList
,
partnerId
,
storeId
,
shoppingCartInfoRequestVo
.
getMenuType
()
,
shoppingCartBaseService
);
}
else
{
//组装加价购商品
if
(
null
!=
premiumExchangeActivity
&&
CollectionUtils
.
isNotEmpty
(
premiumExchangeActivity
.
getProducts
()))
{
List
<
ShoppingCartInfoRequestVo
.
SendGoods
>
sendGoods
=
premiumExchangeActivity
.
getProducts
().
stream
().
map
(
product
->
{
ShoppingCartInfoRequestVo
.
SendGoods
sendGood
=
new
ShoppingCartInfoRequestVo
.
SendGoods
();
sendGood
.
setGoodsId
(
product
.
getSkuId
());
sendGood
.
setQty
(
product
.
getQty
());
return
sendGood
;
}).
collect
(
toList
());
shoppingCartInfoRequestVo
.
setSendGoods
(
sendGoods
);
}
}
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
);
// 获取优惠信息
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
=
getCalculationDiscountResult
(
menuType
,
partnerId
,
storeId
,
userId
,
appId
,
userLoginInfoDto
.
getWxAppid
(),
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
cartGoodsList
,
coupons
,
sendGoodsList
,
shoppingCartInfoRequestVo
.
getReceiveId
(),
deliveryAmount
);
ActivityQueryDto
activityQueryDto
=
activityAdapter
.
getActivityQueryDto
(
partnerId
,
storeId
,
userId
,
appId
,
shoppingCartInfoRequestVo
.
getOrderType
());
CouponPromotionVO
couponPromotionVO
=
couponAdapter
.
getCouponPromotionVO
(
shoppingCartInfoRequestVo
,
userLoginInfoDto
);
// 临时方案
packgeAdditional
(
shoppingCartInfoRequestVo
,
premiumExchangeActivity
);
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount
(
couponPromotionVO
,
activityQueryDto
,
calculationDiscountResult
,
cartGoodsList
,
shoppingCartGoodsResponseVo
,
shoppingCartInfoRequestVo
,
userLoginInfoDto
,
shoppingCartInfoRequestVo
.
getMenuType
(),
deliveryAmount
);
//设置更新响应信息
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
partnerId
,
storeId
,
userId
,
ShoppingCartConstant
.
QUERY_INFO
,
shoppingCartInfoRequestVo
);
//设置均摊信息,商品行信息
updateShoppingCartGoodsApportion
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
shoppingCartGoodsDto
,
premiumExchangeActivity
,
shoppingCartInfoRequestVo
);
// 计算第一次使用会员卡需多支付的金额 单位:分
getNeedCardAmount
(
shoppingCartInfoRequestVo
,
shoppingCartGoodsDto
);
shoppingCartGoodsDto
.
setDeliveryAmount
(
shoppingCartGoodsResponseVo
.
getDeliveryAmount
());
shoppingCartGoodsDto
.
setDiscountDeliveryAmount
(
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
());
shoppingCartGoodsDto
.
setThresholdAmount
(
shoppingCartGoodsResponseVo
.
getThresholdAmount
());
shoppingCartGoodsDto
.
setIsDiscountDelivery
(
shoppingCartGoodsResponseVo
.
getIsDiscountDelivery
());
shoppingCartGoodsDto
.
setDiscountDeliveryActivityCode
(
shoppingCartGoodsResponseVo
.
getDiscountDeliveryActivityCode
());
return
ResponseUtil
.
success
(
shoppingCartGoodsDto
);
}
@Override
...
...
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