You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
5.2 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.example.demo.mapper.bean.BeanConsumeMapper">
  4. <!--获取消费用户分部-->
  5. <select id="getDept" resultType="java.lang.String">
  6. select distinct fm.dept
  7. from fx_member fm
  8. inner join fx_yaoqing_records fyr on fyr.uid = fm.id
  9. where fm.dept is not null and fm.dept != ''
  10. </select>
  11. <!--筛选查询直播消费-->
  12. <select id="selectLiveBy" resultType="com.example.demo.domain.vo.bean.BeanConsumeLive">
  13. SELECT *
  14. FROM (
  15. SELECT fm.nickname AS name,
  16. fm.jwcode,
  17. fm.dept,
  18. fyr.source_type AS type,
  19. CASE
  20. WHEN LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
  21. THEN SUBSTRING(content, LOCATE('送礼物', content) + CHAR_LENGTH('送礼物'))
  22. ELSE NULL
  23. END AS gift,
  24. fyr.money AS beanNum,
  25. CASE
  26. WHEN LOCATE('直播间', content) > 0 AND LOCATE('送礼物', content) > 0
  27. THEN SUBSTRING_INDEX(SUBSTRING(content, LOCATE('直播间', content) + CHAR_LENGTH('直播间')), '送礼物', 1)
  28. ELSE NULL
  29. END AS channel,
  30. fyr.source_name AS liveName,
  31. FROM_UNIXTIME(fyr.time, '%Y-%m-%d %H:%i:%s') AS consumeTime,
  32. fyr.pay_type AS payType
  33. FROM fx_member fm
  34. INNER JOIN fx_yaoqing_records fyr ON fyr.uid = fm.id
  35. <where>
  36. fyr.pay_type IN (1,2,3,4,5)
  37. <if test="beanConsumeLive.jwcode != null and beanConsumeLive.jwcode != ''">
  38. AND fm.jwcode = #{beanConsumeLive.jwcode}
  39. </if>
  40. <if test="beanConsumeLive.dept != null and beanConsumeLive.dept != ''">
  41. AND fm.dept = #{beanConsumeLive.dept}
  42. </if>
  43. <if test="beanConsumeLive.type != null and beanConsumeLive.type != ''">
  44. AND fyr.source_type = #{beanConsumeLive.type}
  45. </if>
  46. <if test="beanConsumeLive.consumeTime != null and beanConsumeLive.consumeTime != null">
  47. AND consumeTime BETWEEN #{beanConsumeLive.startTime} AND #{beanConsumeLive.endTime}
  48. </if>
  49. </where>
  50. ) AS t
  51. <where>
  52. <if test="beanConsumeLive.gift != null and beanConsumeLive.gift != ''">
  53. AND t.gift = #{beanConsumeLive.gift}
  54. </if>
  55. <if test="beanConsumeLive.channel != null and beanConsumeLive.channel != ''">
  56. AND t.channel = #{beanConsumeLive.channel}
  57. </if>
  58. </where>
  59. <choose>
  60. <when test="beanConsumeLive.sortField != null and beanConsumeLive.sortField != '' and beanConsumeLive.sortOrder != null and beanConsumeLive.sortOrder != ''">
  61. ORDER BY t.${beanConsumeLive.sortField} ${beanConsumeLive.sortOrder}
  62. </when>
  63. <otherwise>
  64. ORDER BY t.consumeTime DESC
  65. </otherwise>
  66. </choose>
  67. </select>
  68. <!--获取金豆消费订单金额-->
  69. <select id="selectConsumeGoldsBy" resultType="com.example.demo.domain.vo.bean.BeanConsumeGold">
  70. </select>
  71. <select id="selectSumLiveBy" resultType="com.example.demo.domain.vo.bean.BeanConsumeGold">
  72. SELECT
  73. IFNULL(SUM(t.money_buy), 0) AS permanentBean,
  74. IFNULL(SUM(t.money_free), 0) AS freeBean,
  75. COUNT(*) AS totalNum
  76. FROM (
  77. SELECT
  78. fyr.money_buy,
  79. fyr.money_free,
  80. fyr.time
  81. FROM fx_member fm
  82. INNER JOIN fx_yaoqing_records fyr ON fyr.uid = fm.id
  83. <where>
  84. fyr.pay_type IN (1,2,3,4,5)
  85. <if test="beanConsumeLive.jwcode != null and beanConsumeLive.jwcode != ''">
  86. AND fm.jwcode = #{beanConsumeLive.jwcode}
  87. </if>
  88. <if test="beanConsumeLive.dept != null and beanConsumeLive.dept != ''">
  89. AND fm.dept = #{beanConsumeLive.dept}
  90. </if>
  91. <if test="beanConsumeLive.type != null and beanConsumeLive.type != ''">
  92. AND fyr.source_type = #{beanConsumeLive.type}
  93. </if>
  94. <if test="beanConsumeLive.gift != null and beanConsumeLive.gift != ''">
  95. AND CASE
  96. WHEN LOCATE('直播间', fyr.content) > 0 AND LOCATE('送礼物', fyr.content) > 0
  97. THEN SUBSTRING(fyr.content, LOCATE('送礼物', fyr.content) + CHAR_LENGTH('送礼物'))
  98. ELSE NULL
  99. END = #{beanConsumeLive.gift}
  100. </if>
  101. <if test="beanConsumeLive.channel != null and beanConsumeLive.channel != ''">
  102. AND CASE
  103. WHEN LOCATE('直播间', fyr.content) > 0 AND LOCATE('送礼物', fyr.content) > 0
  104. THEN SUBSTRING_INDEX(SUBSTRING(fyr.content, LOCATE('直播间', fyr.content) + CHAR_LENGTH('直播间')), '送礼物', 1)
  105. ELSE NULL
  106. END = #{beanConsumeLive.channel}
  107. </if>
  108. <if test="beanConsumeLive.consumeTime != null and beanConsumeLive.consumeTime != null">
  109. AND consumeTime BETWEEN #{beanConsumeLive.startTime} AND #{beanConsumeLive.endTime}
  110. </if>
  111. </where>
  112. ) AS t
  113. </select>
  114. </mapper>