GoodsMapper.xml 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245
  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.goods.mapper.GoodsMapper">
  6. <resultMap type="com.zhongzheng.modules.goods.domain.Goods" id="GoodsResult">
  7. <result property="goodsId" column="goods_id"/>
  8. <result property="year" column="year"/>
  9. <result property="supplyId" column="supply_id"/>
  10. <result property="goodsType" column="goods_type"/>
  11. <result property="educationTypeId" column="education_type_id"/>
  12. <result property="businessId" column="business_id"/>
  13. <result property="schoolId" column="school_id"/>
  14. <result property="majorId" column="major_id"/>
  15. <result property="goodsName" column="goods_name"/>
  16. <result property="standPrice" column="stand_price"/>
  17. <result property="lowestPrice" column="lowest_price"/>
  18. <result property="createTime" column="create_time"/>
  19. <result property="updateTime" column="update_time"/>
  20. <result property="status" column="status"/>
  21. <result property="validityStartTime" column="validity_start_time"/>
  22. <result property="validityEndTime" column="validity_end_time"/>
  23. <result property="studyStartTime" column="study_start_time"/>
  24. <result property="studyEndTime" column="study_end_time"/>
  25. <result property="certificateIds" column="certificate_ids"/>
  26. <result property="introduce" column="introduce"/>
  27. <result property="suitableObject" column="suitable_object"/>
  28. <result property="buyNote" column="buy_note"/>
  29. <result property="pcDetailHtml" column="pc_detail_html"/>
  30. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  31. <result property="goodsStatus" column="goods_status"/>
  32. <result property="coverUrl" column="cover_url"/>
  33. <result property="classHours" column="class_hours"/>
  34. <result property="standPriceJson" column="stand_price_json"/>
  35. <result property="code" column="code"/>
  36. <result property="supplyName" column="supply_name"/>
  37. <result property="projectId" column="project_id"/>
  38. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  39. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  40. <result property="goodsPlayConfig" column="goods_play_config"/>
  41. <result property="goodsExamConfig" column="goods_exam_config"/>
  42. <result property="handoutsId" column="handouts_id"/>
  43. <result property="serviceTimeType" column="service_time_type"/>
  44. <result property="serviceTimeNum" column="service_time_num"/>
  45. <result property="sectionMaxNum" column="section_max_num"/>
  46. <result property="examNumber" column="exam_number"/>
  47. <result property="doNumber" column="do_number"/>
  48. <result property="teacherId" column="teacher_id"/>
  49. <result property="subjectIds" column="subject_ids"/>
  50. <result property="certificateTypeId" column="certificate_type_id"/>
  51. <result property="certificateId" column="certificate_id"/>
  52. <result property="certificateTpId" column="certificate_tp_id"/>
  53. <result property="commitPeriodStatus" column="commit_period_status"/>
  54. <result property="commitPeriodRemark" column="commit_period_remark"/>
  55. <result property="gradeType" column="grade_type"/>
  56. <result property="examLimitClient" column="exam_limit_client"/>
  57. <result property="firstChoiceStatus" column="first_choice_status"/>
  58. <result property="minClassHour" column="min_class_hour"/>
  59. <result property="firstChoiceGoods" column="first_choice_goods"/>
  60. <result property="moreCertificateStatus" column="more_certificate_status"/>
  61. </resultMap>
  62. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  63. <result property="goodsId" column="goods_id"/>
  64. <result property="year" column="year"/>
  65. <result property="supplyId" column="supply_id"/>
  66. <result property="goodsType" column="goods_type"/>
  67. <result property="gradeId" column="grade_id"/>
  68. <result property="educationTypeId" column="education_type_id"/>
  69. <result property="businessId" column="business_id"/>
  70. <result property="schoolId" column="school_id"/>
  71. <result property="majorId" column="major_id"/>
  72. <result property="goodsName" column="goods_name"/>
  73. <result property="standPrice" column="stand_price"/>
  74. <result property="lowestPrice" column="lowest_price"/>
  75. <result property="createTime" column="create_time"/>
  76. <result property="updateTime" column="update_time"/>
  77. <result property="status" column="status"/>
  78. <result property="validityStartTime" column="validity_start_time"/>
  79. <result property="validityEndTime" column="validity_end_time"/>
  80. <result property="studyStartTime" column="study_start_time"/>
  81. <result property="studyEndTime" column="study_end_time"/>
  82. <result property="certificateIds" column="certificate_ids"/>
  83. <result property="introduce" column="introduce"/>
  84. <result property="suitableObject" column="suitable_object"/>
  85. <result property="buyNote" column="buy_note"/>
  86. <result property="pcDetailHtml" column="pc_detail_html"/>
  87. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  88. <result property="goodsStatus" column="goods_status"/>
  89. <result property="coverUrl" column="cover_url"/>
  90. <result property="classHours" column="class_hours"/>
  91. <result property="standPriceJson" column="stand_price_json"/>
  92. <result property="code" column="code"/>
  93. <result property="projectId" column="project_id"/>
  94. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  95. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  96. <result property="goodsAuditionExamConfig" column="goods_audition_exam_config"/>
  97. <result property="goodsPlayConfig" column="goods_play_config"/>
  98. <result property="goodsExamConfig" column="goods_exam_config"/>
  99. <result property="sectionMaxNum" column="section_max_num"/>
  100. <result property="specTemplateId" column="spec_template_id"/>
  101. <result property="showStatus" column="show_status"/>
  102. <result property="showSort" column="show_sort"/>
  103. <result property="specialGoods" column="special_goods"/>
  104. <result property="externalLink" column="external_link"/>
  105. <result property="externalLinkStatus" column="external_link_status"/>
  106. <result property="sevenYear" column="seven_year"/>
  107. <result property="mailSign" column="mail_sign"/>
  108. <result property="classHoursStr" column="classHoursStr"/>
  109. <result property="hoursSign" column="hours_Sign"/>
  110. <result property="supplyName" column="supply_name"/>
  111. <result property="educationName" column="education_name"/>
  112. <result property="projectName" column="project_name"/>
  113. <result property="businessName" column="business_name"/>
  114. <result property="schoolName" column="school_name"/>
  115. <result property="categoryName" column="category_name"/>
  116. <result property="handoutsId" column="handouts_id"/>
  117. <result property="templateType" column="template_type"/>
  118. <result property="period" column="period"/>
  119. <result property="makeStartTime" column="make_start_time"/>
  120. <result property="makeEndTime" column="make_end_time"/>
  121. <result property="studyCount" column="study_count"/>
  122. <result property="makeGoodsName" column="make_goods_name"/>
  123. <result property="makeGoodsCode" column="make_goods_code"/>
  124. <result property="courseNum" column="course_num"/>
  125. <result property="sectionNum" column="section_num"/>
  126. <result property="serviceTimeType" column="service_time_type"/>
  127. <result property="serviceTimeNum" column="service_time_num"/>
  128. <result property="gradeNum" column="grade_num"/>
  129. <result property="gradeId" column="grade_id"/>
  130. <result property="gradeName" column="grade_name"/>
  131. <result property="examNumber" column="exam_number"/>
  132. <result property="doNumber" column="do_number"/>
  133. <result property="orderNum" column="order_num"/>
  134. <result property="teacherId" column="teacher_id"/>
  135. <result property="goodsLiveNum" column="goods_live_num"/>
  136. <result property="subjectIds" column="subject_ids"/>
  137. <result property="certificateTypeId" column="certificate_type_id"/>
  138. <result property="certificateId" column="certificate_id"/>
  139. <result property="certificateTpId" column="certificate_tp_id"/>
  140. <result property="subjectNames" column="subject_names"/>
  141. <result property="buyUserNum" column="buy_user_num"/>
  142. <result property="chapterNum" column="chapter_num"/>
  143. <result property="examNum" column="exam_num"/>
  144. <result property="linePrice" column="line_price"/>
  145. <result property="specTemplateNumber" column="spec_template_number"/>
  146. <result property="goodsLearningOrder" column="goods_learning_order"/>
  147. <result property="commitPeriodStatus" column="commit_period_status"/>
  148. <result property="commitPeriodRemark" column="commit_period_remark"/>
  149. <result property="gradeType" column="grade_type"/>
  150. <result property="examLimitClient" column="exam_limit_client"/>
  151. <result property="optionalYear" column="optional_year"/>
  152. <result property="firstChoiceStatus" column="first_choice_status"/>
  153. <result property="minClassHour" column="min_class_hour"/>
  154. <result property="firstChoiceGoods" column="first_choice_goods"/>
  155. <result property="aliasName" column="alias_name"/>
  156. <result property="moreCertificateStatus" column="more_certificate_status"/>
  157. <result property="makeGoodsIds" column="make_goods_ids"/>
  158. <result property="reminderSign" column="reminder_sign"/>
  159. </resultMap>
  160. <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
  161. <result property="id" column="id"/>
  162. <result property="examNumberId" column="exam_number_id"/>
  163. <result property="goodsId" column="goods_id"/>
  164. <result property="goodsName" column="goods_name"/>
  165. <result property="code" column="code"/>
  166. <result property="standPrice" column="stand_price"/>
  167. <result property="goodsStatus" column="goods_status"/>
  168. <result property="validityStartTime" column="validity_start_time"/>
  169. <result property="validityEndTime" column="validity_end_time"/>
  170. <result property="goodsStatus" column="goods_status"/>
  171. <result property="status" column="status"/>
  172. <result property="selectStatus" column="select_status"/>
  173. </resultMap>
  174. <select id="getSectionNum" parameterType="Long" resultType="Long">
  175. SELECT COUNT(m.id) + (
  176. SELECT COUNT(n.id)
  177. FROM course_chapter_section n
  178. LEFT JOIN course_module_chapter p ON n.chapter_id = p.chapter_id
  179. LEFT JOIN course_menu m ON m.menu_id = p.module_id
  180. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  181. WHERE gc.goods_id = #{goodsId}
  182. AND m.type = 1) + (
  183. SELECT COUNT(n.id)
  184. FROM course_chapter_section n
  185. LEFT JOIN course_menu m ON m.menu_id = n.chapter_id
  186. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  187. WHERE gc.goods_id = #{goodsId}
  188. AND m.type = 2)
  189. FROM course_menu m
  190. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  191. WHERE gc.goods_id = #{goodsId}
  192. AND m.type = 3
  193. </select>
  194. <select id="selectAllList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsResultVo">
  195. SELECT
  196. g.*,
  197. g.class_hours as classHoursStr,
  198. ps.supply_name,
  199. cet.education_name,
  200. cpt.project_name,
  201. cb.business_name,
  202. cb.alias_name,
  203. cb.goods_learning_order,
  204. s.school_name,
  205. m.category_name,
  206. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names,
  207. (SELECT COUNT( DISTINCT gar.spec_template_id ) FROM goods_spec_attribute_relation gar WHERE gar.goods_id =
  208. g.goods_id AND gar.`status` = 1 ) spec_template_number,
  209. ot.type AS template_type,
  210. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  211. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  212. <if test="chapterNum ==1">
  213. ,(SELECT COUNT(m.id)+(SELECT COUNT(p.id) FROM course_module_chapter p LEFT JOIN course_menu m on m.menu_id =
  214. p.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and
  215. m.type in(1))+(SELECT COUNT(cmc.id) FROM course_module_chapter cmc LEFT JOIN course_menu m on m.menu_id =
  216. cmc.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and
  217. m.type in(2)) FROM course_menu m LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id =
  218. g.goods_id and m.type in(3)) as chapter_num
  219. </if>
  220. ,(case WHEN g.goods_type =1 then (SELECT count(*) FROM goods_course gc LEFT JOIN course c on gc.course_id =
  221. c.course_id where gc.goods_id =g.goods_id and c.course_show=1) ELSE 0 end) as course_num
  222. <if test="goodsType ==1">
  223. , (SELECT count(*) FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  224. cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
  225. </if>
  226. <if test="goodsType ==2">
  227. , (SELECT count(*) from order_goods og where og.goods_id = g.goods_id and og.pay_status IN ( 2, 3, 4 )
  228. AND og.refund_status IN (0,3,1) ) as order_num
  229. </if>
  230. <if test="getOrderNum != null and getOrderNum == 1">
  231. ,ou.goods_live_num
  232. </if>
  233. <if test="getUserNum != null and getUserNum == 1">
  234. ,(SELECT count(*) from order_goods og where og.goods_id = g.goods_id and og.`status` = 1
  235. AND og.refund_status in (0,1,3)
  236. AND og.pay_status in (2,3,4)) as buy_user_num
  237. </if>
  238. FROM
  239. goods g
  240. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  241. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  242. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  243. LEFT JOIN course_business cb ON g.business_id = cb.id
  244. LEFT JOIN school s ON s.id = g.school_id
  245. LEFT JOIN major m ON g.major_id = m.id
  246. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  247. <if test="getOrderNum != null and getOrderNum == 1">
  248. LEFT JOIN (
  249. SELECT
  250. og.goods_id,
  251. sum( CASE WHEN g.goods_type = 6 THEN 1 ELSE 0 END ) AS goods_live_num
  252. FROM
  253. `order` o
  254. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  255. LEFT JOIN goods g ON og.goods_id = g.goods_id
  256. WHERE o.`status` = 1
  257. AND og.refund_status in (0,1,3)
  258. AND og.pay_status in (2,3,4)
  259. GROUP BY
  260. og.goods_id
  261. ) ou ON g.goods_id = ou.goods_id
  262. </if>
  263. WHERE
  264. 1 = 1
  265. AND g.goods_type != 5
  266. AND g.first_choice_goods = 0
  267. <if test="status != null and status.size()!=0 ">
  268. AND g.status in
  269. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  270. #{item}
  271. </foreach>
  272. </if>
  273. <if test="goodsIds != null and goodsIds.size()!=0 ">
  274. AND g.goods_id in
  275. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  276. #{item}
  277. </foreach>
  278. </if>
  279. <if test="goodsTypes != null and goodsTypes.size()!=0 ">
  280. AND g.goods_type in
  281. <foreach collection="goodsTypes" item="item" index="index" open="(" close=")" separator=",">
  282. #{item}
  283. </foreach>
  284. </if>
  285. <if test="withNotSpec != null and withNotSpec != ''">
  286. AND g.spec_template_id is NULL
  287. </if>
  288. <if test="goodsType != null and goodsType != ''">
  289. AND g.goods_type = #{goodsType}
  290. </if>
  291. <if test="showStatus != null and showStatus != ''">
  292. AND g.show_status = #{showStatus}
  293. </if>
  294. <if test="code != null and code != ''">
  295. AND g.code = #{code}
  296. </if>
  297. <if test="makeGoodsId != null and makeGoodsId != ''">
  298. AND INSTR(g.make_goods_ids,#{makeGoodsId})
  299. </if>
  300. <if test="goodsName != null and goodsName != ''">
  301. AND g.goods_name like concat('%', #{goodsName}, '%')
  302. </if>
  303. <if test="educationTypeId != null and educationTypeId != ''">
  304. AND g.education_type_id = #{educationTypeId}
  305. </if>
  306. <if test="projectId != null and projectId != ''">
  307. AND g.project_id = #{projectId}
  308. </if>
  309. <if test="businessIds != null and businessIds.size()!=0 ">
  310. AND g.business_id in
  311. <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
  312. #{item}
  313. </foreach>
  314. </if>
  315. <if test="businessId != null and businessId != ''">
  316. AND g.business_id = #{businessId}
  317. </if>
  318. <if test="projectId != null and projectId != ''">
  319. AND g.project_id = #{projectId}
  320. </if>
  321. <if test="schoolId != null and schoolId != ''">
  322. AND g.school_id = #{schoolId}
  323. </if>
  324. <if test="majorId != null and majorId != ''">
  325. AND g.major_id = #{majorId}
  326. </if>
  327. <if test="standPrice != null ">
  328. AND g.stand_price = #{standPrice}
  329. </if>
  330. <if test="searchKey != null and searchKey != ''">
  331. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  332. </if>
  333. <if test="goodsStatus != null ">
  334. AND g.goods_status = #{goodsStatus}
  335. </if>
  336. <if test="commitPeriodStatus != null ">
  337. AND g.commit_period_status = #{commitPeriodStatus}
  338. </if>
  339. <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
  340. and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN
  341. g.validity_start_time and g.validity_end_time
  342. </if>
  343. <if test="validityStartTime != null or validityEndTime != null ">
  344. AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime}
  345. BETWEEN g.validity_start_time and g.validity_end_time)
  346. </if>
  347. <if test="subjectId != null and subjectId >0">
  348. AND FIND_IN_SET(#{subjectId},g.subject_ids)
  349. </if>
  350. <if test="subjectIdList != null and subjectIdList.size > 0 ">
  351. AND (
  352. <foreach collection="subjectIdList" item="item" index="index">
  353. <if test=" index == 0 ">
  354. FIND_IN_SET(#{item},g.subject_ids)
  355. </if>
  356. <if test=" index != 0 ">
  357. OR FIND_IN_SET(#{item},g.subject_ids)
  358. </if>
  359. </foreach>
  360. )
  361. </if>
  362. <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
  363. AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id
  364. = g.goods_id and c.`status` = 1
  365. ) >0
  366. </if>
  367. <if test="gradeType != null and gradeType != ''">
  368. AND g.grade_type = #{gradeType}
  369. </if>
  370. <!-- 数据范围过滤 -->
  371. ${params.dataScope}
  372. <if test="sortType != null and sortType == 2">
  373. ORDER BY g.show_sort DESC,g.stand_price ASC
  374. </if>
  375. <if test="sortType != null and sortType == 3">
  376. ORDER BY g.show_sort DESC,g.stand_price DESC
  377. </if>
  378. <if test="sortType != null and sortType == 1">
  379. ORDER BY g.show_sort DESC,g.create_time DESC
  380. </if>
  381. <if test="sortType == null">
  382. ORDER BY g.create_time DESC
  383. </if>
  384. </select>
  385. <select id="selectListToInput" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
  386. resultMap="GoodsResultVo">
  387. SELECT
  388. g.*,
  389. ps.supply_name,
  390. cet.education_name,
  391. cpt.project_name,
  392. cb.business_name,
  393. s.school_name,
  394. m.category_name,
  395. ot.type AS template_type,
  396. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  397. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  398. <if test="sectionNum ==1">
  399. ,(SELECT COUNT(m.id)+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_module_chapter p on
  400. n.chapter_id = p.chapter_id LEFT JOIN course_menu m on m.menu_id = p.module_id LEFT JOIN goods_course gc on
  401. gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(1))+(SELECT COUNT(n.id) FROM
  402. course_chapter_section n LEFT JOIN course_menu m on m.menu_id = n.chapter_id LEFT JOIN goods_course gc on
  403. gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(2)) FROM course_menu m LEFT JOIN
  404. goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(3)) as
  405. section_num
  406. </if>
  407. <if test="goodsType ==1">
  408. , (SELECT count(*) FROM goods_course where goods_id =g.goods_id ) as course_num
  409. -- , (SELECT count(*) FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  410. -- cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
  411. -- , (SELECT cg.grade_id FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  412. -- where cgg.goods_id = g.goods_id and cg.`status` = 1 AND (unix_timestamp(now()) &lt; cg.class_end_time or
  413. -- cg.class_start_time is null) AND cg.`status` = 1 AND (SELECT COUNT(a.id) FROM class_grade_user a where
  414. -- a.grade_id = cg.grade_id and a.status =1) &lt; cg.student_upper limit 1) as grade_id
  415. -- , (SELECT cg.class_name FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  416. -- where cgg.goods_id = g.goods_id and cg.`status` = 1 AND (unix_timestamp(now()) &lt; cg.class_end_time or
  417. -- cg.class_start_time is null) AND cg.`status` = 1 AND (SELECT COUNT(a.id) FROM class_grade_user a where
  418. -- a.grade_id = cg.grade_id and a.status =1) &lt; cg.student_upper limit 1) as grade_name
  419. </if>
  420. FROM
  421. goods g
  422. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  423. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  424. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  425. LEFT JOIN course_business cb ON g.business_id = cb.id
  426. LEFT JOIN school s ON s.id = g.school_id
  427. LEFT JOIN major m ON g.major_id = m.id
  428. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  429. WHERE
  430. 1 = 1
  431. AND g.goods_type != 5
  432. AND g.input_sign = 0
  433. AND g.first_choice_goods = 0
  434. <if test="status != null and status.size()!=0 ">
  435. AND g.status in
  436. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  437. #{item}
  438. </foreach>
  439. </if>
  440. <if test="goodsIds != null and goodsIds.size()!=0 ">
  441. AND g.goods_id in
  442. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  443. #{item}
  444. </foreach>
  445. </if>
  446. <if test="goodsType != null and goodsType != ''">
  447. AND g.goods_type = #{goodsType}
  448. </if>
  449. <if test="makeGoodsId != null and makeGoodsId != ''">
  450. AND g.make_goods_id = #{makeGoodsId}
  451. </if>
  452. <if test="goodsName != null and goodsName != ''">
  453. AND g.goods_name like concat('%', #{goodsName}, '%')
  454. </if>
  455. <if test="educationTypeId != null and educationTypeId != ''">
  456. AND g.education_type_id = #{educationTypeId}
  457. </if>
  458. <if test="projectId != null and projectId != ''">
  459. AND g.project_id = #{projectId}
  460. </if>
  461. <if test="businessIds != null and businessIds.size()!=0 ">
  462. AND g.business_id in
  463. <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
  464. #{item}
  465. </foreach>
  466. </if>
  467. <if test="businessId != null and businessId != ''">
  468. AND g.business_id = #{businessId}
  469. </if>
  470. <if test="projectId != null and projectId != ''">
  471. AND g.project_id = #{projectId}
  472. </if>
  473. <if test="schoolId != null and schoolId != ''">
  474. AND g.school_id = #{schoolId}
  475. </if>
  476. <if test="majorId != null and majorId != ''">
  477. AND g.major_id = #{majorId}
  478. </if>
  479. <if test="standPrice != null and standPrice != ''">
  480. AND g.stand_price = #{standPrice}
  481. </if>
  482. <if test="searchKey != null and searchKey != ''">
  483. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  484. </if>
  485. <if test="goodsStatus != null ">
  486. AND g.goods_status = #{goodsStatus}
  487. </if>
  488. <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
  489. and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN
  490. g.validity_start_time and g.validity_end_time
  491. </if>
  492. <if test="validityStartTime != null or validityEndTime != null ">
  493. AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime}
  494. BETWEEN g.validity_start_time and g.validity_end_time)
  495. </if>
  496. <if test="subjectId != null and subjectId >0">
  497. AND FIND_IN_SET(#{subjectId},g.subject_ids)
  498. </if>
  499. <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
  500. AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id
  501. = g.goods_id and c.`status` = 1
  502. ) >0
  503. </if>
  504. <if test="sortType != null and sortType == 2">
  505. ORDER BY g.stand_price
  506. </if>
  507. <if test="sortType != null and sortType == 3">
  508. ORDER BY g.stand_price DESC
  509. </if>
  510. <if test="sortType == null or sortType == 1">
  511. ORDER BY g.create_time DESC
  512. </if>
  513. </select>
  514. <select id="selectDetail" parameterType="Long" resultMap="GoodsResultVo">
  515. SELECT g.*,
  516. ps.supply_name,
  517. cet.education_name,
  518. cpt.project_name,
  519. cb.business_name,
  520. cb.template_status as special_goods,
  521. s.school_name,
  522. m.category_name,
  523. ot.type AS template_type,
  524. (SELECT gs.goods_name FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  525. (SELECT gs.code FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_code,
  526. (SELECT count(DISTINCT c.subject_id)
  527. FROM course c
  528. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  529. WHERE gc.goods_id = g.goods_id) as subject_num,
  530. (SELECT GROUP_CONCAT(subject_name)
  531. from course_subject
  532. where FIND_IN_SET(id, g.subject_ids)) subject_names
  533. FROM goods g
  534. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  535. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  536. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  537. LEFT JOIN course_business cb ON g.business_id = cb.id
  538. LEFT JOIN school s ON s.id = g.school_id
  539. LEFT JOIN major m ON g.major_id = m.id
  540. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  541. WHERE g.goods_id = #{goodsId}
  542. </select>
  543. <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo"
  544. resultMap="ExamNumberGoodsVoResult">
  545. SELECT
  546. goods_id,
  547. goods_name,
  548. validity_start_time,
  549. validity_end_time,
  550. goods_status,
  551. status,
  552. CODE,
  553. stand_price,
  554. <if test="filtration != null and filtration == 1">
  555. (case WHEN (SELECT COUNT(gs.goods_id) FROM goods gs where 1=1 and gs.make_goods_id = g.goods_id and
  556. gs.status =1 and gs.goods_type =4) >0 then 0 ELSE 1 end) as select_status
  557. </if>
  558. <if test="filtration != null and filtration == 2">
  559. (case WHEN (SELECT COUNT(gs.goods_id) FROM goods gs where 1=1 and gs.make_goods_id = g.goods_id and
  560. gs.status =1 and gs.goods_type =3) >0 then 0 ELSE 1 end) as select_status
  561. </if>
  562. FROM
  563. goods g
  564. WHERE
  565. 1 = 1
  566. and g.status in(1)
  567. and g.goods_type=1
  568. <if test="businessId != null and businessId != ''">
  569. and g.business_id = #{businessId}
  570. </if>
  571. <if test="goodsId != null and goodsId != ''">
  572. and g.goods_id = #{goodsId}
  573. </if>
  574. <if test="projectId != null and projectId != ''">
  575. and g.project_id = #{projectId}
  576. </if>
  577. <if test="goodsType != null and goodsType != ''">
  578. and g.goods_type = #{goodsType}
  579. </if>
  580. <if test="goodsStatus != null and goodsStatus != ''">
  581. and g.goods_status = #{goodsStatus}
  582. </if>
  583. <if test="searchKey != null and searchKey != ''">
  584. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  585. </if>
  586. order by g.create_time desc
  587. </select>
  588. <select id="selectUserDetail" parameterType="map" resultMap="GoodsResultVo">
  589. SELECT g.*,
  590. ps.supply_name,
  591. cet.education_name,
  592. cpt.project_name,
  593. cb.business_name,
  594. cb.reminder_sign,
  595. cb.template_status AS special_goods,
  596. s.school_name,
  597. m.category_name,
  598. ot.type AS template_type,
  599. (SELECT gs.goods_name FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  600. (SELECT gs.code FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_code,
  601. (SELECT DISTINCT cg.grade_id
  602. FROM class_grade_user cgu
  603. LEFT JOIN class_grade_goods cgg on cgg.grade_id = cgu.grade_id
  604. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  605. where cgu.user_id = #{userId}
  606. <if test="orderGoodsId != null and orderGoodsId != ''">
  607. and cgu.order_goods_id = #{orderGoodsId}
  608. </if>
  609. and cgg.goods_id = g.goods_id
  610. and cg.`status` = 1
  611. and unix_timestamp(now()) BETWEEN cg.class_start_time and cg.class_end_time limit 1) as grade_id
  612. FROM goods g
  613. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  614. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  615. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  616. LEFT JOIN course_business cb ON g.business_id = cb.id
  617. LEFT JOIN school s ON s.id = g.school_id
  618. LEFT JOIN major m ON g.major_id = m.id
  619. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  620. WHERE g.goods_id = #{goodsId}
  621. </select>
  622. <select id="getQuestionNum" parameterType="Long" resultType="Long">
  623. SELECT count(DISTINCT question_id) question_num
  624. FROM exam_question
  625. WHERE find_in_set(
  626. exam_id, (
  627. SELECT concat(
  628. IFNULL((
  629. SELECT GROUP_CONCAT(exam_id)
  630. FROM question_chapter_exam
  631. WHERE FIND_IN_SET(chapter_exam_id,
  632. (SELECT concat(
  633. IFNULL(
  634. (SELECT GROUP_CONCAT(major_id) eids
  635. FROM goods_attached
  636. WHERE goods_id = #{goodsId}
  637. AND type = 2), ''),
  638. ',',
  639. IFNULL(
  640. (
  641. SELECT GROUP_CONCAT(chapter_exam_id) eids2
  642. FROM question_module_chapter
  643. WHERE module_exam_id IN
  644. (SELECT major_id
  645. FROM goods_attached
  646. WHERE goods_id = #{goodsId} AND type = 1)),
  647. ''
  648. ))))),
  649. ''
  650. ),
  651. ',',
  652. IFNULL((SELECT GROUP_CONCAT(major_id)
  653. FROM goods_attached
  654. WHERE goods_id = #{goodsId} AND type = 3), ''))))
  655. </select>
  656. <select id="getMakeGoodsList" parameterType="map" resultType="com.zhongzheng.modules.goods.vo.MakeGoodsVo">
  657. select g.goods_id as make_goods_id,g.goods_name as make_goods_name,g.code as make_goods_code from goods g where FIND_IN_SET(g.goods_id,#{makeGoodsIds})
  658. </select>
  659. <select id="getRandomQuestionNum" parameterType="map" resultType="Long">
  660. SELECT count(DISTINCT eq.question_id) question_num
  661. FROM exam_question eq
  662. LEFT JOIN exam e on eq.exam_id = e.exam_id
  663. WHERE find_in_set(
  664. eq.exam_id, (
  665. SELECT concat(
  666. IFNULL((
  667. SELECT GROUP_CONCAT(exam_id)
  668. FROM question_chapter_exam
  669. WHERE FIND_IN_SET(chapter_exam_id,
  670. (SELECT concat(
  671. IFNULL(
  672. (SELECT GROUP_CONCAT(major_id) eids
  673. FROM goods_attached
  674. WHERE goods_id = #{goodsId}
  675. AND type = 2), ''),
  676. ',',
  677. IFNULL(
  678. (
  679. SELECT GROUP_CONCAT(chapter_exam_id) eids2
  680. FROM question_module_chapter
  681. WHERE module_exam_id IN
  682. (SELECT major_id
  683. FROM goods_attached
  684. WHERE goods_id = #{goodsId} AND type = 1)),
  685. ''
  686. ))))),
  687. ''
  688. ),
  689. ',',
  690. IFNULL((SELECT GROUP_CONCAT(major_id)
  691. FROM goods_attached
  692. WHERE goods_id = #{goodsId} AND type = 3), ''))))
  693. and e.exam_paper_id = #{examPaperId}
  694. </select>
  695. <update id="queryUpGoods">
  696. update goods g
  697. set g.goods_status=0
  698. where unix_timestamp(now()) > g.validity_end_time
  699. and g.goods_status = 1
  700. </update>
  701. <select id="getExamNum" parameterType="Long" resultType="Long">
  702. SELECT count(exam_id) + ((
  703. SELECT count(major_id)
  704. FROM goods_attached
  705. WHERE goods_id = #{goodsId}
  706. AND type = 3
  707. )) AS exam_num
  708. FROM question_chapter_exam
  709. WHERE FIND_IN_SET(
  710. chapter_exam_id,
  711. (
  712. SELECT concat(
  713. IFNULL((SELECT GROUP_CONCAT(major_id) eids
  714. FROM goods_attached
  715. WHERE goods_id = #{goodsId} AND type = 2), ''),
  716. ',',
  717. IFNULL(
  718. (
  719. SELECT GROUP_CONCAT(chapter_exam_id) eids2
  720. FROM question_module_chapter
  721. WHERE module_exam_id IN (SELECT major_id
  722. FROM goods_attached
  723. WHERE goods_id = #{goodsId} AND type = 1)),
  724. ''
  725. ))))
  726. </select>
  727. <select id="getSectionNumByBo" parameterType="Long" resultMap="GoodsResultVo">
  728. SELECT (SELECT IFNULL(COUNT(m.id), 0) + (SELECT IFNULL(COUNT(n.id), 0)
  729. FROM course_chapter_section n
  730. LEFT JOIN course_module_chapter p on n.chapter_id = p.chapter_id
  731. LEFT JOIN course_menu m on m.menu_id = p.module_id
  732. LEFT JOIN goods_course gc on gc.course_id = m.course_id
  733. where gc.goods_id = g.goods_id
  734. and m.type in (1)) + (SELECT IFNULL(COUNT(n.id), 0)
  735. FROM course_chapter_section n
  736. LEFT JOIN course_menu m on m.menu_id = n.chapter_id
  737. LEFT JOIN goods_course gc on gc.course_id = m.course_id
  738. where gc.goods_id = g.goods_id
  739. and m.type in (2))
  740. FROM course_menu m
  741. LEFT JOIN goods_course gc on gc.course_id = m.course_id
  742. where gc.goods_id = g.goods_id
  743. and m.type in (3)) as section_num,
  744. (SELECT IFNULL(COUNT(1), 0) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  745. (SELECT IFNULL(COUNT(m.id), 0)
  746. FROM goods_course c
  747. LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  748. where m.type = 1
  749. and c.goods_id = g.goods_id) as exam_num
  750. FROM goods g
  751. WHERE g.goods_id = #{goodsId}
  752. </select>
  753. <select id="getOrderGoodsListByUser" parameterType="Long"
  754. resultType="com.zhongzheng.modules.goods.vo.UserGoodsListVo">
  755. SELECT og.goods_id AS goodsId,
  756. og.order_goods_id as orderGoodsId,
  757. o.order_id as orderId,
  758. g.goods_name as categoryName,
  759. m.category_name as majorName,
  760. o.tenant_id as tenantId,
  761. g.goods_type as courseType,
  762. concat('https://file.xyyxt.net/', g.cover_url) as imageUrl,
  763. o.create_time as createTimeStr,
  764. og.grade_id as gradeId
  765. FROM `order` o
  766. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  767. LEFT JOIN goods g ON og.goods_id = g.goods_id
  768. LEFT JOIN major m ON g.major_id = m.id
  769. WHERE o.user_id = #{userId}
  770. AND og.pay_status IN (2, 3, 4)
  771. AND og.refund_status !=2
  772. </select>
  773. <select id="getUserOrderGoodsList" parameterType="Long"
  774. resultType="com.zhongzheng.modules.goods.vo.UserOrderGoodsListVo">
  775. SELECT og.goods_id AS goodsId,
  776. og.order_goods_id as orderGoodsId,
  777. o.order_id as orderId,
  778. g.goods_name as categoryName,
  779. m.category_name as majorName,
  780. o.tenant_id as tenantId,
  781. g.goods_type as courseType,
  782. concat('https://file.xyyxt.net/', g.cover_url) as imageUrl,
  783. o.create_time as createTimeStr,
  784. og.grade_id as gradeId
  785. FROM `order` o
  786. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  787. LEFT JOIN goods g ON og.goods_id = g.goods_id
  788. LEFT JOIN major m ON g.major_id = m.id
  789. WHERE o.user_id = #{userId}
  790. AND og.pay_status IN (2, 3, 4)
  791. AND og.refund_status !=2
  792. ORDER BY o.create_time DESC
  793. </select>
  794. <select id="countUserOrderGoods" parameterType="Long" resultType="com.zhongzheng.modules.goods.vo.UserOrderGoodsVo">
  795. SELECT og.order_goods_id,
  796. og.goods_id,
  797. og.grade_id
  798. FROM `order` o
  799. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  800. WHERE o.user_id = #{userId}
  801. AND og.goods_id = #{goodsId}
  802. AND og.pay_status IN (2, 3, 4)
  803. AND og.refund_status != 2
  804. AND og.`status` = 1
  805. AND o.`status` = 1
  806. AND o.tenant_id = #{tenantId}
  807. AND og.tenant_id = #{tenantId}
  808. </select>
  809. <select id="getExternalQuestion" parameterType="com.zhongzheng.modules.course.bo.ExternalQuestionBo" resultType="com.zhongzheng.modules.course.vo.ExternalQuestionVo">
  810. SELECT
  811. g.goods_id,
  812. qm.merchant_id,
  813. g.goods_name,
  814. qm.merchant_name,
  815. qm.do_num,
  816. g.stand_price AS goodsPrice,
  817. g.cover_url
  818. FROM
  819. question_merchant qm
  820. LEFT JOIN goods g ON qm.merchant_id = g.question_merchant_id
  821. WHERE
  822. qm.`status` = 1
  823. AND qm.tenant_id = #{tenantId}
  824. AND g.`status` = 1
  825. </select>
  826. <select id="getReplenishExam" parameterType="com.zhongzheng.modules.course.bo.ReplenishExamBo" resultType="com.zhongzheng.modules.course.vo.ReplenishExamVo">
  827. SELECT
  828. g.goods_id,
  829. g.goods_name,
  830. g.stand_price AS goodsPrice,
  831. g.cover_url
  832. FROM
  833. goods g
  834. WHERE
  835. g.`status` = 1
  836. and g.unify_sign = 1
  837. </select>
  838. <select id="queryGoodsByIdTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  839. SELECT *
  840. FROM `goods`
  841. WHERE goods_id = #{goodsId}
  842. AND tenant_id = #{tenantId}
  843. </select>
  844. <select id="getRelevanceGoodsNoTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  845. SELECT
  846. g.*
  847. FROM
  848. goods g
  849. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  850. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  851. LEFT JOIN course_business cb ON g.business_id = cb.id
  852. LEFT JOIN major m ON g.major_id = m.id
  853. WHERE
  854. g.`status` = 1
  855. AND g.goods_status = 1
  856. AND INSTR(#{businessName}, cet.education_name)
  857. AND INSTR(#{businessName}, cpt.project_name)
  858. AND INSTR(#{majName}, m.category_name)
  859. AND g.goods_id != #{goodsId}
  860. </select>
  861. <select id="getRelGoodsNoTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  862. SELECT
  863. g.*
  864. FROM
  865. goods g
  866. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  867. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  868. LEFT JOIN course_business cb ON g.business_id = cb.id
  869. LEFT JOIN major m ON g.major_id = m.id
  870. WHERE
  871. g.`status` = 1
  872. AND g.goods_status = 1
  873. AND INSTR(#{businessName}, cet.education_name)
  874. AND INSTR(#{businessName}, cpt.project_name)
  875. AND INSTR(#{categoryName}, m.category_name)
  876. AND INSTR(#{businessName},cb.business_name)
  877. AND g.tenant_id = #{tenantId}
  878. AND INSTR(g.goods_name,'测试') &lt;= 0
  879. </select>
  880. <select id="getCourseNum" parameterType="java.lang.Long" resultType="java.lang.Integer">
  881. SELECT
  882. (SELECT
  883. COUNT( cs.section_id )
  884. FROM
  885. goods g
  886. LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
  887. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  888. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  889. LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
  890. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  891. WHERE
  892. g.goods_id = #{goodsId}
  893. AND cm.`status` = 1
  894. AND cm.type = 1
  895. AND cs.`status` = 1
  896. ) +
  897. (SELECT
  898. COUNT( cs.section_id )
  899. FROM
  900. goods g
  901. LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
  902. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  903. LEFT JOIN course_chapter_section ccs ON cm.menu_id = ccs.chapter_id
  904. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  905. WHERE
  906. g.goods_id = #{goodsId}
  907. AND cm.`status` = 1
  908. AND cm.type = 2
  909. AND cs.`status` = 1
  910. ) +
  911. (SELECT
  912. COUNT( cs.section_id )
  913. FROM
  914. goods g
  915. LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
  916. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  917. LEFT JOIN course_section cs ON cm.menu_id = cs.section_id
  918. WHERE
  919. g.goods_id = #{goodsId}
  920. AND cm.`status` = 1
  921. AND cm.type = 3
  922. AND cs.`status` = 1
  923. )
  924. </select>
  925. <select id="getCourseExamNumNoTenant" parameterType="java.lang.Long" resultType="java.lang.Integer">
  926. SELECT
  927. COUNT(*)
  928. FROM
  929. course_menu_exam cme
  930. LEFT JOIN goods_course gc ON cme.course_id = gc.course_id
  931. WHERE
  932. cme.type != 2
  933. AND gc.goods_id = #{goodsId}
  934. </select>
  935. <select id="queryGoodsByTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  936. SELECT *
  937. FROM `goods`
  938. WHERE `code` = #{code}
  939. AND tenant_id = #{tenantId}
  940. </select>
  941. <select id="getGoodsByIdNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.domain.Goods">
  942. SELECT *
  943. FROM `goods`
  944. WHERE goods_id = #{goodsId}
  945. </select>
  946. <select id="getGoodsByTenantTwo" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  947. SELECT *
  948. FROM `goods`
  949. WHERE goods_name = #{goodsName} and code = #{code} and tenant_id = #{tenantId}
  950. </select>
  951. <select id="getModuleExam" resultType="com.zhongzheng.modules.bank.domain.QuestionModule">
  952. SELECT * FROM question_module qm WHERE (SELECT COUNT( qb.id)FROM question_business qb WHERE qb.major_id = qm.module_exam_id AND qb.type = 4) &lt;= 0 AND `status` = 1
  953. </select>
  954. <select id="getChapterExam" resultType="com.zhongzheng.modules.bank.domain.QuestionChapter">
  955. SELECT * FROM question_chapter qm WHERE (SELECT COUNT( qb.id)FROM question_business qb WHERE qb.major_id = qm.chapter_exam_id AND qb.type = 3) &lt;= 0 AND `status` = 1
  956. </select>
  957. <select id="getExam" resultType="com.zhongzheng.modules.bank.domain.Exam">
  958. SELECT * FROM exam qm WHERE (SELECT COUNT( qb.id)FROM question_business qb WHERE qb.major_id = qm.exam_id AND qb.type = 2) &lt;= 0 AND `status` = 1
  959. </select>
  960. <select id="getSysGoodsCopy" parameterType="map" resultType="com.zhongzheng.modules.system.domain.SysGoodsCopyRecord">
  961. SELECT * FROM sys_goods_copy_record WHERE new_id = #{moduleExamId} AND type = #{type} LIMIT 1
  962. </select>
  963. <select id="getModuleExamBusiness" parameterType="map" resultType="com.zhongzheng.modules.bank.domain.QuestionBusiness">
  964. SELECT * FROM question_business WHERE major_id = #{oldId} AND type = #{type} AND tenant_id = 867735392558919680
  965. </select>
  966. <insert id="saveExamBusiness" parameterType="com.zhongzheng.modules.bank.domain.QuestionBusiness" >
  967. INSERT INTO question_business (education_type_id,business_id,tenant_id,project_id,subject_id,major_id,type)
  968. VALUES(#{educationTypeId},#{businessId},#{tenantId},#{projectId},#{subjectId},#{majorId},#{type})
  969. </insert>
  970. <select id="getGoodsCourseTree" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.vo.GoodsCourseTreeVo">
  971. SELECT
  972. gc.goods_id,
  973. cm.course_id,
  974. cmc.module_id,
  975. cpc.chapter_id,
  976. cs.section_id
  977. FROM
  978. goods_course gc
  979. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  980. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  981. LEFT JOIN course_chapter_section cpc ON cmc.chapter_id = cpc.chapter_id
  982. LEFT JOIN course_section cs ON cpc.section_id = cs.section_id
  983. WHERE
  984. gc.goods_id = #{goodsId}
  985. AND cm.`status` = 1
  986. AND cs.`status` = 1
  987. AND cm.type = 1 UNION ALL
  988. SELECT
  989. gc.goods_id,
  990. cm.course_id,
  991. 0 AS module_id,
  992. cpc.chapter_id,
  993. cs.section_id
  994. FROM
  995. goods_course gc
  996. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  997. LEFT JOIN course_chapter_section cpc ON cm.menu_id = cpc.chapter_id
  998. LEFT JOIN course_section cs ON cpc.section_id = cs.section_id
  999. WHERE
  1000. gc.goods_id = #{goodsId}
  1001. AND cm.`status` = 1
  1002. AND cs.`status` = 1
  1003. AND cm.type = 2 UNION ALL
  1004. SELECT
  1005. gc.goods_id,
  1006. cm.course_id,
  1007. 0 AS module_id,
  1008. 0 AS chapter_id,
  1009. cs.section_id
  1010. FROM
  1011. goods_course gc
  1012. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  1013. LEFT JOIN course_section cs ON cm.menu_id = cs.section_id
  1014. WHERE
  1015. gc.goods_id = #{goodsId}
  1016. AND cm.`status` = 1
  1017. AND cs.`status` = 1
  1018. AND cm.type = 3
  1019. </select>
  1020. <update id="updateByTenant" parameterType="com.zhongzheng.modules.goods.domain.Goods">
  1021. UPDATE goods
  1022. SET `year` = #{year},
  1023. supply_id = #{supplyId},
  1024. goods_type = #{goodsType},
  1025. education_type_id = #{educationTypeId},
  1026. business_id = #{businessId},
  1027. school_id = #{schoolId},
  1028. major_id = #{majorId},
  1029. goods_name = #{goodsName},
  1030. stand_price = #{standPrice},
  1031. lowest_price = #{lowestPrice},
  1032. create_time = #{createTime},
  1033. update_time = #{updateTime},
  1034. `status` = #{status},
  1035. validity_start_time = #{validityStartTime},
  1036. validity_end_time = #{validityEndTime},
  1037. study_start_time = #{studyStartTime},
  1038. study_end_time = #{studyEndTime},
  1039. certificate_ids = #{certificateIds},
  1040. introduce = #{introduce},
  1041. suitable_object = #{suitableObject},
  1042. buy_note = #{buyNote},
  1043. pc_detail_html = #{pcDetailHtml},
  1044. mobile_detail_html = #{mobileDetailHtml},
  1045. goods_status = #{goodsStatus},
  1046. cover_url = #{coverUrl},
  1047. class_hours = #{classHours},
  1048. stand_price_json = #{standPriceJson},
  1049. tenant_id = #{tenantId},
  1050. `code` = #{code},
  1051. project_id = #{projectId},
  1052. goods_audition_config = #{goodsAuditionConfig},
  1053. goods_photograph_config = #{goodsPhotographConfig},
  1054. goods_play_config = #{goodsPlayConfig},
  1055. goods_exam_config = #{goodsExamConfig},
  1056. handouts_id = #{handoutsId},
  1057. make_start_time = #{makeStartTime},
  1058. make_end_time = #{makeEndTime},
  1059. study_count = #{studyCount},
  1060. goods_photo_exam_config = #{goodsPhotoExamConfig},
  1061. make_goods_id = #{makeGoodsId},
  1062. service_time_type = #{serviceTimeType},
  1063. service_time_num = #{serviceTimeNum},
  1064. section_max_num = #{sectionMaxNum},
  1065. exam_number = #{examNumber},
  1066. do_number = #{doNumber},
  1067. teacher_id = #{teacherId},
  1068. subject_ids = #{subjectIds},
  1069. certificate_type_id = #{certificateTypeId},
  1070. certificate_id = #{certificateId},
  1071. certificate_tp_id = #{certificateTpId},
  1072. line_price = #{linePrice},
  1073. spec_template_id = #{specTemplateId},
  1074. show_status = #{showStatus},
  1075. show_sort = #{showSort}
  1076. WHERE goods_id = #{goodsId}
  1077. and tenant_id = #{tenantId}
  1078. </update>
  1079. <select id="getUserGoodsListAll" parameterType="com.zhongzheng.modules.goods.bo.UserGoodsListAllBo"
  1080. resultType="com.zhongzheng.modules.goods.vo.GoodsListAllVo">
  1081. SELECT
  1082. o.order_id,
  1083. og.order_goods_id,
  1084. g.goods_id,
  1085. g.goods_name,
  1086. g.goods_type,
  1087. g.class_hours,
  1088. g.validity_start_time,
  1089. g.validity_end_time,
  1090. g.study_start_time AS serviceStartTime,
  1091. g.study_end_time AS serviceEndTime,
  1092. cg.class_status,
  1093. cg.class_start_time,
  1094. cg.class_end_time
  1095. FROM
  1096. order_goods og
  1097. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  1098. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1099. LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
  1100. WHERE
  1101. og.pay_status IN ( 2, 3, 4 )
  1102. AND og.refund_status != 2
  1103. <if test="goodsType != null and goodsType != ''">
  1104. AND g.goods_type = #{goodsType}
  1105. </if>
  1106. <if test="goodsName != null and goodsName != ''">
  1107. AND g.goods_name like concat('%', #{goodsName}, '%')
  1108. </if>
  1109. <if test="educationTypeId != null and educationTypeId != ''">
  1110. AND g.education_type_id = #{educationTypeId}
  1111. </if>
  1112. <if test="businessId != null and businessId != ''">
  1113. AND g.business_id = #{businessId}
  1114. </if>
  1115. <if test="userId != null and userId != ''">
  1116. AND o.user_id = #{userId}
  1117. </if>
  1118. </select>
  1119. <select id="getCourseExamNum" parameterType="java.lang.Long" resultType="java.lang.Long">
  1120. SELECT
  1121. COUNT(*)
  1122. FROM
  1123. course_menu_exam cme
  1124. LEFT JOIN goods_course gc ON cme.course_id = gc.course_id
  1125. WHERE
  1126. cme.type != 2
  1127. AND gc.goods_id = #{goodsId}
  1128. </select>
  1129. <select id="getUserStudyNum" parameterType="java.lang.Long" resultType="java.lang.Long">
  1130. SELECT COUNT(*) FROM
  1131. (SELECT COUNT(*) num FROM user_study_record WHERE user_id = #{userId} AND order_goods_id = #{orderGoodsId} GROUP BY course_id,module_id,chapter_id,section_id UNION ALL
  1132. SELECT COUNT(*) num FROM user_bank_record WHERE user_id = #{userId} AND order_goods_id = #{orderGoodsId} AND type != 2 GROUP BY course_id,module_id,chapter_id,exam_id) a
  1133. </select>
  1134. <select id="getAlikeGoods" parameterType="com.zhongzheng.modules.goods.domain.Goods" resultType="com.zhongzheng.modules.goods.vo.GoodsVo">
  1135. SELECT g.*,
  1136. cet.education_name as educationName,
  1137. cb.business_name as businessName,
  1138. cpt.project_name as projectName,
  1139. m.category_name as categoryName
  1140. from goods g
  1141. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id and cet.tenant_id = #{tenantId}
  1142. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id and cpt.tenant_id = #{tenantId}
  1143. LEFT JOIN course_business cb ON g.business_id = cb.id and cb.tenant_id = #{tenantId}
  1144. LEFT JOIN major m ON g.major_id = m.id and m.tenant_id = #{tenantId}
  1145. where
  1146. g.goods_status = 1
  1147. and g.status = 1
  1148. and g.goods_type != 5
  1149. and g.education_type_id = #{educationTypeId}
  1150. and g.project_id = #{projectId}
  1151. and g.business_id = #{businessId}
  1152. and g.stand_price = #{standPrice}
  1153. and g.tenant_id = #{tenantId}
  1154. </select>
  1155. <update id="updateHandoutsId" parameterType="java.lang.Long">
  1156. UPDATE goods SET handouts_id = #{handoutsId} WHERE goods_id = #{goodsId} and tenant_id = #{tenantId}
  1157. </update>
  1158. <select id="getNewHandoutsId" parameterType="map" resultType="java.lang.Long">
  1159. SELECT handouts_id FROM course_handouts WHERE INSTR(handouts_name,#{handoutsName}) AND encoder = #{encoder} AND tenant_id = #{newTenantId}
  1160. </select>
  1161. <select id="getGoodsBusinessName" parameterType="java.lang.Long" resultType="java.lang.String">
  1162. SELECT
  1163. CONCAT( cet.education_name, cb.business_name, cpt.project_name )
  1164. FROM
  1165. goods g
  1166. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1167. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1168. LEFT JOIN course_business cb ON g.business_id = cb.id
  1169. WHERE
  1170. g.goods_id = #{goodsId}
  1171. </select>
  1172. <select id="getBusinessName" parameterType="java.lang.Long" resultType="java.lang.String">
  1173. SELECT
  1174. CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name
  1175. FROM
  1176. goods g
  1177. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1178. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1179. LEFT JOIN course_business cb ON g.business_id = cb.id
  1180. WHERE
  1181. g.goods_id = #{goodsId}
  1182. </select>
  1183. <select id="getGoodsSectionInfo" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.CourseSection">
  1184. SELECT
  1185. cs.*
  1186. FROM
  1187. goods_course gc
  1188. LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
  1189. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  1190. LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
  1191. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  1192. WHERE
  1193. gc.goods_id = #{goodsId}
  1194. AND cm.`status` = 1
  1195. </select>
  1196. </mapper>