后台服务
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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