diff --git a/src/main/java/com/sqx/config/ShardingConfig.java b/src/main/java/com/sqx/config/ShardingConfig.java index 36cfeaab..d5a490d6 100644 --- a/src/main/java/com/sqx/config/ShardingConfig.java +++ b/src/main/java/com/sqx/config/ShardingConfig.java @@ -53,7 +53,7 @@ public class ShardingConfig { /** * 广播表 */ - private Set broadcastTables; +// private Set broadcastTables; /** * 中心库的节点 @@ -112,7 +112,7 @@ public class ShardingConfig { shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigs()); // 配置广播表 - shardingRuleConfig.setBroadcastTables(broadcastTables); +// shardingRuleConfig.setBroadcastTables(broadcastTables); // 配置表的切分策略 shardingRuleConfig.setTableRuleConfigs(addTableRuleConfigs()); diff --git a/src/main/java/com/sqx/modules/course/dao/CourseDetailsDao.java b/src/main/java/com/sqx/modules/course/dao/CourseDetailsDao.java index d5b90e56..c23a6857 100644 --- a/src/main/java/com/sqx/modules/course/dao/CourseDetailsDao.java +++ b/src/main/java/com/sqx/modules/course/dao/CourseDetailsDao.java @@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; @Mapper public interface CourseDetailsDao extends BaseMapper { @@ -20,4 +21,6 @@ public interface CourseDetailsDao extends BaseMapper { List selectCourseDetailsList(String randomNum,Integer wxShow,Integer dyShow); + Map countCourse(String courseId); + } diff --git a/src/main/java/com/sqx/modules/course/service/impl/CourseServiceImpl.java b/src/main/java/com/sqx/modules/course/service/impl/CourseServiceImpl.java index 022485e0..d65631f0 100644 --- a/src/main/java/com/sqx/modules/course/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/sqx/modules/course/service/impl/CourseServiceImpl.java @@ -20,7 +20,6 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.sqx.common.utils.*; -import com.sqx.modules.app.entity.InviteAchievement; import com.sqx.common.utils.DateUtils; import com.sqx.common.utils.PageUtils; 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.CourseUserService; 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.redisService.RedisService; import com.sqx.modules.search.service.AppSearchService; @@ -75,6 +75,8 @@ public class CourseServiceImpl extends ServiceImpl implements @Autowired private OrdersService ordersService; @Autowired + private OrdersDao ordersDao; + @Autowired private CommonInfoService commonInfoService; @Autowired private JwtUtils jwtUtils; @@ -171,7 +173,6 @@ public class CourseServiceImpl extends ServiceImpl implements } } } - Page> pages = new Page<>(page, limit); // 一周的第一天 DateTime begin = DateUtil.beginOfWeek(new Date()); String startTime = begin.toString(); @@ -193,26 +194,35 @@ public class CourseServiceImpl extends ServiceImpl implements PageInfo> pageInfo = new PageInfo<>(map); List> records = pageInfo.getList(); for (Map m : records) { + Integer i = courseDetailsDao.selectCount(new QueryWrapper().eq("course_id", m.get("courseId"))); + m.put("courseDetailsCount", i == null ? 0 : i); m.put("courseDetailsId", null); m.put("courseDetailsName", ""); m.put("dyEpisodeId", ""); m.put("wxCourseDetailsId", ""); } - PageUtils pageUtils = PageUtils.page(pageInfo); + PageUtils pageUtils = PageUtils.page(pageInfo, true); setCache(cacheKey, JSONUtil.toJsonStr(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> list = baseMapper.selectCourseAdmin(classifyId, title, isRecommend, status, bannerId, sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow); PageInfo> pageInfo = new PageInfo<>(list); List> records = pageInfo.getList(); for (Map map : records) { - map.put("courseDetailsId", null); + Map 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("dyEpisodeId", ""); map.put("wxCourseDetailsId", ""); + map.putAll(countMap); } - PageUtils pageUtils = PageUtils.page(pageInfo); + PageUtils pageUtils = PageUtils.page(pageInfo, true); setCache(cacheKey, JSONUtil.toJsonStr(pageUtils)); return Result.success().put("data", pageUtils); } diff --git a/src/main/java/com/sqx/modules/orders/dao/OrdersDao.java b/src/main/java/com/sqx/modules/orders/dao/OrdersDao.java index 8a11fd1f..a9939df8 100644 --- a/src/main/java/com/sqx/modules/orders/dao/OrdersDao.java +++ b/src/main/java/com/sqx/modules/orders/dao/OrdersDao.java @@ -5,6 +5,7 @@ import com.sqx.modules.orders.entity.Orders; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; @Mapper @@ -43,5 +44,5 @@ public interface OrdersDao extends BaseMapper { Integer countOrderNum(Long userId, String time); - + BigDecimal sumPayByCourseId(String courseId); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aba66daf..ebdfe071 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -107,8 +107,8 @@ spring: # matching-strategy: ant_path_matcher shardingsphere: #广播表 - broadcast-tables: - - course +# broadcast-tables: +# - course # 短剧集表 通过course_id 分 course-details: - course_details @@ -131,6 +131,7 @@ spring: - sys_user #中心表 center-tables: + - course - message_info - announcement - schedule_job_log diff --git a/src/main/resources/mapper/course/CourseDao.xml b/src/main/resources/mapper/course/CourseDao.xml index 118aeb2f..4154d796 100644 --- a/src/main/resources/mapper/course/CourseDao.xml +++ b/src/main/resources/mapper/course/CourseDao.xml @@ -28,19 +28,9 @@ c.title_img AS titleImg, c.update_time AS updateTime, c.course_type AS courseType, - c.banner_id AS bannerId, - COALESCE(d.courseDetailsCount, 0) AS courseDetailsCount + c.banner_id AS bannerId FROM 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 c.is_delete = 0 @@ -71,9 +61,9 @@ and c.is_over=#{over} - - and c.course_id in (select course_id from course_details where good=1) - + + + and c.status=#{status} @@ -123,7 +113,6 @@ c.course_type as courseType, c.banner_id as bannerId, b.name as bannerName, - ifnull(d.viewCounts,0) as viewCounts, c.dy_img_id as dyImgId, c.dy_course_id as dyCourseId, c.dy_status as dyStatus, @@ -152,20 +141,14 @@ c.`cost_of_production` as costOfProduction, c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId, c.`wx_course_status` as wxCourseStatus, - t.dyUrlStatus, - o.payMoney, - ifnull(d.goodNum,0) as goodNum, - ifnull(d.courseDetailsCount, 0) as courseDetailsCount, - 0 as weekGoodNum, - ifnull(tt.isRecommend,0) as isRecommend +-- t.dyUrlStatus, + 0 as weekGoodNum + FROM course AS c 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 (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 +-- 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 WHERE 1 = 1 AND c.is_delete = 0 @@ -199,9 +182,9 @@ and (c.is_over is null or c.is_over=2) - - and c.course_id in (select course_id from course_details where good=1) - + + + and c.status=#{status} diff --git a/src/main/resources/mapper/course/CourseDetailsDao.xml b/src/main/resources/mapper/course/CourseDetailsDao.xml index 6d3512fb..a83279cf 100644 --- a/src/main/resources/mapper/course/CourseDetailsDao.xml +++ b/src/main/resources/mapper/course/CourseDetailsDao.xml @@ -74,4 +74,13 @@ order by SUBSTR(uid, ${randomNum}, 6) + + diff --git a/src/main/resources/mapper/orders/OrdersDao.xml b/src/main/resources/mapper/orders/OrdersDao.xml index 118e1901..6237cad6 100644 --- a/src/main/resources/mapper/orders/OrdersDao.xml +++ b/src/main/resources/mapper/orders/OrdersDao.xml @@ -323,4 +323,13 @@ AND orders.`pay_way` = 9 AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00') + + +