Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f3320b7b
authored
Apr 10, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:【优惠券需求】优惠券活动代码分页查询
1 parent
de331684
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
3 deletions
aus-core/src/main/java/com/glsx/usedcar/module/coupon/dao/CouponActivityPriceRangeRepository.java
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponActivityService.java
aus-core/src/main/java/com/glsx/usedcar/module/coupon/vo/CouponActivityRespVO.java
aus-core/src/main/java/com/glsx/usedcar/module/coupon/dao/CouponActivityPriceRangeRepository.java
View file @
f3320b7
...
@@ -56,4 +56,13 @@ public interface CouponActivityPriceRangeRepository extends JpaRepository<Coupon
...
@@ -56,4 +56,13 @@ public interface CouponActivityPriceRangeRepository extends JpaRepository<Coupon
* @return 价格区间列表
* @return 价格区间列表
*/
*/
List
<
CouponActivityPriceRange
>
findByTemplateIdAndDeleteFlag
(
Long
templateId
,
String
deleteFlag
);
List
<
CouponActivityPriceRange
>
findByTemplateIdAndDeleteFlag
(
Long
templateId
,
String
deleteFlag
);
/**
* 根据活动 ID 列表和删除标识批量查询
*
* @param activityIds 活动 ID 列表
* @param deleteFlag 删除标识
* @return 价格区间列表
*/
List
<
CouponActivityPriceRange
>
findByActivityIdInAndDeleteFlag
(
List
<
String
>
activityIds
,
String
deleteFlag
);
}
}
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponActivityService.java
View file @
f3320b7
...
@@ -22,8 +22,7 @@ import org.summerframework.core.exception.BusinessCodeException;
...
@@ -22,8 +22,7 @@ import org.summerframework.core.exception.BusinessCodeException;
import
org.summerframework.orm.paging.Pagination
;
import
org.summerframework.orm.paging.Pagination
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.*
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -330,7 +329,24 @@ public class CouponActivityService {
...
@@ -330,7 +329,24 @@ public class CouponActivityService {
sortField
,
sortOrder
,
pagination
.
getPageRequest
()
sortField
,
sortOrder
,
pagination
.
getPageRequest
()
);
);
// 4. DTO 转 VO(小驼峰映射)
// 4. 收集所有自动触发活动的 ID
List
<
String
>
autoTriggerActivityIds
=
dtoPage
.
getContent
().
stream
()
.
filter
(
dto
->
dto
.
getActivityType
()
!=
null
&&
dto
.
getActivityType
().
equals
(
CouponActivityTypeEnum
.
AUTO_TRIGGER
.
getCode
()))
.
map
(
CouponActivityStatDTO:
:
getActivityId
)
.
collect
(
Collectors
.
toList
());
// 5. 批量查询价格区间规则(只做一次查询)
Map
<
String
,
List
<
CouponActivityPriceRange
>>
priceRangeMap
=
new
java
.
util
.
HashMap
<>();
if
(!
autoTriggerActivityIds
.
isEmpty
())
{
List
<
CouponActivityPriceRange
>
allPriceRanges
=
priceRangeRepository
.
findByActivityIdInAndDeleteFlag
(
autoTriggerActivityIds
,
DeleteFlag
.
NOT_DELETED
.
getCode
());
// 按 activityId 分组
priceRangeMap
=
allPriceRanges
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
CouponActivityPriceRange:
:
getActivityId
));
}
// 6. DTO 转 VO(小驼峰映射)
final
Map
<
String
,
List
<
CouponActivityPriceRange
>>
finalPriceRangeMap
=
priceRangeMap
;
return
dtoPage
.
map
(
dto
->
{
return
dtoPage
.
map
(
dto
->
{
CouponActivityRespVO
vo
=
new
CouponActivityRespVO
();
CouponActivityRespVO
vo
=
new
CouponActivityRespVO
();
vo
.
setId
(
dto
.
getId
());
vo
.
setId
(
dto
.
getId
());
...
@@ -351,6 +367,23 @@ public class CouponActivityService {
...
@@ -351,6 +367,23 @@ public class CouponActivityService {
vo
.
setTemplateId
(
dto
.
getTemplateId
());
vo
.
setTemplateId
(
dto
.
getTemplateId
());
vo
.
setUsedCount
(
dto
.
getUsedCount
());
vo
.
setUsedCount
(
dto
.
getUsedCount
());
vo
.
setWriteOffRate
(
dto
.
getWriteOffRate
());
vo
.
setWriteOffRate
(
dto
.
getWriteOffRate
());
// 如果是自动触发活动,从 Map 中获取价格区间规则
if
(
dto
.
getActivityType
()
!=
null
&&
dto
.
getActivityType
().
equals
(
CouponActivityTypeEnum
.
AUTO_TRIGGER
.
getCode
()))
{
List
<
CouponActivityPriceRange
>
priceRanges
=
finalPriceRangeMap
.
get
(
dto
.
getActivityId
());
if
(
priceRanges
!=
null
&&
!
priceRanges
.
isEmpty
())
{
List
<
CouponActivityPriceRangeRespVO
>
priceRangeVOs
=
priceRanges
.
stream
().
map
(
pr
->
{
CouponActivityPriceRangeRespVO
prVO
=
new
CouponActivityPriceRangeRespVO
();
prVO
.
setId
(
pr
.
getId
());
prVO
.
setPriceMin
(
pr
.
getPriceMin
());
prVO
.
setPriceMax
(
pr
.
getPriceMax
());
prVO
.
setTemplateId
(
pr
.
getTemplateId
());
return
prVO
;
}).
collect
(
Collectors
.
toList
());
vo
.
setPriceRanges
(
priceRangeVOs
);
}
}
return
vo
;
return
vo
;
});
});
}
}
...
...
aus-core/src/main/java/com/glsx/usedcar/module/coupon/vo/CouponActivityRespVO.java
View file @
f3320b7
...
@@ -7,6 +7,7 @@ import java.io.Serial;
...
@@ -7,6 +7,7 @@ import java.io.Serial;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
/**
* 优惠券活动响应 VO
* 优惠券活动响应 VO
...
@@ -69,4 +70,7 @@ public class CouponActivityRespVO implements Serializable {
...
@@ -69,4 +70,7 @@ public class CouponActivityRespVO implements Serializable {
@Schema
(
description
=
"核销率"
)
@Schema
(
description
=
"核销率"
)
private
BigDecimal
writeOffRate
;
private
BigDecimal
writeOffRate
;
@Schema
(
description
=
"价格区间规则列表(仅自动触发活动)"
)
private
List
<
CouponActivityPriceRangeRespVO
>
priceRanges
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment