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
840ea36e
Commit
840ea36e
authored
Dec 11, 2023
by
box
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature/box/查卡包链路优化
parent
05359cb9
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
579 additions
and
20 deletions
+579
-20
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/AvailableCouponDto.java
+23
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponAvailabilityQueryRequest.java
+135
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponAvailabilityQueryResponse.java
+18
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponInfoDto.java
+182
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponResponseDTO.java
+2
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/FastTemplateInfoResponseVO.java
+36
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/UnAvailableCouponDto.java
+29
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
+128
-6
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+2
-2
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+3
-5
shopping-cart-application-service/src/main/java/cn/freemud/service/thirdparty/CouponQueryClient.java
+17
-3
shopping-cart-application-service/src/test/java/cn.freemud/client/CouponQueryClientTest.java
+4
-4
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/AvailableCouponDto.java
0 → 100644
View file @
840ea36e
package
cn
.
freemud
.
entities
.
dto
.
coupon
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
/**
* © All rights Reserved
*
* @author wénkǎi.zhāng 2023-12-08
* @since 1.0
*/
@Data
public
class
AvailableCouponDto
{
/**
* 券信息
*/
private
CouponInfoDto
couponInfo
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponAvailabilityQueryRequest.java
0 → 100644
View file @
840ea36e
package
cn
.
freemud
.
entities
.
dto
.
coupon
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.Valid
;
import
javax.validation.constraints.*
;
import
java.util.List
;
/**
* © All rights Reserved
*
* @author wénkǎi.zhāng 2023-12-08
* @since 1.0
*/
@Data
public
class
CouponAvailabilityQueryRequest
{
/**
* 商户号
*/
@NotEmpty
(
message
=
"商户号不能为空"
)
private
String
partnerId
;
/**
* 会员ID
*/
@NotNull
(
message
=
"memberId不能为空"
)
private
String
memberId
;
/**
* 券类型列表
* <p>
* 根据类型列表查询指定类型的券,为空则查询全部
*/
private
List
<
Integer
>
types
;
/**
* 所属门店
*/
@NotNull
(
message
=
"门店编号不能为空"
)
private
String
storeId
;
/**
* 门店所属渠道
*/
private
List
<
String
>
storeChannels
;
/**
* 当前小程序appid
*/
private
String
appId
;
/**
* 核销场景
*/
private
String
scene
;
@ApiModelProperty
(
"门店餐段配置"
)
private
List
<
MealSectionTimePeriod
>
mealSectionTimePeriods
;
/**
* 购物车信息
*/
@Valid
private
ShoppingCardInfo
shoppingCardInfo
;
@Data
public
static
class
ShoppingCardInfo
{
/**
* 商品列表
*/
@Valid
@Size
(
min
=
1
,
message
=
"购物车商品不能为空"
)
private
List
<
Product
>
products
;
/**
* 总金额
*/
private
Integer
totalAmount
;
}
/**
* 商品信息
*/
@Data
public
static
class
Product
{
/**
* 商品编号
* sku
*/
@NotNull
(
message
=
"商品代码不能为空"
)
private
String
productCode
;
/**
* 券号
* <p>
* 如果是商品券、换购券、买M免N则存在券号
*/
private
String
couponCode
;
/**
* 商品原价
*/
private
Integer
originalPrice
;
/**
* 商品优惠价
*/
private
Integer
preferentialPrice
;
}
@Data
public
static
class
MealSectionTimePeriod
{
@NotNull
(
message
=
"餐段类型不能为空"
)
private
Integer
sectionType
;
@ApiModelProperty
(
value
=
"餐段开始时间,单位:秒,1代表当天0点0分1秒"
,
required
=
true
,
allowableValues
=
"range[0, 86398]"
,
example
=
"0"
)
@NotNull
(
message
=
"餐段开始时间为不能为空"
)
@Min
(
value
=
0
,
message
=
"餐段结束时间取值范围[0,86398]"
)
@Max
(
value
=
86398
,
message
=
"餐段结束时间取值范围[0,86398]"
)
private
Integer
beginTime
;
@ApiModelProperty
(
value
=
"餐段结束时间,单位:秒,86399代表当天23点59分59秒"
,
required
=
true
,
allowableValues
=
"range[1, 86399]"
,
example
=
"86399"
)
@NotNull
(
message
=
"餐段结束时间为不能为空"
)
@Min
(
value
=
1
,
message
=
"结束时间取值范围[1,86399]"
)
@Max
(
value
=
86399
,
message
=
"餐段结束时间取值范围[1,86399]"
)
private
Integer
endTime
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponAvailabilityQueryResponse.java
0 → 100644
View file @
840ea36e
package
cn
.
freemud
.
entities
.
dto
.
coupon
;
import
lombok.Data
;
import
java.util.List
;
/**
* © All rights Reserved
*
* @author wénkǎi.zhāng 2023-12-08
* @since 1.0
*/
@Data
public
class
CouponAvailabilityQueryResponse
{
private
List
<
AvailableCouponDto
>
availableCoupons
;
private
List
<
UnAvailableCouponDto
>
unAvailableCoupons
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponInfoDto.java
0 → 100644
View file @
840ea36e
package
cn
.
freemud
.
entities
.
dto
.
coupon
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
/**
* © All rights Reserved
*
* @author wénkǎi.zhāng 2023-12-11
* @since 1.0
*/
@Data
public
class
CouponInfoDto
{
/**
* 券主键ID
* <p>
* 冗余字段,方便查询
*/
private
Long
id
;
/**
* 券名称
*/
private
String
name
;
/**
* 券号
*/
private
String
code
;
/**
* 类型
*/
private
Integer
type
;
/**
* 状态
*/
private
Integer
state
;
/**
* 开始时间
*/
private
String
startTime
;
/**
* 结束时间
*/
private
String
endTime
;
/**
* 所有券类型通用的券面值
* 该字段不为null时,取该字段作为面值,金额单位为分,100代表1元,如果是折扣,60代表6折.如果字段为null,按照老券处理,不同券从不同的地方取值
*/
private
Integer
faceValue
;
/**
* 启用金额
*/
private
Integer
minAmount
;
/**
* 模板ID
*/
private
String
templateId
;
/**
* 模板编号
*/
private
String
templateCode
;
/**
* 券Logo
*/
private
String
logo
;
/**
* 所属门店
* <p>
* 发券时指定门店特有
*/
private
String
storeId
;
/**
* 是否优惠同享
* <p>
* 0 否 1 是
*/
private
Integer
promotionSharing
;
/**
* 核销次数限制类型
* <p>
* 1:不限,2:每日,3:每周,4:每月
*/
private
Integer
redeemNumLimitType
;
/**
* 最大可用次数
*/
private
Integer
configMaxRedeemNums
;
/**
* 每日最大可用次数
*/
private
Integer
configDayMaxRedeemNums
;
/**
* 当前剩余的可用次数
*/
private
Integer
leftAvailableNums
;
/**
* 最大剩余可用次数
*/
private
Integer
leftMaxAvailableNums
;
/**
* 不可用原因
*/
private
String
unAvailableReason
;
/**
* 不可用错误码
*/
private
String
unAvailableCode
;
@JsonIgnore
private
boolean
hasRedeemNumLimitType
=
false
;
/**
* 次数统计周期过期时间
*/
@JsonIgnore
private
Date
redeemCycleExpiredTime
;
/**
* 周期内已核销次数
*/
@JsonIgnore
private
Integer
redeemCycleNum
;
/**
* 全局已核销次数
*/
@JsonIgnore
private
Integer
redeemMaxNum
;
/**
* 券可用的小程序ID
*/
private
List
<
String
>
appIds
;
@ApiModelProperty
(
value
=
"发码来源类型"
)
private
Integer
sourceOrigin
;
/**
* 发码来源类型id
*/
@ApiModelProperty
(
value
=
"发码来源类型id"
,
notes
=
"来源ID最大长度未64位"
)
private
String
sourceOriginId
;
private
Integer
exemptionRule
;
@ApiModelProperty
(
value
=
"活动商品类别描述,买A赠B必传"
,
example
=
"主食"
)
private
String
activityProductDesc
;
@ApiModelProperty
(
value
=
"赠送商品描述,买A赠B必传"
,
example
=
"小吃"
)
private
String
giftDesc
;
@ApiModelProperty
(
"券主页图片-使用券时,页面的图片"
)
private
String
couponHomePicture
;
@ApiModelProperty
(
"商家实收金额(分)"
)
private
Integer
receivedAmount
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/CouponResponseDTO.java
View file @
840ea36e
package
cn
.
freemud
.
entities
.
dto
.
coupon
;
import
com.fasterxml.jackson.annotation.JsonAlias
;
import
lombok.Data
;
/**
...
...
@@ -17,6 +18,7 @@ public class CouponResponseDTO<T> {
*/
private
String
msg
;
@JsonAlias
(
"data"
)
private
T
result
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/FastTemplateInfoResponseVO.java
View file @
840ea36e
...
...
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author : xh.Z
...
...
@@ -68,4 +69,39 @@ public class FastTemplateInfoResponseVO {
@ApiModelProperty
(
"活动状态:0未启用、 1启用、2开始、 3结束、 4暂停、5作废、6禁用"
)
private
Integer
status
;
@ApiModelProperty
(
value
=
"核销方式限制,pickup:自提,delivery:外送,sassmall:微商城"
,
required
=
true
)
private
List
<
String
>
redeemScene
;
@ApiModelProperty
(
"商品适用范围文案说明"
)
private
String
productScopeDesc
;
@ApiModelProperty
(
"门店适用范围文案说明"
)
private
String
storeScopeDesc
;
@ApiModelProperty
(
"最大可核销次数,大于1时为频次券"
)
private
Integer
maxRedeemTimes
;
@ApiModelProperty
(
"核销次数限制类型对应的可核销次数,频次券时有效"
)
private
Integer
limitedRedeemTimes
;
@ApiModelProperty
(
"核销次数限制类型,频次券时有效,1:不限,2:每日,3:每周,4:每月"
)
private
Integer
redeemTimesLimitType
;
/**
* 0 全部 1 部分白 2 黑
*/
private
Integer
checkStoreLimitType
;
/**
* 0 全部 1 部分白 2 黑
*/
private
Integer
checkProductLimitType
;
/**
* 减免规则 1-20:运费券规则,21开始为买M免N券规则。
* 1:免配送费,2:部分减免
* 21:免最低价格,22:免最高价格
*/
private
Integer
exemptionRule
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/coupon/UnAvailableCouponDto.java
0 → 100644
View file @
840ea36e
package
cn
.
freemud
.
entities
.
dto
.
coupon
;
import
lombok.Data
;
import
java.util.List
;
/**
* © All rights Reserved
*
* @author wénkǎi.zhāng 2023-12-11
* @since 1.0
*/
@Data
public
class
UnAvailableCouponDto
{
/**
* 券信息
*/
private
CouponInfoDto
couponInfo
;
/**
* 不可用原因
*/
private
String
unAvailableReason
;
/**
* 不可用错误码
*/
private
String
unAvailableCode
;
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
View file @
840ea36e
...
...
@@ -18,8 +18,7 @@ import cn.freemud.base.util.DateUtil;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.demo.manager.coupon.Finals
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.coupon.Active
;
import
cn.freemud.entities.dto.coupon.CouponAvailableRespDto
;
import
cn.freemud.entities.dto.coupon.*
;
import
cn.freemud.entities.dto.product.*
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.entities.vo.coupon.CouponAvailableReqVo
;
...
...
@@ -59,7 +58,7 @@ import java.util.stream.Collectors;
public
class
CouponServiceImpl
implements
CouponService
{
@Autowired
private
C
ustomerExtendClient
customerExtend
Client
;
private
C
ouponQueryClient
couponQuery
Client
;
@Autowired
private
CouponAdapter
couponAdapter
;
@Autowired
...
...
@@ -84,6 +83,8 @@ public class CouponServiceImpl implements CouponService {
@Value
(
"${coupon.app.id}"
)
private
String
appid
;
@Value
(
"${useNewApiQueryCoupon:true}"
)
private
boolean
useNewApiQueryCoupon
;
/**
...
...
@@ -95,7 +96,7 @@ public class CouponServiceImpl implements CouponService {
public
GetMemberCouponListResponseDto
.
Result
getMemberCouponList
(
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
)
{
GetMemberCouponListResponseDto
getMemberCouponListResponseDto
=
null
;
try
{
getMemberCouponListResponseDto
=
c
ustomerExtend
Client
.
getMemberCouponListRequestDto
(
getMemberCouponListRequestDto
);
getMemberCouponListResponseDto
=
c
ouponQuery
Client
.
getMemberCouponListRequestDto
(
getMemberCouponListRequestDto
);
}
catch
(
Exception
ex
)
{
ErrorLog
.
errorConvertJson
(
this
.
getClass
(),
"会员服务优惠券接口调用失败"
,
ex
);
}
...
...
@@ -224,6 +225,35 @@ public class CouponServiceImpl implements CouponService {
return
result
;
}
/**
* key = 活动code , value = 返回是否匹配点餐方式
*/
public
Map
<
String
,
Boolean
>
checkCouponOrderWay
(
String
partnerId
,
List
<
String
>
activityCodes
,
Integer
orderTye
)
{
Map
<
String
,
Boolean
>
result
=
new
HashMap
<>();
if
(
CollectionUtils
.
isEmpty
(
activityCodes
))
{
return
result
;
}
// 付初始值
activityCodes
.
forEach
(
code
->
{
result
.
put
(
code
,
false
);
});
FastBatchQueryTemplateInfoRequest
request
=
new
FastBatchQueryTemplateInfoRequest
();
request
.
setPartnerId
(
partnerId
);
request
.
setTemplateCode
(
new
HashSet
<>(
activityCodes
));
CouponResponseDTO
<
List
<
FastTemplateInfoResponseVO
>>
fastResp
=
couponOnlineClient
.
fastBatchQueryTemplateInfo
(
request
);
if
(
fastResp
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
fastResp
.
getStatusCode
().
toString
()))
{
return
result
;
}
ActivityChannelEnum
activityChannelEnum
=
PropertyConvertUtil
.
orderTypeConvert2ActivityChannel
(
orderTye
);
if
(
activityChannelEnum
==
null
)
{
activityChannelEnum
=
ActivityChannelEnum
.
pickup
;
}
for
(
FastTemplateInfoResponseVO
dto
:
fastResp
.
getResult
())
{
result
.
put
(
dto
.
getTemplateCode
(),
CollectionUtils
.
isEmpty
(
dto
.
getRedeemScene
())
||
dto
.
getRedeemScene
().
contains
(
activityChannelEnum
.
getCode
()));
}
return
result
;
}
@Override
public
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
...
...
@@ -247,7 +277,7 @@ public class CouponServiceImpl implements CouponService {
// 过滤优惠券得点餐方式
if
(!
Objects
.
isNull
(
result
)
&&
CollectionUtils
.
isNotEmpty
(
result
.
getMemberCoupons
()))
{
List
<
String
>
activityCodes
=
result
.
getMemberCoupons
().
stream
().
map
(
GetMemberCouponListResponseDto
.
Result
.
MemberCoupon
::
getActivityCode
).
collect
(
Collectors
.
toList
());
Map
<
String
,
Boolean
>
activityCodesMap
=
couponOrderWay
(
partnerId
,
activityCodes
,
orderType
);
Map
<
String
,
Boolean
>
activityCodesMap
=
useNewApiQueryCoupon
?
checkCouponOrderWay
(
partnerId
,
activityCodes
,
orderType
)
:
couponOrderWay
(
partnerId
,
activityCodes
,
orderType
);
result
.
getMemberCoupons
().
forEach
(
memberCoupon
->
{
if
(
activityCodesMap
.
get
(
memberCoupon
.
getActivityCode
())
!=
null
&&
activityCodesMap
.
get
(
memberCoupon
.
getActivityCode
()))
{
memberCoupons
.
add
(
memberCoupon
);
...
...
@@ -278,13 +308,105 @@ public class CouponServiceImpl implements CouponService {
Long
deliveryAmount
=
couponPromotionVO
.
getDeliveryAmount
();
freightAmount
=
deliveryAmount
==
null
?
null
:
deliveryAmount
.
intValue
();
}
List
<
CouponStateVo
>
couponStateList
=
buildAvailiableCoupons
(
cartGoods
,
partnerId
,
storeId
,
couponCodes
,
isNew
,
appId
,
menuType
,
freightAmount
);
List
<
CouponStateVo
>
couponStateList
;
if
(
useNewApiQueryCoupon
)
{
// 性能更好
couponStateList
=
buildAvailiableCoupons
(
cartGoods
,
partnerId
,
storeId
,
couponCodes
,
isNew
,
appId
,
menuType
,
freightAmount
,
userId
);
}
else
{
// 分批查询codev4,性能差
couponStateList
=
buildAvailiableCoupons
(
cartGoods
,
partnerId
,
storeId
,
couponCodes
,
isNew
,
appId
,
menuType
,
freightAmount
);
}
if
(
CollectionUtils
.
isNotEmpty
(
couponStateList
))
{
return
returnSuccessAvailiableCoupons
(
couponPromotionVO
==
null
?
new
HashSet
<>()
:
couponPromotionVO
.
getCouponCodes
(),
hasGoodsCoupon
,
availableCouponResponseVo
,
usableCoupons
,
disableCoupons
,
memberCouponMap
,
couponStateList
,
chooseCouponCode
);
}
return
null
;
}
private
List
<
CouponStateVo
>
buildAvailiableCoupons
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
storeId
,
List
<
String
>
couponCodes
,
int
isNew
,
String
appId
,
String
menuType
,
Integer
freightAmount
,
String
memberId
)
{
CouponAvailabilityQueryRequest
queryRequest
=
new
CouponAvailabilityQueryRequest
();
queryRequest
.
setPartnerId
(
partnerId
);
queryRequest
.
setMemberId
(
memberId
);
queryRequest
.
setStoreId
(
storeId
);
queryRequest
.
setStoreChannels
(
commonService
.
getOrgIdsForCoupon
(
partnerId
,
storeId
));
queryRequest
.
setAppId
(
appId
);
queryRequest
.
setShoppingCardInfo
(
convertShoppingCardInfo
(
cartGoods
));
if
(
StringUtils
.
isNotBlank
(
menuType
))
{
String
code
=
BusinessTypeEnum
.
getByType
(
menuType
).
getCode
();
String
channel
=
CouponRedeemChannel
.
getChannelByType
(
code
);
if
(
StringUtils
.
isNotBlank
(
channel
))
{
queryRequest
.
setScene
(
channel
);
}
}
CouponResponseDTO
<
CouponAvailabilityQueryResponse
>
queryResponse
=
couponQueryClient
.
availability
(
queryRequest
);
if
(
queryResponse
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
queryResponse
.
getStatusCode
().
toString
()))
{
return
new
ArrayList
<>();
}
List
<
CouponStateVo
>
couponStateVos
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
queryResponse
.
getResult
().
getAvailableCoupons
()))
{
queryResponse
.
getResult
().
getAvailableCoupons
().
forEach
(
dto
->
{
CouponInfoDto
couponInfo
=
dto
.
getCouponInfo
();
CouponStateVo
vo
=
new
CouponStateVo
();
vo
.
setCouponCode
(
couponInfo
.
getCode
());
vo
.
setType
(
couponInfo
.
getType
());
vo
.
setState
(
CouponStateEnum
.
STATE_0
.
getCode
());
vo
.
setMinAmount
(
couponInfo
.
getMinAmount
());
vo
.
setAmount
(
couponInfo
.
getFaceValue
());
vo
.
setPriceDiscount
(
couponInfo
.
getFaceValue
());
vo
.
setOriginalPrice
(
couponInfo
.
getFaceValue
());
vo
.
setDiscount
(
couponInfo
.
getFaceValue
());
vo
.
setDailyAvailableTimes
(
couponInfo
.
getLeftAvailableNums
());
vo
.
setAvailableTimes
(
couponInfo
.
getConfigMaxRedeemNums
());
couponStateVos
.
add
(
vo
);
});
}
if
(
CollectionUtils
.
isNotEmpty
(
queryResponse
.
getResult
().
getUnAvailableCoupons
()))
{
queryResponse
.
getResult
().
getUnAvailableCoupons
().
forEach
(
dto
->
{
CouponInfoDto
couponInfo
=
dto
.
getCouponInfo
();
CouponStateVo
vo
=
new
CouponStateVo
();
vo
.
setCouponCode
(
couponInfo
.
getCode
());
vo
.
setType
(
couponInfo
.
getType
());
vo
.
setState
(
CouponStateEnum
.
STATE_1
.
getCode
());
vo
.
setMinAmount
(
couponInfo
.
getMinAmount
());
vo
.
setAmount
(
couponInfo
.
getFaceValue
());
vo
.
setPriceDiscount
(
couponInfo
.
getFaceValue
());
vo
.
setOriginalPrice
(
couponInfo
.
getFaceValue
());
vo
.
setDiscount
(
couponInfo
.
getFaceValue
());
vo
.
setDailyAvailableTimes
(
couponInfo
.
getLeftAvailableNums
());
vo
.
setAvailableTimes
(
couponInfo
.
getConfigMaxRedeemNums
());
vo
.
setMessage
(
dto
.
getUnAvailableReason
());
couponStateVos
.
add
(
vo
);
});
}
return
couponStateVos
;
}
private
CouponAvailabilityQueryRequest
.
ShoppingCardInfo
convertShoppingCardInfo
(
List
<
CartGoods
>
cartGoods
)
{
CouponAvailabilityQueryRequest
.
ShoppingCardInfo
cardInfo
=
new
CouponAvailabilityQueryRequest
.
ShoppingCardInfo
();
List
<
CouponAvailabilityQueryRequest
.
Product
>
products
=
new
ArrayList
<>();
int
totalAmount
=
0
;
if
(
CollectionUtils
.
isNotEmpty
(
cartGoods
))
{
for
(
CartGoods
goods
:
cartGoods
)
{
CouponAvailabilityQueryRequest
.
Product
product
=
new
CouponAvailabilityQueryRequest
.
Product
();
product
.
setProductCode
(
goods
.
getSkuId
());
product
.
setOriginalPrice
(
goods
.
getOriginalPrice
().
intValue
());
product
.
setPreferentialPrice
(
goods
.
getAmount
().
intValue
());
products
.
add
(
product
);
totalAmount
+=
goods
.
getAmount
().
intValue
();
}
}
cardInfo
.
setProducts
(
products
);
cardInfo
.
setTotalAmount
(
totalAmount
);
return
cardInfo
;
}
private
List
<
CouponStateVo
>
buildAvailiableCoupons
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
storeId
,
List
<
String
>
couponCodes
,
int
isNew
,
String
appId
,
String
menuType
,
Integer
freightAmount
)
{
// String appSecret = getAppSecret(partnerId);
// 最大15一提交
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
840ea36e
...
...
@@ -178,7 +178,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private
CalculationSharingValidatorService
calculationSharingValidatorService
;
@Autowired
private
C
ustomerExtendClient
customerExtend
Client
;
private
C
ouponQueryClient
couponQuery
Client
;
@Autowired
private
MemberPropertyService
memberPropertyService
;
...
...
@@ -3111,7 +3111,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
public
GetMemberCouponListResponseDto
.
Result
getMemberCouponList
(
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
)
{
GetMemberCouponListResponseDto
getMemberCouponListResponseDto
=
null
;
try
{
getMemberCouponListResponseDto
=
c
ustomerExtend
Client
.
getMemberCouponListRequestDto
(
getMemberCouponListRequestDto
);
getMemberCouponListResponseDto
=
c
ouponQuery
Client
.
getMemberCouponListRequestDto
(
getMemberCouponListRequestDto
);
}
catch
(
Exception
ex
)
{
ErrorLog
.
errorConvertJson
(
this
.
getClass
(),
"会员服务优惠券接口调用失败"
,
ex
);
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
840ea36e
package
cn
.
freemud
.
service
.
impl
.
mcoffee
.
calculation
;
import
cn.freemud.adapter.CouponAdapter
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.base.util.DateUtil
;
import
cn.freemud.constant.ApplicationConstant
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.activity.ActivityDiscountsDto
;
import
cn.freemud.entities.dto.calculate.*
;
...
...
@@ -15,7 +13,7 @@ import cn.freemud.service.CommonService;
import
cn.freemud.service.impl.ItemServiceImpl
;
import
cn.freemud.service.impl.mcoffee.entity.*
;
import
cn.freemud.service.thirdparty.CouponClient
;
import
cn.freemud.service.thirdparty.C
ustomerExtend
Client
;
import
cn.freemud.service.thirdparty.C
ouponQuery
Client
;
import
cn.freemud.utils.BarcodeUtil
;
import
cn.freemud.utils.ExceptionUtils
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -52,7 +50,7 @@ import java.util.stream.Collectors;
public
class
CouponDiscountCalculation
{
@Autowired
private
C
ustomerExtendClient
customerExtend
Client
;
private
C
ouponQueryClient
couponQuery
Client
;
@Autowired
private
ItemServiceImpl
itemService
;
...
...
@@ -502,7 +500,7 @@ public class CouponDiscountCalculation {
public
GetMemberCouponListResponseDto
.
Result
getMemberCouponList
(
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
)
{
GetMemberCouponListResponseDto
getMemberCouponListResponseDto
=
null
;
try
{
getMemberCouponListResponseDto
=
c
ustomerExtend
Client
.
getMemberCouponListRequestDto
(
getMemberCouponListRequestDto
);
getMemberCouponListResponseDto
=
c
ouponQuery
Client
.
getMemberCouponListRequestDto
(
getMemberCouponListRequestDto
);
}
catch
(
Exception
ex
)
{
ErrorLog
.
errorConvertJson
(
this
.
getClass
(),
"会员服务优惠券接口调用失败"
,
ex
);
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/thirdparty/C
ustomerExtend
Client.java
→
shopping-cart-application-service/src/main/java/cn/freemud/service/thirdparty/C
ouponQuery
Client.java
View file @
840ea36e
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: C
ustomerExtend
Client
* @Title: C
ouponQuery
Client
* @Package cn.freemud.service.thirdparty
* @Description:
* @author: song.cai
...
...
@@ -18,18 +18,32 @@ import cn.freemud.constant.ResponseCodeConstant;
import
cn.freemud.constant.ResponseCodeKeyConstant
;
import
cn.freemud.entities.dto.GetMemberCouponListRequestDto
;
import
cn.freemud.entities.dto.GetMemberCouponListResponseDto
;
import
cn.freemud.entities.dto.coupon.CouponAvailabilityQueryRequest
;
import
cn.freemud.entities.dto.coupon.CouponAvailabilityQueryResponse
;
import
cn.freemud.entities.dto.coupon.CouponResponseDTO
;
import
feign.HeaderMap
;
import
feign.Headers
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
@FeignClient
(
name
=
"
customer-extend-service"
,
url
=
"${saas.customerextendclient.feign.url
}"
)
@FeignClient
(
name
=
"
OPEN-STORE-COUPON-QUERY-SERVICE"
,
url
=
"${saas.coupon-query-service.feign.url:
}"
)
@RequestMapping
(
produces
=
{
"application/json;charset=UTF-8"
})
public
interface
C
ustomerExtend
Client
{
public
interface
C
ouponQuery
Client
{
/**
* 会员优惠券列表
*/
@IgnoreFeignLogAnnotation
(
logMessage
=
"getMemberCouponListRequestDto"
,
excludeStatusCodes
=
{
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
},
statusCodeFieldName
=
ResponseCodeKeyConstant
.
STATUS_CODE
,
messageFieldName
=
ResponseCodeKeyConstant
.
MSG
)
@PostMapping
(
value
=
"/customerextendservice/coupon/getCoupons"
)
GetMemberCouponListResponseDto
getMemberCouponListRequestDto
(
@RequestBody
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
);
/**
* 查询并校验券
* <pre></pre>
* @param request
* @return
*/
@PostMapping
(
value
=
"coupon/query/availability"
,
headers
=
"API-VERSION=2"
)
CouponResponseDTO
<
CouponAvailabilityQueryResponse
>
availability
(
CouponAvailabilityQueryRequest
request
);
}
shopping-cart-application-service/src/test/java/cn.freemud/client/C
ustomerExtend
ClientTest.java
→
shopping-cart-application-service/src/test/java/cn.freemud/client/C
ouponQuery
ClientTest.java
View file @
840ea36e
...
...
@@ -2,7 +2,7 @@ package cn.freemud.client;
import
cn.freemud.entities.dto.GetMemberCouponListRequestDto
;
import
cn.freemud.entities.dto.GetMemberCouponListResponseDto
;
import
cn.freemud.service.thirdparty.C
ustomerExtend
Client
;
import
cn.freemud.service.thirdparty.C
ouponQuery
Client
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -19,9 +19,9 @@ import java.util.ArrayList;
@EnableDiscoveryClient
@EnableFeignClients
@EnableAutoConfiguration
public
class
C
ustomerExtend
ClientTest
{
public
class
C
ouponQuery
ClientTest
{
@Autowired
private
C
ustomerExtendClient
customerExtend
Client
;
private
C
ouponQueryClient
couponQuery
Client
;
@Test
public
void
getUserInfo
()
{
GetMemberCouponListRequestDto
requestDto
=
new
GetMemberCouponListRequestDto
(
"1864"
,
"115417276085674268"
);
...
...
@@ -30,6 +30,6 @@ public class CustomerExtendClientTest {
requestDto
.
setStatusFlags
(
new
ArrayList
<>(
0
));
requestDto
.
setIsProduct
(
1
);
requestDto
.
setCouponType
(
0
);
GetMemberCouponListResponseDto
responseDto
=
customerExtend
Client
.
getMemberCouponListRequestDto
(
requestDto
);
GetMemberCouponListResponseDto
responseDto
=
couponQuery
Client
.
getMemberCouponListRequestDto
(
requestDto
);
}
}
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