123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104 |
- <?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.order.mapper.OrderGoodsMapper">
- <resultMap type="com.zhongzheng.modules.order.domain.OrderGoods" id="OrderGoodsResult">
- <result property="orderGoodsId" column="order_goods_id"/>
- <result property="orderSn" column="order_sn"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsInputData" column="goods_input_data"/>
- <result property="goodsPrice" column="goods_price"/>
- <result property="goodsRealPrice" column="goods_real_price"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="status" column="status"/>
- <result property="goodsReceived" column="goods_received"/>
- <result property="refundStatus" column="refund_status"/>
- <result property="payStatus" column="pay_status"/>
- <result property="businessOwner" column="business_owner"/>
- <result property="dept" column="dept"/>
- <result property="source" column="source"/>
- <result property="school" column="school"/>
- <result property="address" column="address"/>
- <result property="company" column="company"/>
- <result property="remark" column="remark"/>
- <result property="gradeId" column="grade_id"/>
- <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
- <result property="studyCount" column="study_count"/>
- <result property="serviceStartTime" column="service_start_time"/>
- <result property="serviceEndTime" column="service_end_time"/>
- <result property="closeReason" column="close_reason"/>
- <result property="sevenClassVersion" column="seven_class_version"/>
- <result property="sevenClassStatus" column="seven_class_status"/>
- <result property="sevenYear" column="seven_year"/>
- <result property="sevenClassCopy" column="seven_class_copy"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.order.vo.OrderGoodsVo" id="OrderGoodsResultVo">
- <result property="orderGoodsId" column="order_goods_id"/>
- <result property="orderSn" column="order_sn"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsInputData" column="goods_input_data"/>
- <result property="goodsPrice" column="goods_price"/>
- <result property="goodsRealPrice" column="goods_real_price"/>
- <result property="status" column="status"/>
- <result property="goodsReceived" column="goods_received"/>
- <result property="refundStatus" column="refund_status"/>
- <result property="payStatus" column="pay_status"/>
- <result property="businessOwner" column="business_owner"/>
- <result property="dept" column="dept"/>
- <result property="source" column="source"/>
- <result property="school" column="school"/>
- <result property="address" column="address"/>
- <result property="company" column="company"/>
- <result property="createTime" column="create_time"/>
- <result property="remark" column="remark"/>
- <result property="userId" column="user_id"/>
- <result property="realname" column="realname"/>
- <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
- <result property="externalLink" column="external_link"/>
- <result property="externalLinkStatus" column="external_link_status"/>
- <result property="periodStatus" column="period_status"/>
- <result property="distributionCode" column="distribution_code"/>
- <result property="distributionLinkCode" column="distribution_link_code"/>
- <result property="offlineRefundSign" column="offline_refund_sign"/>
- <result property="code" column="code"/>
- <result property="goodsName" column="goods_name"/>
- <result property="educationName" column="education_name"/>
- <result property="projectName" column="project_name"/>
- <result property="businessName" column="business_name"/>
- <result property="createBy" column="create_by"/>
- <result property="goodsType" column="goods_type"/>
- <result property="gradeId" column="grade_id"/>
- <result property="coverUrl" column="cover_url"/>
- <result property="gradeName" column="class_name"/>
- <result property="studyCount" column="study_count"/>
- <result property="class_name" column="gradeName"/>
- <result property="serviceStartTime" column="service_start_time"/>
- <result property="serviceEndTime" column="service_end_time"/>
- <result property="orderStatus" column="order_status"/>
- <result property="classStartTime" column="class_start_time"/>
- <result property="classEndTime" column="class_end_time"/>
- <result property="interfaceAccountId" column="interface_account_id"/>
- <result property="interfacePushId" column="interface_push_id"/>
- <result property="introduce" column="introduce"/>
- <result property="learningStatus" column="learning_status"/>
- <result property="learningTimeStart" column="learning_time_start"/>
- <result property="officialLearningUrl" column="official_learning_url"/>
- <result property="learnStatus" column="learn_status"/>
- <result property="officialStatus" column="official_status"/>
- <result property="classStatus" column="class_status"/>
- <result property="closeReason" column="close_reason"/>
- <result property="joinLiveNum" column="join_live_num"/>
- <result property="seeTime" column="see_time"/>
- <result property="categoryName" column="category_name"/>
- <result property="subjectIds" column="subject_ids"/>
- <result property="businessId" column="business_id"/>
- <result property="examNum" column="exam_num"/>
- <result property="recordNum" column="record_num"/>
- <result property="sysUserId" column="sys_user_id"/>
- <result property="applyStatus" column="apply_status"/>
- <result property="subExamStatus" column="sub_exam_status"/>
- <result property="subPerformance" column="sub_performance"/>
- <result property="subResult" column="sub_result"/>
- <result property="subApplySiteStartTime" column="sub_apply_site_start_time"/>
- <result property="subApplySiteEndTime" column="sub_apply_site_end_time"/>
- <result property="subApplySiteExamTime" column="sub_apply_site_exam_time"/>
- <result property="subscribeId" column="subscribe_id"/>
- <result property="gradeId" column="grade_id"/>
- <result property="userStudyCount" column="user_study_count"/>
- <result property="goodsLearningOrder" column="goods_learning_order"/>
- <result property="classHours" column="class_hours"/>
- <result property="courseNum" column="course_num"/>
- <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="sevenClassVersion" column="seven_class_version"/>
- <result property="sevenClassStatus" column="seven_class_status"/>
- <result property="sevenYear" column="seven_year"/>
- <result property="orderYear" column="order_year"/>
- <result property="sevenClassCopy" column="seven_class_copy"/>
- <result property="studyStatus" column="study_status"/>
- <result property="mailSign" column="mail_sign"/>
- <result property="profileStatus" column="profile_status"/>
- <result property="profileChangeStatus" column="profile_change_status"/>
- <result property="majorName" column="major_name"/>
- </resultMap>
- <select id="selectListBybo" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- og.*,
- g.`code`,
- g.goods_name,
- g.goods_type,
- g.cover_url,
- g.mail_sign,
- cet.education_name,
- cpt.project_name,
- cb.business_name
- FROM
- order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_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 `order` o ON o.order_sn = og.order_sn
- WHERE
- 1 = 1
- and og.status = 1
- <if test="refundStatusList != null and refundStatusList.size()!=0 ">
- AND og.refund_status in
- <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="goodsId != null and goodsId != ''">
- AND og.goods_id = #{goodsId}
- </if>
- <if test="userId != null">
- AND o.user_id = #{userId}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND og.order_sn = #{orderSn}
- </if>
- <if test="payStatusList != null and payStatusList.size()!=0 ">
- AND og.pay_status in
- <foreach collection="payStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderGoodsIds != null and orderGoodsIds.size()!=0 ">
- AND og.order_goods_id in
- <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectDetail" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- og.*,
- o.order_status,
- g.`code`,
- g.goods_name,
- g.goods_type,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- cg.class_name,
- o.create_username as create_by,
- cg.class_start_time,
- cg.class_end_time,
- cg.interface_account_id,
- cg.interface_push_id,
- g.introduce,
- cg.learning_status,
- cg.learning_time_start,
- cg.official_learning_url,
- cgu.learn_status,
- cgu.official_status,
- cg.class_status,
- m.category_name
- FROM
- order_goods og
- LEFT JOIN class_grade cg on og.grade_id = cg.grade_id
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN major m ON g.major_id = m.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 `order` o ON og.order_sn = o.order_sn
- LEFT JOIN class_grade_user cgu on cgu.user_id = o.user_id and cgu.grade_id = cg.grade_id and cgu.order_goods_id = og.order_goods_id
- WHERE
- 1=1
- <if test="orderSn != null and orderSn != ''">
- AND og.order_sn = #{orderSn} AND og.goods_id = #{goodsId}
- </if>
- <if test="orderGoodsId != null and orderGoodsId != ''">
- AND og.order_goods_id= #{orderGoodsId}
- </if>
- </select>
- <select id="selectOrderGoods" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT og.*,
- o.user_id
- FROM `order` o
- LEFT JOIN order_goods og on o.order_sn = og.order_sn
- where 1 = 1
- and og.`status` = 1
- and og.refund_status in (0, 1, 3)
- and og.pay_status in (2, 3, 4)
- AND (SELECT COUNT(1)
- FROM inform_user iu
- where iu.user_id = o.user_id and iu.goods_id = og.goods_id and system_status = 1) < 1
- </select>
- <select id="selectOrderTwoGoods" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT og.*,
- o.user_id
- FROM `order` o
- LEFT JOIN order_goods og on o.order_sn = og.order_sn
- where 1 = 1
- and og.`status` = 1
- and og.refund_status in (0, 1, 3)
- and og.pay_status in (2, 3, 4)
- AND (SELECT COUNT(1)
- FROM inform_user iu
- where iu.user_id = o.user_id and iu.goods_id = og.goods_id and system_status = 3) < 1
- </select>
- <select id="sendGoods" resultMap="OrderGoodsResultVo">
- SELECT og.*,
- o.user_id
- FROM `order` o
- LEFT JOIN order_goods og on o.order_sn = og.order_sn
- where 1 = 1
- and og.`status` = 1
- and og.refund_status in (0, 1, 3)
- and og.pay_status in (2, 3, 4)
- and (SELECT COUNT(1)
- FROM user_exam_goods ueg
- where ueg.user_id = o.user_id and og.goods_id = ueg.goods_id) < 1
- and (SELECT COUNT(1)
- FROM exam_number en
- LEFT JOIN exam_number_goods eng on en.exam_number_id = eng.exam_number_id
- where eng.goods_id = og.goods_id
- and en.`status` = 1) > 0
- </select>
- <select id="getBuyGoodsHistory" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo" resultType="Long">
- SELECT ifnull(count(*), 0) num
- 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.`status` = 1
- AND og.pay_status > 1
- AND og.refund_status != 2
- </select>
- <select id="getBuyGoodsReadyPay" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultType="Long">
- SELECT ifnull(count(*), 0) num
- 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 o.order_status = 0
- </select>
- <select id="rebuyInfo" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT og.order_sn,
- g.goods_name,
- cg.class_name
- FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN class_grade cg ON og.grade_id = cg.grade_id
- LEFT JOIN `order` o on og.order_sn = o.order_sn
- LEFT JOIN class_grade_user cgu ON cgu.grade_id = cg.grade_id and cgu.order_goods_id = og.order_goods_id and cgu.user_id = #{userId}
- WHERE o.user_id = #{userId}
- and og.goods_id = #{goodsId}
- and og.pay_status in (2, 3, 4)
- and og.order_goods_id != #{orderGoodsId}
- and cgu.period_plush = 1
- </select>
- <select id="gradeGoods" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT og.*
- FROM order_goods og
- LEFT JOIN `order` o on og.order_sn = o.order_sn
- WHERE o.user_id = #{userId}
- and og.grade_id = #{gradeId}
- and og.order_goods_id = #{orderGoodsId}
- and og.pay_status in (2, 3, 4)
- and og.refund_status !=2
- </select>
- <select id="selectCanInvoiceList" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- og.*,
- g.`code`,
- g.goods_name,
- g.goods_type,
- g.cover_url
- FROM
- order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN `order` o ON o.order_sn = og.order_sn
- WHERE
- 1 = 1
- AND og.order_goods_id NOT IN (
- SELECT
- oio.order_goods_id
- FROM
- order_invoice oi
- LEFT JOIN order_invoice_order oio ON oi.invoice_id = oio.invoice_id
- WHERE
- oi.period_status IN ( 1, 3 ) and oi.user_id = #{userId} and oi.status != -1 and oio.order_goods_id is not NULL)
- <if test="refundStatusList != null and refundStatusList.size()!=0 ">
- AND og.refund_status in
- <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="goodsId != null and goodsId != ''">
- AND og.goods_id = #{goodsId}
- </if>
- <if test="userId != null">
- AND o.user_id = #{userId}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND og.order_sn = #{orderSn}
- </if>
- <if test="payStatusList != null and payStatusList.size()!=0 ">
- AND og.pay_status in
- <foreach collection="payStatusList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderGoodsIds != null and orderGoodsIds.size()!=0 ">
- AND og.order_goods_id in
- <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectBuyGoodsUserList" parameterType="com.zhongzheng.modules.order.bo.OrderGoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT DISTINCT u.user_id,
- u.realname
- FROM order_goods og
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- LEFT JOIN `user` u ON o.user_id = u.user_id
- WHERE og.`status` = 1
- -- AND og.refund_status IN (0, 1, 3)
- AND og.refund_status IN (0,3)
- AND og.pay_status IN (2, 3, 4)
- AND og.goods_id = #{goodsId}
- </select>
- <select id="listLiveGoodsList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- g.*,
- o.user_id,
- o.order_sn,
- og.service_start_time,
- og.service_end_time,
- og.order_goods_id,
- u.realname,
- u.id_card,
- u.user_id,
- un.live_num as join_live_num,
- un.study_duration as see_time
- 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 `user` u ON u.user_id = o.user_id
- LEFT JOIN (SELECT
- usr.order_goods_id,
- count( DISTINCT usr.section_id ) live_num,
- SUM( usr.study_duration ) study_duration
- FROM
- user_study_record usr
- LEFT JOIN course_section cs ON usr.section_id = cs.section_id
- WHERE
- cs.section_type IN ( 2, 3 )
- GROUP BY
- usr.order_goods_id)un on un.order_goods_id = og.order_goods_id
- WHERE
- 1 = 1
- AND g.goods_type = 6
- AND og.pay_status IN ( 2, 3, 4 )
- -- AND og.refund_status IN (0,3,1)
- AND og.refund_status IN (0,3)
- <if test="goodsId != null and goodsId != ''">
- AND og.goods_id = #{goodsId}
- </if>
- <if test="searchKey != null and searchKey != ''">
- and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%') or
- u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%'))
- </if>
- ORDER BY og.create_time DESC
- </select>
- <select id="listGoodsUserLive" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- g.*,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- o.user_id,
- og.create_time as order_create_time,
- og.service_start_time,
- og.service_end_time,
- og.order_goods_id
- FROM
- order_goods og
- LEFT JOIN goods g on g.goods_id =og.goods_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 `order` o on o.order_sn = og.order_sn
- WHERE
- 1 = 1
- AND g.goods_type = 6
- AND o.user_id=#{userId}
- AND og.`status` =1
- and og.pay_status in (2,3,4)
- -- AND og.refund_status in (0,3,1)
- AND og.refund_status in (0,3)
- <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>
- ORDER BY og.create_time DESC
- </select>
- <select id="listUserVideoLive" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- g.*,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- cb.goods_learning_order,
- o.user_id,
- og.create_time as order_create_time,
- og.service_start_time,
- og.service_end_time,
- og.order_goods_id,
- og.seven_year as order_year,
- og.grade_id,
- (SELECT m.category_name FROM major m where m.id = g.major_id) as major_name,
- (SELECT
- COUNT( m.id )
- FROM
- goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
- where
- m.type in (1,3)
- and c.goods_id = g.goods_id) as exam_num,
- -- (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN
- -- class_grade_goods cgg on cgg.goods_id
- -- = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = og.grade_id and ubr.order_goods_id = og.order_goods_id and ubr.user_id =
- -- o.user_id and ubr.current_status = 1) as record_num,
- (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id LEFT JOIN exam_apply_user eau on eau.apply_id = ea.apply_id where eag.goods_id = g.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
- us.exam_status as sub_exam_status,
- us.performance as sub_performance,
- us.`result` as sub_result,
- us.subscribe_id,
- us.apply_site_start_time as sub_apply_site_start_time,
- us.apply_site_end_time as sub_apply_site_end_time,
- us.apply_site_exam_time as sub_apply_site_exam_time,
- (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
- og.study_count as user_study_count,
- (SELECT `status` from user_profile where user_id = o.user_id and goods_id = g.goods_id and current_status = 1 and type_status = 1 and order_goods_id = og.order_goods_id limit 1 ) as profile_status,
- (SELECT change_status from user_profile where user_id = o.user_id and goods_id = g.goods_id and current_status = 1 and type_status = 1 and order_goods_id = og.order_goods_id limit 1 ) as profile_change_status,
- (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id) as study_status
- FROM
- order_goods og
- LEFT JOIN goods g on g.goods_id =og.goods_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 `order` o on o.order_sn = og.order_sn
- LEFT JOIN (SELECT * from user_subscribe where subscribe_id in (SELECT MAX(subscribe_id) from user_subscribe where user_id = #{userId} and subscribe_status = 1 GROUP BY order_goods_id)) us on us.order_goods_id = og.order_goods_id
- WHERE
- 1 = 1
- AND g.goods_type in (1,6)
- AND o.user_id=#{userId}
- AND og.`status` =1
- and og.pay_status in (2,3,4)
- -- AND og.refund_status in (0,3,1)
- AND og.refund_status in (0,3)
- <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>
- ORDER BY og.create_time DESC
- </select>
- <select id="listUserSubjectGoods" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo"
- resultMap="OrderGoodsResultVo">
- SELECT
- og.goods_id,
- og.grade_id,
- og.order_sn,
- g.business_id,
- g.subject_ids,
- cg.class_status,
- cg.class_start_time,
- cg.class_end_time,
- cg.class_name,
- g.goods_name,
- og.goods_price,
- og.seven_year as order_year,
- og.goods_real_price
- 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 class_grade cg ON og.grade_id = cg.grade_id
- WHERE
- o.user_id = #{userId}
- AND og.`status` =1
- and og.pay_status in (2,3,4)
- AND og.refund_status in (0,3,1)
- <if test="businessId != null and businessId != ''">
- AND g.business_id = #{businessId}
- </if>
- <if test="subjectId != null and subjectId != ''">
- AND FIND_IN_SET(#{subjectId},g.subject_ids)
- </if>
- </select>
- <select id="selectBuyUserList" parameterType="java.lang.Long" resultMap="OrderGoodsResultVo">
- SELECT og.*,
- o.user_id
- FROM order_goods og
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- LEFT JOIN mock_major_subject_goods mmsg ON og.goods_id = mmsg.goods_id
- WHERE og.refund_status != 2
- and og.pay_status in (2,3,4)
- and og.`status` = 1
- and mmsg.mock_major_subject_id = #{mockMajorSubjectId}
- </select>
- <select id="getLiveList" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.vo.CourseLiveVo">
- SELECT
- *
- FROM
- (
- SELECT
- gc.course_id AS courseId,
- og.order_goods_id AS orderGoodsId,
- g.goods_id AS goodsId,
- cm.menu_id AS chapterId,
- '' AS moduleId,
- ct.*
- 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
- INNER 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 cs ON cm.menu_id = cs.chapter_id
- LEFT JOIN course_section ct ON cs.section_id = ct.section_id
- WHERE
- o.user_id = #{userId}
- AND og.pay_status IN ( 2, 3, 4 )
- -- AND og.refund_status != 2
- AND og.refund_status IN (0,3)
- AND og.STATUS = 1
- AND o.`status` = 1
- AND g.`status` = 1
- AND g.goods_type = 6
- AND cm.type = 2
- AND ct.section_type = 2 UNION ALL
- SELECT
- gc.course_id AS courseId,
- og.order_goods_id AS orderGoodsId,
- g.goods_id AS goodsId,
- '' AS chapterId,
- '' AS moduleId,
- ct.*
- 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
- INNER 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 ct ON cm.menu_id = ct.section_id
- WHERE
- o.user_id = #{userId}
- AND og.pay_status IN ( 2, 3, 4 )
- -- AND og.refund_status != 2
- AND og.refund_status IN (0,3)
- AND og.STATUS = 1
- AND o.`status` = 1
- AND g.`status` = 1
- AND g.goods_type = 6
- AND cm.type = 3
- AND ct.section_type = 2 UNION ALL
- SELECT
- gc.course_id AS courseId,
- og.order_goods_id AS orderGoodsId,
- g.goods_id AS goodsId,
- cmc.chapter_id AS chapterId,
- cmc.module_id AS moduleId,
- ct.*
- 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
- INNER 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 ct ON ccs.section_id = ct.section_id
- WHERE
- o.user_id = #{userId}
- AND og.pay_status IN ( 2, 3, 4 )
- -- AND og.refund_status != 2
- AND og.refund_status IN (0,3)
- AND og.STATUS = 1
- AND o.`status` = 1
- AND g.`status` = 1
- AND g.goods_type = 6
- AND cm.type = 1
- AND ct.section_type = 2
- ) a
- ORDER BY
- a.live_start_time ASC
- </select>
- <select id="getBuyNotStudyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderGoodsResultVo">
- SELECT
- o.user_id,
- any_value (og.order_goods_id) order_goods_id,
- any_value (g.goods_id) goods_id,
- any_value (og.grade_id) grade_id,
- any_value (cg.sys_user_id) sys_user_id,
- any_value (g.goods_name) goods_name
- 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
- LEFT JOIN ( SELECT count(*) study_num, usr.user_id, usr.grade_id FROM user_study_record usr GROUP BY usr.user_id, usr.grade_id ) r ON r.grade_id = og.grade_id
- AND r.user_id = o.user_id
- WHERE
- og.refund_status != 2
- AND og.pay_status IN ( 2, 3, 4 )
- AND og.`status` = 1
- AND g.goods_type = 1
- AND r.study_num IS NULL
- AND og.create_time > #{startTime}
- AND #{endTime} >= og.create_time
- GROUP BY o.user_id
- </select>
- <select id="getLongNotStudyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderGoodsResultVo">
- SELECT
- o.user_id,
- any_value (og.order_goods_id) order_goods_id,
- any_value (g.goods_id) goods_id,
- any_value (og.grade_id) grade_id,
- any_value (cg.sys_user_id) sys_user_id,
- any_value (g.goods_name) goods_name
- 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
- LEFT JOIN ( SELECT MAX(usr.update_time) last_time, usr.user_id, usr.grade_id FROM user_study_record usr GROUP BY usr.user_id, usr.grade_id ) r ON r.grade_id = og.grade_id
- AND r.user_id = o.user_id
- WHERE
- og.refund_status != 2
- AND og.pay_status IN ( 2, 3, 4 )
- AND og.`status` = 1
- AND g.goods_type = 1
- AND r.last_time > #{startTime}
- AND #{endTime} >= r.last_time
- GROUP BY o.user_id
- </select>
- <select id="getGoodsSectionList" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.goods.vo.GoodsSectionListVo">
- SELECT
- *
- FROM
- (
- SELECT
- gc.goods_id,
- gc.sort AS gcSort,
- cm.sort AS cmSort,
- cmd.sort AS cmdSort,
- ccs.sort AS ccsSort,
- cs.sort AS csSort,
- cm.course_id,
- cmd.module_id,
- ccs.chapter_id,
- cs.section_id,
- cs.`name` as sectionName
- FROM
- goods_course gc
- LEFT JOIN course_menu cm ON gc.course_id = cm.course_id
- LEFT JOIN course_module_chapter cmd ON cm.menu_id = cmd.module_id
- LEFT JOIN course_chapter_section ccs ON cmd.chapter_id = ccs.chapter_id
- LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
- WHERE
- gc.goods_id = #{goodsId}
- AND cm.type = 1
- UNION ALL
- SELECT
- gc.goods_id,
- gc.sort AS gcSort,
- cm.sort AS cmSort,
- NULL AS cmdSort,
- ccs.sort AS ccsSort,
- cs.sort AS csSort,
- cm.course_id,
- 0 AS module_id,
- ccs.chapter_id,
- cs.section_id,
- cs.`name` as sectionName
- FROM
- goods_course gc
- 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
- gc.goods_id = #{goodsId}
- AND cm.type = 2
- UNION ALL
- SELECT
- gc.goods_id,
- gc.sort AS gcSort,
- cm.sort AS cmSort,
- NULL AS cmdSort,
- NULL AS ccsSort,
- cs.sort AS csSort,
- cm.course_id,
- 0 AS module_id,
- 0 AS chapter_id,
- cs.section_id,
- cs.`name` as sectionName
- 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.type = 3
- ) a
- ORDER BY
- a.gcSort,
- cmSort,
- cmdSort,
- ccsSort,
- csSort
- </select>
- <select id="getOrderByGoods" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
- SELECT
- *
- 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
- WHERE
- og.`status` = 1
- AND o.`status` = 1
- AND g.`status` = 1
- AND og.refund_status != 2
- AND og.pay_status IN ( 2, 3, 4 )
- AND o.user_id = #{userId}
- AND g.goods_id = #{goodsId}
- LIMIT 1
- </select>
- <resultMap id="getlist" type="com.zhongzheng.modules.top.goods.vo.TopOldOrderGoodsListVo">
- <result property="orderGoodsId" column="order_goods_id"/>
- <result property="gradeId" column="grade_id"/>
- <result property="goodsId" column="goods_id"/>
- <result property="userId" column="user_id" />
- <result property="userName" column="realname" />
- <result property="userCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="userPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="goodsName" column="goods_name"/>
- <result property="goodsType" column="goods_type"/>
- <result property="subjectIds" column="subject_ids"/>
- <result property="businessName" column="business_name"/>
- <result property="goodsPrice" column="goods_price"/>
- <result property="goodsRealPrice" column="goods_real_price"/>
- <result property="checkStatus" column="check_status"/>
- <result property="goodsYear" column="goods_year"/>
- <result property="divideType" column="divide_type"/>
- <result property="divideRate" column="divide_rate"/>
- <result property="divideMoney" column="divide_money"/>
- </resultMap>
- <select id="listByOrderSn" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderGoodsQuery" resultMap="getlist">
- SELECT
- og.order_goods_id,
- og.grade_id,
- og.goods_id,
- u.user_id,
- u.realname,
- u.id_card,
- u.telphone,
- g.goods_name,
- g.goods_type,
- g.subject_ids,
- CONCAT( cb.business_name, cpt.project_name ) AS business_name,
- og.goods_price,
- og.goods_real_price,
- og.goods_year,
- og.divide_type,
- og.divide_rate,
- og.divide_money,
- 1 as check_status
- FROM
- order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_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 `order` o ON og.order_sn = o.order_sn
- LEFT JOIN `user` u ON o.user_id = u.user_id
- WHERE
- og.order_sn = #{orderSn}
- AND og.`status` = 1
- -- AND og.refund_status != 2
- -- AND og.pay_status IN ( 2, 3, 4 )
- <if test="userCard != null and userCard != ''">
- AND u.id_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="userName != null and userName != ''">
- AND u.realname LIKE CONCAT( '%', #{userName}, '%' )
- </if>
- </select>
- <select id="getBusinessById" parameterType="java.lang.Long" resultType="java.lang.String">
- SELECT
- CONCAT( '学校业务', cet.education_name, cb.business_name, cpt.project_name ) AS businessName
- FROM
- order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_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
- WHERE
- og.`status` = 1
- AND og.order_goods_id = #{orderGoodsId}
- </select>
- <select id="getApplyOrderGoods" parameterType="map" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
- SELECT
- og.*
- FROM
- order_goods og
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- WHERE
- og.`status` = 1
- AND og.refund_status != 2
- AND og.pay_status IN ( 2, 3, 4 )
- AND og.goods_id in
- <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- AND o.`status` = 1
- AND o.user_id = #{userId}
- </select>
- <select id="getSevenLastOne" parameterType="map" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
- SELECT
- og.*
- FROM
- order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- WHERE
- og.`status` = 1
- AND og.refund_status != 2
- AND o.user_id = #{userId}
- AND og.pay_status IN ( 2, 3, 4 )
- AND g.project_id = #{projectId}
- AND og.seven_class_status = 3
- AND og.seven_year = #{sevenYear}
- AND og.seven_class_version > 0
- ORDER BY og.seven_class_version DESC
- LIMIT 1
- </select>
- <select id="countOrderGoodsByYear" parameterType="map" resultType="java.lang.Long">
- SELECT
- COUNT( og.order_goods_id )
- FROM
- order_goods og
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- WHERE
- og.refund_status != 2
- AND og.pay_status IN ( 2, 3, 4 )
- AND og.`status` = 1
- AND o.`status` = 1
- AND o.user_id = #{userId}
- AND og.goods_id = #{goodsId}
- AND og.seven_year = #{sevenYear}
- AND og.service_start_time <![CDATA[ <= ]]> UNIX_TIMESTAMP()
- AND og.service_end_time <![CDATA[ >= ]]> UNIX_TIMESTAMP()
- </select>
- <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
- SELECT
- *
- FROM
- order_goods
- WHERE
- order_goods_id = #{orderGoodsId}
- </select>
- <select id="getMailList" parameterType="com.zhongzheng.modules.order.bo.MailOrderBo" resultType="com.zhongzheng.modules.order.vo.MailOrderVo">
- SELECT
- order_sn,
- mail_status,
- consignee,
- consignee_phone,
- consignee_site,
- mail_remark
- FROM
- `order`
- WHERE
- `status` = 1
- AND order_type = 5
- <if test="orderSn != null and orderSn != ''">
- AND order_sn = #{orderSn}
- </if>
- <if test="mailStatus != null">
- AND mail_status = #{mailStatus}
- </if>
- order by create_time DESC
- </select>
- <select id="sendTenOrderGoods" parameterType="java.lang.Long" resultMap="OrderGoodsResultVo">
- SELECT
- og.*,o.user_id
- 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 inform_remind_business irb on irb.business_id = g.business_id
- LEFT JOIN class_grade_user cgu on cgu.order_goods_id = og.order_goods_id
- where 1=1
- and irb.remind_id =#{remindId}
- and og.status = 1
- and cgu.period_status in (0,-1)
- AND og.service_end_time BETWEEN ( unix_timestamp(now()) + 864000) AND (unix_timestamp(now()) + 950400)
- </select>
- <select id="listByNotTenant" resultType="com.zhongzheng.modules.order.domain.OrderGoods">
- SELECT og.* FROM order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- WHERE og.`status` = 1
- AND (( og.course_num IS NULL OR og.course_num = 0 ) AND ( og.exam_num IS NULL OR og.exam_num = 0 ))
- AND og.refund_status != 2
- AND og.pay_status != 1
- AND g.goods_type = 1
- </select>
- <update id="upBatchNumById" parameterType="com.zhongzheng.modules.order.domain.OrderGoods">
- UPDATE order_goods SET course_num = #{courseNum}, exam_num = #{examNum} WHERE order_goods_id = #{orderGoodsId}
- </update>
- <select id="listRepByOrderSn" parameterType="com.zhongzheng.modules.top.order.bo.TopOrderRepGoodsQueryBo"
- resultType="com.zhongzheng.modules.top.order.vo.TopOldOrderRepDetailVo">
- SELECT
- og.order_sn,
- og.order_goods_id,
- og.goods_id,
- u.user_id,
- u.realname as userName,
- u.sex,
- u.id_card,
- g.goods_name,
- og.goods_price,
- og.goods_year,
- m.category_name as majorName,
- og.refund_status,
- og.finish_time,
- og.publicity_time,
- og.acquire_time,
- (SELECT ogr.refund_time FROM order_goods_refund ogr WHERE ogr.order_goods_id = og.order_goods_id AND ogr.`status` = 1 AND ogr.period_status = 3 LIMIT 1) AS refund_time
- FROM
- order_goods og
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN `order` o ON og.order_sn = o.order_sn
- LEFT JOIN `user` u ON o.user_id = u.user_id
- LEFT JOIN major m ON g.major_id = m.id
- WHERE
- og.order_sn = #{orderSn}
- AND og.`status` = 1
- </select>
- <select id="getHandleStudyList" parameterType="com.zhongzheng.modules.order.bo.HandleStudyQuery" resultType="com.zhongzheng.modules.order.vo.HandleStudyVo">
- SELECT
- o.order_sn ,
- FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,
- u.realname AS userName,
- AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS userCard,
- AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS userTel,
- u.company_name,
- g.goods_name,
- g.seven_year,
- CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
- m.category_name,
- cg.class_name,
- CASE
- WHEN cg.class_status = 1 THEN '已开班'
- WHEN cg.class_status = 0 THEN '未开班'
- ELSE '其他' END AS classStart,
- FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classTime,
- CONCAT((
- ((SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = og.grade_id and ubr.order_goods_id = og.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) +
- (
- SELECT
- COUNT( DISTINCT course_id, module_id, chapter_id, section_id )
- FROM
- user_study_record
- WHERE
- current_status = 1
- AND grade_id = og.grade_id
- AND order_goods_id = og.order_goods_id
- AND user_id = o.user_id
- AND status = 1
- AND goods_id = og.goods_id
- ))
- ),"/",og.course_num + og.exam_num) AS studySchedule
- FROM
- order_handle oh
- LEFT JOIN `order` o ON oh.handle_order_sn = o.handle_order_sn
- 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 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
- LEFT JOIN `user` u ON o.user_id = u.user_id
- LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
- LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
- WHERE
- 1=1
- AND og.pay_status != 1
- AND og.refund_status != 2
- AND o.`status` = 1
- AND og.`status` = 1
- AND cgu.`status` = 1
- AND oh.create_user_id = #{userId}
- <if test="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="userName != null and userName != ''">
- AND u.realname LIKE CONCAT('%',#{userName},'%')
- </if>
- <if test="userCard != null and userCard != ''">
- AND AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') = #{userCard}
- </if>
- <if test="userTel != null and userTel != ''">
- AND AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') = #{userTel}
- </if>
- </select>
- </mapper>
|