金币系统后端
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.

123 lines
4.3 KiB

  1. package com.example.demo.mapper;
  2. import com.example.demo.domain.entity.User;
  3. import com.example.demo.domain.entity.UserGold;
  4. import com.example.demo.domain.vo.UserVo;
  5. import org.apache.ibatis.annotations.Mapper;
  6. import org.apache.ibatis.annotations.Select;
  7. import org.apache.ibatis.annotations.Update;
  8. import java.math.BigDecimal;
  9. import java.util.List;
  10. @Mapper
  11. public interface UserMapper {
  12. @Select({
  13. "<script>",
  14. "select name from user",
  15. "<where>",
  16. "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>",
  17. "</where>",
  18. "</script>"
  19. })
  20. User select(String user);
  21. @Select({
  22. "<script>",
  23. "select * from user_gold",
  24. "<where>",
  25. "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>",
  26. "</where>",
  27. "</script>"
  28. })
  29. UserGold selectGold(String userGold);
  30. @Select({
  31. "<script>",
  32. "select * from user",
  33. "<where>",
  34. "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>",
  35. "</where>",
  36. "</script>"
  37. })
  38. User get(String jwcode);
  39. @Select({
  40. "SELECT\n" +
  41. " u.*,user.name,user.area," +
  42. " MIN(d.create_time) AS first_recharge_date, \n" +
  43. " SUM(CASE WHEN d.update_type = '0' THEN d.recharge_coin ELSE 0 END) AS total_recharge_gold, \n" +
  44. " SUM(CASE WHEN d.update_type = '1' THEN d.recharge_coin ELSE 0 END) AS total_spend_gold, \n" +
  45. " COUNT(CASE WHEN d.update_type = '0' THEN 1 END) AS recharge_times, \n" +
  46. " COUNT(CASE WHEN d.update_type = '1' THEN 1 END) AS spend_times, \n" +
  47. " COUNT(CASE WHEN a.status = 0 AND d.update_type = '0' THEN 1 END) AS pending_recharge_times, \n" +
  48. " COUNT(CASE WHEN a.status = 0 AND d.update_type = '1' THEN 1 END) AS pending_spend_times \n" +
  49. "FROM\n" +
  50. " user_gold u\n" +
  51. "LEFT JOIN user on user.jwcode=u.jwcode",
  52. "LEFT JOIN\n" +
  53. " detail d ON u.jwcode = d.jwcode\n" +
  54. "LEFT JOIN\n" +
  55. " audit a ON d.detail_id = a.detail_id AND a.audit_flag = 1\n" +
  56. "WHERE\n" +
  57. " u.jwcode =#{jwcode}\n"
  58. })
  59. UserVo selectA(UserVo userVo);
  60. @Select({
  61. "<script>",
  62. "select * from user",
  63. "<where>",
  64. "<if test='jwcode!=null and jwcode.length>0'>and jwcode=#{jwcode}</if>",
  65. "</where>",
  66. "</script>"
  67. })
  68. List<User> selectAll(User user);
  69. @Select({
  70. "select * from user where name=#{name}"
  71. })
  72. User selectByName(String name);
  73. @Select({
  74. "select * from user where jwcode=#{jwcode}"
  75. })
  76. User selectByJwcode(String jwcode);
  77. @Update({
  78. "<script>",
  79. "update user",
  80. "<set>",
  81. "<if test='buyJb!=null'>buy_jb=#{buyJb},</if>",
  82. "<if test='coreJb!=null'>core_jb=#{coreJb},</if>",
  83. "<if test='free6!=null'>free_6=#{free6},</if>",
  84. "<if test='free12!=null'>free_12=#{free12},</if>",
  85. "</set>",
  86. "where jwcode=#{jwcode}",
  87. "</script>",
  88. })
  89. int update(User user);
  90. @Update({
  91. "<script>",
  92. "update user_gold",
  93. "<set>",
  94. "<if test='buyJb!=null'>buy_jb=#{buyJb},</if>",
  95. "<if test='coreJb!=null'>core_jb=#{coreJb},</if>",
  96. "<if test='free6!=null'>free_6=#{free6},</if>",
  97. "<if test='free12!=null'>free_12=#{free12},</if>",
  98. "</set>",
  99. "where jwcode=#{jwcode}",
  100. "</script>",
  101. })
  102. int updateGold(UserGold userGold);
  103. // //去掉免费金币,先去6个月,再去12月
  104. // @Update({
  105. // "<script>",
  106. // "update user",
  107. // "<set>",
  108. // "<if test='Free6!=null'>free_6=#{Free6},</if>",
  109. // "<if test='Free12!=null'>free_12=#{Free12},</if>",
  110. // "</set>",
  111. // "where jwcode=#{jwcode}",
  112. // "</script>",
  113. // })
  114. // int updatecoin();
  115. }