StudentRepairMapper.xml 16 KB

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