選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

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