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.
 
 
 
 
 

188 lines
7.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 if(sum(mtd.trade_amt) is null,0,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.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  77. /100,2) volume,
  78. round(
  79. (select if(sum(mtd.trade_amt) is null,0,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.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  82. /
  83. (select if(sum(ws.operation_area) is null,0,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} and m.status = 1 and m.is_del = 0 )
  88. /100,2) sale,
  89. round(
  90. (select
  91. (select if(sum(br.receive_pay) is null,0,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} and m.status = 1 and m.is_del = 0 )
  93. +
  94. (select if(sum(br.receive_pay) is null,0,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} and m.status = 1 and m.is_del = 0 )
  96. from dual) /
  97. (select if(sum(ws.operation_area) is null,0,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} and m.status = 1 and m.is_del = 0 )
  102. /100,2) rent,
  103. round(
  104. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  105. from wx_merchant m
  106. 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.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 ) /
  107. (select sum(mtd.trade_count)
  108. from wx_merchant m
  109. 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.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  110. /100,2) comPrice
  111. from wx_business b
  112. </select>
  113. <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
  114. select mm.name merchantName,
  115. round(
  116. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  117. from wx_merchant m
  118. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = #{id} and m.tenant_id=#{tenantId} and mtd.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 and m.id = mm.id)
  119. /
  120. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  121. from wx_merchant m
  122. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  123. left join wx_shop ws on(mtd.shop_id = ws.id)
  124. where m.status = 1 and m.is_del = 0 and m.business_id = #{id} and m.tenant_id=#{tenantId} and m.id = mm.id)
  125. /100,2) sale,
  126. round(
  127. round(
  128. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  129. from wx_merchant m
  130. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = #{id} and m.tenant_id=#{tenantId} and mtd.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 and m.id = mm.id)/
  131. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  132. from wx_merchant m
  133. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  134. left join wx_shop ws on(mtd.shop_id = ws.id)
  135. where m.status = 1 and m.is_del = 0 and m.business_id = #{id} and m.tenant_id=#{tenantId} and m.id = mm.id)/100,2)
  136. /
  137. round(
  138. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  139. from wx_merchant m
  140. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = #{id} and m.tenant_id=#{tenantId} and mtd.report_date between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  141. /
  142. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  143. from wx_merchant m
  144. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  145. left join wx_shop ws on(mtd.shop_id = ws.id)
  146. where m.business_id = #{id} and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 )
  147. /100,2)
  148. *100,2) devoteRate
  149. from wx_merchant mm
  150. left join wx_merchant_trade_daily mtd on mtd.merchant_id = mm.id
  151. left join wx_merchant_shop wmt on wmt.merchant_id = mm.id
  152. left join wx_shop ws on(wmt.shop_id = ws.id)
  153. where mm.business_id=#{id} and mm.tenant_id=#{tenantId}
  154. and mm.status = 1 and mm.is_del = 0
  155. and mtd.report_date between #{startdate} and #{enddate}
  156. group by mm.id
  157. order by devoteRate desc
  158. <if test="null != limitStart and null != limitEnd">
  159. limit #{limitStart},#{limitEnd}
  160. </if>
  161. </select>
  162. </mapper>