Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

175 linhas
6.8 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 STR_TO_DATE(mtd.report_date,'%Y-%m-%d') 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 STR_TO_DATE(mtd.report_date,'%Y-%m-%d') 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. (select ifnull(sum(rent_area),0) from wx_rent_contract where tenant_id=#{tenantId} and business_id=b.id and status in (2,3,4)) area,
  90. round(
  91. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  92. from wx_merchant m
  93. 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 STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 ) /
  94. (select sum(mtd.trade_count)
  95. from wx_merchant m
  96. 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 STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  97. /100,2) comPrice
  98. from wx_business b
  99. </select>
  100. <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
  101. select mm.name merchantName,
  102. round(
  103. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  104. from wx_merchant m
  105. 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)
  106. /
  107. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  108. from wx_merchant m
  109. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  110. left join wx_shop ws on(mtd.shop_id = ws.id)
  111. where m.status = 1 and m.is_del = 0 and m.business_id = #{id} and m.tenant_id=#{tenantId} and m.id = mm.id)
  112. /100,2) sale,
  113. round(
  114. round(
  115. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  116. from wx_merchant m
  117. 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)/
  118. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  119. from wx_merchant m
  120. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  121. left join wx_shop ws on(mtd.shop_id = ws.id)
  122. 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)
  123. /
  124. round(
  125. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  126. from wx_merchant m
  127. 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 )
  128. /
  129. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  130. from wx_merchant m
  131. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  132. left join wx_shop ws on(mtd.shop_id = ws.id)
  133. where m.business_id = #{id} and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 )
  134. /100,2)
  135. *100,2) devoteRate
  136. from wx_merchant mm
  137. left join wx_merchant_trade_daily mtd on mtd.merchant_id = mm.id
  138. left join wx_merchant_shop wmt on wmt.merchant_id = mm.id
  139. left join wx_shop ws on(wmt.shop_id = ws.id)
  140. where mm.business_id=#{id} and mm.tenant_id=#{tenantId}
  141. and mm.status = 1 and mm.is_del = 0
  142. and mtd.report_date between #{startdate} and #{enddate}
  143. group by mm.id
  144. order by devoteRate desc
  145. <if test="null != limitStart and null != limitEnd">
  146. limit #{limitStart},#{limitEnd}
  147. </if>
  148. </select>
  149. </mapper>