123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?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.OrderInputMapper">
- <resultMap type="com.zhongzheng.modules.order.domain.OrderInput" id="OrderInputResult">
- <result property="id" column="id"/>
- <result property="inputOrderSn" column="input_order_sn"/>
- <result property="createUsername" column="create_username"/>
- <result property="status" column="status"/>
- <result property="createSysUserId" column="create_sys_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="oldOrderSn" column="old_order_sn"/>
- <result property="inputFrom" column="input_from"/>
- </resultMap>
- <resultMap type="com.zhongzheng.modules.order.vo.OrderInputVo" id="OrderInputVoResult">
- <result property="id" column="id"/>
- <result property="inputOrderSn" column="input_order_sn"/>
- <result property="createUsername" column="create_username"/>
- <result property="status" column="status"/>
- <result property="createSysUserId" column="create_sys_user_id"/>
- <result property="createTime" column="create_time"/>
- <result property="educationTypeId" column="education_type_id"/>
- <result property="businessId" column="business_id"/>
- <result property="projectId" column="project_id"/>
- <result property="educationName" column="education_name"/>
- <result property="projectName" column="project_name"/>
- <result property="businessName" column="business_name"/>
- <result property="userNum" column="user_num"/>
- <result property="goodsNum" column="goods_num"/>
- <result property="goodsReceived" column="goods_received"/>
- <result property="orderPrice" column="order_price"/>
- <result property="payPrice" column="pay_price"/>
- <result property="realname" column="realname"/>
- <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="goodsId" column="goods_id"/>
- <result property="goodsName" column="goods_name"/>
- <result property="orderSn" column="order_sn"/>
- <result property="userId" column="user_id"/>
- <result property="orderFrom" column="order_from"/>
- <result property="orderGoodsId" column="order_goods_id"/>
- <result property="goodsRefund" column="goods_refund"/>
- <result property="goodsType" column="goods_type"/>
- <result property="goodsRealPrice" column="goods_real_price"/>
- <result property="oldOrderSn" column="old_order_sn"/>
- <result property="inputFrom" column="input_from"/>
- </resultMap>
- <select id="selectList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
- SELECT u.input_order_sn,
- u.order_from,
- any_value (u.old_order_sn ) old_order_sn,
- any_value(g.goods_type) goods_type,
- count( DISTINCT u.user_id ) user_num,
- count( DISTINCT og.goods_id ) goods_num,
- any_value ( cet.education_name ) education_name,
- any_value ( cpt.project_name ) project_name,
- any_value ( 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.input_order_sn = u.input_order_sn and og.refund_status = 2) goods_refund,
- IFNULL(sum( og.goods_received ),0) goods_received,
- IFNULL(sum(og.goods_price ),0) order_price,
- IFNULL(sum(og.goods_real_price),0) pay_price,
- any_value ( u.create_username ) create_username,
- any_value ( u.create_time ) create_time FROM (SELECT
- oi.*,
- o.user_id,
- sum( o.order_price ) order_price,
- sum( o.pay_price ) pay_price,
- o.order_sn,
- any_value(o.order_from) order_from
- FROM
- order_input oi
- LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
- where 1=1
- <if test="orderFrom != null and orderFrom != ''">
- AND o.order_from = #{orderFrom}
- </if>
- <if test="businessId != null and businessId != ''">
- AND oi.business_id = #{businessId}
- </if>
- <if test="inputOrderSn != null and inputOrderSn != ''">
- AND oi.input_order_sn = #{inputOrderSn}
- </if>
- <if test="inputOrderSns != null and inputOrderSns.size()!=0">
- AND oi.input_order_sn in
- <foreach collection="inputOrderSns" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="educationTypeId != null and educationTypeId != ''">
- AND oi.education_type_id = #{educationTypeId}
- </if>
- <if test="oldOrderSn != null and oldOrderSn != ''">
- AND oi.old_order_sn = #{oldOrderSn}
- </if>
- <if test="searchKey != null and searchKey != ''">
- AND (oi.create_username like concat('%', #{searchKey}, '%') or oi.input_order_sn = #{searchKey} or (select
- count(*) from `user` us where us.user_id = o.user_id AND us.realname like concat('%', #{searchKey}, '%')
- )>0)
- </if>
- <if test="startTime != null and startTime != ''">
- AND oi.create_time >= #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND #{endTime} >= oi.create_time
- </if>
- GROUP BY oi.id,o.order_sn,o.user_id)u LEFT JOIN order_goods og ON u.order_sn = og.order_sn
- 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
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- where 1=1
- <if test="goodsType != null">
- AND g.goods_type = #{goodsType}
- </if>
- <if test="salesman != null and salesman != ''">
- AND og.salesman like concat('%', #{salesman}, '%')
- </if>
- GROUP BY
- u.input_order_sn
- ORDER BY create_time DESC
- </select>
- <select id="getInfo" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
- SELECT
- oi.input_order_sn,
- count( DISTINCT o.user_id ) user_num,
- count( DISTINCT og.goods_id ) goods_num,
- any_value ( cet.education_name ) education_name,
- any_value ( cpt.project_name ) project_name,
- any_value ( 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.input_order_sn = oi.input_order_sn and og.refund_status = 2) goods_refund,
- IFNULL(sum( og.goods_received ),0) goods_received,
- IFNULL(sum( og.goods_real_price ),0) goods_real_price,
- IFNULL(sum( o.order_price ),0) order_price,
- IFNULL(sum( o.pay_price ),0) pay_price,
- any_value ( oi.create_username ) create_username,
- any_value ( oi.create_time ) create_time,
- any_value ( oi.project_id ) project_id,
- any_value ( oi.business_id ) business_id,
- any_value ( oi.education_type_id ) education_type_id
- FROM
- order_input oi
- LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
- LEFT JOIN order_goods og ON o.order_sn = og.order_sn
- LEFT JOIN course_education_type cet ON oi.education_type_id = cet.id
- LEFT JOIN course_project_type cpt ON oi.project_id = cpt.id
- LEFT JOIN course_business cb ON oi.business_id = cb.id
- where 1=1
- AND oi.input_order_sn = #{inputOrderSn}
- GROUP BY
- oi.input_order_sn
- </select>
- <select id="getUserList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
- SELECT
- o.user_id,
- u.realname,
- u.id_card
- FROM
- order_input oi
- LEFT JOIN `order` o ON oi.input_order_sn = o.input_order_sn
- LEFT JOIN `user` u ON o.user_id = u.user_id
- WHERE
- 1 = 1
- AND oi.input_order_sn = #{inputOrderSn}
- GROUP BY
- o.user_id
- </select>
- <select id="getUserGoodsList" parameterType="com.zhongzheng.modules.order.bo.OrderInputQueryBo" resultMap="OrderInputVoResult">
- SELECT
- o.user_id,
- g.goods_id,
- g.goods_name,
- o.order_sn,
- o.order_from,
- og.order_goods_id
- FROM
- order_input oi
- LEFT JOIN `order` o ON oi.input_order_sn = o.input_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
- WHERE
- 1 = 1
- AND oi.input_order_sn = #{inputOrderSn}
- and o.user_id = #{userId}
- </select>
- </mapper>
|