OrderInfoMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.miaxis.order.mapper.OrderInfoMapper">
  6. <resultMap type="OrderInfo" id="OrderInfoResult">
  7. <result property="id" column="id" />
  8. <result property="goodsId" column="goods_id" />
  9. <result property="goodsName" column="goods_name" />
  10. <result property="goodsType" column="goods_type" />
  11. <result property="userId" column="user_id" />
  12. <result property="userName" column="user_name" />
  13. <result property="logincode" column="logincode" />
  14. <result property="outTradeNo" column="out_trade_no" />
  15. <result property="outRefundNo" column="out_refund_no" />
  16. <result property="tradeType" column="trade_type" />
  17. <result property="successTime" column="success_time" />
  18. <result property="payType" column="pay_type" />
  19. <result property="createTime" column="create_time" />
  20. <result property="updateTime" column="update_time" />
  21. <result property="isShare" column="is_share" />
  22. <result property="dqbh" column="dqbh" />
  23. <result property="dqmc" column="dqmc" />
  24. <result property="school" column="school" />
  25. <result property="schoolName" column="school_name" />
  26. <result property="schoolCommission" column="school_commission" />
  27. <result property="phoneType" column="phone_type" />
  28. <result property="refundReason" column="refund_reason" />
  29. </resultMap>
  30. <sql id="selectOrderInfoVo">
  31. select * from order_info
  32. </sql>
  33. <select id="selectOrderInfoList" parameterType="OrderInfo" resultMap="OrderInfoResult">
  34. <include refid="selectOrderInfoVo"/>
  35. <where>
  36. <if test="isShare != null"> and is_share = #{isShare }</if>
  37. <if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
  38. <if test="goodsType != null"> and goods_type = #{goodsType }</if>
  39. <if test="schoolName != null and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
  40. <if test="userId != null "> and user_id = #{userId}</if>
  41. <if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
  42. <if test="logincode != null and logincode != ''"> and logincode = #{logincode} </if>
  43. <if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
  44. <if test="outRefundNo != null and outRefundNo != ''"> and out_refund_no = #{outRefundNo}</if>
  45. <if test="tradeType != null and tradeType != ''"> and trade_type = #{tradeType}</if>
  46. <if test="successTime != null "> and success_time = #{successTime}</if>
  47. <if test="payType != null "> and pay_type = #{payType}</if>
  48. </where>
  49. order by success_time desc
  50. </select>
  51. <select id="getByOutTradeNo" parameterType="string" resultType="com.miaxis.order.domain.OrderInfo">
  52. select * from order_info where out_trade_no =#{outTradeNo}
  53. </select>
  54. <!--
  55. <select id="selectSchoolOrderInfoList" parameterType="com.miaxis.order.dto.QuerySchoolOrderListDTO" resultType="com.miaxis.order.vo.QuerySchoolOrderListVo">
  56. select
  57. school,
  58. school_name,
  59. IFNULL(sum(school_commission),0) as school_commission,
  60. IFNULL(sum(total),0) as order_total,
  61. COUNT(DISTINCT logincode) as people_count,
  62. COUNT(id) as order_count
  63. <if test="isShare==1 and dqbh !='2108' ">
  64. ,
  65. IFNULL(COUNT(DISTINCT logincode),0)*49*100 as activation_commission,
  66. (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission)) as subsidy_bak,
  67. (case
  68. when (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission)) <![CDATA[ <= ]]> 0 then 0
  69. when (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission)) <![CDATA[ > ]]> 0 then (IFNULL(COUNT(DISTINCT logincode),0)*49*100-sum(school_commission))
  70. else 0 end) as subsidy
  71. </if>
  72. from order_info
  73. <where>
  74. <if test="isShare != null">
  75. and is_share = #{isShare }
  76. </if>
  77. <if test="tradeType != null">
  78. and trade_type = #{tradeType }
  79. </if>
  80. <if test="dqbh != null and dqbh != ''">
  81. and dqbh = #{dqbh}
  82. </if>
  83. <if test="schoolName != null and schoolName != ''">
  84. and school_name like concat('%', #{schoolName}, '%')
  85. </if>
  86. <if test="startTime != null and startTime != ''">
  87. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  88. </if>
  89. <if test="endTime != null and endTime != '' ">
  90. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  91. </if>
  92. </where>
  93. group by school,school_name
  94. </select>
  95. -->
  96. <select id="selectSchoolOrderInfoList" parameterType="com.miaxis.order.dto.QuerySchoolOrderListDTO" resultType="com.miaxis.order.vo.QuerySchoolOrderListVo">
  97. SELECT *,
  98. CASE
  99. WHEN subsidy_bak <![CDATA[ <= ]]> 0 THEN 0
  100. WHEN subsidy_bak <![CDATA[ > ]]> 0 THEN subsidy_bak
  101. ELSE 0
  102. END AS subsidy
  103. FROM (
  104. SELECT
  105. school,
  106. school_name,
  107. IFNULL(SUM(school_commission), 0) AS school_commission,
  108. IFNULL(SUM(total), 0) AS order_total,
  109. COUNT(DISTINCT logincode) AS people_count,
  110. COUNT(id) AS order_count,
  111. IFNULL(COUNT(DISTINCT CASE WHEN dqbh NOT IN ('2108') THEN logincode END), 0) * 49 * 100 AS activation_commission,
  112. IFNULL(COUNT(DISTINCT CASE WHEN dqbh NOT IN ('2108') THEN logincode END), 0) * 49 * 100 - SUM(school_commission) AS subsidy_bak
  113. from order_info
  114. <where>
  115. <if test="isShare != null">
  116. and is_share = #{isShare }
  117. </if>
  118. <if test="tradeType != null">
  119. and trade_type = #{tradeType }
  120. </if>
  121. <if test="dqbh != null and dqbh != ''">
  122. and dqbh = #{dqbh}
  123. </if>
  124. <if test="schoolName != null and schoolName != ''">
  125. and school_name like concat('%', #{schoolName}, '%')
  126. </if>
  127. <if test="startTime != null and startTime != ''">
  128. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  129. </if>
  130. <if test="endTime != null and endTime != '' ">
  131. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  132. </if>
  133. </where>
  134. group by school,school_name) as subquery
  135. </select>
  136. <select id="selectSchoolOrderInfoExcel" resultType="com.miaxis.order.vo.QuerySchoolOrderListVo">
  137. select
  138. school,
  139. school_name,
  140. IFNULL(sum(school_commission)/100,0) as school_commission,
  141. IFNULL(sum(total)/100,0) as order_total,
  142. COUNT(DISTINCT logincode) as people_count,
  143. COUNT(id) as order_count
  144. <if test="isShare==1">
  145. ,
  146. IFNULL(COUNT(DISTINCT logincode),0)*49 as activation_commission,
  147. (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission/100)) as subsidy_bak,
  148. (case
  149. when (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission)/100) <![CDATA[ <= ]]> 0 then 0
  150. when (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission)/100) <![CDATA[ > ]]> 0 then (IFNULL(COUNT(DISTINCT logincode),0)*49-sum(school_commission)/100)
  151. else 0 end) as subsidy
  152. </if>
  153. from order_info
  154. <where>
  155. <if test="isShare != null">
  156. and is_share = #{isShare }
  157. </if>
  158. <if test="tradeType != null">
  159. and trade_type = #{tradeType }
  160. </if>
  161. <if test="dqbh != null and dqbh != ''">
  162. and dqbh = #{dqbh}
  163. </if>
  164. <if test="schoolName != null and schoolName != ''">
  165. and school_name like concat('%', #{schoolName}, '%')
  166. </if>
  167. <if test="startTime != null and startTime !='' ">
  168. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  169. </if>
  170. <if test="endTime != null and endTime !=''">
  171. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  172. </if>
  173. </where>
  174. group by school,school_name
  175. </select>
  176. <select id="getTotalMoney" resultType="java.lang.Integer">
  177. select
  178. IFNULL(sum(total),0) as orderTotal
  179. from order_info
  180. <where>
  181. <if test="isShare != null">
  182. and is_share = #{isShare }
  183. </if>
  184. <if test="tradeType != null">
  185. and trade_type = #{tradeType }
  186. </if>
  187. <if test="dqbh != null and dqbh != ''">
  188. and dqbh = #{dqbh}
  189. </if>
  190. <if test="schoolName != null and schoolName != ''">
  191. and school_name like concat('%', #{schoolName}, '%')
  192. </if>
  193. <if test="startTime != null and startTime != ''">
  194. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  195. </if>
  196. <if test="endTime != null and endTime != ''">
  197. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  198. </if>
  199. </where>
  200. </select>
  201. <select id="getCommissionMoney" resultType="java.lang.Integer">
  202. select
  203. IFNULL(sum(school_commission),0) as commission
  204. from order_info
  205. <where>
  206. <if test="isShare != null">
  207. and is_share = #{isShare }
  208. </if>
  209. <if test="tradeType != null">
  210. and trade_type = #{tradeType }
  211. </if>
  212. <if test="dqbh != null and dqbh != ''">
  213. and dqbh = #{dqbh}
  214. </if>
  215. <if test="schoolName != null and schoolName != ''">
  216. and school_name like concat('%', #{schoolName}, '%')
  217. </if>
  218. <if test="startTime != null and startTime!=''">
  219. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  220. </if>
  221. <if test="endTime != null and endTime!=''">
  222. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  223. </if>
  224. </where>
  225. </select>
  226. <select id="selectSchoolOrderDetailed" resultType="com.miaxis.order.domain.OrderInfo">
  227. select * from order_info
  228. <where>
  229. <if test="isShare != null">
  230. and is_share = #{isShare }
  231. </if>
  232. <if test="tradeType != null">
  233. and trade_type = #{tradeType }
  234. </if>
  235. <if test="schoolName != null and schoolName != ''">
  236. and school_name like concat('%', #{schoolName}, '%')
  237. </if>
  238. <if test="startTime != null and startTime!=''">
  239. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  240. </if>
  241. <if test="endTime != null and endTime!=''">
  242. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  243. </if>
  244. </where>
  245. order by success_time desc
  246. </select>
  247. <select id="selectSchoolOrderDetailedExcel" resultType="com.miaxis.order.vo.QuerySchoolOrderDetailedVo">
  248. select
  249. school_name,
  250. goods_name,user_name,logincode,out_trade_no,
  251. case when trade_type = 1 then '支付成功'
  252. when trade_type = 2 then '支付失败'
  253. when trade_type = 3 then '已退款' else '未知' end as trade_type,
  254. case when phone_type = 1 then '苹果' else '安卓' end as phone_type,
  255. IFNULL(total/100,0) as total,IFNULL(school_commission/100,0) as school_commission,
  256. success_time,
  257. case when is_share = 1 then '是' else '否' end as is_share
  258. from order_info
  259. <where>
  260. <if test="isShare != null">
  261. and is_share = #{isShare }
  262. </if>
  263. <if test="tradeType != null">
  264. and trade_type = #{tradeType }
  265. </if>
  266. <if test="schoolName != null and schoolName != ''">
  267. and school_name like concat('%', #{schoolName}, '%')
  268. </if>
  269. <if test="startTime != null and startTime != '' ">
  270. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
  271. </if>
  272. <if test="endTime != null and endTime!='' ">
  273. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
  274. </if>
  275. </where>
  276. order by success_time desc
  277. </select>
  278. <select id="getIncomeList" resultType="com.miaxis.order.vo.OrderIncomeVo">
  279. select
  280. (select sum(total) from order_info o where DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> #{startTime}
  281. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') )<![CDATA[ <= ]]> #{endTime}
  282. and trade_type = 1) as total,
  283. IFNULL(COUNT(DISTINCT logincode),0)*49 as activation_commission,
  284. sum(school_commission)/100 from order_info o
  285. where DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> #{startTime}
  286. and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ <= ]]> #{endTime}
  287. and is_share = 1
  288. and trade_type = 1
  289. </select>
  290. <select id="getByOutTradeNo" parameterType="string" resultType="com.miaxis.order.domain.OrderInfo">
  291. select * from order_info where out_trade_no =#{outTradeNo}
  292. </select>
  293. </mapper>