Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

184 Zeilen
6.5 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.WxBusinessMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBusiness">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="title" jdbcType="VARCHAR" property="title" />
  7. <result column="type" jdbcType="INTEGER" property="type" />
  8. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  9. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  10. </resultMap>
  11. <sql id="allColumns">
  12. `id`,`title`,`type`,`create_date`,`update_date`
  13. </sql>
  14. <sql id="dynamicWhereConditions">
  15. where 1 = 1
  16. <if test=" null != id ">
  17. and `id` = #{id}
  18. </if>
  19. <if test=" null != title ">
  20. and `title` like concat('%', #{title},'%')
  21. </if>
  22. <if test=" null != type ">
  23. and `type` = #{type}
  24. </if>
  25. <if test=" null != createDate ">
  26. and `create_date` = #{createDate}
  27. </if>
  28. <if test=" null != updateDate ">
  29. and `update_date` = #{updateDate}
  30. </if>
  31. <if test=" null != ids ">
  32. and id in
  33. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  34. #{idItem}
  35. </foreach>
  36. </if>
  37. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  38. </sql>
  39. <select id="findList" parameterType="com.iformall.domain.po.WxBusiness" resultMap="BaseResultMap">
  40. select <include refid="allColumns" /> from wx_business
  41. <include refid="dynamicWhereConditions" />
  42. </select>
  43. <select id="findListAll" resultMap="BaseResultMap">
  44. select <include refid="allColumns" /> from wx_business
  45. order by create_date asc
  46. </select>
  47. <select id="findListForMerchant" resultMap="BaseResultMap">
  48. select <include refid="allColumns" />
  49. from wx_business b
  50. where
  51. (select count(*) from wx_merchant m
  52. where
  53. m.tenant_id = #{tenantId}
  54. and b.id = m.business_id
  55. and m.status = 1
  56. and m.is_public = 1) > 0
  57. order by create_date asc
  58. </select>
  59. <select id="findListForCoupon" resultMap="BaseResultMap">
  60. select <include refid="allColumns" />
  61. from wx_business b
  62. where
  63. (select count(*) from wx_coupon_channel cc
  64. where
  65. cc.tenant_id = #{tenantId}
  66. and b.id = cc.business
  67. and cc.status = 0
  68. and cc.target_ad = 1) > 0
  69. order by create_date asc
  70. </select>
  71. <select id="businessDataList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
  72. select b.id,b.title,
  73. round(
  74. (select sum(mtd.trade_amt)
  75. from wx_merchant m
  76. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate})
  77. /100,2) volume,
  78. round(
  79. (select sum(mtd.trade_amt)
  80. from wx_merchant m
  81. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate})
  82. /
  83. (select sum(ws.operation_area)
  84. from wx_merchant m
  85. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  86. left join wx_shop ws on(mtd.shop_id = ws.id)
  87. where m.business_id = b.id and m.tenant_id=#{tenantId})
  88. /100,2) sale,
  89. round(
  90. (select
  91. (select sum(br.receive_pay) receive_pay from wx_merchant m
  92. left join wx_bill_rent br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate})
  93. +
  94. (select sum(br.receive_pay) receive_pay from wx_merchant m
  95. left join wx_bill_property br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate})
  96. from dual) /
  97. (select sum(ws.operation_area)
  98. from wx_merchant m
  99. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  100. left join wx_shop ws on(mtd.shop_id = ws.id)
  101. where m.business_id = b.id and m.tenant_id=#{tenantId} )
  102. /100,2) rent,
  103. round(
  104. round(
  105. (select sum(mtd.trade_amt)
  106. from wx_merchant m
  107. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate})
  108. /
  109. (select sum(ws.operation_area)
  110. from wx_merchant m
  111. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  112. left join wx_shop ws on(mtd.shop_id = ws.id)
  113. where m.business_id = b.id and m.tenant_id=#{tenantId})
  114. /100,2)
  115. /
  116. round(
  117. (select
  118. (select sum(br.receive_pay) receive_pay from wx_merchant m
  119. left join wx_bill_rent br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate})
  120. +
  121. (select sum(br.receive_pay) receive_pay from wx_merchant m
  122. left join wx_bill_property br on(br.merchant_id=m.id) where m.business_id = b.id and m.tenant_id=#{tenantId} and br.receive_date between #{startdate} and #{enddate})
  123. from dual) /
  124. (select sum(ws.operation_area)
  125. from wx_merchant m
  126. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  127. left join wx_shop ws on(mtd.shop_id = ws.id)
  128. where m.business_id = b.id)
  129. /100,2)
  130. ,4)
  131. rentSaleRate,
  132. round(
  133. (select sum(mtd.trade_amt)
  134. from wx_merchant m
  135. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate}) /
  136. (select count(mtd.id)
  137. from wx_merchant m
  138. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and mtd.create_date between #{startdate} and #{enddate})
  139. /100,2) comPrice
  140. from wx_business b
  141. </select>
  142. <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
  143. select m.name merchantName,round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2) sale,
  144. round(
  145. round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2)/
  146. (select round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2)
  147. from wx_merchant m
  148. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
  149. left join wx_merchant_shop wmt on wmt.merchant_id = m.id
  150. left join wx_shop ws on(wmt.shop_id = ws.id)
  151. where m.business_id=#{id} and m.tenant_id=#{tenantId})
  152. ,2) devoteRate
  153. from wx_merchant m
  154. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
  155. left join wx_merchant_shop wmt on wmt.merchant_id = m.id
  156. left join wx_shop ws on(wmt.shop_id = ws.id)
  157. where m.business_id=#{id} and m.tenant_id=#{tenantId}
  158. group by m.id
  159. order by devoteRate desc
  160. </select>
  161. </mapper>