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.
 
 
 
 
 

209 lines
7.2 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. <result column="trade_count" property="tradeCount" />
  14. <result column="proof" property="proof"/>
  15. </resultMap>
  16. <sql id="allColumns">
  17. `id`,`tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`,trade_count,proof
  18. </sql>
  19. <sql id="dynamicWhereConditions">
  20. where 1 = 1
  21. <if test=" null != id ">
  22. and `id` = #{id}
  23. </if>
  24. <if test=" null != tenantId ">
  25. and `tenant_id` = #{tenantId}
  26. </if>
  27. <if test=" null != merchantId ">
  28. and `merchant_id` = #{merchantId}
  29. </if>
  30. <if test=" null != bUserId ">
  31. and `b_user_id` = #{bUserId}
  32. </if>
  33. <if test=" null != tradeAmt ">
  34. and `trade_amt` = #{tradeAmt}
  35. </if>
  36. <if test=" null != createDate ">
  37. and `create_date` = #{createDate}
  38. </if>
  39. <if test=" null != updateDate ">
  40. and `update_date` = #{updateDate}
  41. </if>
  42. <if test=" null != reportDate ">
  43. and `report_date` = #{reportDate}
  44. </if>
  45. <if test=" null != month ">
  46. and date_format(create_date,'%Y-%m')=#{month}
  47. </if>
  48. <if test=" null != ids ">
  49. and id in
  50. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  51. #{idItem}
  52. </foreach>
  53. </if>
  54. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  55. <if test=" null == sortColumns"> order by report_date desc </if>
  56. </sql>
  57. <select id="findList" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap">
  58. select <include refid="allColumns" /> from wx_merchant_trade_daily
  59. <include refid="dynamicWhereConditions" />
  60. </select>
  61. <select id="findListOfWeek" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap">
  62. select <include refid="allColumns" /> from wx_merchant_trade_daily
  63. where 1=1
  64. <if test="reportDate!=null">
  65. and `report_date` != #{reportDate}
  66. </if>
  67. <if test=" null != tenantId ">
  68. and `tenant_id` = #{tenantId}
  69. </if>
  70. <if test=" null != merchantId ">
  71. and `merchant_id` = #{merchantId}
  72. </if>
  73. order by create_date desc LIMIT 7
  74. </select>
  75. <resultMap id="BaseResultMapVo" type="com.iformall.domain.vo.WxMerchantTradeDailyVo">
  76. <id column="id" jdbcType="BIGINT" property="id" />
  77. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  78. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  79. <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
  80. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  81. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  82. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  83. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  84. <result column="trade_count" property="tradeCount" />
  85. <result column="proof" property="proof"/>
  86. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  87. <result column="business_id" jdbcType="VARCHAR" property="businessId" />
  88. <result column="sub_business_id" jdbcType="VARCHAR" property="subBusinessId" />
  89. <result column="b_user_name" jdbcType="VARCHAR" property="bUserName" />
  90. <result column="b_user_phone" jdbcType="VARCHAR" property="bUserPhone"/>
  91. </resultMap>
  92. <sql id="allColumnsVo">
  93. mtd.id as id, mtd.b_user_id as b_user_id, mtd.trade_amt, mtd.report_date, mtd.trade_count, mtd.proof,
  94. mtd.create_date as create_date, mtd.update_date as update_date,
  95. m.tenant_id as tenant_id, m.id as merchant_id, m.name as merchant_name, m.business_id, m.sub_business_id,
  96. mbu.name as b_user_name, mbu.phone as b_user_phone
  97. </sql>
  98. <select id="findVoList" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMapVo">
  99. select <include refid="allColumnsVo" />
  100. from wx_merchant_trade_daily mtd
  101. inner join wx_merchant m on mtd.merchant_id = m.id
  102. left join wx_merchant_b_user mbu on mtd.b_user_id = mbu.id
  103. where 1 = 1
  104. <if test=" null != tenantId ">
  105. and mtd.tenant_id = #{tenantId}
  106. </if>
  107. <if test=" null != merchantId ">
  108. and mtd.merchant_id = #{merchantId}
  109. </if>
  110. <if test=" null != merchantName and ''!=merchantName">
  111. and m.name like concat('%', #{merchantName},'%')
  112. </if>
  113. <if test=" null != startTime and null != endTime">
  114. and mtd.report_date &gt;= date_format(#{startTime},'%Y-%m-%d')
  115. and mtd.report_date &lt;= date_format(#{endTime},'%Y-%m-%d')
  116. </if>
  117. <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
  118. and mtd.merchant_id in(
  119. select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
  120. inner join wx_merchant m on ms.merchant_id = m.id
  121. inner join wx_shop s on s.id=ms.shop_id
  122. where m.tenant_id=#{tenantId} and s.is_del=0
  123. <if test=" null != businessForRule and '' != businessForRule ">
  124. and m.business_id in (${businessForRule})
  125. </if>
  126. <if test=" null != floorForRule and '' != floorForRule ">
  127. and s.`floor` in (${floorForRule})
  128. </if>
  129. )
  130. </if>
  131. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  132. </select>
  133. <select id="findSumMoney" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultType="String">
  134. select round(sum(mtd.trade_amt)/100,2)
  135. from wx_merchant_trade_daily mtd
  136. inner join wx_merchant m on mtd.merchant_id = m.id
  137. left join wx_merchant_b_user mbu on mtd.b_user_id = mbu.id
  138. where 1 = 1
  139. <if test=" null != tenantId ">
  140. and mtd.tenant_id = #{tenantId}
  141. </if>
  142. <if test=" null != merchantId ">
  143. and mtd.merchant_id = #{merchantId}
  144. </if>
  145. <if test=" null != startTime and null != endTime">
  146. and mtd.report_date &gt;= date_format(#{startTime},'%Y-%m-%d')
  147. and mtd.report_date &lt;= date_format(#{endTime},'%Y-%m-%d')
  148. </if>
  149. </select>
  150. <resultMap id="BaseTotalResultMap" type="com.iformall.domain.po.WxMerchantTradeDaily">
  151. <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
  152. <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
  153. </resultMap>
  154. <select id="findTotalListOfMonth" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseTotalResultMap">
  155. select report_date, IFNULL(sum(mtd.trade_amt),0) as trade_amt
  156. from wx_merchant_trade_daily mtd
  157. where 1 = 1
  158. <if test=" null != tenantId ">
  159. and mtd.tenant_id = #{tenantId}
  160. </if>
  161. <if test=" null != reportDate ">
  162. and mtd.report_date = #{reportDate}
  163. </if>
  164. group by mtd.report_date
  165. order by mtd.report_date desc
  166. LIMIT 30
  167. </select>
  168. </mapper>