parent
3ef249a5d4
commit
c49a165dd9
|
|
@ -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.setBroadcastTables(broadcastTables);
|
||||
// shardingRuleConfig.setBroadcastTables(broadcastTables);
|
||||
|
||||
// 配置表的切分策略
|
||||
shardingRuleConfig.setTableRuleConfigs(addTableRuleConfigs());
|
||||
|
|
|
|||
|
|
@ -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<CourseDetails> {
|
||||
|
|
@ -20,4 +21,6 @@ public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
|
|||
|
||||
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.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<CourseDao, Course> 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<CourseDao, Course> implements
|
|||
}
|
||||
}
|
||||
}
|
||||
Page<Map<String, Object>> pages = new Page<>(page, limit);
|
||||
// 一周的第一天
|
||||
DateTime begin = DateUtil.beginOfWeek(new Date());
|
||||
String startTime = begin.toString();
|
||||
|
|
@ -193,26 +194,35 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(map);
|
||||
List<Map<String, Object>> records = pageInfo.getList();
|
||||
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("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<Map<String, Object>> list = baseMapper.selectCourseAdmin(classifyId, title, isRecommend, status, bannerId,
|
||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
List<Map<String, Object>> records = pageInfo.getList();
|
||||
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("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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Orders> {
|
|||
|
||||
|
||||
Integer countOrderNum(Long userId, String time);
|
||||
|
||||
BigDecimal sumPayByCourseId(String courseId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 @@
|
|||
<if test="over!=null">
|
||||
and c.is_over=#{over}
|
||||
</if>
|
||||
<if test="isRecommend!=null and isRecommend!=-1">
|
||||
and c.course_id in (select course_id from course_details where good=1)
|
||||
</if>
|
||||
<!-- <if test="isRecommend!=null and isRecommend!=-1">-->
|
||||
<!-- and c.course_id in (select course_id from course_details where good=1)-->
|
||||
<!-- </if>-->
|
||||
<if test="status!=null and status!=0">
|
||||
and c.status=#{status}
|
||||
</if>
|
||||
|
|
@ -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 @@
|
|||
<if test="over!=null and over==2">
|
||||
and (c.is_over is null or c.is_over=2)
|
||||
</if>
|
||||
<if test="isRecommend!=null and isRecommend!=-1">
|
||||
and c.course_id in (select course_id from course_details where good=1)
|
||||
</if>
|
||||
<!-- <if test="isRecommend!=null and isRecommend!=-1">-->
|
||||
<!-- and c.course_id in (select course_id from course_details where good=1)-->
|
||||
<!-- </if>-->
|
||||
<if test="status!=null and status!=0">
|
||||
and c.status=#{status}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -74,4 +74,13 @@
|
|||
order by SUBSTR(uid, ${randomNum}, 6)
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -323,4 +323,13 @@
|
|||
AND orders.`pay_way` = 9
|
||||
AND orders.create_time > DATE_FORMAT(CURDATE(), '%Y-%m-%d 00:00:00')
|
||||
</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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue