123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- <?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.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_real_price),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.*,s.id_card,s.telphone,s.realname AS createUsername
- FROM
- order_handle oh left join user s on oh.create_user_id=s.user_id
- where 1=1
- <if test="idCard != null and idCard != ''">
- AND s.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="telphone != null and telphone != ''">
- AND s.telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
- </if>
- <if test="createUsername != null and createUsername != ''">
- AND s.realname = #{createUsername}
- </if>
- <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.pay_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND oh.pay_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 == 1">
- AND (SELECT
- oi.period_status
- 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
- AND (oi.wash_status is null or oi.wash_status = 1)
- order by oi.create_time DESC limit 1
- ) = 1
- </if>
- <if test="invoiceStatus != null and invoiceStatus == 2">
- AND (SELECT
- oi.invoice_status
- 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
- AND (oi.wash_status is null or oi.wash_status = 1)
- order by oi.create_time DESC limit 1
- ) = 2
- </if>
- <if test="invoiceStatus != null and invoiceStatus == 3">
- AND (SELECT
- oi.period_status
- 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
- AND (oi.wash_status is null or oi.wash_status = 1)
- order by oi.create_time DESC limit 1
- ) = 2
- </if>
- <if test="invoiceStatus != null and invoiceStatus == 4">
- AND (SELECT
- oi.invoice_status
- 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
- AND (oi.wash_status is null or oi.wash_status = 1)
- order by oi.create_time DESC limit 1
- ) = 4
- </if>
- <if test="invoiceStatus != null and invoiceStatus == 5">
- 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
- 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,
- <if test="handleOrderSn != null">
- oh.pay_status,
- </if>
- og.goods_id
- FROM
- `order` o
- <if test="handleOrderSn != null">
- LEFT JOIN order_handle oh ON o.handle_order_sn = oh.handle_order_sn
- </if>
- 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
- 1=1
- <if test="handleOrderSn != null">
- AND o.handle_order_sn = #{handleOrderSn}
- </if>
- <if test="inputOrderSn != null">
- AND o.input_order_sn = #{inputOrderSn}
- </if>
- <if test="refundStatus != null">
- AND og.refund_status = #{refundStatus}
- </if>
- </select>
- <select id="selectOverTimeOrderList" parameterType="com.zhongzheng.modules.order.bo.OrderHandleQueryBo" resultType="com.zhongzheng.modules.order.vo.OrderHandleOverVo">
- SELECT oh.*
- FROM
- order_handle oh
- where 1=1 and oh.pay_status = 0 and #{overTime} > oh.over_time
- </select>
- <select id="getorderTotalPrice" parameterType="java.lang.String" resultType="java.math.BigDecimal">
- SELECT
- SUM(o.pay_price)
- FROM
- `order` o
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- WHERE
- o.handle_order_sn = #{handleOrderSn}
- AND og.pay_status != 1
- AND og.refund_status != 2
- AND o.`status` = 1
- AND og.`status` = 1
- </select>
- </mapper>
|