UserPeriodMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.grade.mapper.UserPeriodMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.UserPeriod" id="UserPeriodResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="courseId" column="course_id"/>
  10. <result property="sectionId" column="section_id"/>
  11. <result property="goodsId" column="goods_id"/>
  12. <result property="type" column="type"/>
  13. <result property="examId" column="exam_id"/>
  14. <result property="createTime" column="create_time"/>
  15. <result property="updateTime" column="update_time"/>
  16. <result property="moduleId" column="module_id"/>
  17. <result property="chapterId" column="chapter_id"/>
  18. <result property="orderGoodsId" column="order_goods_id"/>
  19. </resultMap>
  20. <select id="checkGoodsChange" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  21. SELECT
  22. IFNULL(count(*),0)
  23. FROM
  24. user_period up
  25. LEFT JOIN class_grade_user cgu ON up.grade_id = cgu.grade_id
  26. WHERE
  27. cgu.period_status = 1
  28. <if test="goodsId != null and goodsId != ''">
  29. and up.goods_id = #{goodsId}
  30. </if>
  31. <if test="gradeId != null and gradeId != ''">
  32. and up.grade_id = #{gradeId}
  33. </if>
  34. <if test="userId != null and userId != ''">
  35. and up.user_id = #{userId}
  36. </if>
  37. <if test="sectionId != null ">
  38. and up.section_id = #{sectionId}
  39. </if>
  40. <if test="moduleId != null ">
  41. and up.module_id = #{moduleId}
  42. </if>
  43. <if test="chapterId != null">
  44. and up.chapter_id = #{chapterId}
  45. </if>
  46. <if test="courseId != null ">
  47. and up.course_id = #{courseId}
  48. </if>
  49. <if test="examId != null ">
  50. and up.exam_id = #{examId}
  51. </if>
  52. </select>
  53. <select id="checkGoodsStudy" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  54. SELECT
  55. IFNULL(count(*),0)
  56. FROM
  57. user_period up
  58. WHERE
  59. 1=1
  60. <if test="goodsId != null and goodsId != ''">
  61. and up.goods_id = #{goodsId}
  62. </if>
  63. <if test="gradeId != null and gradeId != ''">
  64. and up.grade_id = #{gradeId}
  65. </if>
  66. <if test="userId != null and userId != ''">
  67. and up.user_id = #{userId}
  68. </if>
  69. <if test="sectionId != null ">
  70. and up.section_id = #{sectionId}
  71. </if>
  72. <if test="moduleId != null ">
  73. and up.module_id = #{moduleId}
  74. </if>
  75. <if test="chapterId != null">
  76. and up.chapter_id = #{chapterId}
  77. </if>
  78. <if test="courseId != null ">
  79. and up.course_id = #{courseId}
  80. </if>
  81. <if test="examId != null ">
  82. and up.exam_id = #{examId}
  83. </if>
  84. </select>
  85. <select id="checkBatchGoodsStudy" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  86. SELECT
  87. IFNULL(count(*),0)
  88. FROM
  89. user_period up
  90. WHERE
  91. 1=1
  92. <if test="sectionIds != null and sectionIds.size()!=0 ">
  93. AND up.section_id in
  94. <foreach collection="sectionIds" item="item" index="index" open="(" close=")" separator=",">
  95. #{item}
  96. </foreach>
  97. </if>
  98. <if test="courseIds != null and courseIds.size()!=0 ">
  99. AND up.course_id in
  100. <foreach collection="courseIds" item="item" index="index" open="(" close=")" separator=",">
  101. #{item}
  102. </foreach>
  103. </if>
  104. <if test="moduleIds != null and moduleIds.size()!=0 ">
  105. AND up.module_id in
  106. <foreach collection="moduleIds" item="item" index="index" open="(" close=")" separator=",">
  107. #{item}
  108. </foreach>
  109. </if>
  110. <if test="chapterIds != null and chapterIds.size()!=0 ">
  111. AND up.chapter_id in
  112. <foreach collection="chapterIds" item="item" index="index" open="(" close=")" separator=",">
  113. #{item}
  114. </foreach>
  115. </if>
  116. </select>
  117. <select id="selectCountPeriod" parameterType="map" resultType="Long">
  118. SELECT
  119. COUNT(1)
  120. FROM
  121. user_period_status ups JOIN user_period up on ups.period_id = up.id JOIN goods g on g.goods_id = up.goods_id JOIN course_business b on g.business_id = b.id
  122. WHERE
  123. 1 = 1
  124. AND ups.id = #{id}
  125. and FIND_IN_SET(#{userId},b.period_user_ids)
  126. </select>
  127. <select id="selectCountConfirmPeriod" parameterType="map" resultType="Long">
  128. SELECT
  129. COUNT(1)
  130. FROM
  131. goods g LEFT JOIN course_business b on g.business_id = b.id
  132. WHERE
  133. 1 = 1
  134. AND g.goods_id = #{goodsId}
  135. and FIND_IN_SET(#{userId},b.period_confirm_user_ids)
  136. </select>
  137. <select id="todayStudySectionNum" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  138. SELECT
  139. IFNULL(count(*),0)
  140. FROM
  141. user_period up
  142. WHERE
  143. 1=1
  144. <if test="goodsId != null and goodsId != ''">
  145. and up.goods_id = #{goodsId}
  146. </if>
  147. <if test="gradeId != null and gradeId != ''">
  148. and up.grade_id = #{gradeId}
  149. </if>
  150. <if test="userId != null and userId != ''">
  151. and up.user_id = #{userId}
  152. </if>
  153. <if test="sectionId != null ">
  154. and up.section_id = #{sectionId}
  155. </if>
  156. <if test="moduleId != null ">
  157. and up.module_id = #{moduleId}
  158. </if>
  159. <if test="chapterId != null">
  160. and up.chapter_id = #{chapterId}
  161. </if>
  162. <if test="courseId != null ">
  163. and up.course_id = #{courseId}
  164. </if>
  165. <if test="examId != null ">
  166. and up.exam_id = #{examId}
  167. </if>
  168. <if test="todayStartTime != null ">
  169. and up.create_time >= #{todayStartTime}
  170. </if>
  171. <if test="todayEndTime != null ">
  172. and #{todayEndTime} >= up.create_time
  173. </if>
  174. </select>
  175. </mapper>