| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 | <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.zhongzheng.modules.order.mapper.OrderHandleMapper">    <resultMap type="com.zhongzheng.modules.order.domain.OrderHandle" id="OrderHandleResult">        <result property="id" column="id"/>        <result property="handleOrderSn" column="handle_order_sn"/>        <result property="createUsername" column="create_username"/>        <result property="status" column="status"/>        <result property="createUserId" column="create_user_id"/>        <result property="createTime" column="create_time"/>        <result property="updateTime" column="update_time"/>        <result property="educationTypeId" column="education_type_id"/>        <result property="businessId" column="business_id"/>        <result property="projectId" column="project_id"/>        <result property="inputFrom" column="input_from"/>        <result property="payStatus" column="pay_status"/>        <result property="goodsType" column="goods_type"/>    </resultMap>    <resultMap type="com.zhongzheng.modules.order.vo.OrderHandleGoodsVo" id="OrderHandleGoodsVoResult">        <result property="realname" column="realname"/>        <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>        <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>        <result property="goodsName" column="goods_name"/>        <result property="year" column="year"/>        <result property="goodsRealPrice" column="goods_real_price"/>        <result property="orderGoodsId" column="order_goods_id"/>        <result property="userId" column="user_id"/>        <result property="gradeId" column="grade_id"/>        <result property="goodsId" column="goods_id"/>        <result property="subjectNames" column="subject_names"/>    </resultMap>    <select id="selectOrderList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultType="com.zhongzheng.modules.order.vo.OrderHandleVo">        SELECT  u.*,        (select count( DISTINCT o.user_id ) from `order` o  where  u.handle_order_sn = o.handle_order_sn) user_num,        (select count( DISTINCT og.goods_id ) from `order` o  LEFT JOIN order_goods og ON o.order_sn = og.order_sn where  u.handle_order_sn = o.handle_order_sn) goods_num,        cet.education_name education_name,        cpt.project_name project_name,        cb.business_name business_name,        (select IFNULL(sum(og.goods_received),0) from order_goods og LEFT JOIN `order` o on o.order_sn = og.order_sn  where o.handle_order_sn = u.handle_order_sn and og.refund_status = 2) goods_refund        FROM (SELECT        oh.*        FROM        order_handle oh        where 1=1        <if test="businessId != null and businessId != ''">            AND oh.business_id = #{businessId}        </if>        <if test="educationTypeId != null and educationTypeId != ''">            AND oh.education_type_id = #{educationTypeId}        </if>        <if test="searchKey != null and searchKey != ''">            AND (select count(*) from `order` o left JOIN `user` u  on o.user_id = u.user_id left JOIN order_goods og on o.order_sn = og.order_sn LEFT JOIN goods g on og.goods_id = g.goods_id where  o.handle_order_sn = oh.handle_order_sn and (u.realname like concat('%', #{searchKey}, '%') or (u.id_card = #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}) or (g.goods_name like concat('%', #{searchKey}, '%'))))>0        </if>        <if test="goodsType != null">            AND oh.goods_type = #{goodsType}        </if>        <if test="createUserId != null">            AND oh.create_user_id = #{createUserId}        </if>        <if test="handleOrderSn != null and handleOrderSn != ''">            AND oh.handle_order_sn = #{handleOrderSn}        </if>        <if test="refundStatus != null">            AND oh.refund_status = #{refundStatus}        </if>        <if test="startTime != null and startTime != ''">            AND oh.check_time >= #{startTime}        </if>        <if test="endTime != null and endTime != ''">            AND oh.check_time <= #{endTime}        </if>        <if test="payStatus != null">            AND oh.pay_status = #{payStatus}        </if>)u        LEFT JOIN course_education_type cet ON u.education_type_id = cet.id        LEFT JOIN course_project_type cpt ON u.project_id = cpt.id        LEFT JOIN course_business cb ON u.business_id = cb.id        where 1=1        <if test="invoiceStatus != null and invoiceStatus != ''">        AND          (SELECT            COUNT(oi.invoice_id)            FROM            order_invoice_order oio            LEFT JOIN order_invoice oi ON oio.invoice_id = oi.invoice_id            WHERE            oio.order_sn = u.handle_order_sn            <if test="invoiceStatus != null and invoiceStatus == 1">                AND oi.period_status = 1            </if>            <if test="invoiceStatus != null and invoiceStatus == 2">                AND oi.invoice_status = 2            </if>            <if test="invoiceStatus != null and invoiceStatus == 3">                AND oi.period_status = 2            </if>            AND (oi.wash_status is null or oi.wash_status = 1)           ) > 0        </if>        ORDER BY u.create_time DESC    </select>    <select id="selectOrderGoodsList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultMap="OrderHandleGoodsVoResult">        SELECT            u.realname,            u.id_card,            u.telphone,            g.goods_name,            g.`year`,            (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names,            og.goods_real_price,            og.order_goods_id,            o.user_id,            og.grade_id,            og.goods_id,            og.pay_status        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        WHERE            o.handle_order_sn = #{handleOrderSn}            <if test="refundStatus != null and invoiceStatus == 0">                AND og.refund_status = 1            </if>    </select></mapper>
 |