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.

126 lines
5.5 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.pay.BeanRechargeMapper3">
  4. <select id="selectByOnline" resultType="com.example.demo.domain.vo.bean.BeanOnlineRechargeInfo">
  5. SELECT g.id AS id,
  6. g.jwcode AS jwcode,
  7. m.name AS name,
  8. m.deptName AS market,
  9. g.order_no AS orderNo,
  10. g.count AS num,
  11. g.price AS money,
  12. g.platform AS platform,
  13. FROM_UNIXTIME(g.add_time) AS rechargeTime
  14. FROM g_order g
  15. LEFT JOIN member_info m ON g.jwcode = m.jwcode
  16. <where>
  17. g.type = "gold" AND g.state = 1
  18. <if test="jwcode != null and jwcode != ''">
  19. AND g.jwcode = #{jwcode}
  20. </if>
  21. <if test="market != null and market != ''">
  22. AND m.deptName = #{market}
  23. </if>
  24. <if test="orderNo != null and orderNo != ''">
  25. AND g.order_no = #{orderNo}
  26. </if>
  27. <if test="platform != null and platform != ''">
  28. AND g.platform = #{platform}
  29. </if>
  30. <if test="startTime != null and endTime != null">
  31. AND FROM_UNIXTIME(g.add_time) BETWEEN #{startTime} AND #{endTime}
  32. </if>
  33. </where>
  34. <trim prefix="ORDER BY" suffixOverrides=",">
  35. <choose>
  36. <!-- 当指定排序字段时使用指定字段排序 -->
  37. <when test="sortField != null and sortField != ''">
  38. <choose>
  39. <!-- 对金币数量的排序处理 -->
  40. <when test="sortField == 'num'">g.count</when>
  41. <when test="sortField == 'money'">g.price</when>
  42. <!-- 对时间字段的排序处理 -->
  43. <when test="sortField == 'rechargeTime'">g.add_time</when>
  44. <!-- 其他字段不支持排序,使用默认排序 -->
  45. <otherwise>g.add_time</otherwise>
  46. </choose>
  47. <!-- 排序方向处理 -->
  48. <if test="sortOrder != null and sortOrder != ''">
  49. <choose>
  50. <when test="sortOrder == 'ASC'">ASC</when>
  51. <when test="sortOrder == 'DESC'">DESC</when>
  52. <otherwise>DESC</otherwise>
  53. </choose>
  54. </if>
  55. <if test="sortOrder == null or sortOrder == ''">
  56. DESC
  57. </if>
  58. </when>
  59. <!-- 未指定排序字段时,使用默认的时间降序排序 -->
  60. <otherwise>
  61. g.add_time DESC
  62. </otherwise>
  63. </choose>
  64. </trim>
  65. </select>
  66. <select id="onlineMarket" resultType="java.lang.String">
  67. select DISTINCT deptName from member_info
  68. </select>
  69. <select id="selectOnlineSum" resultType="com.example.demo.domain.vo.bean.GoldBean">
  70. SELECT
  71. sum(g.count) as num,
  72. sum(g.price) as money
  73. FROM g_order g
  74. LEFT JOIN member_info m ON g.jwcode = m.jwcode
  75. <where>
  76. g.type = "gold" AND g.state = 1
  77. <if test="jwcode != null and jwcode != ''">
  78. AND g.jwcode = #{jwcode}
  79. </if>
  80. <if test="market != null and market != ''">
  81. AND m.deptName = #{market}
  82. </if>
  83. <if test="orderNo != null and orderNo != ''">
  84. AND g.order_no = #{orderNo}
  85. </if>
  86. <if test="platform != null and platform != ''">
  87. AND g.platform = #{platform}
  88. </if>
  89. <if test="startTime != null and endTime != null">
  90. AND FROM_UNIXTIME(g.add_time) BETWEEN #{startTime} AND #{endTime}
  91. </if>
  92. </where>
  93. <trim prefix="ORDER BY" suffixOverrides=",">
  94. <choose>
  95. <!-- 当指定排序字段时使用指定字段排序 -->
  96. <when test="sortField != null and sortField != ''">
  97. <choose>
  98. <!-- 对金币数量的排序处理 -->
  99. <when test="sortField == 'num'">g.count</when>
  100. <when test="sortField == 'money'">g.price</when>
  101. <!-- 对时间字段的排序处理 -->
  102. <when test="sortField == 'rechargeTime'">g.add_time</when>
  103. <!-- 其他字段不支持排序,使用默认排序 -->
  104. <otherwise>g.add_time</otherwise>
  105. </choose>
  106. <!-- 排序方向处理 -->
  107. <if test="sortOrder != null and sortOrder != ''">
  108. <choose>
  109. <when test="sortOrder == 'ASC'">ASC</when>
  110. <when test="sortOrder == 'DESC'">DESC</when>
  111. <otherwise>DESC</otherwise>
  112. </choose>
  113. </if>
  114. <if test="sortOrder == null or sortOrder == ''">
  115. DESC
  116. </if>
  117. </when>
  118. <!-- 未指定排序字段时,使用默认的时间降序排序 -->
  119. <otherwise>
  120. g.add_time DESC
  121. </otherwise>
  122. </choose>
  123. </trim>
  124. </select>
  125. </mapper>