ShoppingFundsDetailMapper.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.ylx.shopingfundsdetail.mapper.ShoppingFundsDetailMapper">
  6. <!-- C端购物金明细 -->
  7. <select id="queryShoppingFundsDetail" resultType="com.ylx.shopingfundsdetail.domain.vo.ShoppingFundsDetailQueryVo">
  8. select
  9. d.id AS id,
  10. d.user_id AS userId,
  11. d.expense_type AS expenseType,
  12. CASE
  13. WHEN d.expense_type = 0 THEN '收入'
  14. WHEN d.expense_type = 1 THEN '支出'
  15. ELSE '未知'
  16. END AS expenseTypeName,
  17. d.amount AS amount,
  18. d.balance AS balance,
  19. DATE_FORMAT(d.create_time, '%c.%d %H:%i:%s') AS createTime
  20. from t_shopping_funds_detail d
  21. where 1=1
  22. <if test="dto.userId != null">
  23. and d.user_id = #{dto.userId}
  24. </if>
  25. <if test="dto.startTime != null and dto.endTime != null and dto.startTime != '' and dto.endTime != ''">
  26. and DATE_FORMAT(d.create_time, '%Y-%m-%d') >= #{dto.startTime}
  27. and DATE_FORMAT(d.create_time, '%Y-%m-%d') &lt;= #{dto.endTime}
  28. </if>
  29. </select>
  30. <!--查询支出的购物金明细-->
  31. <select id="selectPcExpenseShoppingFundsDetail" resultType="com.ylx.giftCard.domain.vo.UserShoppingFundsDetailItemVO">
  32. SELECT
  33. d.order_no AS orderNo,
  34. NULL AS giftCardName,
  35. -d.amount AS orderAmount,
  36. d.create_time AS orderTime
  37. FROM t_shopping_funds_detail d
  38. <where>
  39. d.user_id = #{dto.userId}
  40. AND d.expense_type = 1
  41. <if test="dto.startTime != null and dto.startTime != ''">
  42. AND d.create_time &gt;= #{dto.startTime}
  43. </if>
  44. <if test="dto.endTime != null and dto.endTime != ''">
  45. AND d.create_time &lt;= #{dto.endTime}
  46. </if>
  47. </where>
  48. ORDER BY
  49. d.create_time DESC
  50. </select>
  51. <!--查询支出的购物金明细摘要-->
  52. <select id="selectPcExpenseShoppingFundsSummary" resultType="com.ylx.giftCard.domain.vo.UserShoppingFundsSummaryVO">
  53. SELECT
  54. COALESCE(SUM(d.amount), 0) AS totalAmount,
  55. COUNT(1) AS totalCount
  56. FROM t_shopping_funds_detail d
  57. <where>
  58. d.user_id = #{dto.userId}
  59. AND d.expense_type = 1
  60. <if test="dto.startTime != null and dto.startTime != ''">
  61. AND d.create_time &gt;= #{dto.startTime}
  62. </if>
  63. <if test="dto.endTime != null and dto.endTime != ''">
  64. AND d.create_time &lt;= #{dto.endTime}
  65. </if>
  66. </where>
  67. </select>
  68. </mapper>