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
5e0e5b74
Commit
5e0e5b74
authored
Nov 04, 2020
by
huiyang.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 买三赠一开发
parent
3520d4c1
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
269 additions
and
45 deletions
+269
-45
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/domain/CartParamDto.java
+5
-0
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/domain/CouponTypeVo.java
+15
-0
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/ShoppingCartBaseService.java
+20
-0
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/impl/ShoppingCartBaseServiceImpl.java
+32
-19
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/CouponTypeVo.java
+15
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartGoodsResponseVo.java
+15
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
+11
-13
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
+35
-4
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+115
-7
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/entity/MCoffeeAddGoodsRequestVo.java
+2
-2
No files found.
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/constant/RedisKeyConstant.java
View file @
5e0e5b74
...
@@ -25,6 +25,10 @@ public class RedisKeyConstant {
...
@@ -25,6 +25,10 @@ public class RedisKeyConstant {
/**
/**
* 用户购物车在redis的key前缀
* 用户购物车在redis的key前缀
*/
*/
public
final
static
String
SAAS_SHOPPINGCART_COUPON_KEY_PREFIX_TYPE
=
"saas:user:info:cart:coupon:type:"
;
/**
* 用户购物车在redis的key前缀
*/
public
final
static
String
SAAS_USER_INFO_CART_CARTADDPRODUCT
=
"saas:user:info:cart:cartAddProduct:goods:"
;
public
final
static
String
SAAS_USER_INFO_CART_CARTADDPRODUCT
=
"saas:user:info:cart:cartAddProduct:goods:"
;
/**
/**
* 用户购物车总价在redis的key前缀
* 用户购物车总价在redis的key前缀
...
...
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/domain/CartParamDto.java
View file @
5e0e5b74
...
@@ -41,4 +41,9 @@ public class CartParamDto {
...
@@ -41,4 +41,9 @@ public class CartParamDto {
private
MealClearOperationEnum
operationType
;
private
MealClearOperationEnum
operationType
;
private
Integer
couponType
;
private
Integer
couponType
;
/**
* 各类券信息
*/
private
List
<
CouponTypeVo
>
couponTypeList
;
}
}
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/domain/CouponTypeVo.java
0 → 100644
View file @
5e0e5b74
package
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
;
import
lombok.Data
;
@Data
public
class
CouponTypeVo
{
/**
* 券类型 1:买三赠一券
*/
private
Integer
type
;
/**
* 券code
*/
private
String
code
;
}
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/ShoppingCartBaseService.java
View file @
5e0e5b74
...
@@ -120,6 +120,26 @@ public interface ShoppingCartBaseService {
...
@@ -120,6 +120,26 @@ public interface ShoppingCartBaseService {
}
}
/**
/**
*
* @param cartParamDto
* @param trackingNo
* @return
*/
default
BaseResponse
<
List
<
CouponTypeVo
>>
setTypeCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
return
null
;
}
/**
*
* @param cartParamDto
* @param trackingNo
* @return
*/
default
BaseResponse
<
List
<
CouponTypeVo
>>
getTypeCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
return
null
;
}
/**
* 清除麦咖啡购物车商品行信息
* 清除麦咖啡购物车商品行信息
*
*
* @param cartParamDto
* @param cartParamDto
...
...
assortment-shoppingcart-sdk/src/main/java/com/freemud/sdk/api/assortment/shoppingcart/service/impl/ShoppingCartBaseServiceImpl.java
View file @
5e0e5b74
...
@@ -3,41 +3,23 @@ package com.freemud.sdk.api.assortment.shoppingcart.service.impl;
...
@@ -3,41 +3,23 @@ package com.freemud.sdk.api.assortment.shoppingcart.service.impl;
import
ch.qos.logback.classic.Level
;
import
ch.qos.logback.classic.Level
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.redis.RedisCache
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.application.sdk.api.couponcenter.enums.CouponTypeEnum
;
import
com.freemud.application.sdk.api.couponcenter.online.domain.*
;
import
com.freemud.application.sdk.api.couponcenter.online.domain.*
;
import
com.freemud.application.sdk.api.couponcenter.online.request.ActiveBatchQueryRequest
;
import
com.freemud.application.sdk.api.couponcenter.online.request.ActiveBatchQueryRequest
;
import
com.freemud.application.sdk.api.couponcenter.online.request.CouponDetailRequest
;
import
com.freemud.application.sdk.api.couponcenter.online.request.PartnerRequest
;
import
com.freemud.application.sdk.api.couponcenter.online.response.CouponDetailResponse
;
import
com.freemud.application.sdk.api.couponcenter.online.service.FMActiveSdkService
;
import
com.freemud.application.sdk.api.couponcenter.online.service.FMActiveSdkService
;
import
com.freemud.application.sdk.api.couponcenter.online.service.OnlineCouponSdkService
;
import
com.freemud.application.sdk.api.couponcenter.online.service.OnlineCouponSdkService
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.application.sdk.api.productcenter.constant.ResponseConstant
;
import
com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO
;
import
com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO
;
import
com.freemud.application.sdk.api.productcenter.domain.ProductInfosDTO
;
import
com.freemud.application.sdk.api.productcenter.request.menu.GetMenuCategoryByIdsRequest
;
import
com.freemud.application.sdk.api.productcenter.request.product.GetProductRequest
;
import
com.freemud.application.sdk.api.productcenter.response.menu.GetMenuCategoryByIdsResponse
;
import
com.freemud.application.sdk.api.productcenter.response.menu.GetMenuCategoryInfoResponse
;
import
com.freemud.application.sdk.api.productcenter.response.product.GetProductInfosResponse
;
import
com.freemud.application.sdk.api.productcenter.service.MenuService
;
import
com.freemud.application.sdk.api.productcenter.service.MenuService
;
import
com.freemud.application.sdk.api.productcenter.service.ProductService
;
import
com.freemud.application.sdk.api.productcenter.service.ProductService
;
import
com.freemud.sdk.api.assortment.shoppingcart.adapter.ShoppingCartAdapter
;
import
com.freemud.sdk.api.assortment.shoppingcart.adapter.ShoppingCartAdapter
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.*
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.*
;
import
com.freemud.sdk.api.assortment.shoppingcart.domain.*
;
import
com.freemud.sdk.api.assortment.shoppingcart.domain.*
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.SaveCouponType
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.SaveCouponType
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.GetProductInfoRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.CartResponseUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.CartResponseUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.DateTimeUtils
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.PropertyConvertUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.PropertyConvertUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.BoundHashOperations
;
import
org.springframework.data.redis.core.BoundHashOperations
;
...
@@ -45,7 +27,6 @@ import org.springframework.data.redis.core.BoundValueOperations;
...
@@ -45,7 +27,6 @@ import org.springframework.data.redis.core.BoundValueOperations;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.function.Predicate
;
import
java.util.function.Predicate
;
...
@@ -154,6 +135,34 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -154,6 +135,34 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
}
}
@Override
@Override
public
BaseResponse
<
List
<
CouponTypeVo
>>
setTypeCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
String
redisKey
=
getShoppingCartTypeCouponCodeKey
(
cartParamDto
);
redisTemplate
.
delete
(
redisKey
);
BoundValueOperations
<
String
,
List
<
CouponTypeVo
>>
operations
=
redisTemplate
.
boundValueOps
(
redisKey
);
operations
.
set
(
cartParamDto
.
getCouponTypeList
());
return
CartResponseUtil
.
success
();
}
catch
(
Exception
e
)
{
ErrorLog
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
trackingNo
,
e
.
getMessage
(),
"setTypeCartCouponCode"
,
cartParamDto
,
e
,
Level
.
ERROR
);
return
null
;
}
}
@Override
public
BaseResponse
<
List
<
CouponTypeVo
>>
getTypeCartCouponCode
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
String
redisKey
=
getShoppingCartTypeCouponCodeKey
(
cartParamDto
);
BoundValueOperations
<
String
,
List
<
CouponTypeVo
>>
operations
=
redisTemplate
.
boundValueOps
(
redisKey
);
List
<
CouponTypeVo
>
couponTypeVos
=
operations
.
get
();
return
CartResponseUtil
.
success
(
couponTypeVos
);
}
catch
(
Exception
e
)
{
ErrorLog
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
trackingNo
,
e
.
getMessage
(),
"getTypeCartCouponCode"
,
cartParamDto
,
e
,
Level
.
ERROR
);
return
null
;
}
}
@Override
public
BaseResponse
<
CartGoods
>
getCartGoods
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
public
BaseResponse
<
CartGoods
>
getCartGoods
(
CartParamDto
cartParamDto
,
String
trackingNo
)
{
try
{
try
{
String
redisKey
=
getShoppingCartGoodsKey
(
cartParamDto
);
String
redisKey
=
getShoppingCartGoodsKey
(
cartParamDto
);
...
@@ -341,6 +350,10 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
...
@@ -341,6 +350,10 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
return
RedisKeyConstant
.
SAAS_SHOPPINGCART_COUPON_KEY_PREFIX
+
cartParamDto
.
getPartnerId
()
+
"_"
+
cartParamDto
.
getStoreId
()
+
"_"
+
cartParamDto
.
getUserId
()
+
"_"
+
cartParamDto
.
getCouponType
();
return
RedisKeyConstant
.
SAAS_SHOPPINGCART_COUPON_KEY_PREFIX
+
cartParamDto
.
getPartnerId
()
+
"_"
+
cartParamDto
.
getStoreId
()
+
"_"
+
cartParamDto
.
getUserId
()
+
"_"
+
cartParamDto
.
getCouponType
();
}
}
private
String
getShoppingCartTypeCouponCodeKey
(
CartParamDto
cartParamDto
)
{
return
RedisKeyConstant
.
SAAS_SHOPPINGCART_COUPON_KEY_PREFIX_TYPE
+
cartParamDto
.
getPartnerId
()
+
"_"
+
cartParamDto
.
getStoreId
()
+
"_"
+
cartParamDto
.
getUserId
();
}
/**
/**
* 获取记录购物车价格的key
* 获取记录购物车价格的key
*
*
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/CouponTypeVo.java
0 → 100644
View file @
5e0e5b74
package
cn
.
freemud
.
entities
.
vo
;
import
lombok.Data
;
@Data
public
class
CouponTypeVo
{
/**
* 券类型 1:买三赠一券
*/
private
Integer
type
;
/**
* 券code
*/
private
String
code
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartGoodsResponseVo.java
View file @
5e0e5b74
...
@@ -141,4 +141,19 @@ public class ShoppingCartGoodsResponseVo extends ShoppingCartGoodsBaseResponseV
...
@@ -141,4 +141,19 @@ public class ShoppingCartGoodsResponseVo extends ShoppingCartGoodsBaseResponseV
*/
*/
private
Long
payCardFee
;
private
Long
payCardFee
;
/**
* 各类券信息
*/
private
List
<
CouponTypeVo
>
couponTypeList
;
/**
* 麦咖啡-买三赠一券活动号
*/
private
String
buyThreeGiveOneActivityCode
;
/**
* 麦咖啡-买三赠一券默认券号
*/
private
String
buyThreeGiveOneCouponCode
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
View file @
5e0e5b74
...
@@ -100,7 +100,17 @@ public class ShoppingCartInfoRequestVo extends BaseRequestVo {
...
@@ -100,7 +100,17 @@ public class ShoppingCartInfoRequestVo extends BaseRequestVo {
/**
/**
* 各类券信息
* 各类券信息
*/
*/
private
List
<
CouponType
>
couponTypeList
;
private
List
<
CouponTypeVo
>
couponTypeList
;
/**
* 麦咖啡-买三赠一券活动号
*/
private
String
buyThreeGiveOneActivityCode
;
/**
* 麦咖啡-买三赠一券默认券号
*/
private
String
buyThreeGiveOneCouponCode
;
@Data
@Data
public
final
static
class
SendGoods
{
public
final
static
class
SendGoods
{
...
@@ -131,18 +141,6 @@ public class ShoppingCartInfoRequestVo extends BaseRequestVo {
...
@@ -131,18 +141,6 @@ public class ShoppingCartInfoRequestVo extends BaseRequestVo {
private
String
ruleId
;
private
String
ruleId
;
}
}
@Data
public
final
static
class
CouponType
{
/**
* 券类型 1:买三赠一券
*/
private
Integer
type
;
/**
* 券code
*/
private
String
code
;
}
/**
/**
* 运费券code
* 运费券code
*/
*/
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
View file @
5e0e5b74
...
@@ -3,11 +3,10 @@ package cn.freemud.service.impl;
...
@@ -3,11 +3,10 @@ package cn.freemud.service.impl;
import
ch.qos.logback.classic.Level
;
import
ch.qos.logback.classic.Level
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.entities.vo.CartGoods
;
import
cn.freemud.entities.vo.CartGoods
;
import
cn.freemud.entities.vo.CouponTypeVo
;
import
cn.freemud.entities.vo.ShoppingCartGoodsBaseResponseVo
;
import
cn.freemud.entities.vo.ShoppingCartGoodsBaseResponseVo
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.utils.LogUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.application.sdk.api.base.SDKCommonBaseContextWare
;
import
com.freemud.application.sdk.api.base.SDKCommonBaseContextWare
;
...
@@ -20,10 +19,8 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.GetProductInfoRequest
...
@@ -20,10 +19,8 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.GetProductInfoRequest
import
com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService
;
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.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.naming.Name
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -149,6 +146,25 @@ public class AssortmentSdkService {
...
@@ -149,6 +146,25 @@ public class AssortmentSdkService {
}
}
/**
/**
* 获取用户选择的优惠券列表
*
* @param partnerId
* @param storeId
* @param useId
* @param shoppingCartService
* @return
*/
public
List
<
CouponTypeVo
>
getTypeCartCouponCode
(
String
partnerId
,
String
storeId
,
String
useId
,
ShoppingCartBaseService
shoppingCartService
)
{
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartParamDto
cartParamDto
=
getCartParamDto
(
partnerId
,
storeId
,
useId
);
BaseResponse
<
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CouponTypeVo
>>
baseResponse
=
shoppingCartService
.
getTypeCartCouponCode
(
cartParamDto
,
LogThreadLocal
.
getTrackingNo
());
if
(
baseResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
baseResponse
.
getCode
())
||
CollectionUtils
.
isEmpty
(
baseResponse
.
getResult
()))
{
return
null
;
}
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
baseResponse
.
getResult
()),
CouponTypeVo
.
class
);
}
/**
* 调用聚合sdk设置缓存中购物车信息
* 调用聚合sdk设置缓存中购物车信息
*
*
* @param partnerId
* @param partnerId
...
@@ -190,6 +206,21 @@ public class AssortmentSdkService {
...
@@ -190,6 +206,21 @@ public class AssortmentSdkService {
}
}
/**
/**
* 保存用户选择的优惠券列表
* @param partnerId
* @param storeId
* @param useId
* @param couponTypeList
* @param shoppingCartService
* @return
*/
public
void
setTypeCartCouponCode
(
String
partnerId
,
String
storeId
,
String
useId
,
List
<
CouponTypeVo
>
couponTypeList
,
ShoppingCartBaseService
shoppingCartService
)
{
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartParamDto
cartParamDto
=
getCartParamDto
(
partnerId
,
storeId
,
useId
);
cartParamDto
.
setCouponTypeList
(
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
couponTypeList
),
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CouponTypeVo
.
class
));
shoppingCartService
.
setTypeCartCouponCode
(
cartParamDto
,
LogThreadLocal
.
getTrackingNo
());
}
/**
* 调用SDK校验购物车
* 调用SDK校验购物车
*
*
* @param oldAllCartGoodsList
* @param oldAllCartGoodsList
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
5e0e5b74
...
@@ -61,12 +61,14 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -61,12 +61,14 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
cn
.
freemud
.
constant
.
ShoppingCartConstant
.
SHOPPING_CART_EMPTY_GOODS_LIST
;
import
static
cn
.
freemud
.
constant
.
ShoppingCartConstant
.
SHOPPING_CART_EMPTY_GOODS_LIST
;
...
@@ -149,8 +151,8 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -149,8 +151,8 @@ public class ShoppingCartMCoffeeServiceImpl {
String
receiveId
=
addShoppingCartGoodsRequestVo
.
getReceiveId
();
String
receiveId
=
addShoppingCartGoodsRequestVo
.
getReceiveId
();
Integer
operationType
=
addShoppingCartGoodsRequestVo
.
getOperationType
();
Integer
operationType
=
addShoppingCartGoodsRequestVo
.
getOperationType
();
String
couponCode
=
addShoppingCartGoodsRequestVo
.
getCouponCode
();
String
couponCode
=
addShoppingCartGoodsRequestVo
.
getCouponCode
();
String
threeToOneActivityCode
=
addShoppingCartGoodsRequestVo
.
get
ThreeTo
OneActivityCode
();
String
threeToOneActivityCode
=
addShoppingCartGoodsRequestVo
.
get
BuyThreeGive
OneActivityCode
();
String
threeToOneCouponCode
=
addShoppingCartGoodsRequestVo
.
get
ThreeTo
OneCouponCode
();
String
threeToOneCouponCode
=
addShoppingCartGoodsRequestVo
.
get
BuyThreeGive
OneCouponCode
();
String
spuId2
=
spuId
;
String
spuId2
=
spuId
;
MCoffeeProductIdsVo
vo
=
new
MCoffeeProductIdsVo
();
MCoffeeProductIdsVo
vo
=
new
MCoffeeProductIdsVo
();
...
@@ -354,13 +356,16 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -354,13 +356,16 @@ public class ShoppingCartMCoffeeServiceImpl {
Integer
orderType
=
shoppingCartInfoRequestVo
.
getOrderType
();
Integer
orderType
=
shoppingCartInfoRequestVo
.
getOrderType
();
String
receiveId
=
shoppingCartInfoRequestVo
.
getReceiveId
();
String
receiveId
=
shoppingCartInfoRequestVo
.
getReceiveId
();
String
buyMonthlyCard
=
shoppingCartInfoRequestVo
.
getBuyMonthlyCard
();
String
buyMonthlyCard
=
shoppingCartInfoRequestVo
.
getBuyMonthlyCard
();
String
buyThreeGiveOneCouponCode
=
shoppingCartInfoRequestVo
.
getBuyThreeGiveOneCouponCode
();
String
buyThreeGiveOneActivityCode
=
shoppingCartInfoRequestVo
.
getBuyThreeGiveOneActivityCode
();
List
<
CouponTypeVo
>
couponTypeList
=
shoppingCartInfoRequestVo
.
getCouponTypeList
();
// 获取购物车商品
// 获取购物车商品
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
sessionId
,
""
,
shoppingCartBaseService
);
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
sessionId
,
""
,
shoppingCartBaseService
);
log
.
info
(
"cartGoodsList: {}"
,
JSONObject
.
toJSONString
(
cartGoodsList
));
log
.
info
(
"cartGoodsList: {}"
,
JSONObject
.
toJSONString
(
cartGoodsList
));
// 如果购物车商品不为空, 则check购物车中所有商品
// 如果购物车商品不为空, 则check购物车中所有商品
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
//
todo
合并相同商品数据
// 合并相同商品数据
cartGoodsList
=
mergeProductList
(
cartGoodsList
);
cartGoodsList
=
mergeProductList
(
cartGoodsList
);
// check购物车中所有商品
// check购物车中所有商品
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
cartGoodsList
);
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
cartGoodsList
);
...
@@ -390,7 +395,23 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -390,7 +395,23 @@ public class ShoppingCartMCoffeeServiceImpl {
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
freightCouponCode
,
shoppingCartBaseService
,
SaveCouponType
.
FREIGHT_COUPON
.
getCode
());
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
freightCouponCode
,
shoppingCartBaseService
,
SaveCouponType
.
FREIGHT_COUPON
.
getCode
());
}
}
String
threeToOneCouponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
if
(
StringUtils
.
isEmpty
(
buyThreeGiveOneCouponCode
))
{
buyThreeGiveOneCouponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
}
else
{
if
(
"remove"
.
equals
(
buyThreeGiveOneCouponCode
))
{
buyThreeGiveOneCouponCode
=
""
;
}
if
(
StringUtils
.
isNotEmpty
(
buyThreeGiveOneCouponCode
)
&&
StringUtils
.
isNotEmpty
(
buyThreeGiveOneActivityCode
)){
buyThreeGiveOneCouponCode
=
buyThreeGiveOneCouponCode
+
","
+
buyThreeGiveOneActivityCode
;
}
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
buyThreeGiveOneCouponCode
,
shoppingCartBaseService
,
SaveCouponType
.
THREE_TO_ONE_COUPON
.
getCode
());
}
if
(
CollectionUtils
.
isEmpty
(
couponTypeList
)){
couponTypeList
=
assortmentSdkService
.
getTypeCartCouponCode
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
);
}
else
{
assortmentSdkService
.
setTypeCartCouponCode
(
partnerId
,
storeId
,
userId
,
couponTypeList
,
shoppingCartBaseService
);
}
//放到参数里
//放到参数里
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
)
{
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
)
{
...
@@ -415,17 +436,64 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -415,17 +436,64 @@ public class ShoppingCartMCoffeeServiceImpl {
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
code
,
shoppingCartBaseService
,
SaveCouponType
.
MON_COUPON
.
getCode
());
assortmentSdkService
.
setShoppingCartCouponCode
(
partnerId
,
storeId
,
userId
,
code
,
shoppingCartBaseService
,
SaveCouponType
.
MON_COUPON
.
getCode
());
}
}
// 当couponCode不为空时,需参与价格计算
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
shoppingCartInfoRequestVo
.
getFreightCouponCode
(),
code
,
threeTo
OneCouponCode
,
shoppingCartInfoRequestVo
.
getCouponTypeList
());
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
,
shoppingCartInfoRequestVo
.
getFreightCouponCode
(),
code
,
buyThreeGive
OneCouponCode
,
shoppingCartInfoRequestVo
.
getCouponTypeList
());
// 促销活动的优惠金额计算
// 促销活动的优惠金额计算
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
=
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
=
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
payCardPrice
);
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
payCardPrice
);
if
(
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getDiscounts
()))
{
// 对促销返回的数据进行拆分
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
=
calculationDiscountResult
.
getDiscounts
().
stream
().
filter
(
discount
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
discount
.
getType
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
discounts
)
){
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsList
=
calculationDiscountResult
.
getGoods
();
if
(
CollectionUtils
.
isNotEmpty
(
goodsList
))
{
Map
<
String
,
CartGoods
>
goodsCartMap
=
cartGoodsList
.
parallelStream
().
collect
(
Collectors
.
toMap
(
CartGoods:
:
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
List
<
CartGoods
>
cartGoodsListNew
=
new
ArrayList
<>();
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods:
goodsList
)
{
CartGoods
cartGoods
=
goodsCartMap
.
get
(
goods
.
getCartGoodsUid
());
if
(
cartGoods
==
null
)
continue
;
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
collect
=
goods
.
getDiscounts
().
stream
().
filter
(
s
->
ActivityTypeEnum
.
TYPE_35
.
getCode
().
equals
(
s
.
getType
())).
collect
(
Collectors
.
toList
());
int
sum
=
collect
.
stream
().
mapToInt
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
::
getActualGoodsNumber
).
sum
();
if
(
CollectionUtils
.
isNotEmpty
(
collect
)
){
if
(
sum
>
0
&&
sum
<
goods
.
getGoodsQuantity
())
{
Integer
qty
=
cartGoods
.
getQty
();
//需要拆分
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
goodsDiscount:
collect
)
{
CartGoods
cartGoods1
=
new
CartGoods
();
BeanUtils
.
copyProperties
(
cartGoods
,
cartGoods1
);
cartGoods1
.
setQty
(
goodsDiscount
.
getActualGoodsNumber
());
cartGoodsListNew
.
add
(
cartGoods1
);
qty
=
qty
-
goodsDiscount
.
getActualGoodsNumber
();
}
cartGoods
.
setQty
(
qty
);
cartGoodsListNew
.
add
(
cartGoods
);
}
}
else
{
cartGoodsListNew
.
add
(
cartGoods
);
}
}
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsListNew
,
sessionId
,
""
,
shoppingCartBaseService
);
}
}
}
//设置更新响应信息
//设置更新响应信息
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
ShoppingCartConstant
.
QUERY_INFO
,
shoppingCartInfoRequestVo
);
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
ShoppingCartConstant
.
QUERY_INFO
,
shoppingCartInfoRequestVo
);
//先出参里的券设置为空,然后如果可用,再放到出参里
//先出参里的券设置为空,然后如果可用,再放到出参里
shoppingCartGoodsResponseVo
.
setCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setFreightCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setFreightCouponCode
(
""
);
shoppingCartGoodsResponseVo
.
setBuyThreeGiveOneActivityCode
(
buyThreeGiveOneActivityCode
);
shoppingCartGoodsResponseVo
.
setBuyThreeGiveOneCouponCode
(
buyThreeGiveOneCouponCode
);
shoppingCartGoodsResponseVo
.
setCouponTypeList
(
couponTypeList
);
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
||
StringUtils
.
isNotEmpty
(
freightCouponCode
))
{
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
||
StringUtils
.
isNotEmpty
(
freightCouponCode
))
{
String
finalCouponCode
=
couponCode
;
String
finalCouponCode
=
couponCode
;
String
finalFreightCouponCode
=
freightCouponCode
;
String
finalFreightCouponCode
=
freightCouponCode
;
...
@@ -449,10 +517,50 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -449,10 +517,50 @@ public class ShoppingCartMCoffeeServiceImpl {
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
}
/**
* 合并购物车相同商品,数量相加
* @param cartGoodsList
* @return
*/
public
List
<
CartGoods
>
mergeProductList
(
List
<
CartGoods
>
cartGoodsList
){
public
List
<
CartGoods
>
mergeProductList
(
List
<
CartGoods
>
cartGoodsList
){
if
(
CollectionUtils
.
isEmpty
(
cartGoodsList
)){
return
null
;
return
null
;
}
}
List
<
CartGoods
>
list
=
new
ArrayList
<>();
Map
<
String
,
CartGoods
>
map
=
new
HashMap
<>();
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
String
skuId
=
cartGoods
.
getSkuId
();
if
(
StringUtils
.
isNotEmpty
(
cartGoods
.
getCouponCode
())){
map
.
put
(
skuId
,
cartGoods
);
continue
;
}
String
cartGoodsUid
=
cartGoods
.
getCartGoodsUid
();
if
(
map
.
containsKey
(
skuId
)){
CartGoods
cartGoods1
=
map
.
get
(
skuId
);
//判断是否有加料,加料是否相同
List
<
CartGoods
.
MaterialGoods
>
productMaterialList
=
cartGoods
.
getProductMaterialList
();
List
<
CartGoods
.
MaterialGoods
>
productMaterialList1
=
cartGoods1
.
getProductMaterialList
();
if
((
CollectionUtils
.
isNotEmpty
(
productMaterialList
)
&&
CollectionUtils
.
isNotEmpty
(
productMaterialList1
)
&&
productMaterialList
.
retainAll
(
productMaterialList1
))
||
(
CollectionUtils
.
isNotEmpty
(
productMaterialList
)
&&
CollectionUtils
.
isEmpty
(
productMaterialList1
))
||
(
CollectionUtils
.
isEmpty
(
productMaterialList
)
&&
CollectionUtils
.
isNotEmpty
(
productMaterialList1
))
)
{
map
.
put
(
skuId
+
cartGoodsUid
,
cartGoods
);
}
else
{
cartGoods1
.
setQty
(
cartGoods1
.
getQty
()
+
cartGoods
.
getQty
());
map
.
put
(
skuId
,
cartGoods1
);
}
}
else
{
map
.
put
(
skuId
,
cartGoods
);
}
}
for
(
String
temp:
map
.
keySet
()){
list
.
add
(
map
.
get
(
temp
));
}
return
list
;
}
/**
/**
* 券码用-查询购物车最新信息,计算优惠
* 券码用-查询购物车最新信息,计算优惠
...
@@ -1411,7 +1519,7 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -1411,7 +1519,7 @@ public class ShoppingCartMCoffeeServiceImpl {
}
}
private
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
getCoupon
(
String
couponCode
,
String
activityCode
,
List
<
CartGoods
>
cartGoodsList
,
String
freightCouponCode
,
String
buyMonthlyCard
,
private
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
getCoupon
(
String
couponCode
,
String
activityCode
,
List
<
CartGoods
>
cartGoodsList
,
String
freightCouponCode
,
String
buyMonthlyCard
,
String
threeToOneCouponCode
,
List
<
ShoppingCartInfoRequestVo
.
CouponType
>
couponTypeList
)
{
String
threeToOneCouponCode
,
List
<
CouponTypeVo
>
couponTypeList
)
{
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
new
ArrayList
<>();
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
couponCode
))
{
if
(
StringUtils
.
isNotEmpty
(
couponCode
))
{
...
@@ -1440,7 +1548,7 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -1440,7 +1548,7 @@ public class ShoppingCartMCoffeeServiceImpl {
coupons
.
add
(
coupon
);
coupons
.
add
(
coupon
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
couponTypeList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
couponTypeList
))
{
for
(
ShoppingCartInfoRequestVo
.
CouponType
couponType:
couponTypeList
)
{
for
(
CouponTypeVo
couponType:
couponTypeList
)
{
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
coupon
=
new
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
();
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
coupon
=
new
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
();
coupon
.
setCode
(
couponType
.
getCode
());
coupon
.
setCode
(
couponType
.
getCode
());
coupons
.
add
(
coupon
);
coupons
.
add
(
coupon
);
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/entity/MCoffeeAddGoodsRequestVo.java
View file @
5e0e5b74
...
@@ -136,10 +136,10 @@ public class MCoffeeAddGoodsRequestVo {
...
@@ -136,10 +136,10 @@ public class MCoffeeAddGoodsRequestVo {
/**
/**
* 买三赠一券code
* 买三赠一券code
*/
*/
private
String
threeTo
OneCouponCode
;
private
String
buyThreeGive
OneCouponCode
;
/**
/**
* 买三赠一券活动号
* 买三赠一券活动号
*/
*/
private
String
threeTo
OneActivityCode
;
private
String
buyThreeGive
OneActivityCode
;
}
}
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