QuestionMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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. WHERE
  175. 1 = 1 AND q.status !=-1
  176. <if test="status != null and status.size()!=0 ">
  177. AND q.status in
  178. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  179. #{item}
  180. </foreach>
  181. </if>
  182. <if test="educationTypeId != null and educationTypeId != ''">
  183. AND (select count(*) from question_business qb where qb.type = 1 and qb.major_id = q.question_id and qb.education_type_id = #{educationTypeId}) >0
  184. </if>
  185. <if test="subjectId != null and subjectId != ''">
  186. AND (select count(*) from question_business qb where qb.type = 1 and qb.major_id = q.question_id and qb.subject_id = #{subjectId}) >0
  187. </if>
  188. <if test="type != null and type != ''">
  189. AND q.type = #{type}
  190. </if>
  191. <if test="businessId != null and businessId != ''">
  192. AND (select count(*) from question_business qb where qb.type = 1 and qb.major_id = q.question_id and qb.business_id = #{businessId}) >0
  193. </if>
  194. <if test="publishStatus != null ">
  195. AND q.publish_status = #{publishStatus}
  196. </if>
  197. <if test="prefixName != null and prefixName != ''">
  198. AND q.prefix_name like concat('%', #{prefixName}, '%')
  199. </if>
  200. <if test="key != null and key != ''">
  201. AND (q.content like concat('%', #{key}, '%') or q.prefix_name like concat('%', #{key}, '%') or q.code like concat('%', #{key}, '%'))
  202. </if>
  203. <if test="pageSizeSelf != null and pageSizeSelf != ''">
  204. LIMIT #{currIndex} , #{pageSizeSelf}
  205. </if>
  206. ORDER BY q.question_id DESC
  207. </select>
  208. <select id="selectList_COUNT" resultType="Long">
  209. SELECT
  210. count( q.question_id)
  211. FROM
  212. question q
  213. LEFT JOIN (SELECT
  214. major_id,
  215. type,
  216. any_value ( education_type_id ) as education_type_id,
  217. any_value ( business_id ) as business_id,
  218. any_value ( project_id )as project_id,
  219. any_value ( subject_id ) as subject_id
  220. FROM
  221. question_business
  222. where type = 1
  223. GROUP BY
  224. major_id,
  225. type ) qb ON q.question_id = qb.major_id
  226. WHERE
  227. 1 = 1 AND q.status !=-1
  228. <if test="status != null and status.size()!=0 ">
  229. AND q.status in
  230. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  231. #{item}
  232. </foreach>
  233. </if>
  234. <if test="educationTypeId != null and educationTypeId != ''">
  235. AND qb.education_type_id = #{educationTypeId}
  236. </if>
  237. <if test="subjectId != null and subjectId != ''">
  238. AND qb.subject_id = #{subjectId}
  239. </if>
  240. <if test="type != null and type != ''">
  241. AND q.type = #{type}
  242. </if>
  243. <if test="businessId != null and businessId != ''">
  244. AND qb.business_id = #{businessId}
  245. </if>
  246. <if test="publishStatus != null ">
  247. AND q.publish_status = #{publishStatus}
  248. </if>
  249. <if test="prefixName != null and prefixName != ''">
  250. AND q.prefix_name like concat('%', #{prefixName}, '%')
  251. </if>
  252. <if test="key != null and key != ''">
  253. AND (q.content like concat('%', #{key}, '%') or q.prefix_name like concat('%', #{key}, '%') or q.code like concat('%', #{key}, '%'))
  254. </if>
  255. <if test="pageSizeSelf != null and pageSizeSelf != ''">
  256. LIMIT #{currIndex} , #{pageSizeSelf}
  257. </if>
  258. </select>
  259. <select id="listGoodsUserQuestionVo" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  260. SELECT
  261. g.*,
  262. ps.supply_name,
  263. cet.education_name,
  264. cpt.project_name,
  265. cb.business_name,
  266. s.school_name,
  267. m.category_name,
  268. ot.type AS template_type,
  269. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  270. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  271. o.user_id,
  272. og.create_time as order_create_time,
  273. og.service_start_time,
  274. og.service_end_time,
  275. og.order_goods_id,
  276. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  277. FROM
  278. goods g
  279. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  280. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  281. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  282. LEFT JOIN course_business cb ON g.business_id = cb.id
  283. LEFT JOIN school s ON s.id = g.school_id
  284. LEFT JOIN major m ON g.major_id = m.id
  285. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  286. LEFT JOIN order_goods og on g.goods_id =og.goods_id
  287. LEFT JOIN `order` o on o.order_sn = og.order_sn
  288. WHERE
  289. 1 = 1
  290. AND g.goods_type in (2)
  291. AND o.user_id=#{userId}
  292. AND og.`status` =1
  293. and og.pay_status in (2,3,4)
  294. AND og.refund_status in (0,3,1)
  295. <if test="educationTypeId != null and educationTypeId != ''">
  296. AND g.education_type_id = #{educationTypeId}
  297. </if>
  298. <if test="businessId != null and businessId != ''">
  299. AND g.business_id = #{businessId}
  300. </if>
  301. ORDER BY og.create_time DESC
  302. </select>
  303. <select id="listUserFreeGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  304. SELECT
  305. g.*,
  306. ps.supply_name,
  307. cet.education_name,
  308. cpt.project_name,
  309. cb.business_name,
  310. s.school_name,
  311. m.category_name,
  312. ot.type AS template_type,
  313. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  314. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  315. o.user_id,
  316. og.create_time as order_create_time,
  317. og.service_start_time,
  318. og.service_end_time,
  319. og.order_goods_id
  320. FROM `order` o
  321. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  322. LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
  323. LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
  324. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  325. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  326. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  327. LEFT JOIN course_business cb ON g.business_id = cb.id
  328. LEFT JOIN school s ON s.id = g.school_id
  329. LEFT JOIN major m ON g.major_id = m.id
  330. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  331. WHERE
  332. 1 = 1
  333. AND g.goods_type = 5
  334. AND o.user_id = #{userId}
  335. AND og.`status` = 1
  336. AND og.pay_status IN ( 2, 3, 4 )
  337. AND og.refund_status IN (0,3,1)
  338. <if test="educationTypeId != null and educationTypeId != ''">
  339. AND g.education_type_id = #{educationTypeId}
  340. </if>
  341. <if test="businessId != null and businessId != ''">
  342. AND g.business_id = #{businessId}
  343. </if>
  344. ORDER BY og.create_time DESC
  345. </select>
  346. <select id="listFreeGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  347. SELECT
  348. g.*,
  349. ps.supply_name,
  350. cet.education_name,
  351. cpt.project_name,
  352. cb.business_name,
  353. s.school_name,
  354. m.category_name,
  355. ot.type AS template_type,
  356. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  357. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  358. o.user_id,
  359. o.order_sn,
  360. og.create_time as order_create_time,
  361. og.service_start_time,
  362. og.service_end_time,
  363. og.order_goods_id,
  364. u.realname,
  365. u.id_card,
  366. (SELECT MIN(uer.update_time) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_start_time,
  367. (SELECT MAX(uer.update_time) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_end_time,
  368. (SELECT count(DISTINCT uer.exam_id) from user_exam_record uer where uer.order_goods_id = og.order_goods_id) do_exam_num
  369. FROM `order` o
  370. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  371. LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
  372. LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
  373. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  374. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  375. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  376. LEFT JOIN course_business cb ON g.business_id = cb.id
  377. LEFT JOIN school s ON s.id = g.school_id
  378. LEFT JOIN major m ON g.major_id = m.id
  379. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  380. LEFT JOIN `user` u ON u.user_id = o.user_id
  381. WHERE
  382. 1 = 1
  383. AND g.goods_type = 5
  384. AND og.`status` = 1
  385. AND og.pay_status IN ( 2, 3, 4 )
  386. AND og.refund_status IN (0,3,1)
  387. <if test="educationTypeId != null and educationTypeId != ''">
  388. AND g.education_type_id = #{educationTypeId}
  389. </if>
  390. <if test="businessId != null and businessId != ''">
  391. AND g.business_id = #{businessId}
  392. </if>
  393. <if test="majorId != null and majorId != ''">
  394. AND g.major_id = #{majorId}
  395. </if>
  396. <if test="searchKey != null and searchKey != ''">
  397. 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}, '%'))
  398. </if>
  399. ORDER BY og.create_time DESC
  400. </select>
  401. <select id="listBankGoodsList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsUserQuestionVo">
  402. SELECT
  403. g.*,
  404. ps.supply_name,
  405. cet.education_name,
  406. cpt.project_name,
  407. cb.business_name,
  408. s.school_name,
  409. m.category_name,
  410. ot.type AS template_type,
  411. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  412. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  413. o.user_id,
  414. o.order_sn,
  415. og.create_time as order_create_time,
  416. og.service_start_time,
  417. og.service_end_time,
  418. og.order_goods_id,
  419. u.realname,
  420. u.id_card,
  421. u.user_id,
  422. (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,
  423. (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,
  424. (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
  425. FROM `order` o
  426. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  427. LEFT JOIN goods g ON og.goods_id = g.goods_id
  428. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  429. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  430. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  431. LEFT JOIN course_business cb ON g.business_id = cb.id
  432. LEFT JOIN school s ON s.id = g.school_id
  433. LEFT JOIN major m ON g.major_id = m.id
  434. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  435. LEFT JOIN `user` u ON u.user_id = o.user_id
  436. WHERE
  437. 1 = 1
  438. <if test="goodsType != null and goodsType != ''">
  439. AND g.goods_type = #{goodsType}
  440. </if>
  441. AND og.pay_status IN ( 2, 3, 4 )
  442. AND og.refund_status IN (0,3,1)
  443. <if test="goodsId != null and goodsId != ''">
  444. AND og.goods_id = #{goodsId}
  445. </if>
  446. <if test="educationTypeId != null and educationTypeId != ''">
  447. AND g.education_type_id = #{educationTypeId}
  448. </if>
  449. <if test="businessId != null and businessId != ''">
  450. AND g.business_id = #{businessId}
  451. </if>
  452. <if test="majorId != null and majorId != ''">
  453. AND g.major_id = #{majorId}
  454. </if>
  455. <if test="searchKey != null and searchKey != ''">
  456. 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}, '%'))
  457. </if>
  458. ORDER BY og.create_time DESC
  459. </select>
  460. <select id="listUserFreeUnionBuyGoodsList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="GoodsUserQuestionVo">
  461. SELECT * from (SELECT
  462. g.*,
  463. ps.supply_name,
  464. cet.education_name,
  465. cpt.project_name,
  466. cb.business_name,
  467. s.school_name,
  468. m.category_name,
  469. ot.type AS template_type,
  470. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  471. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  472. o.user_id,
  473. og.create_time as order_create_time,
  474. og.service_start_time,
  475. og.service_end_time,
  476. og.order_goods_id,
  477. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  478. FROM
  479. goods g
  480. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  481. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  482. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  483. LEFT JOIN course_business cb ON g.business_id = cb.id
  484. LEFT JOIN school s ON s.id = g.school_id
  485. LEFT JOIN major m ON g.major_id = m.id
  486. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  487. LEFT JOIN order_goods og on g.goods_id =og.goods_id
  488. LEFT JOIN `order` o on o.order_sn = og.order_sn
  489. WHERE
  490. 1 = 1
  491. AND g.goods_type = 2
  492. AND o.user_id=#{userId}
  493. AND og.`status` =1
  494. and og.pay_status in (2,3,4)
  495. -- AND og.refund_status in (0,3,1)
  496. AND og.refund_status in (0,3)
  497. <if test="educationTypeId != null and educationTypeId != ''">
  498. AND g.education_type_id = #{educationTypeId}
  499. </if>
  500. <if test="businessId != null and businessId != ''">
  501. AND g.business_id = #{businessId}
  502. </if>
  503. <if test="serviceCheck != null and serviceCheck != '' and serviceCheck == 1">
  504. AND UNIX_TIMESTAMP(NOW()) &gt;= og.service_start_time
  505. AND UNIX_TIMESTAMP(NOW()) &lt;= og.service_end_time
  506. </if>
  507. <if test="serviceCheck != null and serviceCheck != '' and serviceCheck == 2">
  508. AND UNIX_TIMESTAMP(NOW()) &gt; og.service_end_time
  509. </if>
  510. UNION
  511. SELECT
  512. g.*,
  513. ps.supply_name,
  514. cet.education_name,
  515. cpt.project_name,
  516. cb.business_name,
  517. s.school_name,
  518. m.category_name,
  519. ot.type AS template_type,
  520. ( SELECT gs.goods_name FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_name,
  521. ( SELECT gs.CODE FROM goods gs WHERE 1 = 1 AND g.make_goods_id = gs.goods_id ) AS make_goods_code,
  522. o.user_id,
  523. og.create_time as order_create_time,
  524. og.service_start_time,
  525. og.service_end_time,
  526. og.order_goods_id,
  527. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  528. FROM `order` o
  529. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  530. LEFT JOIN order_goods_free ogf ON og.order_goods_id = ogf.order_goods_id
  531. LEFT JOIN goods g ON ogf.free_goods_id = g.goods_id
  532. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  533. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  534. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  535. LEFT JOIN course_business cb ON g.business_id = cb.id
  536. LEFT JOIN school s ON s.id = g.school_id
  537. LEFT JOIN major m ON g.major_id = m.id
  538. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  539. WHERE
  540. 1 = 1
  541. AND g.goods_type = 5
  542. AND o.user_id = #{userId}
  543. AND og.`status` = 1
  544. AND og.pay_status IN ( 2, 3, 4 )
  545. -- AND og.refund_status in (0,3,1)
  546. AND og.refund_status in (0,3)
  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. <if test="serviceCheck != null and serviceCheck != '' and serviceCheck == 1">
  554. AND UNIX_TIMESTAMP(NOW()) &gt;= og.service_start_time
  555. AND UNIX_TIMESTAMP(NOW()) &lt;= og.service_end_time
  556. </if>
  557. <if test="serviceCheck != null and serviceCheck != '' and serviceCheck == 2">
  558. AND UNIX_TIMESTAMP(NOW()) &gt; og.service_end_time
  559. </if>
  560. )un ORDER BY un.order_create_time DESC
  561. </select>
  562. <select id="getBankGoodsExamList" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.vo.BankGoodsExamVo">
  563. SELECT
  564. ga.goods_id AS goodsId,
  565. qmc.module_exam_id AS moduleExamId,
  566. qce.chapter_exam_id AS chapterExamId,
  567. e.exam_id AS examId,
  568. e.exam_name AS examName,
  569. ep.paper_name AS paperName
  570. FROM
  571. goods_attached ga
  572. LEFT JOIN question_module_chapter qmc ON ga.major_id = qmc.module_exam_id
  573. LEFT JOIN question_chapter_exam qce ON qmc.chapter_exam_id = qce.chapter_exam_id
  574. LEFT JOIN exam e ON qce.exam_id = e.exam_id
  575. LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
  576. WHERE
  577. ga.goods_id = #{goodsId} AND ga.type = 1
  578. UNION ALL
  579. SELECT
  580. ga.goods_id AS goodsId,
  581. 0 AS moduleExamId,
  582. qce.chapter_exam_id AS chapterExamId,
  583. e.exam_id AS examId,
  584. e.exam_name AS examName,
  585. ep.paper_name AS paperName
  586. FROM
  587. goods_attached ga
  588. LEFT JOIN question_chapter_exam qce ON ga.major_id = qce.chapter_exam_id
  589. LEFT JOIN exam e ON qce.exam_id = e.exam_id
  590. LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
  591. WHERE
  592. ga.goods_id = #{goodsId} AND ga.type = 2
  593. UNION ALL
  594. SELECT
  595. ga.goods_id AS goodsId,
  596. 0 AS moduleExamId,
  597. 0 AS chapterExamId,
  598. e.exam_id AS examId,
  599. e.exam_name AS examName,
  600. ep.paper_name AS paperName
  601. FROM
  602. goods_attached ga
  603. LEFT JOIN exam e ON ga.major_id = e.exam_id
  604. LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
  605. WHERE
  606. ga.goods_id = #{goodsId} AND ga.type = 3
  607. </select>
  608. <select id="getQuestionByTenant" parameterType="map" resultType="com.zhongzheng.modules.bank.domain.Question">
  609. select * from question where `code` = #{code} and tenant_id = #{newTenantId}
  610. </select>
  611. </mapper>