QuestionMapper.xml 29 KB

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