123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.zhongzheng.modules.goods.mapper.GoodsMapper">
- <resultMap type="com.zhongzheng.modules.goods.domain.Goods" id="GoodsResult">
- <result property="goodsId" column="goods_id"/>
- <result property="year" column="year"/>
- <result property="supplyId" column="supply_id"/>
- <result property="goodsType" column="goods_type"/>
- <result property="educationTypeId" column="education_type_id"/>
- <result property="businessId" column="business_id"/>
- <result property="schoolId" column="school_id"/>
- <result property="majorId" column="major_id"/>
- <result property="goodsName" column="goods_name"/>
- <result property="standPrice" column="stand_price"/>
- <result property="lowestPrice" column="lowest_price"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="status" column="status"/>
- <result property="validityStartTime" column="validity_start_time"/>
- <result property="validityEndTime" column="validity_end_time"/>
- <result property="studyStartTime" column="study_start_time"/>
- <result property="studyEndTime" column="study_end_time"/>
- <result property="certificateIds" column="certificate_ids"/>
- <result property="introduce" column="introduce"/>
- <result property="suitableObject" column="suitable_object"/>
- <result property="buyNote" column="buy_note"/>
- <result property="pcDetailHtml" column="pc_detail_html"/>
- <result property="mobileDetailHtml" column="mobile_detail_html"/>
- <result property="goodsStatus" column="goods_status"/>
- <result property="coverUrl" column="cover_url"/>
- <result property="classHours" column="class_hours"/>
- <result property="standPriceJson" column="stand_price_json"/>
- <result property="code" column="code"/>
- <result property="supplyName" column="supply_name"/>
- <result property="projectId" column="project_id"/>
- <result property="goodsAuditionConfig" column="goods_audition_config"/>
- <result property="goodsPhotographConfig" column="goods_photograph_config"/>
- <result property="goodsPlayConfig" column="goods_play_config"/>
- <result property="goodsExamConfig" column="goods_exam_config"/>
- <result property="handoutsId" column="handouts_id"/>
- <result property="serviceTimeType" column="service_time_type"/>
- <result property="serviceTimeNum" column="service_time_num"/>
- <result property="sectionMaxNum" column="section_max_num"/>
- <result property="examNumber" column="exam_number"/>
- <result property="doNumber" column="do_number"/>
- <result property="teacherId" column="teacher_id"/>
- <result property="subjectIds" column="subject_ids"/>
- <result property="certificateTypeId" column="certificate_type_id"/>
- <result property="certificateId" column="certificate_id"/>
- <result property="certificateTpId" column="certificate_tp_id"/>
- <result property="commitPeriodStatus" column="commit_period_status"/>
- <result property="commitPeriodRemark" column="commit_period_remark"/>
- <result property="gradeType" column="grade_type"/>
- <result property="examLimitClient" column="exam_limit_client"/>
- <result property="firstChoiceStatus" column="first_choice_status"/>
- <result property="minClassHour" column="min_class_hour"/>
- <result property="firstChoiceGoods" column="first_choice_goods"/>
- <result property="moreCertificateStatus" column="more_certificate_status"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
- <result property="goodsId" column="goods_id"/>
- <result property="year" column="year"/>
- <result property="supplyId" column="supply_id"/>
- <result property="goodsType" column="goods_type"/>
- <result property="gradeId" column="grade_id"/>
- <result property="educationTypeId" column="education_type_id"/>
- <result property="businessId" column="business_id"/>
- <result property="schoolId" column="school_id"/>
- <result property="majorId" column="major_id"/>
- <result property="goodsName" column="goods_name"/>
- <result property="standPrice" column="stand_price"/>
- <result property="lowestPrice" column="lowest_price"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="status" column="status"/>
- <result property="validityStartTime" column="validity_start_time"/>
- <result property="validityEndTime" column="validity_end_time"/>
- <result property="studyStartTime" column="study_start_time"/>
- <result property="studyEndTime" column="study_end_time"/>
- <result property="certificateIds" column="certificate_ids"/>
- <result property="introduce" column="introduce"/>
- <result property="suitableObject" column="suitable_object"/>
- <result property="buyNote" column="buy_note"/>
- <result property="pcDetailHtml" column="pc_detail_html"/>
- <result property="mobileDetailHtml" column="mobile_detail_html"/>
- <result property="goodsStatus" column="goods_status"/>
- <result property="coverUrl" column="cover_url"/>
- <result property="classHours" column="class_hours"/>
- <result property="standPriceJson" column="stand_price_json"/>
- <result property="code" column="code"/>
- <result property="projectId" column="project_id"/>
- <result property="goodsAuditionConfig" column="goods_audition_config"/>
- <result property="goodsPhotographConfig" column="goods_photograph_config"/>
- <result property="goodsAuditionExamConfig" column="goods_audition_exam_config"/>
- <result property="goodsPlayConfig" column="goods_play_config"/>
- <result property="goodsExamConfig" column="goods_exam_config"/>
- <result property="sectionMaxNum" column="section_max_num"/>
- <result property="specTemplateId" column="spec_template_id"/>
- <result property="showStatus" column="show_status"/>
- <result property="showSort" column="show_sort"/>
- <result property="specialGoods" column="special_goods"/>
- <result property="externalLink" column="external_link"/>
- <result property="externalLinkStatus" column="external_link_status"/>
- <result property="sevenYear" column="seven_year"/>
- <result property="mailSign" column="mail_sign"/>
- <result property="classHoursStr" column="classHoursStr"/>
- <result property="hoursSign" column="hours_Sign"/>
- <result property="supplyName" column="supply_name"/>
- <result property="educationName" column="education_name"/>
- <result property="projectName" column="project_name"/>
- <result property="businessName" column="business_name"/>
- <result property="schoolName" column="school_name"/>
- <result property="categoryName" column="category_name"/>
- <result property="handoutsId" column="handouts_id"/>
- <result property="templateType" column="template_type"/>
- <result property="period" column="period"/>
- <result property="makeStartTime" column="make_start_time"/>
- <result property="makeEndTime" column="make_end_time"/>
- <result property="studyCount" column="study_count"/>
- <result property="makeGoodsName" column="make_goods_name"/>
- <result property="makeGoodsCode" column="make_goods_code"/>
- <result property="courseNum" column="course_num"/>
- <result property="sectionNum" column="section_num"/>
- <result property="serviceTimeType" column="service_time_type"/>
- <result property="serviceTimeNum" column="service_time_num"/>
- <result property="gradeNum" column="grade_num"/>
- <result property="gradeId" column="grade_id"/>
- <result property="gradeName" column="grade_name"/>
- <result property="examNumber" column="exam_number"/>
- <result property="doNumber" column="do_number"/>
- <result property="orderNum" column="order_num"/>
- <result property="teacherId" column="teacher_id"/>
- <result property="goodsLiveNum" column="goods_live_num"/>
- <result property="subjectIds" column="subject_ids"/>
- <result property="certificateTypeId" column="certificate_type_id"/>
- <result property="certificateId" column="certificate_id"/>
- <result property="certificateTpId" column="certificate_tp_id"/>
- <result property="subjectNames" column="subject_names"/>
- <result property="buyUserNum" column="buy_user_num"/>
- <result property="chapterNum" column="chapter_num"/>
- <result property="examNum" column="exam_num"/>
- <result property="linePrice" column="line_price"/>
- <result property="specTemplateNumber" column="spec_template_number"/>
- <result property="goodsLearningOrder" column="goods_learning_order"/>
- <result property="commitPeriodStatus" column="commit_period_status"/>
- <result property="commitPeriodRemark" column="commit_period_remark"/>
- <result property="gradeType" column="grade_type"/>
- <result property="examLimitClient" column="exam_limit_client"/>
- <result property="optionalYear" column="optional_year"/>
- <result property="firstChoiceStatus" column="first_choice_status"/>
- <result property="minClassHour" column="min_class_hour"/>
- <result property="firstChoiceGoods" column="first_choice_goods"/>
- <result property="aliasName" column="alias_name"/>
- <result property="moreCertificateStatus" column="more_certificate_status"/>
- <result property="makeGoodsIds" column="make_goods_ids"/>
- <result property="reminderSign" column="reminder_sign"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
- <result property="id" column="id"/>
- <result property="examNumberId" column="exam_number_id"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsName" column="goods_name"/>
- <result property="code" column="code"/>
- <result property="standPrice" column="stand_price"/>
- <result property="goodsStatus" column="goods_status"/>
- <result property="validityStartTime" column="validity_start_time"/>
- <result property="validityEndTime" column="validity_end_time"/>
- <result property="goodsStatus" column="goods_status"/>
- <result property="status" column="status"/>
- <result property="selectStatus" column="select_status"/>
- </resultMap>
- <select id="getSectionNum" parameterType="Long" resultType="Long">
- SELECT COUNT(m.id) + (
- SELECT COUNT(n.id)
- FROM course_chapter_section n
- LEFT JOIN course_module_chapter p ON n.chapter_id = p.chapter_id
- LEFT JOIN course_menu m ON m.menu_id = p.module_id
- LEFT JOIN goods_course gc ON gc.course_id = m.course_id
- WHERE gc.goods_id = #{goodsId}
- AND m.type = 1) + (
- SELECT COUNT(n.id)
- FROM course_chapter_section n
- LEFT JOIN course_menu m ON m.menu_id = n.chapter_id
- LEFT JOIN goods_course gc ON gc.course_id = m.course_id
- WHERE gc.goods_id = #{goodsId}
- AND m.type = 2)
- FROM course_menu m
- LEFT JOIN goods_course gc ON gc.course_id = m.course_id
- WHERE gc.goods_id = #{goodsId}
- AND m.type = 3
- </select>
- <select id="selectAllList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsResultVo">
- SELECT
- g.*,
- g.class_hours as classHoursStr,
- ps.supply_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- cb.alias_name,
- cb.goods_learning_order,
- s.school_name,
- m.category_name,
- (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names,
- (SELECT COUNT( DISTINCT gar.spec_template_id ) FROM goods_spec_attribute_relation gar WHERE gar.goods_id =
- g.goods_id AND gar.`status` = 1 ) spec_template_number,
- ot.type AS template_type,
- (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
- (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
- <if test="chapterNum ==1">
- ,(SELECT COUNT(m.id)+(SELECT COUNT(p.id) FROM course_module_chapter p LEFT JOIN course_menu m on m.menu_id =
- p.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and
- m.type in(1))+(SELECT COUNT(cmc.id) FROM course_module_chapter cmc LEFT JOIN course_menu m on m.menu_id =
- cmc.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and
- m.type in(2)) FROM course_menu m LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id =
- g.goods_id and m.type in(3)) as chapter_num
- </if>
- ,(case WHEN g.goods_type =1 then (SELECT count(*) FROM goods_course gc LEFT JOIN course c on gc.course_id =
- c.course_id where gc.goods_id =g.goods_id and c.course_show=1) ELSE 0 end) as course_num
- <if test="goodsType ==1">
- , (SELECT count(*) FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
- cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
- </if>
- <if test="goodsType ==2">
- , (SELECT count(*) from order_goods og where og.goods_id = g.goods_id and og.pay_status IN ( 2, 3, 4 )
- AND og.refund_status IN (0,3,1) ) as order_num
- </if>
- <if test="getOrderNum != null and getOrderNum == 1">
- ,ou.goods_live_num
- </if>
- <if test="getUserNum != null and getUserNum == 1">
- ,(SELECT count(*) from order_goods og where og.goods_id = g.goods_id and og.`status` = 1
- AND og.refund_status in (0,1,3)
- AND og.pay_status in (2,3,4)) as buy_user_num
- </if>
- FROM
- goods g
- LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN school s ON s.id = g.school_id
- LEFT JOIN major m ON g.major_id = m.id
- LEFT JOIN order_input_template ot ON cb.template_status = ot.id
- <if test="getOrderNum != null and getOrderNum == 1">
- LEFT JOIN (
- SELECT
- og.goods_id,
- sum( CASE WHEN g.goods_type = 6 THEN 1 ELSE 0 END ) AS goods_live_num
- FROM
- `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- WHERE o.`status` = 1
- AND og.refund_status in (0,1,3)
- AND og.pay_status in (2,3,4)
- GROUP BY
- og.goods_id
- ) ou ON g.goods_id = ou.goods_id
- </if>
- WHERE
- 1 = 1
- AND g.goods_type != 5
- AND g.first_choice_goods = 0
- <if test="status != null and status.size()!=0 ">
- AND g.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="goodsIds != null and goodsIds.size()!=0 ">
- AND g.goods_id in
- <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="goodsTypes != null and goodsTypes.size()!=0 ">
- AND g.goods_type in
- <foreach collection="goodsTypes" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="withNotSpec != null and withNotSpec != ''">
- AND g.spec_template_id is NULL
- </if>
- <if test="goodsType != null and goodsType != ''">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="showStatus != null and showStatus != ''">
- AND g.show_status = #{showStatus}
- </if>
- <if test="code != null and code != ''">
- AND g.code = #{code}
- </if>
- <if test="makeGoodsId != null and makeGoodsId != ''">
- AND INSTR(g.make_goods_ids,#{makeGoodsId})
- </if>
- <if test="goodsName != null and goodsName != ''">
- AND g.goods_name like concat('%', #{goodsName}, '%')
- </if>
- <if test="educationTypeId != null and educationTypeId != ''">
- AND g.education_type_id = #{educationTypeId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND g.project_id = #{projectId}
- </if>
- <if test="businessIds != null and businessIds.size()!=0 ">
- AND g.business_id in
- <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="businessId != null and businessId != ''">
- AND g.business_id = #{businessId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND g.project_id = #{projectId}
- </if>
- <if test="schoolId != null and schoolId != ''">
- AND g.school_id = #{schoolId}
- </if>
- <if test="majorId != null and majorId != ''">
- AND g.major_id = #{majorId}
- </if>
- <if test="standPrice != null ">
- AND g.stand_price = #{standPrice}
- </if>
- <if test="searchKey != null and searchKey != ''">
- and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
- </if>
- <if test="goodsStatus != null ">
- AND g.goods_status = #{goodsStatus}
- </if>
- <if test="commitPeriodStatus != null ">
- AND g.commit_period_status = #{commitPeriodStatus}
- </if>
- <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
- and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN
- g.validity_start_time and g.validity_end_time
- </if>
- <if test="validityStartTime != null or validityEndTime != null ">
- AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime}
- BETWEEN g.validity_start_time and g.validity_end_time)
- </if>
- <if test="subjectId != null and subjectId >0">
- AND FIND_IN_SET(#{subjectId},g.subject_ids)
- </if>
- <if test="subjectIdList != null and subjectIdList.size > 0 ">
- AND (
- <foreach collection="subjectIdList" item="item" index="index">
- <if test=" index == 0 ">
- FIND_IN_SET(#{item},g.subject_ids)
- </if>
- <if test=" index != 0 ">
- OR FIND_IN_SET(#{item},g.subject_ids)
- </if>
- </foreach>
- )
- </if>
- <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
- AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id
- = g.goods_id and c.`status` = 1
- ) >0
- </if>
- <if test="gradeType != null and gradeType != ''">
- AND g.grade_type = #{gradeType}
- </if>
- <!-- 数据范围过滤 -->
- ${params.dataScope}
- <if test="sortType != null and sortType == 2">
- ORDER BY g.show_sort DESC,g.stand_price ASC
- </if>
- <if test="sortType != null and sortType == 3">
- ORDER BY g.show_sort DESC,g.stand_price DESC
- </if>
- <if test="sortType != null and sortType == 1">
- ORDER BY g.show_sort DESC,g.create_time DESC
- </if>
- <if test="sortType == null">
- ORDER BY g.create_time DESC
- </if>
- </select>
- <select id="selectListToInput" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
- resultMap="GoodsResultVo">
- SELECT
- g.*,
- ps.supply_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- s.school_name,
- m.category_name,
- ot.type AS template_type,
- (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
- (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
- <if test="sectionNum ==1">
- ,(SELECT COUNT(m.id)+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_module_chapter p on
- n.chapter_id = p.chapter_id LEFT JOIN course_menu m on m.menu_id = p.module_id LEFT JOIN goods_course gc on
- gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(1))+(SELECT COUNT(n.id) FROM
- course_chapter_section n LEFT JOIN course_menu m on m.menu_id = n.chapter_id LEFT JOIN goods_course gc on
- gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(2)) FROM course_menu m LEFT JOIN
- goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(3)) as
- section_num
- </if>
- <if test="goodsType ==1">
- , (SELECT count(*) FROM goods_course where goods_id =g.goods_id ) as course_num
- -- , (SELECT count(*) FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
- -- cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
- -- , (SELECT cg.grade_id FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
- -- where cgg.goods_id = g.goods_id and cg.`status` = 1 AND (unix_timestamp(now()) < cg.class_end_time or
- -- cg.class_start_time is null) AND cg.`status` = 1 AND (SELECT COUNT(a.id) FROM class_grade_user a where
- -- a.grade_id = cg.grade_id and a.status =1) < cg.student_upper limit 1) as grade_id
- -- , (SELECT cg.class_name FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
- -- where cgg.goods_id = g.goods_id and cg.`status` = 1 AND (unix_timestamp(now()) < cg.class_end_time or
- -- cg.class_start_time is null) AND cg.`status` = 1 AND (SELECT COUNT(a.id) FROM class_grade_user a where
- -- a.grade_id = cg.grade_id and a.status =1) < cg.student_upper limit 1) as grade_name
- </if>
- FROM
- goods g
- LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN school s ON s.id = g.school_id
- LEFT JOIN major m ON g.major_id = m.id
- LEFT JOIN order_input_template ot ON cb.template_status = ot.id
- WHERE
- 1 = 1
- AND g.goods_type != 5
- AND g.input_sign = 0
- AND g.first_choice_goods = 0
- <if test="status != null and status.size()!=0 ">
- AND g.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="goodsIds != null and goodsIds.size()!=0 ">
- AND g.goods_id in
- <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="goodsType != null and goodsType != ''">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="makeGoodsId != null and makeGoodsId != ''">
- AND g.make_goods_id = #{makeGoodsId}
- </if>
- <if test="goodsName != null and goodsName != ''">
- AND g.goods_name like concat('%', #{goodsName}, '%')
- </if>
- <if test="educationTypeId != null and educationTypeId != ''">
- AND g.education_type_id = #{educationTypeId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND g.project_id = #{projectId}
- </if>
- <if test="businessIds != null and businessIds.size()!=0 ">
- AND g.business_id in
- <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="businessId != null and businessId != ''">
- AND g.business_id = #{businessId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND g.project_id = #{projectId}
- </if>
- <if test="schoolId != null and schoolId != ''">
- AND g.school_id = #{schoolId}
- </if>
- <if test="majorId != null and majorId != ''">
- AND g.major_id = #{majorId}
- </if>
- <if test="standPrice != null and standPrice != ''">
- AND g.stand_price = #{standPrice}
- </if>
- <if test="searchKey != null and searchKey != ''">
- and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
- </if>
- <if test="goodsStatus != null ">
- AND g.goods_status = #{goodsStatus}
- </if>
- <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
- and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN
- g.validity_start_time and g.validity_end_time
- </if>
- <if test="validityStartTime != null or validityEndTime != null ">
- AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime}
- BETWEEN g.validity_start_time and g.validity_end_time)
- </if>
- <if test="subjectId != null and subjectId >0">
- AND FIND_IN_SET(#{subjectId},g.subject_ids)
- </if>
- <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
- AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id
- = g.goods_id and c.`status` = 1
- ) >0
- </if>
- <if test="sortType != null and sortType == 2">
- ORDER BY g.stand_price
- </if>
- <if test="sortType != null and sortType == 3">
- ORDER BY g.stand_price DESC
- </if>
- <if test="sortType == null or sortType == 1">
- ORDER BY g.create_time DESC
- </if>
- </select>
- <select id="selectDetail" parameterType="Long" resultMap="GoodsResultVo">
- SELECT g.*,
- ps.supply_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- cb.template_status as special_goods,
- s.school_name,
- m.category_name,
- ot.type AS template_type,
- (SELECT gs.goods_name FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_name,
- (SELECT gs.code FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_code,
- (SELECT count(DISTINCT c.subject_id)
- FROM course c
- LEFT JOIN goods_course gc ON gc.course_id = c.course_id
- WHERE gc.goods_id = g.goods_id) as subject_num,
- (SELECT GROUP_CONCAT(subject_name)
- from course_subject
- where FIND_IN_SET(id, g.subject_ids)) subject_names
- FROM goods g
- LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN school s ON s.id = g.school_id
- LEFT JOIN major m ON g.major_id = m.id
- LEFT JOIN order_input_template ot ON cb.template_status = ot.id
- WHERE g.goods_id = #{goodsId}
- </select>
- <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo"
- resultMap="ExamNumberGoodsVoResult">
- SELECT
- goods_id,
- goods_name,
- validity_start_time,
- validity_end_time,
- goods_status,
- status,
- CODE,
- stand_price,
- <if test="filtration != null and filtration == 1">
- (case WHEN (SELECT COUNT(gs.goods_id) FROM goods gs where 1=1 and gs.make_goods_id = g.goods_id and
- gs.status =1 and gs.goods_type =4) >0 then 0 ELSE 1 end) as select_status
- </if>
- <if test="filtration != null and filtration == 2">
- (case WHEN (SELECT COUNT(gs.goods_id) FROM goods gs where 1=1 and gs.make_goods_id = g.goods_id and
- gs.status =1 and gs.goods_type =3) >0 then 0 ELSE 1 end) as select_status
- </if>
- FROM
- goods g
- WHERE
- 1 = 1
- and g.status in(1)
- and g.goods_type=1
- <if test="businessId != null and businessId != ''">
- and g.business_id = #{businessId}
- </if>
- <if test="goodsId != null and goodsId != ''">
- and g.goods_id = #{goodsId}
- </if>
- <if test="projectId != null and projectId != ''">
- and g.project_id = #{projectId}
- </if>
- <if test="goodsType != null and goodsType != ''">
- and g.goods_type = #{goodsType}
- </if>
- <if test="goodsStatus != null and goodsStatus != ''">
- and g.goods_status = #{goodsStatus}
- </if>
- <if test="searchKey != null and searchKey != ''">
- and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
- </if>
- order by g.create_time desc
- </select>
- <select id="selectUserDetail" parameterType="map" resultMap="GoodsResultVo">
- SELECT g.*,
- ps.supply_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- cb.reminder_sign,
- cb.template_status AS special_goods,
- s.school_name,
- m.category_name,
- ot.type AS template_type,
- (SELECT gs.goods_name FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_name,
- (SELECT gs.code FROM goods gs where 1 = 1 and g.make_goods_id = gs.goods_id) as make_goods_code,
- (SELECT DISTINCT cg.grade_id
- FROM class_grade_user cgu
- LEFT JOIN class_grade_goods cgg on cgg.grade_id = cgu.grade_id
- LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
- where cgu.user_id = #{userId}
- <if test="orderGoodsId != null and orderGoodsId != ''">
- and cgu.order_goods_id = #{orderGoodsId}
- </if>
- and cgg.goods_id = g.goods_id
- and cg.`status` = 1
- and unix_timestamp(now()) BETWEEN cg.class_start_time and cg.class_end_time limit 1) as grade_id
- FROM goods g
- LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN school s ON s.id = g.school_id
- LEFT JOIN major m ON g.major_id = m.id
- LEFT JOIN order_input_template ot ON cb.template_status = ot.id
- WHERE g.goods_id = #{goodsId}
- </select>
- <select id="getQuestionNum" parameterType="Long" resultType="Long">
- SELECT count(DISTINCT question_id) question_num
- FROM exam_question
- WHERE find_in_set(
- exam_id, (
- SELECT concat(
- IFNULL((
- SELECT GROUP_CONCAT(exam_id)
- FROM question_chapter_exam
- WHERE FIND_IN_SET(chapter_exam_id,
- (SELECT concat(
- IFNULL(
- (SELECT GROUP_CONCAT(major_id) eids
- FROM goods_attached
- WHERE goods_id = #{goodsId}
- AND type = 2), ''),
- ',',
- IFNULL(
- (
- SELECT GROUP_CONCAT(chapter_exam_id) eids2
- FROM question_module_chapter
- WHERE module_exam_id IN
- (SELECT major_id
- FROM goods_attached
- WHERE goods_id = #{goodsId} AND type = 1)),
- ''
- ))))),
- ''
- ),
- ',',
- IFNULL((SELECT GROUP_CONCAT(major_id)
- FROM goods_attached
- WHERE goods_id = #{goodsId} AND type = 3), ''))))
- </select>
- <select id="getMakeGoodsList" parameterType="map" resultType="com.zhongzheng.modules.goods.vo.MakeGoodsVo">
- select g.goods_id as make_goods_id,g.goods_name as make_goods_name,g.code as make_goods_code from goods g where FIND_IN_SET(g.goods_id,#{makeGoodsIds})
- </select>
- <select id="getRandomQuestionNum" parameterType="map" resultType="Long">
- SELECT count(DISTINCT eq.question_id) question_num
- FROM exam_question eq
- LEFT JOIN exam e on eq.exam_id = e.exam_id
- WHERE find_in_set(
- eq.exam_id, (
- SELECT concat(
- IFNULL((
- SELECT GROUP_CONCAT(exam_id)
- FROM question_chapter_exam
- WHERE FIND_IN_SET(chapter_exam_id,
- (SELECT concat(
- IFNULL(
- (SELECT GROUP_CONCAT(major_id) eids
- FROM goods_attached
- WHERE goods_id = #{goodsId}
- AND type = 2), ''),
- ',',
- IFNULL(
- (
- SELECT GROUP_CONCAT(chapter_exam_id) eids2
- FROM question_module_chapter
- WHERE module_exam_id IN
- (SELECT major_id
- FROM goods_attached
- WHERE goods_id = #{goodsId} AND type = 1)),
- ''
- ))))),
- ''
- ),
- ',',
- IFNULL((SELECT GROUP_CONCAT(major_id)
- FROM goods_attached
- WHERE goods_id = #{goodsId} AND type = 3), ''))))
- and e.exam_paper_id = #{examPaperId}
- </select>
- <update id="queryUpGoods">
- update goods g
- set g.goods_status=0
- where unix_timestamp(now()) > g.validity_end_time
- and g.goods_status = 1
- </update>
- <select id="getExamNum" parameterType="Long" resultType="Long">
- SELECT count(exam_id) + ((
- SELECT count(major_id)
- FROM goods_attached
- WHERE goods_id = #{goodsId}
- AND type = 3
- )) AS exam_num
- FROM question_chapter_exam
- WHERE FIND_IN_SET(
- chapter_exam_id,
- (
- SELECT concat(
- IFNULL((SELECT GROUP_CONCAT(major_id) eids
- FROM goods_attached
- WHERE goods_id = #{goodsId} AND type = 2), ''),
- ',',
- IFNULL(
- (
- SELECT GROUP_CONCAT(chapter_exam_id) eids2
- FROM question_module_chapter
- WHERE module_exam_id IN (SELECT major_id
- FROM goods_attached
- WHERE goods_id = #{goodsId} AND type = 1)),
- ''
- ))))
- </select>
- <select id="getSectionNumByBo" parameterType="Long" resultMap="GoodsResultVo">
- SELECT (SELECT IFNULL(COUNT(m.id), 0) + (SELECT IFNULL(COUNT(n.id), 0)
- FROM course_chapter_section n
- LEFT JOIN course_module_chapter p on n.chapter_id = p.chapter_id
- LEFT JOIN course_menu m on m.menu_id = p.module_id
- LEFT JOIN goods_course gc on gc.course_id = m.course_id
- where gc.goods_id = g.goods_id
- and m.type in (1)) + (SELECT IFNULL(COUNT(n.id), 0)
- FROM course_chapter_section n
- LEFT JOIN course_menu m on m.menu_id = n.chapter_id
- LEFT JOIN goods_course gc on gc.course_id = m.course_id
- where gc.goods_id = g.goods_id
- and m.type in (2))
- FROM course_menu m
- LEFT JOIN goods_course gc on gc.course_id = m.course_id
- where gc.goods_id = g.goods_id
- and m.type in (3)) as section_num,
- (SELECT IFNULL(COUNT(1), 0) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
- (SELECT IFNULL(COUNT(m.id), 0)
- FROM goods_course c
- LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
- where m.type = 1
- and c.goods_id = g.goods_id) as exam_num
- FROM goods g
- WHERE g.goods_id = #{goodsId}
- </select>
- <select id="getOrderGoodsListByUser" parameterType="Long"
- resultType="com.zhongzheng.modules.goods.vo.UserGoodsListVo">
- SELECT og.goods_id AS goodsId,
- og.order_goods_id as orderGoodsId,
- o.order_id as orderId,
- g.goods_name as categoryName,
- m.category_name as majorName,
- o.tenant_id as tenantId,
- g.goods_type as courseType,
- concat('https://file.xyyxt.net/', g.cover_url) as imageUrl,
- o.create_time as createTimeStr,
- og.grade_id as gradeId
- FROM `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN major m ON g.major_id = m.id
- WHERE o.user_id = #{userId}
- AND og.pay_status IN (2, 3, 4)
- AND og.refund_status !=2
- </select>
- <select id="getUserOrderGoodsList" parameterType="Long"
- resultType="com.zhongzheng.modules.goods.vo.UserOrderGoodsListVo">
- SELECT og.goods_id AS goodsId,
- og.order_goods_id as orderGoodsId,
- o.order_id as orderId,
- g.goods_name as categoryName,
- m.category_name as majorName,
- o.tenant_id as tenantId,
- g.goods_type as courseType,
- concat('https://file.xyyxt.net/', g.cover_url) as imageUrl,
- o.create_time as createTimeStr,
- og.grade_id as gradeId
- FROM `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN major m ON g.major_id = m.id
- WHERE o.user_id = #{userId}
- AND og.pay_status IN (2, 3, 4)
- AND og.refund_status !=2
- ORDER BY o.create_time DESC
- </select>
- <select id="countUserOrderGoods" parameterType="Long" resultType="com.zhongzheng.modules.goods.vo.UserOrderGoodsVo">
- SELECT og.order_goods_id,
- og.goods_id,
- og.grade_id
- FROM `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- WHERE o.user_id = #{userId}
- AND og.goods_id = #{goodsId}
- AND og.pay_status IN (2, 3, 4)
- AND og.refund_status != 2
- AND og.`status` = 1
- AND o.`status` = 1
- AND o.tenant_id = #{tenantId}
- AND og.tenant_id = #{tenantId}
- </select>
- <select id="getExternalQuestion" parameterType="com.zhongzheng.modules.course.bo.ExternalQuestionBo" resultType="com.zhongzheng.modules.course.vo.ExternalQuestionVo">
- SELECT
- g.goods_id,
- qm.merchant_id,
- g.goods_name,
- qm.merchant_name,
- qm.do_num,
- g.stand_price AS goodsPrice,
- g.cover_url
- FROM
- question_merchant qm
- LEFT JOIN goods g ON qm.merchant_id = g.question_merchant_id
- WHERE
- qm.`status` = 1
- AND qm.tenant_id = #{tenantId}
- AND g.`status` = 1
- </select>
- <select id="getReplenishExam" parameterType="com.zhongzheng.modules.course.bo.ReplenishExamBo" resultType="com.zhongzheng.modules.course.vo.ReplenishExamVo">
- SELECT
- g.goods_id,
- g.goods_name,
- g.stand_price AS goodsPrice,
- g.cover_url
- FROM
- goods g
- WHERE
- g.`status` = 1
- and g.unify_sign = 1
- </select>
- <select id="queryGoodsByIdTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
- SELECT *
- FROM `goods`
- WHERE goods_id = #{goodsId}
- AND tenant_id = #{tenantId}
- </select>
- <select id="getRelevanceGoodsNoTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
- SELECT
- g.*
- FROM
- goods g
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN major m ON g.major_id = m.id
- WHERE
- g.`status` = 1
- AND g.goods_status = 1
- AND INSTR(#{businessName}, cet.education_name)
- AND INSTR(#{businessName}, cpt.project_name)
- AND INSTR(#{majName}, m.category_name)
- AND g.goods_id != #{goodsId}
- </select>
- <select id="getRelGoodsNoTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
- SELECT
- g.*
- FROM
- goods g
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN major m ON g.major_id = m.id
- WHERE
- g.`status` = 1
- AND g.goods_status = 1
- AND INSTR(#{businessName}, cet.education_name)
- AND INSTR(#{businessName}, cpt.project_name)
- AND INSTR(#{categoryName}, m.category_name)
- AND INSTR(#{businessName},cb.business_name)
- AND g.tenant_id = #{tenantId}
- AND INSTR(g.goods_name,'测试') <= 0
- </select>
- <select id="getCourseNum" parameterType="java.lang.Long" resultType="java.lang.Integer">
- SELECT
- (SELECT
- COUNT( cs.section_id )
- FROM
- goods g
- LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
- LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
- LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
- WHERE
- g.goods_id = #{goodsId}
- AND cm.`status` = 1
- AND cm.type = 1
- AND cs.`status` = 1
- ) +
- (SELECT
- COUNT( cs.section_id )
- FROM
- goods g
- LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_chapter_section ccs ON cm.menu_id = ccs.chapter_id
- LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
- WHERE
- g.goods_id = #{goodsId}
- AND cm.`status` = 1
- AND cm.type = 2
- AND cs.`status` = 1
- ) +
- (SELECT
- COUNT( cs.section_id )
- FROM
- goods g
- LEFT JOIN goods_course gc ON g.goods_id = gc.goods_id
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_section cs ON cm.menu_id = cs.section_id
- WHERE
- g.goods_id = #{goodsId}
- AND cm.`status` = 1
- AND cm.type = 3
- AND cs.`status` = 1
- )
- </select>
- <select id="getCourseExamNumNoTenant" parameterType="java.lang.Long" resultType="java.lang.Integer">
- SELECT
- COUNT(*)
- FROM
- course_menu_exam cme
- LEFT JOIN goods_course gc ON cme.course_id = gc.course_id
- WHERE
- cme.type != 2
- AND gc.goods_id = #{goodsId}
- </select>
- <select id="queryGoodsByTenant" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
- SELECT *
- FROM `goods`
- WHERE `code` = #{code}
- AND tenant_id = #{tenantId}
- </select>
- <select id="getGoodsByIdNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.domain.Goods">
- SELECT *
- FROM `goods`
- WHERE goods_id = #{goodsId}
- </select>
- <select id="getGoodsByTenantTwo" parameterType="map" resultType="com.zhongzheng.modules.goods.domain.Goods">
- SELECT *
- FROM `goods`
- WHERE goods_name = #{goodsName} and code = #{code} and tenant_id = #{tenantId}
- </select>
- <select id="getModuleExam" resultType="com.zhongzheng.modules.bank.domain.QuestionModule">
- 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) <= 0 AND `status` = 1
- </select>
- <select id="getChapterExam" resultType="com.zhongzheng.modules.bank.domain.QuestionChapter">
- 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) <= 0 AND `status` = 1
- </select>
- <select id="getExam" resultType="com.zhongzheng.modules.bank.domain.Exam">
- SELECT * FROM exam qm WHERE (SELECT COUNT( qb.id)FROM question_business qb WHERE qb.major_id = qm.exam_id AND qb.type = 2) <= 0 AND `status` = 1
- </select>
- <select id="getSysGoodsCopy" parameterType="map" resultType="com.zhongzheng.modules.system.domain.SysGoodsCopyRecord">
- SELECT * FROM sys_goods_copy_record WHERE new_id = #{moduleExamId} AND type = #{type} LIMIT 1
- </select>
- <select id="getModuleExamBusiness" parameterType="map" resultType="com.zhongzheng.modules.bank.domain.QuestionBusiness">
- SELECT * FROM question_business WHERE major_id = #{oldId} AND type = #{type} AND tenant_id = 867735392558919680
- </select>
- <insert id="saveExamBusiness" parameterType="com.zhongzheng.modules.bank.domain.QuestionBusiness" >
- INSERT INTO question_business (education_type_id,business_id,tenant_id,project_id,subject_id,major_id,type)
- VALUES(#{educationTypeId},#{businessId},#{tenantId},#{projectId},#{subjectId},#{majorId},#{type})
- </insert>
- <select id="getGoodsCourseTree" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.vo.GoodsCourseTreeVo">
- SELECT
- gc.goods_id,
- cm.course_id,
- cmc.module_id,
- cpc.chapter_id,
- cs.section_id
- FROM
- goods_course gc
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
- LEFT JOIN course_chapter_section cpc ON cmc.chapter_id = cpc.chapter_id
- LEFT JOIN course_section cs ON cpc.section_id = cs.section_id
- WHERE
- gc.goods_id = #{goodsId}
- AND cm.`status` = 1
- AND cs.`status` = 1
- AND cm.type = 1 UNION ALL
- SELECT
- gc.goods_id,
- cm.course_id,
- 0 AS module_id,
- cpc.chapter_id,
- cs.section_id
- FROM
- goods_course gc
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_chapter_section cpc ON cm.menu_id = cpc.chapter_id
- LEFT JOIN course_section cs ON cpc.section_id = cs.section_id
- WHERE
- gc.goods_id = #{goodsId}
- AND cm.`status` = 1
- AND cs.`status` = 1
- AND cm.type = 2 UNION ALL
- SELECT
- gc.goods_id,
- cm.course_id,
- 0 AS module_id,
- 0 AS chapter_id,
- cs.section_id
- FROM
- goods_course gc
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_section cs ON cm.menu_id = cs.section_id
- WHERE
- gc.goods_id = #{goodsId}
- AND cm.`status` = 1
- AND cs.`status` = 1
- AND cm.type = 3
- </select>
- <update id="updateByTenant" parameterType="com.zhongzheng.modules.goods.domain.Goods">
- UPDATE goods
- SET `year` = #{year},
- supply_id = #{supplyId},
- goods_type = #{goodsType},
- education_type_id = #{educationTypeId},
- business_id = #{businessId},
- school_id = #{schoolId},
- major_id = #{majorId},
- goods_name = #{goodsName},
- stand_price = #{standPrice},
- lowest_price = #{lowestPrice},
- create_time = #{createTime},
- update_time = #{updateTime},
- `status` = #{status},
- validity_start_time = #{validityStartTime},
- validity_end_time = #{validityEndTime},
- study_start_time = #{studyStartTime},
- study_end_time = #{studyEndTime},
- certificate_ids = #{certificateIds},
- introduce = #{introduce},
- suitable_object = #{suitableObject},
- buy_note = #{buyNote},
- pc_detail_html = #{pcDetailHtml},
- mobile_detail_html = #{mobileDetailHtml},
- goods_status = #{goodsStatus},
- cover_url = #{coverUrl},
- class_hours = #{classHours},
- stand_price_json = #{standPriceJson},
- tenant_id = #{tenantId},
- `code` = #{code},
- project_id = #{projectId},
- goods_audition_config = #{goodsAuditionConfig},
- goods_photograph_config = #{goodsPhotographConfig},
- goods_play_config = #{goodsPlayConfig},
- goods_exam_config = #{goodsExamConfig},
- handouts_id = #{handoutsId},
- make_start_time = #{makeStartTime},
- make_end_time = #{makeEndTime},
- study_count = #{studyCount},
- goods_photo_exam_config = #{goodsPhotoExamConfig},
- make_goods_id = #{makeGoodsId},
- service_time_type = #{serviceTimeType},
- service_time_num = #{serviceTimeNum},
- section_max_num = #{sectionMaxNum},
- exam_number = #{examNumber},
- do_number = #{doNumber},
- teacher_id = #{teacherId},
- subject_ids = #{subjectIds},
- certificate_type_id = #{certificateTypeId},
- certificate_id = #{certificateId},
- certificate_tp_id = #{certificateTpId},
- line_price = #{linePrice},
- spec_template_id = #{specTemplateId},
- show_status = #{showStatus},
- show_sort = #{showSort}
- WHERE goods_id = #{goodsId}
- and tenant_id = #{tenantId}
- </update>
- <select id="getUserGoodsListAll" parameterType="com.zhongzheng.modules.goods.bo.UserGoodsListAllBo"
- resultType="com.zhongzheng.modules.goods.vo.GoodsListAllVo">
- SELECT
- o.order_id,
- og.order_goods_id,
- g.goods_id,
- g.goods_name,
- g.goods_type,
- g.class_hours,
- g.validity_start_time,
- g.validity_end_time,
- g.study_start_time AS serviceStartTime,
- g.study_end_time AS serviceEndTime,
- cg.class_status,
- cg.class_start_time,
- cg.class_end_time
- FROM
- order_goods og
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
- WHERE
- og.pay_status IN ( 2, 3, 4 )
- AND og.refund_status != 2
- <if test="goodsType != null and goodsType != ''">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="goodsName != null and goodsName != ''">
- AND g.goods_name like concat('%', #{goodsName}, '%')
- </if>
- <if test="educationTypeId != null and educationTypeId != ''">
- AND g.education_type_id = #{educationTypeId}
- </if>
- <if test="businessId != null and businessId != ''">
- AND g.business_id = #{businessId}
- </if>
- <if test="userId != null and userId != ''">
- AND o.user_id = #{userId}
- </if>
- </select>
- <select id="getCourseExamNum" parameterType="java.lang.Long" resultType="java.lang.Long">
- SELECT
- COUNT(*)
- FROM
- course_menu_exam cme
- LEFT JOIN goods_course gc ON cme.course_id = gc.course_id
- WHERE
- cme.type != 2
- AND gc.goods_id = #{goodsId}
- </select>
- <select id="getUserStudyNum" parameterType="java.lang.Long" resultType="java.lang.Long">
- SELECT COUNT(*) FROM
- (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
- 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
- </select>
- <select id="getAlikeGoods" parameterType="com.zhongzheng.modules.goods.domain.Goods" resultType="com.zhongzheng.modules.goods.vo.GoodsVo">
- SELECT g.*,
- cet.education_name as educationName,
- cb.business_name as businessName,
- cpt.project_name as projectName,
- m.category_name as categoryName
- from goods g
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id and cet.tenant_id = #{tenantId}
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id and cpt.tenant_id = #{tenantId}
- LEFT JOIN course_business cb ON g.business_id = cb.id and cb.tenant_id = #{tenantId}
- LEFT JOIN major m ON g.major_id = m.id and m.tenant_id = #{tenantId}
- where
- g.goods_status = 1
- and g.status = 1
- and g.goods_type != 5
- and g.education_type_id = #{educationTypeId}
- and g.project_id = #{projectId}
- and g.business_id = #{businessId}
- and g.stand_price = #{standPrice}
- and g.tenant_id = #{tenantId}
- </select>
- <update id="updateHandoutsId" parameterType="java.lang.Long">
- UPDATE goods SET handouts_id = #{handoutsId} WHERE goods_id = #{goodsId} and tenant_id = #{tenantId}
- </update>
- <select id="getNewHandoutsId" parameterType="map" resultType="java.lang.Long">
- SELECT handouts_id FROM course_handouts WHERE INSTR(handouts_name,#{handoutsName}) AND encoder = #{encoder} AND tenant_id = #{newTenantId}
- </select>
- <select id="getGoodsBusinessName" parameterType="java.lang.Long" resultType="java.lang.String">
- SELECT
- CONCAT( cet.education_name, cb.business_name, cpt.project_name )
- FROM
- goods g
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE
- g.goods_id = #{goodsId}
- </select>
- <select id="getBusinessName" parameterType="java.lang.Long" resultType="java.lang.String">
- SELECT
- CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name
- FROM
- goods g
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- WHERE
- g.goods_id = #{goodsId}
- </select>
- <select id="getGoodsSectionInfo" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.CourseSection">
- SELECT
- cs.*
- FROM
- goods_course gc
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
- LEFT JOIN course_chapter_section ccs ON cmc.chapter_id = ccs.chapter_id
- LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
- WHERE
- gc.goods_id = #{goodsId}
- AND cm.`status` = 1
- </select>
- </mapper>
|