StudentRepairMapper.xml 16 KB

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