QuestionMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  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.bank.mapper.QuestionMapper">
  6. <resultMap type="com.zhongzheng.modules.bank.domain.Question" id="QuestionResult">
  7. <result property="questionId" column="question_id"/>
  8. <result property="content" column="content"/>
  9. <result property="type" column="type"/>
  10. <result property="answerQuestion" column="answer_question"/>
  11. <result property="status" column="status"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. <result property="analysisContent" column="analysis_content"/>
  15. <result property="imgUrl" column="img_url"/>
  16. <result property="jsonStr" column="json_str"/>
  17. <result property="prefixName" column="prefix_name"/>
  18. <result property="knowledgeIds" column="knowledge_ids"/>
  19. <result property="publishStatus" column="publish_status"/>
  20. <result property="code" column="code"/>
  21. <result property="importNo" column="import_no"/>
  22. <result property="createBy" column="create_by"/>
  23. <result property="importSort" column="import_sort"/>
  24. </resultMap>
  25. <resultMap type="com.zhongzheng.modules.bank.vo.QuestionVo" id="QuestionResultVo">
  26. <result property="questionId" column="question_id"/>
  27. <result property="content" column="content"/>
  28. <result property="type" column="type"/>
  29. <result property="answerQuestion" column="answer_question"/>
  30. <result property="status" column="status"/>
  31. <result property="analysisContent" column="analysis_content"/>
  32. <result property="imgUrl" column="img_url"/>
  33. <result property="jsonStr" column="json_str"/>
  34. <result property="prefixName" column="prefix_name"/>
  35. <result property="knowledgeIds" column="knowledge_ids"/>
  36. <result property="publishStatus" column="publish_status"/>
  37. <result property="code" column="code"/>
  38. <result property="createTime" column="create_time"/>
  39. <result property="updateTime" column="update_time"/>
  40. <result property="importSort" column="import_sort"/>
  41. <collection property="businessList" column="question_id" select="findBusinessList" />
  42. <collection property="knowledgeList" column="knowledge_ids" select="findKnowledge"/>
  43. <collection property="examList" column="question_id" select="findExamList" />
  44. </resultMap>
  45. <resultMap type="com.zhongzheng.modules.bank.vo.ExamVo" id="ExamVoResult">
  46. <result property="examId" column="exam_id"/>
  47. <result property="examName" column="exam_name"/>
  48. </resultMap>
  49. <select id="findExamList" resultMap="ExamVoResult">
  50. SELECT
  51. e.exam_id,
  52. e.exam_name
  53. FROM
  54. exam_question eq
  55. LEFT JOIN exam e ON eq.exam_id = e.exam_id
  56. WHERE
  57. eq.question_id = #{question_id} AND e.status !=-1
  58. </select>
  59. <select id="findKnowledge" resultMap="ExamKnowledge">
  60. SELECT
  61. ek.knowledge_name,
  62. ek.knowledge_id
  63. FROM
  64. exam_knowledge ek
  65. WHERE
  66. FIND_IN_SET( ek.knowledge_id, #{knowledge_ids} ) AND ek.status !=-1
  67. </select>
  68. <select id="findBusinessList" resultMap="QuestionBusiness">
  69. SELECT
  70. qb.education_type_id,
  71. qb.business_id,
  72. qb.project_id,
  73. qb.subject_id,
  74. qb.type as business_type,
  75. cet.education_name,
  76. cpt.project_name,
  77. cb.business_name,
  78. cs.subject_name
  79. FROM
  80. question_business qb
  81. LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id AND cet.status =1
  82. LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id AND cpt.status =1
  83. LEFT JOIN course_business cb ON qb.business_id = cb.id AND cb.status =1
  84. LEFT JOIN course_subject cs ON cs.id = qb.subject_id AND cs.status =1
  85. WHERE
  86. qb.major_id=#{question_id} and qb.type = 1
  87. </select>
  88. <resultMap type="com.zhongzheng.modules.bank.domain.QuestionBusiness" id="QuestionBusiness">
  89. <result property="id" column="id"/>
  90. <result property="subjectId" column="subject_id"/>
  91. <result property="educationTypeId" column="education_type_id"/>
  92. <result property="businessId" column="business_id"/>
  93. <result property="projectId" column="project_id"/>
  94. <result property="educationName" column="education_name"/>
  95. <result property="projectName" column="project_name"/>
  96. <result property="businessName" column="business_name"/>
  97. <result property="subjectName" column="subject_name"/>
  98. <result property="type" column="business_type"/>
  99. </resultMap>
  100. <resultMap type="com.zhongzheng.modules.exam.domain.ExamKnowledge" id="ExamKnowledge">
  101. <result property="knowledgeId" column="knowledge_id"/>
  102. <result property="knowledgeName" column="knowledge_name"/>
  103. </resultMap>
  104. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo" id="GoodsUserQuestionVo">
  105. <result property="goodsId" column="goods_id"/>
  106. <result property="year" column="year"/>
  107. <result property="supplyId" column="supply_id"/>
  108. <result property="goodsType" column="goods_type"/>
  109. <result property="educationTypeId" column="education_type_id"/>
  110. <result property="businessId" column="business_id"/>
  111. <result property="schoolId" column="school_id"/>
  112. <result property="majorId" column="major_id"/>
  113. <result property="goodsName" column="goods_name"/>
  114. <result property="standPrice" column="stand_price"/>
  115. <result property="lowestPrice" column="lowest_price"/>
  116. <result property="createTime" column="create_time"/>
  117. <result property="updateTime" column="update_time"/>
  118. <result property="status" column="status"/>
  119. <result property="validityStartTime" column="validity_start_time"/>
  120. <result property="validityEndTime" column="validity_end_time"/>
  121. <result property="studyStartTime" column="study_start_time"/>
  122. <result property="studyEndTime" column="study_end_time"/>
  123. <result property="certificateIds" column="certificate_ids"/>
  124. <result property="introduce" column="introduce"/>
  125. <result property="suitableObject" column="suitable_object"/>
  126. <result property="buyNote" column="buy_note"/>
  127. <result property="pcDetailHtml" column="pc_detail_html"/>
  128. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  129. <result property="goodsStatus" column="goods_status"/>
  130. <result property="coverUrl" column="cover_url"/>
  131. <result property="classHours" column="class_hours"/>
  132. <result property="standPriceJson" column="stand_price_json"/>
  133. <result property="code" column="code"/>
  134. <result property="projectId" column="project_id"/>
  135. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  136. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  137. <result property="goodsPlayConfig" column="goods_play_config"/>
  138. <result property="goodsExamConfig" column="goods_exam_config"/>
  139. <result property="supplyName" column="supply_name"/>
  140. <result property="educationName" column="education_name"/>
  141. <result property="projectName" column="project_name"/>
  142. <result property="businessName" column="business_name"/>
  143. <result property="schoolName" column="school_name"/>
  144. <result property="categoryName" column="category_name"/>
  145. <result property="handoutsId" column="handouts_id"/>
  146. <result property="templateType" column="template_type"/>
  147. <result property="period" column="period"/>
  148. <result property="makeStartTime" column="make_start_time"/>
  149. <result property="makeEndTime" column="make_end_time"/>
  150. <result property="studyCount" column="study_count"/>
  151. <result property="makeGoodsName" column="make_goods_name"/>
  152. <result property="makeGoodsCode" column="make_goods_code"/>
  153. <result property="serviceStartTime" column="service_start_time"/>
  154. <result property="serviceEndTime" column="service_end_time"/>
  155. <result property="orderGoodsId" column="order_goods_id"/>
  156. <result property="realName" column="realname"/>
  157. <result property="idCard" column="id_card"/>
  158. <result property="userId" column="user_id"/>
  159. <result property="orderSn" column="order_sn"/>
  160. <result property="doStartTime" column="do_start_time"/>
  161. <result property="doEndTime" column="do_end_time"/>
  162. <result property="doExamNum" column="do_exam_num"/>
  163. <result property="subjectNames" column="subject_names"/>
  164. </resultMap>
  165. <select id="selectList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="QuestionResultVo">
  166. SELECT
  167. q.*
  168. FROM
  169. question q
  170. LEFT JOIN (SELECT
  171. major_id,
  172. type,
  173. any_value ( education_type_id ) as education_type_id,
  174. any_value ( business_id ) as business_id,
  175. any_value ( project_id )as project_id,
  176. any_value ( subject_id ) as subject_id
  177. FROM
  178. question_business
  179. where type = 1
  180. GROUP BY
  181. major_id,
  182. type ) qb ON q.question_id = qb.major_id
  183. WHERE
  184. 1 = 1 AND q.status !=-1
  185. <if test="status != null and status.size()!=0 ">
  186. AND q.status in
  187. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  188. #{item}
  189. </foreach>
  190. </if>
  191. <if test="educationTypeId != null and educationTypeId != ''">
  192. AND qb.education_type_id = #{educationTypeId}
  193. </if>
  194. <if test="subjectId != null and subjectId != ''">
  195. AND qb.subject_id = #{subjectId}
  196. </if>
  197. <if test="type != null and type != ''">
  198. AND q.type = #{type}
  199. </if>
  200. <if test="businessId != null and businessId != ''">
  201. AND qb.business_id = #{businessId}
  202. </if>
  203. <if test="publishStatus != null ">
  204. AND q.publish_status = #{publishStatus}
  205. </if>
  206. <if test="prefixName != null and prefixName != ''">
  207. AND q.prefix_name like concat('%', #{prefixName}, '%')
  208. </if>
  209. <if test="key != null and key != ''">
  210. AND (q.content like concat('%', #{key}, '%') or q.prefix_name like concat('%', #{key}, '%') or q.code like concat('%', #{key}, '%'))
  211. </if>
  212. <if test="pageSizeSelf != null and pageSizeSelf != ''">
  213. LIMIT #{currIndex} , #{pageSizeSelf}
  214. </if>
  215. ORDER BY q.question_id DESC
  216. </select>
  217. <select id="selectList_COUNT" resultType="Long">
  218. SELECT
  219. count( q.question_id)
  220. FROM
  221. question q
  222. LEFT JOIN (SELECT
  223. major_id,
  224. type,
  225. any_value ( education_type_id ) as education_type_id,
  226. any_value ( business_id ) as business_id,
  227. any_value ( project_id )as project_id,
  228. any_value ( subject_id ) as subject_id
  229. FROM
  230. question_business
  231. where type = 1
  232. GROUP BY
  233. major_id,
  234. type ) qb ON q.question_id = qb.major_id
  235. WHERE
  236. 1 = 1 AND q.status !=-1
  237. <if test="status != null and status.size()!=0 ">
  238. AND q.status in
  239. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  240. #{item}
  241. </foreach>
  242. </if>
  243. <if test="educationTypeId != null and educationTypeId != ''">
  244. AND qb.education_type_id = #{educationTypeId}
  245. </if>
  246. <if test="subjectId != null and subjectId != ''">
  247. AND qb.subject_id = #{subjectId}
  248. </if>
  249. <if test="type != null and type != ''">
  250. AND q.type = #{type}
  251. </if>
  252. <if test="businessId != null and businessId != ''">
  253. AND qb.business_id = #{businessId}
  254. </if>
  255. <if test="publishStatus != null ">
  256. AND q.publish_status = #{publishStatus}
  257. </if>
  258. <if test="prefixName != null and prefixName != ''">
  259. AND q.prefix_name like concat('%', #{prefixName}, '%')
  260. </if>
  261. <if test="key != null and key != ''">
  262. AND (q.content like concat('%', #{key}, '%') or q.prefix_name like concat('%', #{key}, '%') or q.code like concat('%', #{key}, '%'))
  263. </if>
  264. <if test="pageSizeSelf != null and pageSizeSelf != ''">
  265. LIMIT #{currIndex} , #{pageSizeSelf}
  266. </if>
  267. </select>
  268. <select id="listGoodsUserQuestionVo" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  269. SELECT
  270. g.*,
  271. ps.supply_name,
  272. cet.education_name,
  273. cpt.project_name,
  274. cb.business_name,
  275. s.school_name,
  276. m.category_name,
  277. ot.type AS template_type,
  278. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  279. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  280. o.user_id,
  281. og.create_time as order_create_time,
  282. og.service_start_time,
  283. og.service_end_time,
  284. og.order_goods_id,
  285. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  286. FROM
  287. goods g
  288. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  289. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  290. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  291. LEFT JOIN course_business cb ON g.business_id = cb.id
  292. LEFT JOIN school s ON s.id = g.school_id
  293. LEFT JOIN major m ON g.major_id = m.id
  294. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  295. LEFT JOIN order_goods og on g.goods_id =og.goods_id
  296. LEFT JOIN `order` o on o.order_sn = og.order_sn
  297. WHERE
  298. 1 = 1
  299. AND g.goods_type = 2
  300. AND o.user_id=#{userId}
  301. AND og.`status` =1
  302. and og.pay_status in (2,3,4)
  303. AND og.refund_status in (0,3,1)
  304. <if test="educationTypeId != null and educationTypeId != ''">
  305. AND g.education_type_id = #{educationTypeId}
  306. </if>
  307. <if test="businessId != null and businessId != ''">
  308. AND g.business_id = #{businessId}
  309. </if>
  310. ORDER BY og.create_time DESC
  311. </select>
  312. <select id="listUserFreeGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  313. SELECT
  314. g.*,
  315. ps.supply_name,
  316. cet.education_name,
  317. cpt.project_name,
  318. cb.business_name,
  319. s.school_name,
  320. m.category_name,
  321. ot.type AS template_type,
  322. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  323. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  324. o.user_id,
  325. og.create_time as order_create_time,
  326. og.service_start_time,
  327. og.service_end_time,
  328. og.order_goods_id
  329. FROM `order` o
  330. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  331. LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
  332. LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
  333. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  334. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  335. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  336. LEFT JOIN course_business cb ON g.business_id = cb.id
  337. LEFT JOIN school s ON s.id = g.school_id
  338. LEFT JOIN major m ON g.major_id = m.id
  339. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  340. WHERE
  341. 1 = 1
  342. AND g.goods_type = 5
  343. AND o.user_id = #{userId}
  344. AND og.`status` = 1
  345. AND og.pay_status IN ( 2, 3, 4 )
  346. AND og.refund_status IN (0,3,1)
  347. <if test="educationTypeId != null and educationTypeId != ''">
  348. AND g.education_type_id = #{educationTypeId}
  349. </if>
  350. <if test="businessId != null and businessId != ''">
  351. AND g.business_id = #{businessId}
  352. </if>
  353. ORDER BY og.create_time DESC
  354. </select>
  355. <select id="listFreeGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  356. SELECT
  357. g.*,
  358. ps.supply_name,
  359. cet.education_name,
  360. cpt.project_name,
  361. cb.business_name,
  362. s.school_name,
  363. m.category_name,
  364. ot.type AS template_type,
  365. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  366. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  367. o.user_id,
  368. o.order_sn,
  369. og.create_time as order_create_time,
  370. og.service_start_time,
  371. og.service_end_time,
  372. og.order_goods_id,
  373. u.realname,
  374. u.id_card,
  375. (SELECT MIN(uer.update_time) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_start_time,
  376. (SELECT MAX(uer.update_time) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_end_time,
  377. (SELECT count(DISTINCT uer.exam_id) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_exam_num
  378. FROM `order` o
  379. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  380. LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
  381. LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
  382. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  383. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  384. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  385. LEFT JOIN course_business cb ON g.business_id = cb.id
  386. LEFT JOIN school s ON s.id = g.school_id
  387. LEFT JOIN major m ON g.major_id = m.id
  388. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  389. LEFT JOIN `user` u ON u.user_id = o.user_id
  390. WHERE
  391. 1 = 1
  392. AND g.goods_type = 5
  393. AND og.`status` = 1
  394. AND og.pay_status IN ( 2, 3, 4 )
  395. AND og.refund_status IN (0,3,1)
  396. <if test="educationTypeId != null and educationTypeId != ''">
  397. AND g.education_type_id = #{educationTypeId}
  398. </if>
  399. <if test="businessId != null and businessId != ''">
  400. AND g.business_id = #{businessId}
  401. </if>
  402. <if test="majorId != null and majorId != ''">
  403. AND g.major_id = #{majorId}
  404. </if>
  405. <if test="searchKey != null and searchKey != ''">
  406. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
  407. </if>
  408. ORDER BY og.create_time DESC
  409. </select>
  410. <select id="listBankGoodsList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsUserQuestionVo">
  411. SELECT
  412. g.*,
  413. ps.supply_name,
  414. cet.education_name,
  415. cpt.project_name,
  416. cb.business_name,
  417. s.school_name,
  418. m.category_name,
  419. ot.type AS template_type,
  420. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  421. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  422. o.user_id,
  423. o.order_sn,
  424. og.create_time as order_create_time,
  425. og.service_start_time,
  426. og.service_end_time,
  427. og.order_goods_id,
  428. u.realname,
  429. u.id_card,
  430. u.user_id,
  431. (SELECT MIN(uer.update_time) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_start_time,
  432. (SELECT MAX(uer.update_time) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_end_time,
  433. (SELECT count(DISTINCT uer.exam_id) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_exam_num
  434. FROM `order` o
  435. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  436. LEFT JOIN goods g ON og.goods_id = g.goods_id
  437. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  438. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  439. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  440. LEFT JOIN course_business cb ON g.business_id = cb.id
  441. LEFT JOIN school s ON s.id = g.school_id
  442. LEFT JOIN major m ON g.major_id = m.id
  443. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  444. LEFT JOIN `user` u ON u.user_id = o.user_id
  445. WHERE
  446. 1 = 1
  447. <if test="goodsType != null and goodsType != ''">
  448. AND g.goods_type = #{goodsType}
  449. </if>
  450. AND og.pay_status IN ( 2, 3, 4 )
  451. AND og.refund_status IN (0,3,1)
  452. <if test="goodsId != null and goodsId != ''">
  453. AND og.goods_id = #{goodsId}
  454. </if>
  455. <if test="educationTypeId != null and educationTypeId != ''">
  456. AND g.education_type_id = #{educationTypeId}
  457. </if>
  458. <if test="businessId != null and businessId != ''">
  459. AND g.business_id = #{businessId}
  460. </if>
  461. <if test="majorId != null and majorId != ''">
  462. AND g.major_id = #{majorId}
  463. </if>
  464. <if test="searchKey != null and searchKey != ''">
  465. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
  466. </if>
  467. ORDER BY og.create_time DESC
  468. </select>
  469. <select id="listUserFreeUnionBuyGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  470. SELECT * from (SELECT
  471. g.*,
  472. ps.supply_name,
  473. cet.education_name,
  474. cpt.project_name,
  475. cb.business_name,
  476. s.school_name,
  477. m.category_name,
  478. ot.type AS template_type,
  479. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  480. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  481. o.user_id,
  482. og.create_time as order_create_time,
  483. og.service_start_time,
  484. og.service_end_time,
  485. og.order_goods_id,
  486. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  487. FROM
  488. goods g
  489. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  490. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  491. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  492. LEFT JOIN course_business cb ON g.business_id = cb.id
  493. LEFT JOIN school s ON s.id = g.school_id
  494. LEFT JOIN major m ON g.major_id = m.id
  495. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  496. LEFT JOIN order_goods og on g.goods_id =og.goods_id
  497. LEFT JOIN `order` o on o.order_sn = og.order_sn
  498. WHERE
  499. 1 = 1
  500. AND g.goods_type = 2
  501. AND o.user_id=#{userId}
  502. AND og.`status` =1
  503. and og.pay_status in (2,3,4)
  504. AND og.refund_status in (0,3,1)
  505. <if test="educationTypeId != null and educationTypeId != ''">
  506. AND g.education_type_id = #{educationTypeId}
  507. </if>
  508. <if test="businessId != null and businessId != ''">
  509. AND g.business_id = #{businessId}
  510. </if>
  511. UNION
  512. SELECT
  513. g.*,
  514. ps.supply_name,
  515. cet.education_name,
  516. cpt.project_name,
  517. cb.business_name,
  518. s.school_name,
  519. m.category_name,
  520. ot.type AS template_type,
  521. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  522. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  523. o.user_id,
  524. og.create_time as order_create_time,
  525. og.service_start_time,
  526. og.service_end_time,
  527. og.order_goods_id,
  528. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  529. FROM `order` o
  530. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  531. LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
  532. LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
  533. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  534. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  535. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  536. LEFT JOIN course_business cb ON g.business_id = cb.id
  537. LEFT JOIN school s ON s.id = g.school_id
  538. LEFT JOIN major m ON g.major_id = m.id
  539. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  540. WHERE
  541. 1 = 1
  542. AND g.goods_type = 5
  543. AND o.user_id = #{userId}
  544. AND og.`status` = 1
  545. AND og.pay_status IN ( 2, 3, 4 )
  546. AND og.refund_status IN (0,3,1)
  547. <if test="educationTypeId != null and educationTypeId != ''">
  548. AND g.education_type_id = #{educationTypeId}
  549. </if>
  550. <if test="businessId != null and businessId != ''">
  551. AND g.business_id = #{businessId}
  552. </if>
  553. )un ORDER BY un.order_create_time DESC
  554. </select>
  555. </mapper>