|
@@ -0,0 +1,274 @@
|
|
|
|
|
+<?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.top.goods.mapper.TopGoodsMapper">
|
|
|
|
|
+
|
|
|
|
|
+ <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="TopGoodsResultVo">
|
|
|
|
|
+ <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="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="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"/>
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectAllList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="TopGoodsResultVo">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ g.*,
|
|
|
|
|
+ ps.supply_name,
|
|
|
|
|
+ cet.education_name,
|
|
|
|
|
+ cpt.project_name,
|
|
|
|
|
+ cb.business_name,
|
|
|
|
|
+ cb.goods_learning_order,
|
|
|
|
|
+ s.school_name,
|
|
|
|
|
+ m.category_name,
|
|
|
|
|
+ (SELECT GROUP_CONCAT(subject_name) from top_course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names,
|
|
|
|
|
+ (SELECT COUNT( DISTINCT gar.spec_template_id ) FROM top_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 top_goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
|
|
|
|
|
+ (SELECT gs.code FROM top_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 top_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 top_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
|
|
|
|
|
+ <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="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 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 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>
|
|
|
|
|
+ <!-- 数据范围过滤 -->
|
|
|
|
|
+ ${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>
|
|
|
|
|
+</mapper>
|