移除广播表
短剧首页 关联查询修改
This commit is contained in:
@@ -53,7 +53,7 @@ public class ShardingConfig {
|
|||||||
/**
|
/**
|
||||||
* 广播表
|
* 广播表
|
||||||
*/
|
*/
|
||||||
private Set<String> broadcastTables;
|
// private Set<String> broadcastTables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 中心库的节点
|
* 中心库的节点
|
||||||
@@ -112,7 +112,7 @@ public class ShardingConfig {
|
|||||||
shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigs());
|
shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigs());
|
||||||
|
|
||||||
// 配置广播表
|
// 配置广播表
|
||||||
shardingRuleConfig.setBroadcastTables(broadcastTables);
|
// shardingRuleConfig.setBroadcastTables(broadcastTables);
|
||||||
|
|
||||||
// 配置表的切分策略
|
// 配置表的切分策略
|
||||||
shardingRuleConfig.setTableRuleConfigs(addTableRuleConfigs());
|
shardingRuleConfig.setTableRuleConfigs(addTableRuleConfigs());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
|
public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
|
||||||
@@ -20,4 +21,6 @@ public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
|
|||||||
|
|
||||||
List<CourseDetails> selectCourseDetailsList(String randomNum,Integer wxShow,Integer dyShow);
|
List<CourseDetails> selectCourseDetailsList(String randomNum,Integer wxShow,Integer dyShow);
|
||||||
|
|
||||||
|
Map<String,Object> countCourse(String courseId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.github.pagehelper.PageHelper;
|
|||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import com.sqx.common.utils.*;
|
import com.sqx.common.utils.*;
|
||||||
import com.sqx.modules.app.entity.InviteAchievement;
|
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.PageUtils;
|
import com.sqx.common.utils.PageUtils;
|
||||||
import com.sqx.common.utils.RedisUtils;
|
import com.sqx.common.utils.RedisUtils;
|
||||||
@@ -38,6 +37,7 @@ import com.sqx.modules.course.entity.CourseUser;
|
|||||||
import com.sqx.modules.course.service.CourseService;
|
import com.sqx.modules.course.service.CourseService;
|
||||||
import com.sqx.modules.course.service.CourseUserService;
|
import com.sqx.modules.course.service.CourseUserService;
|
||||||
import com.sqx.modules.course.vo.CourseIn;
|
import com.sqx.modules.course.vo.CourseIn;
|
||||||
|
import com.sqx.modules.orders.dao.OrdersDao;
|
||||||
import com.sqx.modules.orders.service.OrdersService;
|
import com.sqx.modules.orders.service.OrdersService;
|
||||||
import com.sqx.modules.redisService.RedisService;
|
import com.sqx.modules.redisService.RedisService;
|
||||||
import com.sqx.modules.search.service.AppSearchService;
|
import com.sqx.modules.search.service.AppSearchService;
|
||||||
@@ -75,6 +75,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrdersService ordersService;
|
private OrdersService ordersService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private OrdersDao ordersDao;
|
||||||
|
@Autowired
|
||||||
private CommonInfoService commonInfoService;
|
private CommonInfoService commonInfoService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private JwtUtils jwtUtils;
|
private JwtUtils jwtUtils;
|
||||||
@@ -171,7 +173,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Page<Map<String, Object>> pages = new Page<>(page, limit);
|
|
||||||
// 一周的第一天
|
// 一周的第一天
|
||||||
DateTime begin = DateUtil.beginOfWeek(new Date());
|
DateTime begin = DateUtil.beginOfWeek(new Date());
|
||||||
String startTime = begin.toString();
|
String startTime = begin.toString();
|
||||||
@@ -193,26 +194,35 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(map);
|
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(map);
|
||||||
List<Map<String, Object>> records = pageInfo.getList();
|
List<Map<String, Object>> records = pageInfo.getList();
|
||||||
for (Map<String, Object> m : records) {
|
for (Map<String, Object> m : records) {
|
||||||
|
Integer i = courseDetailsDao.selectCount(new QueryWrapper<CourseDetails>().eq("course_id", m.get("courseId")));
|
||||||
|
m.put("courseDetailsCount", i == null ? 0 : i);
|
||||||
m.put("courseDetailsId", null);
|
m.put("courseDetailsId", null);
|
||||||
m.put("courseDetailsName", "");
|
m.put("courseDetailsName", "");
|
||||||
m.put("dyEpisodeId", "");
|
m.put("dyEpisodeId", "");
|
||||||
m.put("wxCourseDetailsId", "");
|
m.put("wxCourseDetailsId", "");
|
||||||
}
|
}
|
||||||
PageUtils pageUtils = PageUtils.page(pageInfo);
|
PageUtils pageUtils = PageUtils.page(pageInfo, true);
|
||||||
setCache(cacheKey, JSONUtil.toJsonStr(pageUtils));
|
setCache(cacheKey, JSONUtil.toJsonStr(pageUtils));
|
||||||
return Result.success().put("data", pageUtils);
|
return Result.success().put("data", pageUtils);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 无用 ifnull(tt.isRecommend,0) as isRecommend
|
||||||
|
// left join (select course_id,count(*) as isRecommend from course_details where good=1 group by course_id) tt on tt.course_id = c.course_id
|
||||||
|
|
||||||
List<Map<String, Object>> list = baseMapper.selectCourseAdmin(classifyId, title, isRecommend, status, bannerId,
|
List<Map<String, Object>> list = baseMapper.selectCourseAdmin(classifyId, title, isRecommend, status, bannerId,
|
||||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||||
List<Map<String, Object>> records = pageInfo.getList();
|
List<Map<String, Object>> records = pageInfo.getList();
|
||||||
for (Map<String, Object> map : records) {
|
for (Map<String, Object> map : records) {
|
||||||
map.put("courseDetailsId", null);
|
Map<String, Object> countMap = courseDetailsDao.countCourse(map.get("courseId").toString());
|
||||||
|
BigDecimal payMoney = ordersDao.sumPayByCourseId(map.get("courseId").toString());
|
||||||
|
map.put("courseDetailsId", payMoney==null?BigDecimal.ZERO:payMoney);
|
||||||
map.put("courseDetailsName", "");
|
map.put("courseDetailsName", "");
|
||||||
map.put("dyEpisodeId", "");
|
map.put("dyEpisodeId", "");
|
||||||
map.put("wxCourseDetailsId", "");
|
map.put("wxCourseDetailsId", "");
|
||||||
|
map.putAll(countMap);
|
||||||
}
|
}
|
||||||
PageUtils pageUtils = PageUtils.page(pageInfo);
|
PageUtils pageUtils = PageUtils.page(pageInfo, true);
|
||||||
setCache(cacheKey, JSONUtil.toJsonStr(pageUtils));
|
setCache(cacheKey, JSONUtil.toJsonStr(pageUtils));
|
||||||
return Result.success().put("data", pageUtils);
|
return Result.success().put("data", pageUtils);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.sqx.modules.orders.entity.Orders;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@@ -43,5 +44,5 @@ public interface OrdersDao extends BaseMapper<Orders> {
|
|||||||
|
|
||||||
|
|
||||||
Integer countOrderNum(Long userId, String time);
|
Integer countOrderNum(Long userId, String time);
|
||||||
|
BigDecimal sumPayByCourseId(String courseId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ spring:
|
|||||||
# matching-strategy: ant_path_matcher
|
# matching-strategy: ant_path_matcher
|
||||||
shardingsphere:
|
shardingsphere:
|
||||||
#广播表
|
#广播表
|
||||||
broadcast-tables:
|
# broadcast-tables:
|
||||||
- course
|
# - course
|
||||||
# 短剧集表 通过course_id 分
|
# 短剧集表 通过course_id 分
|
||||||
course-details:
|
course-details:
|
||||||
- course_details
|
- course_details
|
||||||
@@ -131,6 +131,7 @@ spring:
|
|||||||
- sys_user
|
- sys_user
|
||||||
#中心表
|
#中心表
|
||||||
center-tables:
|
center-tables:
|
||||||
|
- course
|
||||||
- message_info
|
- message_info
|
||||||
- announcement
|
- announcement
|
||||||
- schedule_job_log
|
- schedule_job_log
|
||||||
|
|||||||
@@ -28,19 +28,9 @@
|
|||||||
c.title_img AS titleImg,
|
c.title_img AS titleImg,
|
||||||
c.update_time AS updateTime,
|
c.update_time AS updateTime,
|
||||||
c.course_type AS courseType,
|
c.course_type AS courseType,
|
||||||
c.banner_id AS bannerId,
|
c.banner_id AS bannerId
|
||||||
COALESCE(d.courseDetailsCount, 0) AS courseDetailsCount
|
|
||||||
FROM
|
FROM
|
||||||
course AS c
|
course AS c
|
||||||
LEFT JOIN (
|
|
||||||
SELECT
|
|
||||||
course_id,
|
|
||||||
COUNT(*) AS courseDetailsCount
|
|
||||||
FROM
|
|
||||||
course_details
|
|
||||||
GROUP BY
|
|
||||||
course_id
|
|
||||||
) AS d ON d.course_id = c.course_id
|
|
||||||
WHERE
|
WHERE
|
||||||
c.is_delete = 0
|
c.is_delete = 0
|
||||||
|
|
||||||
@@ -71,9 +61,9 @@
|
|||||||
<if test="over!=null">
|
<if test="over!=null">
|
||||||
and c.is_over=#{over}
|
and c.is_over=#{over}
|
||||||
</if>
|
</if>
|
||||||
<if test="isRecommend!=null and isRecommend!=-1">
|
<!-- <if test="isRecommend!=null and isRecommend!=-1">-->
|
||||||
and c.course_id in (select course_id from course_details where good=1)
|
<!-- and c.course_id in (select course_id from course_details where good=1)-->
|
||||||
</if>
|
<!-- </if>-->
|
||||||
<if test="status!=null and status!=0">
|
<if test="status!=null and status!=0">
|
||||||
and c.status=#{status}
|
and c.status=#{status}
|
||||||
</if>
|
</if>
|
||||||
@@ -123,7 +113,6 @@
|
|||||||
c.course_type as courseType,
|
c.course_type as courseType,
|
||||||
c.banner_id as bannerId,
|
c.banner_id as bannerId,
|
||||||
b.name as bannerName,
|
b.name as bannerName,
|
||||||
ifnull(d.viewCounts,0) as viewCounts,
|
|
||||||
c.dy_img_id as dyImgId,
|
c.dy_img_id as dyImgId,
|
||||||
c.dy_course_id as dyCourseId,
|
c.dy_course_id as dyCourseId,
|
||||||
c.dy_status as dyStatus,
|
c.dy_status as dyStatus,
|
||||||
@@ -152,20 +141,14 @@
|
|||||||
c.`cost_of_production` as costOfProduction,
|
c.`cost_of_production` as costOfProduction,
|
||||||
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
|
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
|
||||||
c.`wx_course_status` as wxCourseStatus,
|
c.`wx_course_status` as wxCourseStatus,
|
||||||
t.dyUrlStatus,
|
-- t.dyUrlStatus,
|
||||||
o.payMoney,
|
0 as weekGoodNum
|
||||||
ifnull(d.goodNum,0) as goodNum,
|
|
||||||
ifnull(d.courseDetailsCount, 0) as courseDetailsCount,
|
|
||||||
0 as weekGoodNum,
|
|
||||||
ifnull(tt.isRecommend,0) as isRecommend
|
|
||||||
FROM
|
FROM
|
||||||
course AS c
|
course AS c
|
||||||
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
||||||
left join banner as b on b.id=c.banner_id
|
left join banner as b on b.id=c.banner_id
|
||||||
left join (select 1 as id,count(*) as dyUrlStatus from course_details where dy_url_status in (1,3) or dy_url_status=null group by course_id) t on t.id = 1
|
-- left join (select 1 as id,count(*) as dyUrlStatus from course_details where dy_url_status in (1,3) or dy_url_status=null group by course_id) t on t.id = 1
|
||||||
left join (select course_id,sum(pay_money) as payMoney from orders where status=1 group by course_id) o on o.course_id = c.course_id
|
|
||||||
left join (select course_id,sum(view_count) as viewCounts,sum(good_num) as goodNum,count(*) as courseDetailsCount from course_details group by course_id) d on d.course_id = c.course_id
|
|
||||||
left join (select course_id,count(*) as isRecommend from course_details where good=1 group by course_id) tt on tt.course_id = c.course_id
|
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND c.is_delete = 0
|
AND c.is_delete = 0
|
||||||
@@ -199,9 +182,9 @@
|
|||||||
<if test="over!=null and over==2">
|
<if test="over!=null and over==2">
|
||||||
and (c.is_over is null or c.is_over=2)
|
and (c.is_over is null or c.is_over=2)
|
||||||
</if>
|
</if>
|
||||||
<if test="isRecommend!=null and isRecommend!=-1">
|
<!-- <if test="isRecommend!=null and isRecommend!=-1">-->
|
||||||
and c.course_id in (select course_id from course_details where good=1)
|
<!-- and c.course_id in (select course_id from course_details where good=1)-->
|
||||||
</if>
|
<!-- </if>-->
|
||||||
<if test="status!=null and status!=0">
|
<if test="status!=null and status!=0">
|
||||||
and c.status=#{status}
|
and c.status=#{status}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -74,4 +74,13 @@
|
|||||||
order by SUBSTR(uid, ${randomNum}, 6)
|
order by SUBSTR(uid, ${randomNum}, 6)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="countCourse" resultType="Map">
|
||||||
|
select
|
||||||
|
ifnull(sum(view_count),0) as viewCounts,
|
||||||
|
ifnull(sum(good_num),0) as goodNum,
|
||||||
|
ifnull(count(*),0) as courseDetailsCount
|
||||||
|
from course_details
|
||||||
|
where course_id = #{courseId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -323,4 +323,13 @@
|
|||||||
AND orders.`pay_way` = 9
|
AND orders.`pay_way` = 9
|
||||||
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="sumPayByCourseId" resultType="java.math.BigDecimal">
|
||||||
|
select sum(pay_money) as payMoney
|
||||||
|
from orders
|
||||||
|
where status = 1
|
||||||
|
and course_id = #{courseId}
|
||||||
|
group by course_id
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user