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
2e433f1f
Commit
2e433f1f
authored
Nov 27, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'qa' of
http://gitlab.freemud.com/order-group-application/order-group
into qa
parents
1e945949
a28806bb
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
694 additions
and
43 deletions
+694
-43
order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
+6
-1
order-application-service/src/main/java/cn/freemud/entities/dto/activity/PayGiftCheckAndJoinResponseDto.java
+11
-0
order-application-service/src/main/java/cn/freemud/entities/vo/QueryOrderResponseVo.java
+7
-0
order-application-service/src/main/java/cn/freemud/entities/vo/QueryOrderVo.java
+1
-1
order-application-service/src/main/java/cn/freemud/enums/QueryOrderStatus.java
+4
-1
order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
+32
-1
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/calculate/CalculationSharingDiscountResponseDto.java
+16
-1
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartGoodsResponseVo.java
+47
-1
shopping-cart-application-service/src/main/java/cn/freemud/enums/ActivityTypeEnum.java
+1
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/DeliveryFactory.java
+25
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/DeliveryService.java
+29
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/AbstractDeliveryServiceImpl.java
+22
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/DeliveryFactoryImpl.java
+58
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/FixDeliveryServiceImpl.java
+58
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/GradDeliveryServiceImpl.java
+69
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+45
-32
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationSharingCartService.java
+8
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/BuyOneGiveOneSendService.java
+247
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
+6
-3
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
+1
-1
No files found.
order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
View file @
2e433f1f
...
...
@@ -947,6 +947,11 @@ public class OrderAdapter {
if
(
QueryOrderStatus
.
ORDER_CANCEL
.
getCode
().
equals
(
queryOrderDto
.
getQueryOrderStatus
()))
{
queryOrdersDto
.
setStatus
(
new
Integer
[]{
OrderStatus
.
CALCEL
.
getCode
()});
}
if
(
QueryOrderStatus
.
ORDER_CANCEL_MIXUE
.
getCode
().
equals
(
queryOrderDto
.
getQueryOrderStatus
()))
{
queryOrdersDto
.
setStatus
(
new
Integer
[]{
OrderStatus
.
CALCEL
.
getCode
()});
queryOrdersDto
.
setPayStatus
(
new
Integer
[]{
PayStatus
.
NOT_PAY
.
getCode
()});
}
}
// 兼容历史版本,如果传参是4 查询拆程4和5
...
...
@@ -1133,7 +1138,7 @@ public class OrderAdapter {
responseVo
.
setPayStatusDesc
(
Optional
.
ofNullable
(
PayStatus
.
getByCode
(
ordersBean
.
getPayStatus
()))
.
map
(
PayStatus:
:
getDesc
).
orElse
(
""
));
responseVo
.
setPayVoucher
(
orderExtInfoDto
!=
null
?
orderExtInfoDto
.
getPayTransId
()
:
""
);
if
(
mcCafePartnerId
.
equals
(
ordersBean
.
getCompanyId
()))
{
if
(
mcCafePartnerId
.
equals
(
ordersBean
.
getCompanyId
())
&&
StringUtils
.
isNotBlank
(
responseVo
.
getPayVoucher
())
)
{
responseVo
.
setPayVoucherBarCode
(
Base64
.
getEncoder
().
encodeToString
(
BarcodeUtil
.
generateBarCode128
(
responseVo
.
getPayVoucher
(),
null
,
null
,
true
,
true
)));
}
...
...
order-application-service/src/main/java/cn/freemud/entities/dto/activity/PayGiftCheckAndJoinResponseDto.java
View file @
2e433f1f
...
...
@@ -22,6 +22,17 @@ import java.util.List;
public
class
PayGiftCheckAndJoinResponseDto
{
private
String
activityName
;
/**
* 发送方式
* 0-静默发送
* 5-手动发送
*/
private
Integer
sendType
;
/**
* 活动类型
*/
private
String
type
;
private
List
<
PayGiftCouponVo
>
coupons
;
private
PayGiftWechatCouponInfoVo
wechatCouponInfo
;
}
order-application-service/src/main/java/cn/freemud/entities/vo/QueryOrderResponseVo.java
View file @
2e433f1f
...
...
@@ -356,6 +356,13 @@ public class QueryOrderResponseVo {
//支付有礼活动名称
private
String
activityName
;
/**
* 支付有礼发送方式
* 0-静默发送
* 5-手动发送
*/
private
Integer
activitySendType
;
//支付有礼领券集合
private
List
<
PayGiftCouponVo
>
coupons
;
private
PayGiftWechatCouponInfoVo
wechatCouponInfo
;
...
...
order-application-service/src/main/java/cn/freemud/entities/vo/QueryOrderVo.java
View file @
2e433f1f
...
...
@@ -31,7 +31,7 @@ public class QueryOrderVo {
@ApiModelProperty
(
value
=
"订单编号"
)
private
String
oid
;
/**
* 订单状态 enum queryOrderStatus 全部订单 1 待取餐 2 已完成 3 全部 4.退款,5 待支付 ,6 已取消
* 订单状态 enum queryOrderStatus 全部订单 1 待取餐 2 已完成 3 全部 4.退款,5 待支付 ,6 已取消
7未支付取消
*/
private
Integer
queryOrderStatus
;
/**
...
...
order-application-service/src/main/java/cn/freemud/enums/QueryOrderStatus.java
View file @
2e433f1f
...
...
@@ -20,7 +20,10 @@ public enum QueryOrderStatus {
ALL_BILL
(
3
,
"全部"
),
REFUND_BILL
(
4
,
"退款"
),
NO_PAY
(
5
,
"待支付"
),
ORDER_CANCEL
(
6
,
"已取消"
);
ORDER_CANCEL
(
6
,
"已取消"
),
//密雪
ORDER_CANCEL_MIXUE
(
7
,
"未支付已取消"
);
private
Integer
code
;
...
...
order-application-service/src/main/java/cn/freemud/service/impl/OrderServiceImpl.java
View file @
2e433f1f
...
...
@@ -183,6 +183,12 @@ public class OrderServiceImpl implements Orderservice {
@Value
(
"${partnerId}"
)
private
String
partnerId
;
/**
* coco商户
*/
@Value
(
"#{'${coco.partnerId}'.split(',')}"
)
private
List
<
String
>
cocoPartnerId
;
@Autowired
private
AssortmentCloudPrinterManager
cloudPrinterManager
;
// @Autowired
...
...
@@ -893,14 +899,32 @@ public class OrderServiceImpl implements Orderservice {
// 取红包图片
queryOrderResponseVo
.
setRedpacketsPicture
(
getRedpacketsPicture
(
activityId
));
queryOrderResponseVo
.
setActivityId
(
activityId
);
// coco订单不考略是否查询待取餐的订单,直接调用支付有礼活动
// 所以在这个地方排除掉coco,在下边单独实现
//参与支付有礼活动
joinPayGift
(
queryOrderVo
.
getSessionId
(),
queryOrderResponseVo
);
if
(!
cocoPartnerId
.
contains
(
queryOrderVo
.
getPartnerId
())){
joinPayGift
(
queryOrderVo
.
getSessionId
(),
queryOrderResponseVo
);
}
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"queryOrders_activity_error"
,
gson
.
toJson
(
queryOrdersDto
),
gson
.
toJson
(
queryOrderResponseVo
),
e
);
}
});
}
// coco订单参与支付有礼活动
if
(
cocoPartnerId
.
contains
(
queryOrderVo
.
getPartnerId
())){
queryOrderResponseVos
.
forEach
(
queryOrderResponseVo
->
{
try
{
joinPayGift
(
queryOrderVo
.
getSessionId
(),
queryOrderResponseVo
);
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
"coco_queryOrders_activity_error"
,
gson
.
toJson
(
queryOrdersDto
),
gson
.
toJson
(
queryOrderResponseVo
),
e
);
}
});
}
responseMap
.
put
(
"count"
,
queryOrderResponse
.
getData
()
==
null
?
0
:
queryOrderResponse
.
getData
().
getCount
());
responseMap
.
put
(
"list"
,
queryOrderResponseVos
);
//只有有订单时才显示用户自定义取餐信息
...
...
@@ -1153,6 +1177,7 @@ public class OrderServiceImpl implements Orderservice {
queryOrderResponseVo
.
setActivityName
(
payGiftResponse
.
getActivityName
());
queryOrderResponseVo
.
setCoupons
(
payGiftResponse
.
getCoupons
());
queryOrderResponseVo
.
setWechatCouponInfo
(
payGiftResponse
.
getWechatCouponInfo
());
queryOrderResponseVo
.
setActivitySendType
(
payGiftResponse
.
getSendType
());
}
}
...
...
@@ -1300,6 +1325,12 @@ public class OrderServiceImpl implements Orderservice {
queryOrderResponseVo
.
setRedpacketsPicture
(
getRedpacketsPicture
(
activityId
));
}
// 支付有礼
// 目前只有coco在订单详情参加支付有礼,且不检查订单的状态
if
(
cocoPartnerId
.
contains
(
partnerId
)){
joinPayGift
(
sessionId
,
queryOrderResponseVo
);
}
return
ResponseUtil
.
success
(
queryOrderResponseVo
);
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
View file @
2e433f1f
...
...
@@ -289,7 +289,7 @@ public class ShoppingCartConvertAdapter {
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
MaterialGoods
goods
=
new
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
MaterialGoods
();
goods
.
setSpuId
(
materialGoods
.
getSpuId
());
goods
.
setSpuName
(
materialGoods
.
getSpuName
());
goods
.
setOriginalPrice
(
materialGoods
.
getOriginalPrice
()
);
goods
.
setOriginalPrice
(
null
!=
materialGoods
.
getOriginalPrice
()
?
materialGoods
.
getOriginalPrice
()
:
0
);
goods
.
setSalePrice
(
materialGoods
.
getFinalPrice
());
goods
.
setQty
(
cartGoods
.
getQty
());
goods
.
setTotalDiscountAmount
(
0
);
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/calculate/CalculationSharingDiscountResponseDto.java
View file @
2e433f1f
...
...
@@ -65,7 +65,7 @@ public class CalculationSharingDiscountResponseDto {
/**
* 满额赠券活动号列表
*/
private
List
<
String
>
sendCoupons
;
//
private List<String> sendCoupons;
/**
* 使用到的优惠券及优惠金额
*/
...
...
@@ -392,6 +392,21 @@ public class CalculationSharingDiscountResponseDto {
* 赠送商品数量
*/
private
Integer
sendNumber
;
/**
* 可兑换商品券编号
*/
private
String
sendCouponCode
;
/**
* 可兑换商品券名称
*/
private
String
sendCouponName
;
/**
* 是否已选择寄杯
*/
private
Boolean
sendCoupon
;
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartGoodsResponseVo.java
View file @
2e433f1f
...
...
@@ -12,9 +12,12 @@
*/
package
cn
.
freemud
.
entities
.
vo
;
import
cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto
;
import
cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.util.Date
;
import
java.math.BigDecimal
;
import
java.util.List
;
...
...
@@ -161,4 +164,47 @@ public class ShoppingCartGoodsResponseVo extends ShoppingCartGoodsBaseResponseV
*/
private
String
buyThreeGiveOneCouponCode
;
}
/**
* 总的优惠信息集合
*/
private
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
;
/**
* 商品优惠信息
*/
private
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goods
;
/**
* 用户可以选择的商品
*/
private
List
<
chooseGood
>
chooseGoods
;
@Data
public
static
class
chooseGood
{
/**
* 活动类型
*/
private
Integer
activeType
;
/**
* 赠送商品名称
*/
private
String
goodsName
;
/**
* 可兑换商品券编号
*/
private
String
couponCode
;
/**
* 可兑换商品券名称
*/
private
String
couponName
;
/**
* 是否已选择寄杯
*/
private
Boolean
sendCoupon
;
}}
shopping-cart-application-service/src/main/java/cn/freemud/enums/ActivityTypeEnum.java
View file @
2e433f1f
...
...
@@ -40,6 +40,7 @@ public enum ActivityTypeEnum {
TYPE_6
(
6
,
"买M赠N"
),
TYPE_61
(
61
,
"单品买M赠N"
),
TYPE_62
(
62
,
"买赠"
),
TYPE_63
(
63
,
"买一赠一寄杯"
),
TYPE_7
(
7
,
"满额赠券"
),
TYPE_8
(
8
,
"满N件换购"
),
/**
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/DeliveryFactory.java
0 → 100644
View file @
2e433f1f
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: CouponService
* @Package cn.freemud.service
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
.
delivery
;
public
interface
DeliveryFactory
{
/**
* 获取运费计算类
* @param orderType
* @param receiveId
* @return
*/
DeliveryService
getCalculateDeliveryAmount
(
Integer
orderType
,
String
receiveId
);
}
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/DeliveryService.java
0 → 100644
View file @
2e433f1f
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: CouponService
* @Package cn.freemud.service
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
.
delivery
;
import
cn.freemud.entities.vo.ShoppingCartGoodsResponseVo
;
public
interface
DeliveryService
{
/**
* 计算运费
* @param receiveId
* @param partnerId
* @param storeId
* @param shoppingCartGoodsResponseVo
* @return
*/
Long
calculateDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
);
}
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/AbstractDeliveryServiceImpl.java
0 → 100644
View file @
2e433f1f
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: CouponService
* @Package cn.freemud.service
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
.
delivery
.
impl
;
import
cn.freemud.service.delivery.DeliveryService
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
public
abstract
class
AbstractDeliveryServiceImpl
implements
DeliveryService
{
}
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/DeliveryFactoryImpl.java
0 → 100644
View file @
2e433f1f
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: CouponService
* @Package cn.freemud.service
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
.
delivery
.
impl
;
import
cn.freemud.enums.CreateOrderType
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.delivery.DeliveryFactory
;
import
cn.freemud.service.delivery.DeliveryService
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Service
;
import
java.util.Objects
;
@Service
public
class
DeliveryFactoryImpl
implements
DeliveryFactory
{
/**
* 梯度运费
*/
@Autowired
@Qualifier
(
"gradDeliveryService"
)
DeliveryService
gradDeliveryService
;
/**
* 固定运费
*/
@Autowired
@Qualifier
(
"fixDeliveryService"
)
DeliveryService
fixDeliveryServiceImpl
;
@Override
public
DeliveryService
getCalculateDeliveryAmount
(
Integer
orderType
,
String
receiveId
)
{
// 如果订单的收获地址为空,且订单是外卖单,使用固定运费
if
(
StringUtils
.
isBlank
(
receiveId
)
&&
Objects
.
equals
(
orderType
,
CreateOrderType
.
TAKE_OUT
.
getCode
()))
{
return
fixDeliveryServiceImpl
;
}
else
if
(
StringUtils
.
isNotBlank
(
receiveId
)){
return
gradDeliveryService
;
}
throw
new
ServiceException
(
ResponseResult
.
STORE_DELIVERY_AMOUNT_ERROR
);
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/FixDeliveryServiceImpl.java
0 → 100644
View file @
2e433f1f
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: CouponService
* @Package cn.freemud.service
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
.
delivery
.
impl
;
import
cn.freemud.entities.vo.ShoppingCartGoodsResponseVo
;
import
cn.freemud.enums.CreateOrderType
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.delivery.DeliveryService
;
import
cn.freemud.utils.ResponseUtil
;
import
com.freemud.application.sdk.api.log.LogThreadLocal
;
import
com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest
;
import
com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse
;
import
com.freemud.application.sdk.api.storecenter.request.QueryDeliveryRequest
;
import
com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest
;
import
com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailResponse
;
import
com.freemud.application.sdk.api.storecenter.response.StoreResponse
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Objects
;
@Service
(
"fixDeliveryService"
)
public
class
FixDeliveryServiceImpl
extends
AbstractDeliveryServiceImpl
implements
DeliveryService
{
@Autowired
private
StoreCenterService
storeCenterService
;
@Override
public
Long
calculateDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
// 获取门店信息,查询基础配送费用
StoreInfoRequest
storeInfoRequest
=
new
StoreInfoRequest
(
partnerId
,
storeId
,
null
);
StoreResponse
storeResponse
=
storeCenterService
.
getStoreInfo
(
storeInfoRequest
,
trackingNo
);
if
(
storeResponse
==
null
||
storeResponse
.
getBizVO
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_NOT_FOUND
);
}
shoppingCartGoodsResponseVo
.
setDeliveryFeeZeroReason
(
0
);
return
new
Double
(
storeResponse
.
getBizVO
().
getDeliveryPrice
()
*
100
).
longValue
();
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/GradDeliveryServiceImpl.java
0 → 100644
View file @
2e433f1f
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: CouponService
* @Package cn.freemud.service
* @Description:
* @author: pengfei.liu
* @date: 2020/11/23
* @version V1.0
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package
cn
.
freemud
.
service
.
delivery
.
impl
;
import
cn.freemud.entities.vo.ShoppingCartGoodsResponseVo
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.delivery.DeliveryService
;
import
com.freemud.application.sdk.api.log.LogThreadLocal
;
import
com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest
;
import
com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse
;
import
com.freemud.application.sdk.api.membercenter.service.MemberCenterService
;
import
com.freemud.application.sdk.api.storecenter.request.QueryDeliveryRequest
;
import
com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailResponse
;
import
com.freemud.application.sdk.api.storecenter.service.StoreCenterService
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
(
"gradDeliveryService"
)
public
class
GradDeliveryServiceImpl
extends
AbstractDeliveryServiceImpl
implements
DeliveryService
{
@Autowired
private
MemberCenterService
memberCenterService
;
@Autowired
private
StoreCenterService
storeCenterService
;
@Override
public
Long
calculateDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
QueryReceiveAddressRequest
queryReceive
=
new
QueryReceiveAddressRequest
(
receiveId
,
partnerId
);
//查询会员收获地址经纬度
com
.
freemud
.
application
.
sdk
.
api
.
base
.
BaseResponse
<
QueryReceiveAddressResponse
>
queryReceiveAddressResponse
=
memberCenterService
.
queryReceiveAddressById
(
queryReceive
,
trackingNo
);
if
(!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
queryReceiveAddressResponse
.
getCode
())
||
queryReceiveAddressResponse
.
getData
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
USER_GETRECEIVEADDRESS_ERROR
);
}
// 查询运费详情
QueryDeliveryRequest
queryDeliveryRequest
=
new
QueryDeliveryRequest
();
queryDeliveryRequest
.
setPartnerId
(
partnerId
);
queryDeliveryRequest
.
setStoreCode
(
storeId
);
queryDeliveryRequest
.
setUserLatitude
(
queryReceiveAddressResponse
.
getData
().
getLatitude
());
queryDeliveryRequest
.
setUserLongitude
(
queryReceiveAddressResponse
.
getData
().
getLongitude
());
com
.
freemud
.
application
.
sdk
.
api
.
base
.
BaseResponse
<
QueryDeliverDetailResponse
>
queryDeliverDetailResponse
=
storeCenterService
.
queryDeliverDetail
(
queryDeliveryRequest
,
trackingNo
);
if
(
queryDeliverDetailResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
queryDeliverDetailResponse
.
getCode
())
||
queryDeliverDetailResponse
.
getData
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_ITEM_NOT_DELIVERY
);
}
if
(
queryDeliverDetailResponse
.
getData
().
getDeliveryAmount
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_DELIVERY_AMOUNT_ERROR
);
}
shoppingCartGoodsResponseVo
.
setDeliveryFeeZeroReason
(
queryDeliverDetailResponse
.
getData
().
getDeliveryFeeZeroReason
()
!=
null
?
queryDeliverDetailResponse
.
getData
().
getDeliveryFeeZeroReason
()
:
0
);
return
queryDeliverDetailResponse
.
getData
().
getDeliveryAmount
();
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
2e433f1f
...
...
@@ -35,6 +35,8 @@ import cn.freemud.interceptor.ServiceException;
import
cn.freemud.interceptor.BizServiceException
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.service.*
;
import
cn.freemud.service.delivery.DeliveryFactory
;
import
cn.freemud.service.delivery.DeliveryService
;
import
cn.freemud.service.impl.calculate.CalculateCenter
;
import
cn.freemud.service.impl.calculate.CalculationSharingCartService
;
import
cn.freemud.service.impl.calculate.CalculationSharingDiscountService
;
...
...
@@ -155,6 +157,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
@Autowired
private
RedisCache
redisCache
;
@Autowired
private
DeliveryFactory
deliveryFactory
;
private
static
final
String
limitCartKey
=
"ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"
;
...
...
@@ -304,7 +309,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
this
.
addProductGoods
(
addShoppingCartGoodsRequestVo
,
cartGoods
,
spuId2
,
userId
,
shoppingCartGoodsResponseVo
,
spuId
,
allCartGoodsList
,
productBeanListSpuClass
,
StringUtils
.
isNotBlank
(
skuId
)
?
true
:
false
);
}
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
,
addShoppingCartGoodsRequestVo
.
getOrderType
()
);
// 当商品数量被设为0时
...
...
@@ -338,6 +343,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
,
menuType
,
deliveryAmount
,
ShoppingCartConstant
.
ADD_AND_UPDATE
);
buildDiscounts
(
shoppingCartGoodsResponseVo
,
discountResult
);
}
else
{
// 获取优惠信息
...
...
@@ -351,6 +358,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
clearMsg
(
shoppingCartGoodsResponseVo
,
cartGoods
.
getCartGoodsUid
());
//设置更新响应信息
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
allCartGoodsList
,
null
,
partnerId
,
storeId
,
userId
,
ShoppingCartConstant
.
ADD_AND_UPDATE
,
null
);
}
//埋点添加购物车行为
this
.
buriedPointShoppingCart
(
addShoppingCartGoodsRequestVo
,
spuId
,
productName
);
...
...
@@ -427,9 +435,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
updateShoppingCartGoodsQtyRequestVo
.
getSessionId
(),
""
,
shoppingCartBaseService
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
,
updateShoppingCartGoodsQtyRequestVo
.
getOrderType
());
ActivityQueryDto
activityQueryDto
=
activityAdapter
.
getActivityQueryDto
(
partnerId
,
storeId
,
userId
,
appId
,
updateShoppingCartGoodsQtyRequestVo
.
getOrderType
());
...
...
@@ -457,6 +463,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
,
menuType
,
deliveryAmount
,
ShoppingCartConstant
.
ADD_AND_UPDATE
);
buildDiscounts
(
shoppingCartGoodsResponseVo
,
discountResult
);
}
else
{
// 获取优惠信息
...
...
@@ -473,6 +481,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
clearMsg
(
shoppingCartGoodsResponseVo
,
cartGoodsUid
);
//设置更新响应信息
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
partnerId
,
storeId
,
userId
,
ShoppingCartConstant
.
ADD_AND_UPDATE
,
null
);
}
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
...
...
@@ -562,7 +571,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
assortmentCustomerInfoVo
.
getSessionId
(),
""
,
this
.
shoppingCartBaseService
);
}
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
,
shoppingCartInfoRequestVo
.
getOrderType
()
);
ActivityQueryDto
activityQueryDto
=
activityAdapter
.
getActivityQueryDto
(
partnerId
,
storeId
,
userId
,
appId
,
shoppingCartInfoRequestVo
.
getOrderType
());
CouponPromotionVO
couponPromotionVO
=
couponAdapter
.
getCouponPromotionVO
(
shoppingCartInfoRequestVo
,
userLoginInfoDto
);
...
...
@@ -608,6 +617,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
,
menuType
,
deliveryAmount
,
ShoppingCartConstant
.
QUERY_INFO
);
buildDiscounts
(
shoppingCartGoodsResponseVo
,
calculationSharingDiscountResult
);
}
else
{
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
new
ArrayList
<>();
...
...
@@ -629,6 +640,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
calculationDiscountResult
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
partnerId
,
storeId
,
userId
,
ShoppingCartConstant
.
QUERY_INFO
,
shoppingCartInfoRequestVo
);
// 在原价、现价、折扣价上增加第一次使用会员卡的费用
this
.
addNeedCardAmount
(
shoppingCartInfoRequestVo
,
shoppingCartGoodsResponseVo
);
}
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
...
...
@@ -778,7 +790,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto
activityQueryDto
=
activityAdapter
.
getActivityQueryDto
(
partnerId
,
storeId
,
userId
,
appId
,
shoppingCartInfoRequestVo
.
getOrderType
());
CouponPromotionVO
couponPromotionVO
=
couponAdapter
.
getCouponPromotionVO
(
shoppingCartInfoRequestVo
,
userLoginInfoDto
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
);
Long
deliveryAmount
=
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
userLoginInfoDto
.
getWxAppid
(),
shoppingCartGoodsResponseVo
,
shoppingCartInfoRequestVo
.
getOrderType
()
);
if
(
grayPush
(
partnerId
,
storeId
,
"2"
))
{
List
<
CalculationSharingDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
new
ArrayList
<>();
// 当couponCode不为空时,需参与价格计算
...
...
@@ -1740,33 +1752,19 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return
amount
;
}
private
Long
getNewDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
private
Long
getNewDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
Integer
orderType
)
{
//
String trackingNo = LogThreadLocal.getTrackingNo();
Long
amount
=
0L
;
if
(
StringUtils
.
isBlank
(
receiveId
))
{
// 如果订单的收获地址为空,且订单是外卖单,返回运费
// 主要是为了兼容coco不传收获地址,需要获取固定运费的情况
if
(
StringUtils
.
isBlank
(
receiveId
)
&&
!
Objects
.
equals
(
orderType
,
CreateOrderType
.
TAKE_OUT
.
getCode
()))
{
return
amount
;
}
QueryReceiveAddressRequest
queryReceive
=
new
QueryReceiveAddressRequest
(
receiveId
,
partnerId
);
//查询会员后货地址经纬度
com
.
freemud
.
application
.
sdk
.
api
.
base
.
BaseResponse
<
QueryReceiveAddressResponse
>
queryReceiveAddressResponse
=
memberCenterService
.
queryReceiveAddressById
(
queryReceive
,
trackingNo
);
if
(!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
queryReceiveAddressResponse
.
getCode
())
||
queryReceiveAddressResponse
.
getData
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
USER_GETRECEIVEADDRESS_ERROR
);
}
QueryDeliveryRequest
queryDeliveryRequest
=
new
QueryDeliveryRequest
();
queryDeliveryRequest
.
setPartnerId
(
partnerId
);
queryDeliveryRequest
.
setStoreCode
(
storeId
);
queryDeliveryRequest
.
setUserLatitude
(
queryReceiveAddressResponse
.
getData
().
getLatitude
());
queryDeliveryRequest
.
setUserLongitude
(
queryReceiveAddressResponse
.
getData
().
getLongitude
());
com
.
freemud
.
application
.
sdk
.
api
.
base
.
BaseResponse
<
QueryDeliverDetailResponse
>
queryDeliverDetailResponse
=
storeCenterService
.
queryDeliverDetail
(
queryDeliveryRequest
,
trackingNo
);
if
(
queryDeliverDetailResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
queryDeliverDetailResponse
.
getCode
())
||
queryDeliverDetailResponse
.
getData
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_ITEM_NOT_DELIVERY
);
}
if
(
queryDeliverDetailResponse
.
getData
().
getDeliveryAmount
()
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
STORE_DELIVERY_AMOUNT_ERROR
);
}
shoppingCartGoodsResponseVo
.
setDeliveryFeeZeroReason
(
queryDeliverDetailResponse
.
getData
().
getDeliveryFeeZeroReason
()
!=
null
?
queryDeliverDetailResponse
.
getData
().
getDeliveryFeeZeroReason
()
:
0
);
return
queryDeliverDetailResponse
.
getData
().
getDeliveryAmount
();
DeliveryService
deliveryService
=
deliveryFactory
.
getCalculateDeliveryAmount
(
orderType
,
receiveId
);
amount
=
deliveryService
.
calculateDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
shoppingCartGoodsResponseVo
);
return
amount
;
}
/**
...
...
@@ -1813,9 +1811,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return
calculationDiscountResult
;
}
private
Long
calculateDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
String
wxappid
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
private
Long
calculateDeliveryAmount
(
String
receiveId
,
String
partnerId
,
String
storeId
,
String
wxappid
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
Integer
orderType
)
{
Long
deliveryAmount
=
0L
;
if
(
StringUtils
.
isBlank
(
receiveId
))
{
// 如果订单的收获地址为空,且订单是外卖单,返回运费
// 主要是为了兼容coco不传收获地址,需要获取固定运费的情况
if
(
StringUtils
.
isBlank
(
receiveId
)
&&
!
Objects
.
equals
(
orderType
,
CreateOrderType
.
TAKE_OUT
.
getCode
()))
{
return
deliveryAmount
;
}
log
.
info
(
"获取配送配逻辑 tackingNo:{},storeDeliveryUseOld:{},receiveId:{},partnerId:{},storeId:{}"
,
LogThreadLocal
.
getTrackingNo
(),
storeDeliveryUseOld
,
receiveId
,
partnerId
,
storeId
);
...
...
@@ -1823,7 +1823,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
deliveryAmount
=
Long
.
parseLong
(
getDeliveryAmount
(
receiveId
,
partnerId
,
storeId
).
toString
());
shoppingCartGoodsResponseVo
.
setDeliveryFeeZeroReason
(
0
);
}
else
{
deliveryAmount
=
getNewDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
shoppingCartGoodsResponseVo
);
deliveryAmount
=
getNewDeliveryAmount
(
receiveId
,
partnerId
,
storeId
,
shoppingCartGoodsResponseVo
,
orderType
);
}
return
deliveryAmount
;
...
...
@@ -2064,4 +2064,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
/**
* 设置总的优惠信息和商品优惠信息
* @param shoppingCartGoodsResponseVo
* @param discountResult
*/
private
void
buildDiscounts
(
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
)
{
if
(
discountResult
!=
null
){
shoppingCartGoodsResponseVo
.
setDiscounts
(
discountResult
.
getDiscounts
());
shoppingCartGoodsResponseVo
.
setGoods
(
discountResult
.
getGoods
());
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationSharingCartService.java
View file @
2e433f1f
...
...
@@ -51,6 +51,9 @@ public class CalculationSharingCartService {
@Autowired
private
CalculationCommonService
calculationCommonService
;
@Autowired
private
BuyOneGiveOneSendService
buyOneGiveOneSendService
;
/**
* 响应购物车价格计算依赖促销
*/
...
...
@@ -109,5 +112,10 @@ public class CalculationSharingCartService {
calculationCommonService
.
addNeedCardAmount
(
shoppingCartInfoRequestVo
,
shoppingCartGoodsResponseVo
);
}
/**
* 买一赠一寄杯
*/
buyOneGiveOneSendService
.
giftResponse
(
discountResult
,
cartGoodsList
,
shoppingCartInfoRequestVo
,
activityQueryDto
,
shoppingCartGoodsResponseVo
);
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/BuyOneGiveOneSendService.java
0 → 100644
View file @
2e433f1f
package
cn
.
freemud
.
service
.
impl
.
calculate
.
promotion
;
import
cn.freemud.constant.ShoppingCartConstant
;
import
cn.freemud.entities.dto.activity.ActivityDiscountsDto
;
import
cn.freemud.entities.dto.activity.ActivityQueryDto
;
import
cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.ActivityTypeEnum
;
import
cn.freemud.enums.CalculationGoodsType
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.ItemService
;
import
cn.freemud.service.impl.AssortmentSdkService
;
import
com.alibaba.fastjson.JSON
;
import
com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.service.impl.calculate.promotion AdditionSharingService
* @Description: 加价购商品
* @author: pengfei.liu
* @date: 2020/11/26
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Service
@Slf4j
public
class
BuyOneGiveOneSendService
{
@Autowired
private
AssortmentSdkService
assortmentSdkService
;
@Autowired
private
ShoppingCartBaseServiceImpl
shoppingCartBaseService
;
public
void
giftResponse
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
List
<
CartGoods
>
cartGoodsList
,
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
,
ActivityQueryDto
activityQueryDto
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
if
(
discountResult
==
null
){
return
;
}
// 过略出来买一赠一寄杯活动,没有直接返回
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
discounts
=
discountResult
.
getDiscounts
();
if
(
null
==
discounts
||
discounts
.
isEmpty
()){
return
;
}
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
buyOneGiveOneSendDiscounts
=
discounts
.
stream
()
.
filter
(
discount
->
ObjectUtils
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_63
.
getCode
()))
.
collect
(
Collectors
.
toList
());
if
(
null
==
buyOneGiveOneSendDiscounts
||
buyOneGiveOneSendDiscounts
.
isEmpty
()){
return
;
}
if
(
discountResult
==
null
||
CollectionUtils
.
isEmpty
(
discountResult
.
getGoods
()))
{
return
;
}
String
menuType
=
shoppingCartInfoRequestVo
==
null
?
null
:
shoppingCartInfoRequestVo
.
getMenuType
();
// 构建赠品detail
List
<
ProductBeanDTO
>
beanDTOList
=
this
.
drawGiftInfo
(
discountResult
,
activityQueryDto
,
menuType
);
this
.
setCartGoods
(
discountResult
,
cartGoodsList
,
beanDTOList
);
// 设置用户可以选择的寄送商品券码
this
.
buildSendGoods
(
discountResult
,
shoppingCartGoodsResponseVo
);
}
/**
* 抽取赠品
* goodsId->goods
*
* @param discountResult
* @return
*/
private
List
<
String
>
getProductIdsForGift
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
)
{
List
<
String
>
gifts
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isEmpty
(
discountResult
.
getGoods
()))
{
return
gifts
;
}
gifts
=
discountResult
.
getGoods
()
.
stream
()
.
filter
(
d
->
CalculationGoodsType
.
TYPE_1
.
getType
().
equals
(
d
.
getCartGoodType
()))
.
map
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getGoodsId
)
.
collect
(
Collectors
.
toList
());
return
gifts
;
}
/**
* 转换参加促销的商品为Map<goodsId,Goods>
*
* @param discountResult
* @return
*/
public
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
getDiscountForGift
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
)
{
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
gifts
=
discountResult
.
getGoods
()
.
stream
()
.
filter
(
d
->
CalculationGoodsType
.
TYPE_1
.
getType
().
equals
(
d
.
getCartGoodType
()))
.
collect
(
Collectors
.
toMap
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
return
gifts
;
}
/**
* 赠品detail
*
* @param discountResult
* @param activityQueryDto
* @param menuType
*/
private
List
<
ProductBeanDTO
>
drawGiftInfo
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
ActivityQueryDto
activityQueryDto
,
String
menuType
)
{
List
<
ProductBeanDTO
>
productBeanList
=
new
ArrayList
<>();
// 抽取赠品
List
<
String
>
gifts
=
this
.
getProductIdsForGift
(
discountResult
);
if
(
CollectionUtils
.
isEmpty
(
gifts
))
return
productBeanList
;
productBeanList
=
assortmentSdkService
.
getProductsInfoSdk
(
activityQueryDto
.
getPartnerId
()
,
activityQueryDto
.
getStoreId
(),
gifts
,
menuType
,
shoppingCartBaseService
);
if
(
CollectionUtils
.
isEmpty
(
productBeanList
))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_GIFTS_PRODUCT_NOT_EXIST
);
}
return
productBeanList
;
}
/**
* 响应购物车行
*/
public
void
setCartGoods
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
List
<
CartGoods
>
cartGoodsLists
,
List
<
ProductBeanDTO
>
products
)
{
if
(
CollectionUtils
.
isEmpty
(
products
))
return
;
// 转换参加促销的商品为Map<goodsId,Goods>
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
discountForGift
=
this
.
getDiscountForGift
(
discountResult
);
List
<
CartGoods
>
cartGoodsList
=
new
ArrayList
<>();
for
(
ProductBeanDTO
product
:
products
)
{
String
k
=
product
.
getPid
();
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
=
discountForGift
.
get
(
k
);
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
discount
=
goods
.
getDiscounts
()
.
stream
()
.
filter
(
g
->
ActivityTypeEnum
.
TYPE_63
.
getCode
().
equals
(
g
.
getType
()))
.
findFirst
()
.
get
();
CartGoods
cartGood
=
new
CartGoods
();
cartGood
.
setGoodsId
(
goods
.
getGoodsId
());
cartGood
.
setGoodsType
(
1
);
cartGood
.
setSpuId
(
goods
.
getGoodsId
());
cartGood
.
setSkuId
(
goods
.
getGoodsId
());
cartGood
.
setOriginalPrice
(
product
.
getFinalPrice
());
cartGood
.
setPackPrice
(
product
.
getPackPrice
());
cartGood
.
setOriginalAmount
(
goods
.
getOriginalPrice
()
*
goods
.
getGoodsQuantity
());
cartGood
.
setAmount
(
goods
.
getRealAmount
());
cartGood
.
setName
(
product
.
getName
());
cartGood
.
setSpuName
(
product
.
getName
());
cartGood
.
setCategoryName
(
product
.
getName
());
cartGood
.
setPic
(
product
.
getPicture
());
cartGood
.
setSkuName
(
product
.
getName
());
cartGood
.
setActivityType
(
discount
.
getType
());
cartGood
.
setStockLimit
(
ObjectUtils
.
equals
(
1
,
product
.
getStockLimit
()));
cartGood
.
setCustomerCode
(
product
.
getCustomerCode
());
cartGood
.
setUnit
(
product
.
getUnit
());
cartGood
.
setWeight
(
product
.
getWeight
());
cartGood
.
setQty
(
goods
.
getGoodsQuantity
());
cartGood
.
setClassificationId
(
product
.
getCategory
());
cartGood
.
setClassificationName
(
product
.
getCategoryName
());
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGood
.
setNodeId
(
discount
.
getActivityCode
());
cartGoodsList
.
add
(
cartGood
);
}
cartGoodsLists
.
addAll
(
cartGoodsList
);
}
/**
* 抽取赠品
* goodsId->goods
*
* @param discountResult
* @return
*/
private
void
buildSendGoods
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
// 赠送、换购商品信息集合
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendGoods
=
discountResult
.
getSendGoods
();
if
(
sendGoods
==
null
||
sendGoods
.
isEmpty
()){
return
;
}
// 抽取买一赠一寄件活动送的商品
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
buyOneGiveOneSendGoods
=
sendGoods
.
stream
()
.
filter
(
sendGood
->
ObjectUtils
.
equals
(
sendGood
.
getActivityType
(),
ActivityTypeEnum
.
TYPE_63
.
getCode
()))
.
collect
(
Collectors
.
toList
());
if
(
null
==
buyOneGiveOneSendGoods
||
buyOneGiveOneSendGoods
.
isEmpty
()){
return
;
}
List
<
ShoppingCartGoodsResponseVo
.
chooseGood
>
chooseGoods
=
shoppingCartGoodsResponseVo
.
getChooseGoods
()
==
null
?
new
ArrayList
<>()
:
shoppingCartGoodsResponseVo
.
getChooseGoods
();
buyOneGiveOneSendGoods
.
forEach
(
sendActivity
->{
// 这个是真正的送的券
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
>
innerSendGoods
=
sendActivity
.
getSendGoods
();
if
(
innerSendGoods
==
null
||
innerSendGoods
.
isEmpty
()){
return
;
}
innerSendGoods
.
forEach
(
innerSendGood
->
{
ShoppingCartGoodsResponseVo
.
chooseGood
chooseGood
=
new
ShoppingCartGoodsResponseVo
.
chooseGood
();
chooseGood
.
setActiveType
(
sendActivity
.
getActivityType
());
chooseGood
.
setCouponCode
(
innerSendGood
.
getSendCouponCode
());
chooseGood
.
setCouponName
(
innerSendGood
.
getSendCouponName
());
chooseGood
.
setSendCoupon
(
innerSendGood
.
getSendCoupon
());
chooseGood
.
setGoodsName
(
innerSendGood
.
getGoodsName
());
chooseGoods
.
add
(
chooseGood
);
});
});
shoppingCartGoodsResponseVo
.
setChooseGoods
(
chooseGoods
);
}
}
\ No newline at end of file
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
View file @
2e433f1f
...
...
@@ -420,7 +420,8 @@ public class CalculationServiceImpl {
material
.
setType
(
2
);
material
.
setGoodsId
(
materialGoods
.
getGoodsId
());
material
.
setGoodsQuantity
(
materialGoods
.
getQty
());
material
.
setOriginalPrice
(
materialGoods
.
getFinalPrice
());
material
.
setOriginalPrice
(
null
!=
materialGoods
.
getFinalPrice
()
?
materialGoods
.
getFinalPrice
()
:
0
);
materials
.
add
(
material
);
}
}
...
...
@@ -438,7 +439,8 @@ public class CalculationServiceImpl {
material
.
setType
(
1
);
material
.
setGoodsId
(
materialGoods2
.
getSpuId
());
material
.
setGoodsQuantity
(
1
);
material
.
setOriginalPrice
(
materialGoods2
.
getFinalPrice
());
material
.
setOriginalPrice
(
null
!=
materialGoods2
.
getFinalPrice
()
?
materialGoods2
.
getFinalPrice
()
:
0
);
materials
.
add
(
material
);
}
}
...
...
@@ -452,7 +454,8 @@ public class CalculationServiceImpl {
material
.
setType
(
1
);
material
.
setGoodsId
(
materialGoods
.
getSpuId
());
material
.
setGoodsQuantity
(
1
);
material
.
setOriginalPrice
(
materialGoods
.
getOriginalPrice
());
material
.
setOriginalPrice
(
null
!=
materialGoods
.
getOriginalPrice
()
?
materialGoods
.
getOriginalPrice
()
:
0
);
material
.
setNowPrice
(
materialGoods
.
getFinalPrice
().
intValue
());
materials
.
add
(
material
);
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/SetMealCalculation.java
View file @
2e433f1f
...
...
@@ -76,7 +76,7 @@ public class SetMealCalculation {
Long
comboxmaterialPrice
=
0L
;
if
(
CollectionUtils
.
isNotEmpty
(
comboxGoods
.
getProductMaterialList
())){
for
(
CartGoods
.
MaterialGoods
materialGoods
:
comboxGoods
.
getProductMaterialList
()){
comboxmaterialPrice
+=
materialGoods
.
getFinalPrice
()
*
cartGoods
.
getQty
()
;
comboxmaterialPrice
+=
null
!=
materialGoods
.
getFinalPrice
()
?
materialGoods
.
getFinalPrice
()
*
cartGoods
.
getQty
()
:
0
;
}
}
comboxGoods
.
setAmount
(
comboxGoods
.
getAmount
()+
comboxmaterialPrice
);
...
...
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