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.
 
 
 
 
 

175 line
5.7 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.iformall.mapper.WxMerchantTradeDailyMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantTradeDaily">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  8. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  9. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  10. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  11. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  12. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  13. </resultMap>
  14. <sql id="allColumns">
  15. `id`,`tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`
  16. </sql>
  17. <sql id="dynamicWhereConditions">
  18. where 1 = 1
  19. <if test=" null != id ">
  20. and `id` = #{id}
  21. </if>
  22. <if test=" null != tenantId ">
  23. and `tenant_id` = #{tenantId}
  24. </if>
  25. <if test=" null != merchantId ">
  26. and `merchant_id` = #{merchantId}
  27. </if>
  28. <if test=" null != bUserId ">
  29. and `b_user_id` = #{bUserId}
  30. </if>
  31. <if test=" null != tradeAmt ">
  32. and `trade_amt` = #{tradeAmt}
  33. </if>
  34. <if test=" null != createDate ">
  35. and `create_date` = #{createDate}
  36. </if>
  37. <if test=" null != updateDate ">
  38. and `update_date` = #{updateDate}
  39. </if>
  40. <if test=" null != reportDate ">
  41. and `report_date` = #{reportDate}
  42. </if>
  43. <if test=" null != ids ">
  44. and id in
  45. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  46. #{idItem}
  47. </foreach>
  48. </if>
  49. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  50. </sql>
  51. <select id="findList" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap">
  52. select <include refid="allColumns" /> from wx_merchant_trade_daily
  53. <include refid="dynamicWhereConditions" />
  54. </select>
  55. <select id="findListOfWeek" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap">
  56. select <include refid="allColumns" /> from wx_merchant_trade_daily
  57. where 1=1
  58. <if test="reportDate!=null">
  59. and `report_date` != #{reportDate}
  60. </if>
  61. <if test=" null != tenantId ">
  62. and `tenant_id` = #{tenantId}
  63. </if>
  64. <if test=" null != merchantId ">
  65. and `merchant_id` = #{merchantId}
  66. </if>
  67. order by create_date desc LIMIT 7
  68. </select>
  69. <resultMap id="BaseResultMapVo" type="com.iformall.domain.vo.WxMerchantTradeDailyVo">
  70. <id column="id" jdbcType="BIGINT" property="id" />
  71. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  72. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  73. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  74. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  75. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  76. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  77. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  78. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  79. <result column="b_user_name" jdbcType="VARCHAR" property="bUserName" />
  80. <result column="b_user_phone" jdbcType="VARCHAR" property="bUserPhone"/>
  81. </resultMap>
  82. <sql id="allColumnsVo">
  83. mtd.id as id, m.tenant_id as tenant_id, m.id as merchant_id, mtd.b_user_id as b_user_id, mtd.trade_amt as trade_amt, mtd.create_date as create_date,mtd.update_date as update_date,mtd.report_date as report_date, m.name as merchant_name, mbu.name as b_user_name, mbu.phone as b_user_phone
  84. </sql>
  85. <select id="findListVo" parameterType="com.iformall.domain.vo.WxMerchantTradeDailyVo" resultMap="BaseResultMapVo">
  86. select <include refid="allColumnsVo" />
  87. from wx_merchant m
  88. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
  89. <if test=" reportDate!=null">
  90. and mtd.report_date = #{reportDate}
  91. </if>
  92. left join wx_merchant_b_user mbu on mtd.b_user_id = mbu.id
  93. where 1=1
  94. <if test=" null != merchantName ">
  95. and m.name like concat('%', #{merchantName},'%')
  96. </if>
  97. <if test=" null != tenantId ">
  98. and m.tenant_id = #{tenantId}
  99. </if>
  100. <if test=" null != merchantId ">
  101. and m.id = #{merchantId}
  102. </if>
  103. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  104. </select>
  105. <select id="findListVoOfMonth" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMapVo">
  106. select <include refid="allColumnsVo" />
  107. from wx_merchant_trade_daily mtd
  108. inner join wx_merchant m on mtd.merchant_id = m.id
  109. left join wx_merchant_b_user mbu on mtd.b_user_id = mbu.id
  110. where 1 = 1
  111. <if test=" null != tenantId ">
  112. and mtd.tenant_id = #{tenantId}
  113. </if>
  114. <if test=" null != merchantId ">
  115. and mtd.merchant_id = #{merchantId}
  116. </if>
  117. order by mtd.create_date desc LIMIT 30
  118. </select>
  119. <resultMap id="BaseTotalResultMap" type="com.iformall.domain.po.WxMerchantTradeDaily">
  120. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  121. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  122. </resultMap>
  123. <select id="findTotalListOfMonth" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseTotalResultMap">
  124. select report_date, sum(mtd.trade_amt) as trade_amt
  125. from wx_merchant_trade_daily mtd
  126. where 1 = 1
  127. <if test=" null != tenantId ">
  128. and mtd.tenant_id = #{tenantId}
  129. </if>
  130. group by mtd.report_date
  131. order by mtd.report_date desc
  132. LIMIT 30
  133. </select>
  134. </mapper>