GoodsMapper.xml 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  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 INSTR(#{businessName}, cet.education_name)
  846. AND INSTR(#{businessName}, cpt.project_name)
  847. AND INSTR(#{categoryName}, m.category_name)
  848. AND INSTR(#{businessName},cb.business_name)
  849. AND g.tenant_id = #{tenantId}
  850. AND INSTR(g.goods_name,'测试') &lt;= 0
  851. </select>
  852. <select id="queryGoodsByTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  853. SELECT *
  854. FROM `goods`
  855. WHERE `code` = #{code}
  856. AND tenant_id = #{tenantId}
  857. </select>
  858. <select id="getGoodsByIdNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.domain.Goods">
  859. SELECT *
  860. FROM `goods`
  861. WHERE goods_id = #{goodsId}
  862. </select>
  863. <select id="getGoodsByTenantTwo" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
  864. SELECT *
  865. FROM `goods`
  866. WHERE goods_name = #{goodsName} and code = #{code} and tenant_id = #{tenantId}
  867. </select>
  868. <update id="updateByTenant" parameterType="com.zhongzheng.modules.goods.domain.Goods">
  869. UPDATE goods
  870. SET `year` = #{year},
  871. supply_id = #{supplyId},
  872. goods_type = #{goodsType},
  873. education_type_id = #{educationTypeId},
  874. business_id = #{businessId},
  875. school_id = #{schoolId},
  876. major_id = #{majorId},
  877. goods_name = #{goodsName},
  878. stand_price = #{standPrice},
  879. lowest_price = #{lowestPrice},
  880. create_time = #{createTime},
  881. update_time = #{updateTime},
  882. `status` = #{status},
  883. validity_start_time = #{validityStartTime},
  884. validity_end_time = #{validityEndTime},
  885. study_start_time = #{studyStartTime},
  886. study_end_time = #{studyEndTime},
  887. certificate_ids = #{certificateIds},
  888. introduce = #{introduce},
  889. suitable_object = #{suitableObject},
  890. buy_note = #{buyNote},
  891. pc_detail_html = #{pcDetailHtml},
  892. mobile_detail_html = #{mobileDetailHtml},
  893. goods_status = #{goodsStatus},
  894. cover_url = #{coverUrl},
  895. class_hours = #{classHours},
  896. stand_price_json = #{standPriceJson},
  897. tenant_id = #{tenantId},
  898. `code` = #{code},
  899. project_id = #{projectId},
  900. goods_audition_config = #{goodsAuditionConfig},
  901. goods_photograph_config = #{goodsPhotographConfig},
  902. goods_play_config = #{goodsPlayConfig},
  903. goods_exam_config = #{goodsExamConfig},
  904. handouts_id = #{handoutsId},
  905. make_start_time = #{makeStartTime},
  906. make_end_time = #{makeEndTime},
  907. study_count = #{studyCount},
  908. goods_photo_exam_config = #{goodsPhotoExamConfig},
  909. make_goods_id = #{makeGoodsId},
  910. service_time_type = #{serviceTimeType},
  911. service_time_num = #{serviceTimeNum},
  912. section_max_num = #{sectionMaxNum},
  913. exam_number = #{examNumber},
  914. do_number = #{doNumber},
  915. teacher_id = #{teacherId},
  916. subject_ids = #{subjectIds},
  917. certificate_type_id = #{certificateTypeId},
  918. certificate_id = #{certificateId},
  919. certificate_tp_id = #{certificateTpId},
  920. line_price = #{linePrice},
  921. spec_template_id = #{specTemplateId},
  922. show_status = #{showStatus},
  923. show_sort = #{showSort}
  924. WHERE goods_id = #{goodsId}
  925. and tenant_id = #{tenantId}
  926. </update>
  927. <select id="getUserGoodsListAll" parameterType="com.zhongzheng.modules.goods.bo.UserGoodsListAllBo"
  928. resultType="com.zhongzheng.modules.goods.vo.GoodsListAllVo">
  929. SELECT
  930. o.order_id,
  931. og.order_goods_id,
  932. g.goods_id,
  933. g.goods_name,
  934. g.goods_type,
  935. g.class_hours,
  936. g.validity_start_time,
  937. g.validity_end_time,
  938. g.study_start_time AS serviceStartTime,
  939. g.study_end_time AS serviceEndTime,
  940. cg.class_status,
  941. cg.class_start_time,
  942. cg.class_end_time
  943. FROM
  944. order_goods og
  945. LEFT JOIN `order` o ON og.order_sn = o.order_sn
  946. LEFT JOIN goods g ON og.goods_id = g.goods_id
  947. LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
  948. WHERE
  949. og.pay_status IN ( 2, 3, 4 )
  950. AND og.refund_status != 2
  951. <if test="goodsType != null and goodsType != ''">
  952. AND g.goods_type = #{goodsType}
  953. </if>
  954. <if test="goodsName != null and goodsName != ''">
  955. AND g.goods_name like concat('%', #{goodsName}, '%')
  956. </if>
  957. <if test="educationTypeId != null and educationTypeId != ''">
  958. AND g.education_type_id = #{educationTypeId}
  959. </if>
  960. <if test="businessId != null and businessId != ''">
  961. AND g.business_id = #{businessId}
  962. </if>
  963. <if test="userId != null and userId != ''">
  964. AND o.user_id = #{userId}
  965. </if>
  966. </select>
  967. <select id="getCourseExamNum" parameterType="java.lang.Long" resultType="java.lang.Long">
  968. SELECT
  969. COUNT(*)
  970. FROM
  971. course_menu_exam cme
  972. LEFT JOIN goods_course gc ON cme.course_id = gc.course_id
  973. WHERE
  974. cme.type != 2
  975. AND gc.goods_id = #{goodsId}
  976. </select>
  977. <select id="getUserStudyNum" parameterType="java.lang.Long" resultType="java.lang.Long">
  978. SELECT COUNT(*) FROM
  979. (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
  980. 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
  981. </select>
  982. <select id="getAlikeGoods" parameterType="com.zhongzheng.modules.goods.domain.Goods" resultType="com.zhongzheng.modules.goods.vo.GoodsVo">
  983. SELECT g.*,
  984. cet.education_name as educationName,
  985. cb.business_name as businessName,
  986. cpt.project_name as projectName,
  987. m.category_name as categoryName
  988. from goods g
  989. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id and cet.tenant_id = #{tenantId}
  990. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id and cpt.tenant_id = #{tenantId}
  991. LEFT JOIN course_business cb ON g.business_id = cb.id and cb.tenant_id = #{tenantId}
  992. LEFT JOIN major m ON g.major_id = m.id and m.tenant_id = #{tenantId}
  993. where
  994. g.goods_status = 1
  995. and g.status = 1
  996. and g.education_type_id = #{educationTypeId}
  997. and g.project_id = #{projectId}
  998. and g.business_id = #{businessId}
  999. and g.stand_price = #{standPrice}
  1000. and g.tenant_id = #{tenantId}
  1001. </select>
  1002. <update id="updateHandoutsId" parameterType="java.lang.Long">
  1003. UPDATE goods SET handouts_id = #{handoutsId} WHERE goods_id = #{goodsId} and tenant_id = #{tenantId}
  1004. </update>
  1005. <select id="getNewHandoutsId" parameterType="map" resultType="java.lang.Long">
  1006. SELECT handouts_id FROM course_handouts WHERE INSTR(handouts_name,#{handoutsName}) AND encoder = #{encoder} AND tenant_id = #{newTenantId}
  1007. </select>
  1008. <select id="getGoodsBusinessName" parameterType="java.lang.Long" resultType="java.lang.String">
  1009. SELECT
  1010. CONCAT( cet.education_name, cb.business_name, cpt.project_name )
  1011. FROM
  1012. goods g
  1013. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1014. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1015. LEFT JOIN course_business cb ON g.business_id = cb.id
  1016. WHERE
  1017. g.goods_id = #{goodsId}
  1018. </select>
  1019. <select id="getBusinessName" parameterType="java.lang.Long" resultType="java.lang.String">
  1020. SELECT
  1021. CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name
  1022. FROM
  1023. goods g
  1024. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1025. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1026. LEFT JOIN course_business cb ON g.business_id = cb.id
  1027. WHERE
  1028. g.goods_id = #{goodsId}
  1029. </select>
  1030. </mapper>