QuestionMapper.xml 29 KB

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