GoodsMapper.xml 60 KB

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