GoodsMapper.xml 55 KB

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