123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296 |
- <?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.OrderMapper">
- <resultMap type="com.zhongzheng.modules.order.domain.Order" id="OrderResult">
- <result property="orderId" column="order_id"/>
- <result property="orderSn" column="order_sn"/>
- <result property="userId" column="user_id"/>
- <result property="orderPrice" column="order_price"/>
- <result property="orderGeneral" column="order_general"/>
- <result property="orderStatus" column="order_status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="payTime" column="pay_time"/>
- <result property="payType" column="pay_type"/>
- <result property="transid" column="transid"/>
- <result property="cancelTime" column="cancel_time"/>
- <result property="finishTime" column="finish_time"/>
- <result property="orderType" column="order_type"/>
- <result property="payPrice" column="pay_price"/>
- <result property="chargingType" column="charging_type"/>
- <result property="orderFrom" column="order_from"/>
- <result property="createUsername" column="create_username"/>
- <result property="createSysUserId" column="create_sys_user_id"/>
- <result property="inputOrderSn" column="input_order_sn"/>
- <result property="payStatus" column="pay_status"/>
- <result property="handleOrderSn" column="handle_order_sn"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.order.vo.OrderListVo" id="OrderResultVo">
- <result property="orderId" column="order_id"/>
- <result property="orderSn" column="order_sn"/>
- <result property="userId" column="user_id"/>
- <result property="orderPrice" column="order_price"/>
- <result property="orderGeneral" column="order_general"/>
- <result property="orderStatus" column="order_status"/>
- <result property="createTime" column="create_time"/>
- <result property="payTime" column="pay_time"/>
- <result property="payType" column="pay_type"/>
- <result property="transid" column="transid"/>
- <result property="cancelTime" column="cancel_time"/>
- <result property="finishTime" column="finish_time"/>
- <result property="orderType" column="order_type"/>
- <result property="payPrice" column="pay_price"/>
- <result property="chargingType" column="charging_type"/>
- <result property="orderFrom" column="order_from"/>
- <result property="status" column="status"/>
- <result property="periodStatus" column="period_status"/>
- <result property="goodsName" column="goods_name"/>
- <result property="goodsId" column="goods_id"/>
- <result property="year" column="year"/>
- <result property="coverUrl" column="cover_url"/>
- <result property="code" column="code"/>
- <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
- <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="goodsPrice" column="goods_price"/>
- <result property="goodsRealPrice" column="goods_real_price"/>
- <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="realname" column="realname"/>
- <result property="companyName" column="company_name"/>
- <result property="goodsReceived" column="goods_received"/>
- <result property="refundStatus" column="refund_status"/>
- <result property="payStatus" column="pay_status"/>
- <result property="orderGoodsId" column="order_goods_id"/>
- <result property="periodPlush" column="period_plush"/>
- <result property="goodsPayStatus" column="goods_pay_status"/>
- <result property="goodsType" column="goods_type"/>
- <result property="invoiceStatus" column="invoice_status"/>
- <result property="serviceStartTime" column="service_start_time"/>
- <result property="serviceEndTime" column="service_end_time"/>
- <result property="handleOrderSn" column="handle_order_sn"/>
- <result property="offlineRefundSign" column="offline_refund_sign"/>
- </resultMap>
- <select id="getGradePeriod" parameterType="Map" resultType="integer">
- SELECT
- cgu.period_plush
- FROM
- order_goods og
- LEFT JOIN class_grade_user cgu ON og.order_goods_id = cgu.order_goods_id
- AND cgu.user_id = #{userId} where og.order_goods_id = #{orderGoodsId}
- AND cgu.`status` = 1 limit 1
- </select>
- <select id="selectListByBo" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
- SELECT
- o.*,
- g.goods_id,
- g.goods_name,
- g.year,
- g.cover_url,
- g.code,
- g.goods_type,
- og.goods_price,
- og.rebuy_order_goods_id,
- og.order_goods_id,
- og.goods_real_price,
- og.offline_refund_sign,
- u.telphone,
- u.realname,
- u.id_card,
- u.company_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- s.school_name,
- m.category_name,
- og.goods_received,
- og.refund_status,
- og.pay_status as goods_pay_status,
- (select cgu.period_plush from class_grade_user cgu where cgu.grade_id = og.grade_id and cgu.order_goods_id = og.order_goods_id and cgu.user_id = o.user_id limit 1 ) period_plush,
- (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
- oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
- 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 o.user_id = u.user_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
- WHERE 1=1
- <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="schoolId != null and schoolId != ''">
- AND g.school_id = #{schoolId}
- </if>
- <if test="majorId != null and majorId != ''">
- AND g.major_id = #{majorId}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="orderStatus != null ">
- AND o.order_status in
- <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="status != null ">
- AND o.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderGoodsStatus == 1">
- AND og.pay_status in (2,3,4) AND og.refund_status != 2
- </if>
- <if test="startTime != null">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= o.create_time
- </if>
- <if test="payStatus != null">
- AND o.pay_status = #{payStatus}
- </if>
- <if test="goodsPayStatus != null">
- AND og.pay_status = #{goodsPayStatus}
- </if>
- <if test="refundStatus != null">
- AND og.refund_status = #{refundStatus}
- </if>
- <if test="goodsType != null">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="userId != null">
- AND u.user_id = #{userId}
- AND og.pay_status in (2,3,4)
- </if>
- <if test="inputOrderSn != null">
- AND o.input_order_sn = #{inputOrderSn}
- </if>
- <if test="companyName != null and companyName != ''">
- AND u.company_name like concat('%', #{companyName}, '%')
- </if>
- <if test="searchKey != null and searchKey != ''">
- AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
- </if>
- <if test="orderGoodsIds != null ">
- AND og.order_goods_id in
- <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderFroms != null and orderFroms.size()!=0">
- AND o.order_from in
- <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- ORDER BY o.order_id DESC
- </select>
- <select id="selectDangAnOrderList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
- SELECT
- o.*,
- g.goods_id,
- g.goods_name,
- g.year,
- g.cover_url,
- g.code,
- g.goods_type,
- og.goods_price,
- og.rebuy_order_goods_id,
- og.order_goods_id,
- og.goods_real_price,
- u.telphone,
- u.realname,
- u.id_card,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- og.goods_received,
- og.refund_status,
- og.pay_status as goods_pay_status,
- og.service_start_time,
- og.service_end_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 o.user_id = u.user_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 1=1
- <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="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="orderStatus != null ">
- AND o.order_status in
- <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="status != null ">
- AND o.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderGoodsStatus == 1">
- AND og.pay_status in (2,3,4) AND og.refund_status != 2
- </if>
- <if test="startTime != null">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= o.create_time
- </if>
- <if test="payStatus != null">
- AND o.pay_status = #{payStatus}
- </if>
- <if test="goodsPayStatus != null">
- AND og.pay_status = #{goodsPayStatus}
- </if>
- <if test="refundStatus != null">
- AND og.refund_status = #{refundStatus}
- </if>
- <if test="goodsType != null">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="userId != null">
- AND u.user_id = #{userId}
- </if>
- <if test="inputOrderSn != null">
- AND o.input_order_sn = #{inputOrderSn}
- </if>
- <if test="searchKey != null and searchKey != ''">
- AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
- </if>
- <if test="orderGoodsIds != null ">
- AND og.order_goods_id in
- <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderFroms != null ">
- AND o.order_from in
- <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- ORDER BY o.order_id DESC
- </select>
- <select id="selectRebuyList" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
- SELECT
- o.*,
- g.goods_id,
- g.goods_name,
- g.year,
- g.cover_url,
- g.code,
- g.goods_type,
- og.goods_price,
- og.rebuy_order_goods_id,
- og.order_goods_id,
- og.goods_real_price,
- u.telphone,
- u.realname,
- u.id_card,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- s.school_name,
- m.category_name,
- og.goods_received,
- og.refund_status,
- og.pay_status as goods_pay_status,
- cgu.period_plush,
- (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
- oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
- 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 o.user_id = u.user_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_goods og2 ON og.rebuy_order_goods_id = og2.order_goods_id
- LEFT JOIN class_grade_user cgu on cgu.grade_id = og2.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id
- WHERE 1=1
- AND og.rebuy_order_goods_id >0
- AND cgu.period_plush = 1
- <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="schoolId != null and schoolId != ''">
- AND g.school_id = #{schoolId}
- </if>
- <if test="majorId != null and majorId != ''">
- AND g.major_id = #{majorId}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="orderStatus != null ">
- AND o.order_status in
- <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="status != null ">
- AND o.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="startTime != null">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= o.create_time
- </if>
- <if test="payStatus != null">
- AND o.pay_status = #{payStatus}
- </if>
- <if test="goodsPayStatus != null">
- AND og.pay_status = #{goodsPayStatus}
- </if>
- <if test="refundStatus != null">
- AND og.refund_status = #{refundStatus}
- </if>
- AND g.goods_type = 1
- <if test="userId != null">
- AND u.user_id = #{userId}
- AND og.pay_status in (2,3,4)
- </if>
- <if test="inputOrderSn != null">
- AND o.input_order_sn = #{inputOrderSn}
- </if>
- <if test="searchKey != null and searchKey != ''">
- AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or u.id_card = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
- </if>
- <if test="orderGoodsIds != null ">
- AND og.order_goods_id in
- <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderFroms != null ">
- AND o.order_from in
- <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- ORDER BY o.order_id DESC
- </select>
- <select id="selectUserClass" parameterType="map" resultType="integer">
- SELECT
- COUNT(cg.grade_id)
- FROM
- class_grade_goods cgg
- LEFT JOIN class_grade_user cgu ON cgu.grade_id = cgg.grade_id
- LEFT JOIN class_grade cg ON cg.grade_id = cgg.grade_id
- WHERE cgg.goods_id =#{goodsId}
- and cgu.user_id=#{userId}
- and cg.`status` =1
- </select>
- <select id="selectListApp" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
- SELECT
- o.*
- FROM
- `order` o
- where 1=1
- <if test="userId != null">
- AND o.user_id = #{userId}
- </if>
- <if test="orderStatus != null">
- AND o.order_status in
- <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="status != null">
- AND o.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="startTime != null">
- AND o.create_time >= #{startTime}
- </if>
- ORDER BY o.order_id DESC
- </select>
- <select id="queryByOrderSn" parameterType="String" resultType="Integer">
- SELECT order_status from `order` where order_sn = #{orderSn}
- </select>
- <select id="getConsoleStudentNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
- SELECT
- count( DISTINCT o.user_id )
- 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
- og.pay_status IN ( 2, 3, 4 )
- AND og.refund_status != 2
- <if test="businessId != null">
- AND g.business_id = #{businessId}
- </if>
- <if test="startTime != null">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= og.create_time
- </if>
- </select>
- <select id="getConsoleInfoUpdateNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
- SELECT
- count( DISTINCT uu.id )
- 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_update uu on o.user_id = uu.user_id
- WHERE
- og.pay_status IN ( 2, 3, 4 )
- AND og.refund_status != 2
- <if test="businessId != null">
- AND g.business_id = #{businessId}
- </if>
- <if test="startTime != null">
- AND uu.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= uu.create_time
- </if>
- </select>
- <select id="getConsoleOrder" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="OrderResultVo">
- SELECT
- o.order_from,g.goods_type
- 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 1 = 1
- <!-- og.pay_status IN ( 2, 3, 4 )
- AND og.refund_status != 2 -->
- <if test="businessId != null">
- AND g.business_id = #{businessId}
- </if>
- <if test="startTime != null">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= og.create_time
- </if>
- </select>
- <select id="getConsoleRebuyNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
- SELECT
- COUNT(og.order_goods_id)
- 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 order_goods og2 ON og.rebuy_order_goods_id = og2.order_goods_id
- LEFT JOIN class_grade_user cgu on cgu.grade_id = og2.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id
- WHERE 1=1
- AND og.pay_status IN ( 2, 3, 4 )
- AND og.rebuy_order_goods_id >0
- AND cgu.period_plush = 1
- <if test="businessId != null">
- AND g.business_id = #{businessId}
- </if>
- <if test="startTime != null">
- AND og.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= og.create_time
- </if>
- </select>
- <select id="queryDetailByOrderSn" parameterType="String" resultMap="OrderResultVo">
- SELECT * from `order` where order_sn = #{orderSn}
- </select>
- <select id="getUserGoods" resultType="java.lang.Long" parameterType="java.lang.Long">
- SELECT DISTINCT og.goods_id
- FROM `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- WHERE o.user_id = #{userId}
- and o.order_status = 1
- and o.pay_status in (2,3)
- and og.status = 1
- </select>
- <select id="queryBusinessFullNameBySn" resultType="java.lang.String" parameterType="java.lang.String">
- SELECT DISTINCT
- CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name
- FROM
- order_goods og
- INNER JOIN goods g ON og.goods_id = g.goods_id
- INNER JOIN course_education_type cet ON g.education_type_id = cet.id
- INNER JOIN course_project_type cpt ON g.project_id = cpt.id
- INNER JOIN course_business cb ON g.business_id = cb.id
- AND og.order_sn = #{orderSn}
- AND og.`status` = 1
- AND og.pay_status IN (2,3,4)
- </select>
- <select id="getSevenGrade" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
- SELECT cg.* FROM class_grade cg
- WHERE cg.`status` = 1 AND (
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
- <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- LIMIT 1
- </select>
- <select id="getSevenGradeNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
- SELECT cg.* FROM class_grade cg
- WHERE cg.`status` = 1 AND (
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
- <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- LIMIT 1
- </select>
- <select id="getStudeCountByCode" resultType="java.lang.Integer" parameterType="java.lang.String">
- SELECT SUM(
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) as num FROM class_grade cg
- WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
- </select>
- <select id="getStudeCountByCodeNoTenant" resultType="java.lang.Integer" parameterType="java.lang.String">
- SELECT SUM(
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) as num FROM class_grade cg
- WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
- </select>
- <select id="getOrderInvoiceList" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderInvoiceVo" parameterType="java.lang.String">
- SELECT
- tnm.create_time as applyUpTime,
- tnm.`status` as invoiceStatus,
- tnm.update_time as invoiceTime,
- tnm.oss_pdf_url as ossPdfUrl,
- tnm.content
- FROM
- order_goods og
- LEFT JOIN order_invoice_order oio ON og.order_goods_id = oio.order_goods_id
- LEFT JOIN order_invoice oi ON oio.invoice_id = oi.invoice_id
- LEFT JOIN top_nuo_mplatform_log tnm ON oi.serial_number = tnm.order_no
- WHERE og.order_sn = #{orderSn}
- </select>
- <select id="getClassNameByGoods" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
- SELECT
- cg.*
- FROM
- class_grade cg
- LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
- LEFT JOIN goods g ON cgg.goods_id = g.goods_id
- WHERE
- cg.`status` = 1
- AND g.education_type_id = #{educationTypeId}
- AND g.project_id = #{projectId}
- AND g.business_id = #{businessId}
- AND major_id = #{majorId}
- AND (
- (
- SELECT
- COUNT( DISTINCT cgu.user_id )
- FROM
- class_grade_user cgu
- WHERE
- cgu.grade_id = cg.grade_id
- AND cgu.`status` = 1
- AND cgu.change_grade = 0
- ) + ( SELECT COUNT( DISTINCT cgut.user_id ) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) <![CDATA[ < ]]> cg.student_upper
- </select>
- <select id="getClassNameByGoodsNotTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
- SELECT
- cg.*
- FROM
- class_grade cg
- LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
- LEFT JOIN goods g ON cgg.goods_id = g.goods_id
- WHERE
- cg.`status` = 1
- AND g.education_type_id = #{educationTypeId}
- AND g.project_id = #{projectId}
- AND g.business_id = #{businessId}
- AND major_id = #{majorId}
- AND (
- (
- SELECT
- COUNT( DISTINCT cgu.user_id )
- FROM
- class_grade_user cgu
- WHERE
- cgu.grade_id = cg.grade_id
- AND cgu.`status` = 1
- AND cgu.change_grade = 0
- ) + ( SELECT COUNT( DISTINCT cgut.user_id ) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) <![CDATA[ < ]]> cg.student_upper
- </select>
- <select id="getBusinessNameBySn" resultType="java.lang.String" parameterType="java.lang.String">
- SELECT
- CONCAT( cet.education_name, '-', cb.business_name, cpt.project_name ) AS 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
- WHERE
- og.`status` = 1
- AND og.order_sn = #{orderSn}
- </select>
- <select id="getOrderGoodsByBo" resultType="java.lang.Long" parameterType="java.lang.Long">
- SELECT
- COUNT(*)
- 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 != 1
- AND og.refund_status != 2
- AND UNIX_TIMESTAMP(
- NOW()) <![CDATA[ >= ]]> og.service_start_time
- AND UNIX_TIMESTAMP(
- NOW()) <![CDATA[ <= ]]> og.service_end_time
- </select>
- <select id="getCountByGoods" resultType="java.lang.Long" parameterType="java.lang.Long">
- SELECT
- COUNT(*)
- FROM
- goods g
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- WHERE
- INSTR( cpt.project_name, '施工现场专业人员' )
- AND g.goods_id IN
- <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </select>
- <!-- <select id="exportNew" resultType="com.zhongzheng.modules.order.vo.OrderExportNewVo"-->
- <!-- parameterType="com.zhongzheng.modules.order.bo.OrderExportNewBo">-->
- <!-- SELECT-->
- <!-- FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,-->
- <!-- u.realname AS realname,-->
- <!-- AES_DECRYPT( UNHEX( u.id_card ), 'base20230213zzkj' ) AS idCard,-->
- <!-- AES_DECRYPT( UNHEX( u.telphone ), 'base20230213zzkj' ) AS telphone,-->
- <!-- u.company_name AS companyName,-->
- <!-- m.category_name AS majorName,-->
- <!-- g.seven_year AS goodsYear,-->
- <!-- CASE-->
- <!-- WHEN og.`status` = 1 THEN-->
- <!-- '否'-->
- <!-- WHEN og.`status` = 0 THEN-->
- <!-- '是' ELSE '其他'-->
- <!-- END AS orderStatus-->
- <!-- 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-->
- <!-- LEFT JOIN goods g ON og.goods_id = g.goods_id-->
- <!-- LEFT JOIN major m ON g.major_id = m.id-->
- <!-- WHERE-->
- <!-- og.refund_status != 2-->
- <!-- AND og.pay_status != 1-->
- <!-- <if test="orderSn != null and orderSn != ''">-->
- <!-- AND o.order_sn = #{orderSn}-->
- <!-- </if>-->
- <!-- <if test="orderStartTime != null and orderStartTime != ''">-->
- <!-- AND og.create_time <![CDATA[ >= ]]> #{orderStartTime}-->
- <!-- </if>-->
- <!-- <if test="orderEndTime != null and orderEndTime != ''">-->
- <!-- AND og.create_time <![CDATA[ <= ]]> #{orderEndTime}-->
- <!-- </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="companyName != null and companyName != ''">-->
- <!-- AND u.company_name = #{companyName}-->
- <!-- </if>-->
- <!-- </select>-->
- <select id="exportNew" resultType="com.zhongzheng.modules.order.vo.OrderExportNewVo"
- parameterType="com.zhongzheng.modules.order.bo.OrderExportNewBo">
- SELECT
- o.order_sn,
- FROM_UNIXTIME( og.create_time, '%Y-%m-%d %H:%i:%s' ) AS orderTime,
- u.realname,
- AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS idCard,
- AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS telphone,
- u.company_name AS companyName,
- g.goods_name AS goodsName,
- g.seven_year AS sevenYear,
- CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
- m.category_name AS categoryName,
- cg.class_name AS className,
- CASE
- WHEN cg.class_status = 1 THEN '已开班'
- WHEN cg.class_status = 0 THEN '未开班'
- ELSE '其他' END AS classStatus,
- FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classEndTime,
- CASE
- WHEN o.order_status = 0 THEN '待支付'
- WHEN o.order_status = 1 THEN '已支付'
- WHEN o.order_status = -1 OR o.order_status = -2 THEN '已关闭'
- WHEN o.order_status = 3 OR o.order_status = 4 THEN '已退款'
- ELSE '其他' END AS orderStatus,
- 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` 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 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.`status` = 1
- AND o.input_order_sn IS NULL
- <if test="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="orderSnList != null and orderSnList.size()!=0">
- AND o.order_sn in
- <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderStartTime != null and orderStartTime != ''">
- AND og.create_time <![CDATA[ >= ]]> #{orderStartTime}
- </if>
- <if test="orderEndTime != null and orderEndTime != ''">
- AND og.create_time <![CDATA[ <= ]]> #{orderEndTime}
- </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="companyName != null and companyName != ''">
- AND u.company_name = #{companyName}
- </if>
- ORDER BY og.create_time DESC
- </select>
- <select id="getSevenOrder" parameterType="com.zhongzheng.modules.order.bo.RepetitionOrderBo"
- resultType="com.zhongzheng.modules.order.vo.RepetitionOrderVo">
- SELECT
- u.user_id,
- og.order_goods_id,
- g.goods_id,
- o.order_sn
- 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
- 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.pay_status != 1
- AND og.refund_status != 2
- AND g.goods_type = 1
- AND INSTR( CONCAT( cet.education_name, cpt.project_name ), "考前培训施工现场专业人员" )
- <if test="userId != null and userId != ''">
- AND u.user_id = #{userId}
- </if>
- </select>
- <select id="getGoodsIdByBusiness" parameterType="com.zhongzheng.modules.order.bo.GoodsByBusinessQuery" resultType="java.lang.Long">
- SELECT
- g.goods_id
- FROM
- goods g
- LEFT JOIN course_business cb ON g.business_id = cb.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 major m ON g.major_id = m.id
- WHERE
- g.`status` = 1
- AND g.goods_status = 1
- AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), #{businessName} )
- AND m.category_name = #{majorName}
- <if test="year != null and year != ''">
- AND g.seven_year = #{year}
- </if>
- ORDER BY g.create_time DESC
- LIMIT 1
- </select>
- <select id="getGradeByBusiness" parameterType="com.zhongzheng.modules.order.bo.CommonGradeBo" resultType="com.zhongzheng.modules.order.vo.CommonGradeVo">
- SELECT
- cg.grade_id,
- cg.class_name AS gradeName,
- CASE
- WHEN cg.class_status = 1 THEN '已开班'
- WHEN cg.class_status = 0 THEN '未开班'
- ELSE '其他' END AS gradeStatus,
- FROM_UNIXTIME( cg.class_start_time, '%Y-%m-%d %H:%i:%s' ) AS startTime,
- FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS endTime,
- cg.student_upper AS upperNum,
- ((
- SELECT
- COUNT(*)
- FROM
- class_grade_user cgu
- WHERE
- cgu.grade_id = cg.grade_id
- AND cgu.`status` = 1
- ) + ( SELECT COUNT(*) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )) AS studyNum
- FROM
- class_grade cg
- LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
- LEFT JOIN goods g ON cgg.goods_id = g.goods_id
- LEFT JOIN course_business cb ON g.business_id = cb.id
- LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
- LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN major m ON g.major_id = m.id
- WHERE
- cg.`status` = 1
- AND g.`status` = 1
- AND g.goods_status = 1
- AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), #{businessName})
- AND m.category_name = #{majorName}
- ORDER BY cg.create_time DESC
- </select>
- <select id="getOfflineOrderList" parameterType="com.zhongzheng.modules.order.bo.OfflineOrderBo" resultType="com.zhongzheng.modules.order.vo.OfflineOrderVo">
- SELECT
- o.order_sn,
- og.create_time,
- u.user_id,
- u.realname AS userName,
- AES_DECRYPT(UNHEX(u.telphone),'base20230213zzkj') AS userPhone,
- AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') AS userCard,
- u.company_name,
- g.goods_name,
- CONCAT(cet.education_name,'-',cb.business_name,'-',cpt.project_name) AS businessName,
- og.goods_price AS orderPrice,
- o.check_status,
- ea.apply_name AS examApplyName
- FROM
- `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- LEFT JOIN `user` u ON o.user_id = u.user_id
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- LEFT JOIN course_business cb ON g.business_id = cb.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 exam_apply ea ON og.exam_sign = ea.apply_id
- WHERE
- o.order_type = 6
- AND o.order_from = 12
- <if test="userName != null and userName != ''">
- AND u.realname like concat('%', #{userName}, '%')
- </if>
- <if test="checkStatus != null and checkStatus != ''">
- AND o.check_status = #{checkStatus}
- </if>
- ORDER BY og.create_time DESC
- </select>
- <select id="getCommonOrderInfo" parameterType="com.zhongzheng.modules.order.bo.CommonOrderInfoBo" resultType="com.zhongzheng.modules.order.vo.CommonOrderInfoVo">
- 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 userPhone,
- u.company_name AS companyName,
- g.goods_name AS goodsName,
- g.seven_year AS sevenYear,
- CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
- m.category_name AS majorName,
- cg.class_name AS className,
- CASE
- WHEN cg.class_status = 1 THEN '已开班'
- WHEN cg.class_status = 0 THEN '未开班'
- ELSE '其他' END AS classStatus,
- FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classEndTime,
- 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` 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 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 o.tenant_id = #{tenantId}
- AND og.pay_status != 1
- AND og.refund_status != 2
- AND o.`status` = 1
- AND og.`status` = 1
- AND cgu.`status` = 1
- <if test="orderSnList != null and orderSnList.size()!=0">
- AND o.order_sn in
- <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="selectWithoutListByBo" parameterType="com.zhongzheng.modules.order.bo.OrderQueryBo" resultMap="OrderResultVo">
- SELECT
- o.*,
- g.goods_id,
- g.goods_name,
- g.year,
- g.cover_url,
- g.code,
- g.goods_type,
- og.goods_price,
- og.rebuy_order_goods_id,
- og.order_goods_id,
- og.goods_real_price,
- og.offline_refund_sign,
- u.telphone,
- u.realname,
- u.id_card,
- u.company_name,
- cet.education_name,
- cpt.project_name,
- cb.business_name,
- s.school_name,
- m.category_name,
- og.goods_received,
- og.refund_status,
- og.pay_status as goods_pay_status,
- (select cgu.period_plush from class_grade_user cgu where cgu.grade_id = og.grade_id and cgu.order_goods_id = og.order_goods_id and cgu.user_id = o.user_id limit 1 ) period_plush,
- (SELECT oi.invoice_status FROM order_invoice oi LEFT JOIN order_invoice_order oio ON oio.invoice_id = oi.invoice_id WHERE
- oio.order_goods_id = og.order_goods_id AND oi.period_status != 2 limit 1) invoice_status
- 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 o.user_id = u.user_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
- WHERE 1=1
- AND o.order_type = 3
- AND og.status = 1
- <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="schoolId != null and schoolId != ''">
- AND g.school_id = #{schoolId}
- </if>
- <if test="majorId != null and majorId != ''">
- AND g.major_id = #{majorId}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND o.order_sn = #{orderSn}
- </if>
- <if test="orderStatus != null ">
- AND o.order_status in
- <foreach collection="orderStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="status != null ">
- AND o.status in
- <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderGoodsStatus == 1">
- AND og.pay_status in (2,3,4) AND og.refund_status != 2
- </if>
- <if test="startTime != null">
- AND o.create_time >= #{startTime}
- </if>
- <if test="endTime != null">
- AND #{endTime} >= o.create_time
- </if>
- <if test="payStatus != null">
- AND o.pay_status = #{payStatus}
- </if>
- <if test="goodsPayStatus != null">
- AND og.pay_status = #{goodsPayStatus}
- </if>
- <if test="refundStatus != null">
- AND og.refund_status = #{refundStatus}
- </if>
- <if test="goodsType != null">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="userId != null">
- AND u.user_id = #{userId}
- AND og.pay_status in (2,3,4)
- </if>
- <if test="inputOrderSn != null">
- AND o.input_order_sn = #{inputOrderSn}
- </if>
- <if test="companyName != null and companyName != ''">
- AND u.company_name like concat('%', #{companyName}, '%')
- </if>
- <if test="searchKey != null and searchKey != ''">
- AND (u.realname like concat('%', #{searchKey}, '%') or o.order_sn = #{searchKey} or AES_DECRYPT(UNHEX(u.id_card),'base20230213zzkj') = #{searchKey} or g.goods_name like concat('%', #{searchKey}, '%'))
- </if>
- <if test="orderGoodsIds != null ">
- AND og.order_goods_id in
- <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="orderFroms != null and orderFroms.size()!=0">
- AND o.order_from in
- <foreach collection="orderFroms" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- ORDER BY o.order_id DESC
- </select>
- <select id="getUserStudyCondition" parameterType="com.zhongzheng.modules.order.bo.UserStudyConditionBo" resultType="com.zhongzheng.modules.order.vo.UserStudyConditionVo">
- 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 userPhone,
- u.password_aes AS userPassword,
- u.company_name AS companyName,
- g.goods_name AS goodsName,
- g.seven_year AS sevenYear,
- CONCAT(cet.education_name,cb.business_name,cpt.project_name) AS businessName,
- m.category_name AS majorName,
- cg.class_name AS className,
- CASE
- WHEN cg.class_status = 1 THEN '已开班'
- WHEN cg.class_status = 0 THEN '未开班'
- ELSE '其他' END AS classStatus,
- CASE
- WHEN cgu.official_status = 1 THEN '是'
- ELSE '否' END AS officialStatus,
- CASE
- WHEN cgu.period_plush = 1 THEN '是'
- ELSE '否' END AS periodPlush,
- FROM_UNIXTIME( cg.class_end_time, '%Y-%m-%d %H:%i:%s' ) AS classEndTime,
- 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` 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 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
- <if test="tenantId != null and tenantId != ''">
- AND o.tenant_id = #{tenantId}
- </if>
- <if test="userCard != null and userCard != ''">
- AND UPPER(AES_DECRYPT(UNHEX(id_card),'base20230213zzkj')) = UPPER(#{userCard})
- </if>
- <if test="userName != null and userName != ''">
- AND u.realname = #{userName}
- </if>
- <if test="sevenYear != null and sevenYear != ''">
- AND og.seven_year = #{sevenYear}
- </if>
- <if test="companyName != null and companyName != ''">
- AND u.company_name = #{companyName}
- </if>
- <if test="businessName != null and businessName != ''">
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName})
- </if>
- <if test="majorName != null and majorName != ''">
- AND m.category_name = #{majorName}
- </if>
- </select>
- <select id="getOrderSnByXY" parameterType="com.zhongzheng.modules.order.vo.UserStudyConditionVo" resultType="java.lang.String">
- SELECT
- o.order_sn
- 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 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 o.tenant_id = 867735392558919680
- <if test="userCard != null and userCard != ''">
- AND UPPER(AES_DECRYPT(UNHEX(id_card),'base20230213zzkj')) = UPPER(#{userCard})
- </if>
- <if test="userName != null and userName != ''">
- AND u.realname = #{userName}
- </if>
- <if test="sevenYear != null and sevenYear != ''">
- AND og.seven_year = #{sevenYear}
- </if>
- <if test="companyName != null and companyName != ''">
- AND u.company_name = #{companyName}
- </if>
- <if test="businessName != null and businessName != ''">
- AND INSTR(CONCAT(cet.education_name,cb.business_name,cpt.project_name),#{businessName})
- </if>
- <if test="majorName != null and majorName != ''">
- AND m.category_name = #{majorName}
- </if>
- LIMIT 1
- </select>
- <select id="getOrderSnByYW" parameterType="java.lang.String" resultType="java.lang.String">
- SELECT
- ( SELECT too.order_sn FROM top_old_order too WHERE too.input_order_sn = o.input_order_sn AND too.`status` = 1 LIMIT 1 ) AS order_sn
- FROM
- `order` o
- WHERE
- o.order_sn = #{orderSn}
- AND o.input_order_sn IS NOT NULL
- </select>
- </mapper>
|