From 418f825179da69573a8a4e6adc5af6b4a0efc857 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 29 二月 2024 16:14:38 +0800
Subject: [PATCH] 11.27,9
---
cloud-server-communityWorldCup/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java | 2
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java | 40 +++++++++++++++++++
cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupMapper.xml | 51 ++++++++++---------------
3 files changed, 61 insertions(+), 32 deletions(-)
diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
index 414218c..b042b56 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
@@ -159,11 +159,40 @@
*/
@Override
public List<WorldCupListVo> getWorldCupList(WorldCupList worldCupList) {
+ if(null == worldCupList.getSort()){
+ worldCupList.setSort(1);
+ }
//没有筛选门店,默认使用当前门店
if(null == worldCupList.getStoreId()){
worldCupList.setStoreId(worldCupList.getStoreId());
}
- return this.baseMapper.getWorldCupList(worldCupList);
+ List<WorldCupListVo> worldCupList1 = this.baseMapper.getWorldCupList(worldCupList);
+ for (WorldCupListVo worldCupListVo : worldCupList1) {
+ Integer id = Integer.valueOf(worldCupListVo.getId());
+ List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("worldCupId", id).eq("payStatus", 2).eq("state", 1));
+ List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
+ Integer heat = worldCupListVo.getHeat();
+ if(collect.size() > 0){
+ int count = worldCupPaymentParticipantService.count(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect));
+ heat += count;
+ }
+ worldCupListVo.setHeat(heat);
+ }
+
+ Collections.sort(worldCupList1, new Comparator<WorldCupListVo>() {
+ @Override
+ public int compare(WorldCupListVo o1, WorldCupListVo o2) {
+ if(worldCupList.getSort() == 1){
+ return o1.getHeat().compareTo(o2.getHeat());
+ }
+ if(worldCupList.getSort() == 2){
+ return o1.getHeat().compareTo(o2.getHeat()) * -1;
+ }
+ return 0;
+ }
+ });
+
+ return worldCupList1;
}
@@ -182,6 +211,15 @@
jsonArray.add(store.getName());
}
worldCupInfo.setStores(jsonArray.toJSONString());
+
+ List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("worldCupId", id).eq("payStatus", 2).eq("state", 1));
+ List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
+ Integer heat = worldCupInfo.getHeat();
+ if(collect.size() > 0){
+ int count = worldCupPaymentParticipantService.count(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect));
+ heat += count;
+ }
+ worldCupInfo.setHeat(heat);
return worldCupInfo;
}
diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java
index 7fa3e32..81fd0e4 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java
@@ -88,7 +88,7 @@
Properties props3 = new Properties();
props3.setProperty("algorithm-expression", "t_world_cup_payment_participant$->{worldCupId % 5 + 1}");
result1.getShardingAlgorithms().put("t_world_cup_payment_participant-inline", new AlgorithmConfiguration("INLINE", props3));
- result1.getKeyGenerators().put("t_world_cup_payment_participantt-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties()));
+ result1.getKeyGenerators().put("t_world_cup_payment_participant-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties()));
linkedList.add(result1);
return linkedList;
diff --git a/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupMapper.xml b/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupMapper.xml
index c8f165c..24fb913 100644
--- a/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupMapper.xml
+++ b/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupMapper.xml
@@ -27,36 +27,28 @@
<select id="getWorldCupList" resultType="com.dsh.communityWorldCup.model.WorldCupListVo">
- select * from (
- select
- a.id,
- a.name,
- DATE_FORMAT(a.registrationClosingTime, '%Y-%m-%d %H:%i') as registrationClosingTime,
- CONCAT(a.startAge, '-', a.endAge) as age,
- a.coverImg,
- a.intro as content,
- a.lon,
- a.lat,
- ifnull(b.num, 0) + a.basePeople as heat
- from t_world_cup a
- left join (select worldCupId, count(*) as num from t_world_cup_payment_participant where worldCupPaymentId in (select id from t_world_cup_payment where payStatus = 2 and refundTime is null and state = 1) group by worldCupId) b on (a.id = b.worldCupId)
- where a.status in (1, 2) order by a.createTime desc
- <if test="null != item.content and '' != item.content">
- and a.name like CONCAT('%', #{item.content}, '%')
- </if>
- <if test="null != item.storeId">
- and a.worldCupId in (select worldCupId from t_world_cup_store where storeId = #{item.storeId})
- </if>
- <if test="null != item.gender">
- and #{item.gender} between #{startAge} and #{endAge}
- </if>
- ) as aa
- <if test="null != item.sort and 1 == item.sort">
- order by aa.heat
+ select
+ a.id,
+ a.name,
+ DATE_FORMAT(a.registrationClosingTime, '%Y-%m-%d %H:%i') as registrationClosingTime,
+ CONCAT(a.startAge, '-', a.endAge) as age,
+ a.coverImg,
+ a.intro as content,
+ a.lon,
+ a.lat,
+ a.basePeople as heat
+ from t_world_cup a
+ where a.status in (1, 2)
+ <if test="null != item.content and '' != item.content">
+ and a.name like CONCAT('%', #{item.content}, '%')
</if>
- <if test="null != item.sort and 2 == item.sort">
- order by aa.heat desc
+ <if test="null != item.storeId">
+ and a.worldCupId in (select worldCupId from t_world_cup_store where storeId = #{item.storeId})
</if>
+ <if test="null != item.gender">
+ and #{item.gender} = a.gender
+ </if>
+ order by a.createTime desc
</select>
@@ -66,7 +58,7 @@
a.id,
a.infoImg,
a.name,
- ifnull(b.num, 0) as heat,
+ a.basePeople as heat,
DATE_FORMAT(a.startTime, '%Y-%m-%d %H:%i') as startTime,
DATE_FORMAT(a.endTime, '%Y-%m-%d %H:%i') as endTime,
DATE_FORMAT(a.registrationClosingTime, '%Y-%m-%d %H:%i') as registrationClosingTime,
@@ -79,7 +71,6 @@
a.intro,
a.content
from t_world_cup a
- left join (select worldCupId, count(*) as num from t_world_cup_payment_participant where worldCupPaymentId in (select id from t_world_cup_payment where payStatus = 2 and state = 1) group by worldCupId) b on (a.id = b.worldCupId)
where a.id = #{id}
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.7.1