StudentRepairMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ym.mec.biz.dal.dao.StudentRepairDao">
  4. <resultMap id="StudentRepair" type="com.ym.mec.biz.dal.entity.StudentRepair">
  5. <result column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="music_group_id_" jdbcType="VARCHAR" property="musicGroupId"/>
  7. <result column="student_instrument_id_" property="studentInstrumentId"/>
  8. <result column="maintenance_status_" property="maintenanceStatus"/>
  9. <result column="repair_name_" property="repairName"/>
  10. <result column="repair_img_" property="repairImg"/>
  11. <result column="exemption_amount_" property="exemptionAmount"/>
  12. <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
  13. <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
  14. <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
  15. <result column="name_" jdbcType="INTEGER" property="organName"/>
  16. <result column="student_id_" jdbcType="INTEGER" property="studentId"/>
  17. <result column="student_name_" jdbcType="VARCHAR" property="studentName"/>
  18. <result column="student_school_" jdbcType="VARCHAR" property="studentSchool"/>
  19. <result column="employee_id_" jdbcType="INTEGER" property="employeeId"/>
  20. <result column="employee_name_" jdbcType="VARCHAR" property="employeeName"/>
  21. <result column="employee_phone_" jdbcType="VARCHAR" property="employeePhone"/>
  22. <result column="employee_address_" jdbcType="VARCHAR" property="employeeAddress"/>
  23. <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
  24. <result column="subject_name_" jdbcType="VARCHAR" property="subjectName"/>
  25. <result column="type_" jdbcType="INTEGER" property="type"/>
  26. <result column="instrument_no_" jdbcType="VARCHAR" property="instrumentNo"/>
  27. <result column="fee_list_" jdbcType="VARCHAR" property="feeList"/>
  28. <result column="description_" jdbcType="VARCHAR" property="description"/>
  29. <result column="amount_" jdbcType="DECIMAL" property="amount"/>
  30. <result column="finish_time_" jdbcType="TIMESTAMP" property="finishTime"/>
  31. <result column="send_type_" jdbcType="INTEGER" property="sendType"/>
  32. <result column="contact_name_" jdbcType="VARCHAR" property="contactName"/>
  33. <result column="contact_mobile_" jdbcType="VARCHAR" property="contactMobile"/>
  34. <result column="address_" jdbcType="VARCHAR" property="address"/>
  35. <result column="pay_status_" jdbcType="INTEGER" property="payStatus"/>
  36. <result column="repair_status_" jdbcType="INTEGER" property="repairStatus"/>
  37. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  38. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  39. <result column="username_" jdbcType="VARCHAR" property="studentName"/>
  40. <result column="goods_json_" jdbcType="VARCHAR" property="goodsJson"/>
  41. <result column="coupon_ids_" jdbcType="VARCHAR" property="couponIds"/>
  42. </resultMap>
  43. <!-- 根据主键查询一条记录 -->
  44. <select id="get" resultMap="StudentRepair">
  45. SELECT *
  46. FROM student_repair
  47. WHERE id_ = #{id}
  48. </select>
  49. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentRepair" useGeneratedKeys="true" keyColumn="id"
  50. keyProperty="id">
  51. <!--@mbg.generated-->
  52. insert into student_repair (id_,music_group_id_, trans_no_,student_instrument_id_,maintenance_status_,repair_name_,
  53. repair_img_,exemption_amount_,organ_id_,student_id_, student_name_,student_school_,employee_id_, employee_name_,
  54. subject_id_,subject_name_, type_, instrument_no_,fee_list_,description_, amount_, finish_time_,send_type_,
  55. contact_name_, contact_mobile_,address_,pay_status_, create_time_,update_time_,repair_status_,goods_json_,coupon_ids_)
  56. values (#{id,jdbcType=INTEGER},#{musicGroupId}, #{transNo,jdbcType=VARCHAR}, #{studentInstrumentId},
  57. #{maintenanceStatus},#{repairName},#{repairImg},#{exemptionAmount},#{organId,jdbcType=INTEGER},
  58. #{studentId,jdbcType=INTEGER}, #{studentName,jdbcType=VARCHAR}, #{studentSchool,jdbcType=VARCHAR},
  59. #{employeeId,jdbcType=INTEGER}, #{employeeName,jdbcType=VARCHAR}, #{subjectId,jdbcType=INTEGER},
  60. #{subjectName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{instrumentNo,jdbcType=VARCHAR},
  61. #{feeList,jdbcType=VARCHAR},#{description,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL},
  62. #{finishTime,jdbcType=TIMESTAMP},#{sendType,jdbcType=INTEGER}, #{contactName,jdbcType=VARCHAR},
  63. #{contactMobile,jdbcType=VARCHAR},#{address,jdbcType=VARCHAR}, #{payStatus,jdbcType=INTEGER},
  64. #{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{repairStatus},#{goodsJson},#{couponIds})
  65. </insert>
  66. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentRepair">
  67. UPDATE student_repair
  68. <set>
  69. <if test="couponIds != null">
  70. coupon_ids_ = #{couponIds},
  71. </if>
  72. <if test="musicGroupId != null">
  73. music_group_id_ = #{musicGroupId},
  74. </if>
  75. <if test="goodsJson != null">
  76. goods_json_ = #{goodsJson},
  77. </if>
  78. <if test="transNo != null">
  79. trans_no_ = #{transNo},
  80. </if>
  81. <if test="repairStatus != null">
  82. repair_status_ = #{repairStatus},
  83. </if>
  84. <if test="organId != null">
  85. organ_id_ = #{organId},
  86. </if>
  87. <if test="studentId != null">
  88. student_id_ = #{studentId},
  89. </if>
  90. <if test="studentName != null">
  91. student_name_ = #{studentName},
  92. </if>
  93. <if test="studentSchool != null">
  94. student_school_ = #{studentSchool},
  95. </if>
  96. <if test="employeeId != null">
  97. employee_id_ = #{employeeId},
  98. </if>
  99. <if test="employeeName != null">
  100. employee_name_ = #{employeeName},
  101. </if>
  102. <if test="subjectId != null">
  103. subject_id_ = #{subjectId},
  104. </if>
  105. <if test="subjectName != null">
  106. subject_name_ = #{subjectName},
  107. </if>
  108. <if test="type != null">
  109. type_ = #{type},
  110. </if>
  111. <if test="instrumentNo != null">
  112. instrument_no_ = #{instrumentNo},
  113. </if>
  114. <if test="feeList != null">
  115. fee_list_ = #{feeList},
  116. </if>
  117. <if test="description != null">
  118. description_ = #{description},
  119. </if>
  120. <if test="amount != null">
  121. amount_ = #{amount},
  122. </if>
  123. <if test="finishTime != null">
  124. finish_time_ = #{finishTime},
  125. </if>
  126. <if test="sendType != null">
  127. send_type_ = #{sendType},
  128. </if>
  129. <if test="contactName != null">
  130. contact_name_ = #{contactName},
  131. </if>
  132. <if test="contactMobile != null">
  133. contact_mobile_ = #{contactMobile},
  134. </if>
  135. <if test="address != null">
  136. address_ = #{address},
  137. </if>
  138. <if test="payStatus != null">
  139. pay_status_ = #{payStatus},
  140. </if>
  141. <if test="updateTime != null">
  142. update_time_ = #{updateTime},
  143. </if>
  144. </set>
  145. WHERE id_ = #{id}
  146. </update>
  147. <select id="getStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  148. SELECT su.username_ ,su.id_ user_id_,su.avatar_ head_url_,su.gender_,su.phone_,s.care_package_,s.come_on_package_,su.organ_id_
  149. FROM sys_user su
  150. LEFT JOIN student s ON su.id_=s.user_id_
  151. WHERE FIND_IN_SET(organ_id_,#{organIdList})
  152. AND user_type_ LIKE '%STUDENT%'
  153. <if test="search">
  154. AND (username_ LIKE CONCAT(#{search},'%') OR phone_ LIKE CONCAT(#{search},'%'))
  155. </if>
  156. AND del_flag_ = 0
  157. <include refid="global.limit"/>
  158. </select>
  159. <select id="getStudentsCount" resultType="java.lang.Integer">
  160. SELECT COUNT(*) FROM sys_user
  161. WHERE FIND_IN_SET(organ_id_,#{organIdList})
  162. AND user_type_ LIKE '%STUDENT%'
  163. <if test="search">
  164. AND (username_ LIKE CONCAT(#{search},'%') OR phone_ LIKE CONCAT(#{search},'%'))
  165. </if>
  166. AND del_flag_ = 0
  167. </select>
  168. <select id="queryPage" resultMap="StudentRepair">
  169. SELECT sr.*,o.name_,su.username_ FROM student_repair sr
  170. LEFT JOIN organization o ON o.id_ = sr.organ_id_
  171. LEFT JOIN sys_user su on sr.student_id_ = su.id_
  172. <include refid="queryPageSql"/>
  173. ORDER BY id_ DESC
  174. <include refid="global.limit"/>
  175. </select>
  176. <sql id="queryPageSql">
  177. <where>
  178. <if test="search != null and search != ''">
  179. AND (sr.trans_no_ LIKE CONCAT('%',#{search},'%') OR sr.student_id_ = #{search} OR su.username_ LIKE
  180. CONCAT('%',#{search},'%'))
  181. </if>
  182. <if test="employeeId != null">
  183. AND sr.employee_id_ = #{employeeId}
  184. </if>
  185. <if test="studentId != null">
  186. AND sr.student_id_ = #{studentId}
  187. </if>
  188. <if test="organIdList != null and organIdList != ''">
  189. AND FIND_IN_SET(sr.organ_id_,#{organIdList})
  190. </if>
  191. <if test="subjectId != null">
  192. AND sr.subject_id_ = #{subjectId}
  193. </if>
  194. <if test="type != null">
  195. AND sr.type_ = #{type}
  196. </if>
  197. <if test="repairStatus != null">
  198. AND sr.repair_status_ = #{repairStatus}
  199. </if>
  200. <if test="payStatus != null">
  201. AND sr.pay_status_ = #{payStatus}
  202. </if>
  203. <if test="startTime != null">
  204. AND sr.create_time_ >= #{startTime}
  205. </if>
  206. <if test="endTime != null">
  207. AND sr.create_time_ &lt;= #{endTime}
  208. </if>
  209. <if test="studentInstrumentId != null">
  210. AND sr.student_instrument_id_ = #{studentInstrumentId}
  211. </if>
  212. <if test="hasExemptionAmount != null and hasExemptionAmount ==1">
  213. AND sr.exemption_amount_ > 0
  214. </if>
  215. <if test="hasExemptionAmount != null and hasExemptionAmount ==0">
  216. AND sr.exemption_amount_ = 0
  217. </if>
  218. </where>
  219. </sql>
  220. <select id="queryCount" resultType="int">
  221. SELECT COUNT(*) FROM student_repair sr
  222. LEFT JOIN sys_user su on sr.student_id_ = su.id_
  223. <include refid="queryPageSql"/>
  224. </select>
  225. <select id="getUserMusicGroup" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.MusicGroup">
  226. SELECT mg.id_,mg.name_,sr.user_id_ repair_user_id_ FROM music_group mg
  227. LEFT JOIN student_registration sr on sr.music_group_id_ = mg.id_
  228. WHERE sr.user_id_ IN
  229. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  230. #{userId}
  231. </foreach>
  232. AND mg.status_='PROGRESS'
  233. ORDER BY id_ DESC
  234. </select>
  235. <select id="getStudentInfo" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  236. SELECT su.username_,
  237. su.id_ user_id_,
  238. su.avatar_ head_url_,
  239. su.gender_,
  240. mg.id_ music_group_id_,
  241. mg.name_ music_group_name_,
  242. sr.actual_subject_id_ subject_id_
  243. FROM sys_user su
  244. LEFT JOIN student_registration sr ON sr.user_id_ = su.id_
  245. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
  246. WHERE su.id_ = #{studentId}
  247. ORDER BY mg.id_ DESC
  248. LIMIT 1
  249. </select>
  250. <select id="getRepairInfo" resultMap="StudentRepair">
  251. SELECT sr.*, su.phone_ employee_phone_, e.contact_address_ employee_address_
  252. FROM student_repair sr
  253. LEFT JOIN sys_user su ON su.id_ = sr.employee_id_
  254. LEFT JOIN employee e ON sr.employee_id_ = e.user_id_
  255. WHERE sr.id_ = #{id}
  256. </select>
  257. <select id="getStudentMusicGroupRepairer" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  258. SELECT repairer.real_name_ username_, repairer.id_ user_id_, repairer.avatar_ head_url_
  259. FROM music_group mg
  260. LEFT JOIN student_registration sr on sr.music_group_id_ = mg.id_
  261. LEFT JOIN sys_user repairer ON repairer.id_ = mg.repair_user_id_
  262. WHERE sr.user_id_ = #{studentId}
  263. AND mg.status_ = 'PROGRESS'
  264. AND mg.repair_user_id_ IS NOT NULL
  265. ORDER BY mg.id_ DESC
  266. LIMIT 1
  267. </select>
  268. <select id="getStudentOrganRepairer" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  269. SELECT su.real_name_ username_, su.id_ user_id_, su.avatar_ head_url_
  270. FROM employee e
  271. LEFT JOIN sys_user su ON su.id_ = e.user_id_
  272. LEFT JOIN sys_user_role sur ON sur.user_id_ = su.id_
  273. WHERE FIND_IN_SET(#{organId}, e.organ_id_list_)
  274. AND sur.role_id_ = 37
  275. ORDER BY RAND()
  276. LIMIT 1
  277. </select>
  278. <select id="countEduStudents" resultType="java.lang.Integer">
  279. SELECT COUNT(DISTINCT su.id_) FROM (
  280. SELECT sr.user_id_ FROM music_group mg
  281. LEFT JOIN student_registration sr ON mg.id_ = sr.music_group_id_
  282. WHERE mg.status_ != 'CANCELED' AND sr.music_group_status_ != 'QUIT' AND mg.educational_teacher_id_ = #{teacherId}
  283. UNION
  284. SELECT cgsm.user_id_ FROM vip_group vg
  285. LEFT JOIN class_group_student_mapper cgsm ON vg.id_ = cgsm.music_group_id_
  286. WHERE cgsm.group_type_ = 'VIP' AND vg.educational_teacher_id_ = #{teacherId} AND cgsm.status_ != 'QUIT'
  287. UNION
  288. SELECT pg.student_id_ user_id_ FROM practice_group pg
  289. WHERE pg.educational_teacher_id_ = #{teacherId}) sid
  290. LEFT JOIN sys_user su ON su.id_ = sid.user_id_
  291. <if test="search != null and search != ''">
  292. WHERE su.id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%')
  293. </if>
  294. </select>
  295. <select id="queryEduStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  296. SELECT su.username_, su.id_ user_id_, su.avatar_ head_url_,su.phone_ FROM (
  297. SELECT sr.user_id_ FROM music_group mg
  298. LEFT JOIN student_registration sr ON mg.id_ = sr.music_group_id_
  299. WHERE mg.status_ != 'CANCELED' AND sr.music_group_status_ != 'QUIT' AND mg.educational_teacher_id_ = #{teacherId}
  300. UNION
  301. SELECT cgsm.user_id_ FROM vip_group vg
  302. LEFT JOIN class_group_student_mapper cgsm ON vg.id_ = cgsm.music_group_id_
  303. WHERE cgsm.group_type_ = 'VIP' AND vg.educational_teacher_id_ = #{teacherId} AND cgsm.status_ != 'QUIT'
  304. UNION
  305. SELECT pg.student_id_ user_id_ FROM practice_group pg
  306. WHERE pg.educational_teacher_id_ = #{teacherId}) sid
  307. LEFT JOIN sys_user su ON su.id_ = sid.user_id_
  308. <if test="search != null and search != ''">
  309. WHERE su.id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%')
  310. </if>
  311. </select>
  312. <select id="countStuEducation" resultType="java.lang.Integer">
  313. SELECT DISTINCT sid.educational_teacher_id_ FROM (
  314. SELECT mg.educational_teacher_id_ FROM music_group mg
  315. LEFT JOIN student_registration sr ON mg.id_ = sr.music_group_id_
  316. WHERE mg.status_ != 'CANCELED' AND sr.music_group_status_ != 'QUIT' AND sr.user_id_ = #{studentId}
  317. UNION
  318. SELECT vg.educational_teacher_id_ FROM vip_group vg
  319. LEFT JOIN course_schedule_student_payment cssp ON vg.id_ = cssp.music_group_id_
  320. WHERE cssp.group_type_ = 'VIP' AND cssp.user_id_ = #{studentId}
  321. UNION
  322. SELECT pg.educational_teacher_id_ FROM practice_group pg
  323. WHERE pg.student_id_ = #{studentId}) sid
  324. </select>
  325. </mapper>