DistributeWaitingSendPointsMapper.xml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.cyksj.mapper.manage.distribute.DistributeWaitingSendPointsMapper">
  4. <select id="getWMoneyStatisticsDataView"
  5. resultType="com.cyksj.model.views.CpsUserWMoneyStatisticsDataView">
  6. select
  7. <if test="today">
  8. date_format(send_time, '%H') as `hour`,
  9. </if>
  10. <if test="!today">
  11. date_format(send_time, '%Y-%m-%d') `date`,
  12. </if>
  13. TRUNCATE(ifnull(sum(points),0)/ 1000,2) money
  14. from `distribute_waiting_send_points`
  15. where shared_id = #{cpsUserId}
  16. and send_status = 'waiting'
  17. <choose>
  18. <when test="today">
  19. <if test="first != null">
  20. and send_time >= #{first}
  21. </if>
  22. <if test="end != null">
  23. and send_time &lt;= #{end}
  24. </if>
  25. group by date_format(send_time, '%H')
  26. order by date_format(send_time, '%H')
  27. </when>
  28. <otherwise>
  29. <if test="first != null">
  30. and date_format(send_time, '%Y-%m-%d') >= #{first}
  31. </if>
  32. <if test="end != null">
  33. and date_format(send_time, '%Y-%m-%d') &lt; #{end}
  34. </if>
  35. group by date_format(send_time, '%Y-%m-%d')
  36. order by date_format(send_time, '%Y-%m-%d')
  37. </otherwise>
  38. </choose>
  39. </select>
  40. <select id="getWMoneyStatisticsDate" resultType="com.cyksj.model.views.BrokenLineCpsUserWMoneyView">
  41. select min(curdate) as firstDate,
  42. max(curdate) as lastDate from (select
  43. <if test="today">
  44. date_format(send_time, '%H') as `curdate`
  45. </if>
  46. <if test="!today">
  47. date_format(send_time, '%Y-%m-%d') `curdate`
  48. </if>
  49. from `distribute_waiting_send_points`
  50. where shared_id = #{cpsUserId}
  51. and send_status = 'waiting'
  52. <choose>
  53. <when test="today">
  54. <if test="first != null">
  55. and send_time >= #{first}
  56. </if>
  57. <if test="end != null">
  58. and send_time &lt;= #{end}
  59. </if>
  60. group by date_format(send_time, '%H')
  61. </when>
  62. <otherwise>
  63. <if test="first != null">
  64. and date_format(send_time, '%Y-%m-%d') >= #{first}
  65. </if>
  66. <if test="end != null">
  67. and date_format(send_time, '%Y-%m-%d') &lt; #{end}
  68. </if>
  69. group by date_format(send_time, '%Y-%m-%d')
  70. </otherwise>
  71. </choose>
  72. )s
  73. </select>
  74. </mapper>