123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?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.miaxis.order.mapper.OrderInfoMapper">
- <resultMap type="OrderInfo" id="OrderInfoResult">
- <result property="id" column="id" />
- <result property="goodsId" column="goods_id" />
- <result property="goodsName" column="goods_name" />
- <result property="goodsType" column="goods_type" />
- <result property="userId" column="user_id" />
- <result property="userName" column="user_name" />
- <result property="logincode" column="logincode" />
- <result property="outTradeNo" column="out_trade_no" />
- <result property="outRefundNo" column="out_refund_no" />
- <result property="tradeType" column="trade_type" />
- <result property="successTime" column="success_time" />
- <result property="payType" column="pay_type" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="isShare" column="is_share" />
- <result property="dqbh" column="dqbh" />
- <result property="dqmc" column="dqmc" />
- <result property="school" column="school" />
- <result property="schoolName" column="school_name" />
- <result property="schoolCommission" column="school_commission" />
- <result property="phoneType" column="phone_type" />
- <result property="refundReason" column="refund_reason" />
- </resultMap>
- <sql id="selectOrderInfoVo">
- select * from order_info
- </sql>
- <select id="selectOrderInfoList" parameterType="OrderInfo" resultMap="OrderInfoResult">
- <include refid="selectOrderInfoVo"/>
- <where>
- <if test="isShare != null"> and is_share = #{isShare }</if>
- <if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
- <if test="goodsType != null"> and goods_type = #{goodsType }</if>
- <if test="schoolName != null and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
- <if test="logincode != null and logincode != ''"> and logincode = #{logincode} </if>
- <if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
- <if test="outRefundNo != null and outRefundNo != ''"> and out_refund_no = #{outRefundNo}</if>
- <if test="tradeType != null and tradeType != ''"> and trade_type = #{tradeType}</if>
- <if test="successTime != null "> and success_time = #{successTime}</if>
- <if test="payType != null "> and pay_type = #{payType}</if>
- </where>
- order by success_time desc
- </select>
- <select id="getByOutTradeNo" parameterType="string" resultType="com.miaxis.order.domain.OrderInfo">
- select * from order_info where out_trade_no =#{outTradeNo}
- </select>
- <!--
- <select id="selectSchoolOrderInfoList" parameterType="com.miaxis.order.dto.QuerySchoolOrderListDTO" resultType="com.miaxis.order.vo.QuerySchoolOrderListVo">
- select
- school,
- school_name,
- IFNULL(sum(school_commission),0) as school_commission,
- IFNULL(sum(total),0) as order_total,
- COUNT(DISTINCT logincode) as people_count,
- COUNT(id) as order_count
- <if test="isShare==1 and dqbh !='2108' ">
- ,
- IFNULL(COUNT(DISTINCT logincode),0)*49*100 as activation_commission,
- (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission)) as subsidy_bak,
- (case
- when (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission)) <![CDATA[ <= ]]> 0 then 0
- when (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission)) <![CDATA[ > ]]> 0 then (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission))
- else 0 end) as subsidy
- </if>
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="dqbh != null and dqbh != ''">
- and dqbh = #{dqbh}
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != '' ">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- group by school,school_name
- </select>
- -->
- <select id="selectSchoolOrderInfoList" parameterType="com.miaxis.order.dto.QuerySchoolOrderListDTO" resultType="com.miaxis.order.vo.QuerySchoolOrderListVo">
- SELECT *,
- CASE
- WHEN subsidy_bak <![CDATA[ <= ]]> 0 THEN 0
- WHEN subsidy_bak <![CDATA[ > ]]> 0 THEN subsidy_bak
- ELSE 0
- END AS subsidy
- FROM (
- SELECT
- school,
- school_name,
- IFNULL(SUM(fz_price), 0) AS fzMoney,
- IFNULL(SUM(school_commission), 0) AS school_commission,
- IFNULL(SUM(total), 0) AS order_total,
- COUNT(DISTINCT logincode) AS people_count,
- COUNT(id) AS order_count,
- IFNULL(COUNT(DISTINCT CASE WHEN dqbh NOT IN ('2108') THEN logincode END), 0) * 49 * 100 AS activation_commission,
- IFNULL(COUNT(DISTINCT CASE WHEN dqbh NOT IN ('2108') THEN logincode END), 0) * 49 * 100 - SUM(school_commission) AS subsidy_bak
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="dqbh != null and dqbh != ''">
- and dqbh = #{dqbh}
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != '' ">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- group by school,school_name) as subquery
- </select>
- <select id="selectSchoolOrderInfoExcel" resultType="com.miaxis.order.vo.QuerySchoolOrderListVo">
- select
- school,
- school_name,
- IFNULL(sum(school_commission)/100,0) as school_commission,
- IFNULL(sum(total)/100,0) as order_total,
- COUNT(DISTINCT logincode) as people_count,
- COUNT(id) as order_count
- <if test="isShare==1">
- ,
- IFNULL(COUNT(DISTINCT logincode),0)*49 as activation_commission,
- (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission/100)) as subsidy_bak,
- (case
- when (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission)/100) <![CDATA[ <= ]]> 0 then 0
- when (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission)/100) <![CDATA[ > ]]> 0 then (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission)/100)
- else 0 end) as subsidy
- </if>
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="dqbh != null and dqbh != ''">
- and dqbh = #{dqbh}
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime !='' ">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime !=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- group by school,school_name
- </select>
- <select id="getTotalMoney" resultType="java.lang.Integer">
- select
- IFNULL(sum(total),0) as orderTotal
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="dqbh != null and dqbh != ''">
- and dqbh = #{dqbh}
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime != ''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime != ''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- </select>
- <select id="getCommissionMoney" resultType="java.lang.Integer">
- select
- IFNULL(sum(school_commission),0) as commission
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="dqbh != null and dqbh != ''">
- and dqbh = #{dqbh}
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime!=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime!=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- </select>
- <select id="getFzMoney" resultType="java.lang.Integer">
- select
- IFNULL(sum(fz_price),0) as fzMoney
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="dqbh != null and dqbh != ''">
- and dqbh = #{dqbh}
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime!=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime!=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- </select>
- <select id="selectSchoolOrderDetailed" resultType="com.miaxis.order.domain.OrderInfo">
- select * from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime!=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime!=''">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- order by success_time desc
- </select>
- <select id="selectSchoolOrderDetailedExcel" resultType="com.miaxis.order.vo.QuerySchoolOrderDetailedVo">
- select
- school_name,
- goods_name,user_name,logincode,out_trade_no,
- case when trade_type = 1 then '支付成功'
- when trade_type = 2 then '支付失败'
- when trade_type = 3 then '已退款' else '未知' end as trade_type,
- case when phone_type = 1 then '苹果' else '安卓' end as phone_type,
- IFNULL(total/100,0) as total,IFNULL(school_commission/100,0) as school_commission,
- success_time,
- case when is_share = 1 then '是' else '否' end as is_share
- from order_info
- <where>
- <if test="isShare != null">
- and is_share = #{isShare }
- </if>
- <if test="tradeType != null">
- and trade_type = #{tradeType }
- </if>
- <if test="schoolName != null and schoolName != ''">
- and school_name like concat('%', #{schoolName}, '%')
- </if>
- <if test="startTime != null and startTime != '' ">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
- </if>
- <if test="endTime != null and endTime!='' ">
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
- </if>
- </where>
- order by success_time desc
- </select>
- <select id="getIncomeList" resultType="com.miaxis.order.vo.OrderIncomeVo">
- select
- (select sum(total) from order_info o where DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> #{startTime}
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') )<![CDATA[ <= ]]> #{endTime}
- and trade_type = 1) as total,
- IFNULL(COUNT(DISTINCT logincode),0)*49 as activation_commission,
- sum(school_commission)/100 from order_info o
- where DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> #{startTime}
- and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ <= ]]> #{endTime}
- and is_share = 1
- and trade_type = 1
- </select>
- <select id="getByOutTradeNo" parameterType="string" resultType="com.miaxis.order.domain.OrderInfo">
- select * from order_info where out_trade_no =#{outTradeNo}
- </select>
- <select id="selectOrderInfoByWaitProfit" resultType="com.miaxis.order.domain.OrderInfo">
- SELECT *
- FROM order_info
- WHERE trade_type = 1
- AND profit_sharing = 1
- AND success_time <![CDATA[ <= ]]> DATE_SUB(NOW(), INTERVAL 10 MINUTE)
- ORDER BY success_time;
- </select>
- <select id="getOrderInfoByIds" parameterType="Long" resultType="com.miaxis.order.domain.OrderInfo">
- select * from order_info
- <where>
- id in
- <foreach collection="array" item="id" index="index" open="(" close=")" separator="," >
- #{id}
- </foreach>
- </where>
- </select>
- </mapper>
|