Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

284 řádky
9.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.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
  41. <include refid="allColumns"/>
  42. from wx_business
  43. <include refid="dynamicWhereConditions" />
  44. </select>
  45. <select id="findListAll" resultMap="BaseResultMap">
  46. select
  47. <include refid="allColumns"/>
  48. from wx_business
  49. order by create_date asc
  50. </select>
  51. <select id="findListForMerchant" resultMap="BaseResultMap">
  52. select
  53. <include refid="allColumns"/>
  54. from wx_business b
  55. where
  56. (select count(*) from wx_merchant m
  57. where b.id = m.business_id
  58. <if test=" null != tenantId and '' != tenantId">
  59. and m.`tenant_id` = #{tenantId}
  60. </if>
  61. <if test=" null != parentTenantId and '' != parentTenantId">
  62. and m.`parent_tenant_id` = #{parentTenantId}
  63. </if>
  64. and m.status = 1
  65. and m.is_public = 1) > 0
  66. order by create_date asc
  67. </select>
  68. <select id="findListForCoupon" resultMap="BaseResultMap">
  69. select
  70. <include refid="allColumns"/>
  71. from wx_business b
  72. where
  73. (select count(*) from wx_coupon_channel cc
  74. where b.id = cc.business
  75. <if test=" null != tenantId and '' != tenantId">
  76. and cc.`tenant_id` = #{tenantId}
  77. </if>
  78. <if test=" null != parentTenantId and '' != parentTenantId">
  79. and cc.`parent_tenant_id` = #{parentTenantId}
  80. </if>
  81. and cc.status = 0
  82. and cc.target_ad = 1) > 0
  83. order by create_date asc
  84. </select>
  85. <select id="businessDataList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
  86. select b.id,b.title,
  87. round(
  88. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  89. from wx_merchant m
  90. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
  91. <if test=" null != tenantId and '' != tenantId">
  92. and m.`tenant_id` = #{tenantId}
  93. </if>
  94. <if test=" null != parentTenantId and '' != parentTenantId">
  95. and m.`parent_tenant_id` = #{parentTenantId}
  96. </if>
  97. and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  98. /100,2) volume,
  99. round(
  100. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  101. from wx_merchant m
  102. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
  103. <if test=" null != tenantId and '' != tenantId">
  104. and m.`tenant_id` = #{tenantId}
  105. </if>
  106. <if test=" null != parentTenantId and '' != parentTenantId">
  107. and m.`parent_tenant_id` = #{parentTenantId}
  108. </if>
  109. and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  110. /
  111. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  112. from wx_merchant m
  113. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  114. left join wx_shop ws on(mtd.shop_id = ws.id)
  115. where m.business_id = b.id and m.status = 1 and m.is_del = 0
  116. <if test=" null != tenantId and '' != tenantId">
  117. and m.`tenant_id` = #{tenantId}
  118. </if>
  119. <if test=" null != parentTenantId and '' != parentTenantId">
  120. and m.`parent_tenant_id` = #{parentTenantId}
  121. </if>
  122. )
  123. /100,2) sale,
  124. (select ifnull(sum(rent_area),0) from wx_rent_contract where business_id=b.id
  125. <if test=" null != tenantId and '' != tenantId">
  126. and `tenant_id` = #{tenantId}
  127. </if>
  128. <if test=" null != parentTenantId and '' != parentTenantId">
  129. and `parent_tenant_id` = #{parentTenantId}
  130. </if>
  131. and status in (2,3,4)) area,
  132. round(
  133. (select if(sum(mtd.trade_amt) is null,0,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
  136. <if test=" null != tenantId and '' != tenantId">
  137. and m.`tenant_id` = #{tenantId}
  138. </if>
  139. <if test=" null != parentTenantId and '' != parentTenantId">
  140. and m.`parent_tenant_id` = #{parentTenantId}
  141. </if>
  142. and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 ) /
  143. (select sum(mtd.trade_count)
  144. from wx_merchant m
  145. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
  146. <if test=" null != tenantId and '' != tenantId">
  147. and m.`tenant_id` = #{tenantId}
  148. </if>
  149. <if test=" null != parentTenantId and '' != parentTenantId">
  150. and m.`parent_tenant_id` = #{parentTenantId}
  151. </if>
  152. and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
  153. /100,2) comPrice
  154. from wx_business b
  155. </select>
  156. <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
  157. select mm.name merchantName,
  158. round(
  159. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  160. from wx_merchant m
  161. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
  162. where m.business_id = #{id}
  163. <if test=" null != tenantId and '' != tenantId">
  164. and m.`tenant_id` = #{tenantId}
  165. </if>
  166. <if test=" null != parentTenantId and '' != parentTenantId">
  167. and m.`parent_tenant_id` = #{parentTenantId}
  168. </if>
  169. and mtd.report_date between #{startdate} and #{enddate}
  170. and m.status = 1 and m.is_del = 0 and m.id = mm.id)
  171. /
  172. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  173. from wx_merchant m
  174. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  175. left join wx_shop ws on(mtd.shop_id = ws.id)
  176. where m.status = 1 and m.is_del = 0 and m.business_id = #{id}
  177. <if test=" null != tenantId and '' != tenantId">
  178. and m.`tenant_id` = #{tenantId}
  179. </if>
  180. <if test=" null != parentTenantId and '' != parentTenantId">
  181. and m.`parent_tenant_id` = #{parentTenantId}
  182. </if>
  183. and m.id = mm.id)
  184. /100,2) sale,
  185. round(
  186. round(
  187. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  188. from wx_merchant m
  189. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
  190. where m.business_id = #{id}
  191. <if test=" null != tenantId and '' != tenantId">
  192. and m.`tenant_id` = #{tenantId}
  193. </if>
  194. <if test=" null != parentTenantId and '' != parentTenantId">
  195. and m.`parent_tenant_id` = #{parentTenantId}
  196. </if>
  197. and mtd.report_date between #{startdate} and #{enddate}
  198. and m.status = 1 and m.is_del = 0 and m.id = mm.id)/
  199. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  200. from wx_merchant m
  201. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  202. left join wx_shop ws on(mtd.shop_id = ws.id)
  203. where m.status = 1 and m.is_del = 0 and m.business_id = #{id}
  204. <if test=" null != tenantId and '' != tenantId">
  205. and m.`tenant_id` = #{tenantId}
  206. </if>
  207. <if test=" null != parentTenantId and '' != parentTenantId">
  208. and m.`parent_tenant_id` = #{parentTenantId}
  209. </if>
  210. and m.id = mm.id)/100,2)
  211. /
  212. round(
  213. (select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
  214. from wx_merchant m
  215. left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
  216. where m.business_id = #{id}
  217. <if test=" null != tenantId and '' != tenantId">
  218. and m.`tenant_id` = #{tenantId}
  219. </if>
  220. <if test=" null != parentTenantId and '' != parentTenantId">
  221. and m.`parent_tenant_id` = #{parentTenantId}
  222. </if>
  223. and mtd.report_date between #{startdate} and #{enddate}
  224. and m.status = 1 and m.is_del = 0 )
  225. /
  226. (select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
  227. from wx_merchant m
  228. left join wx_merchant_shop mtd on mtd.merchant_id = m.id
  229. left join wx_shop ws on(mtd.shop_id = ws.id)
  230. where m.business_id = #{id}
  231. <if test=" null != tenantId and '' != tenantId">
  232. and m.`tenant_id` = #{tenantId}
  233. </if>
  234. <if test=" null != parentTenantId and '' != parentTenantId">
  235. and m.`parent_tenant_id` = #{parentTenantId}
  236. </if>
  237. and m.status = 1 and m.is_del = 0 )
  238. /100,2)
  239. *100,2) devoteRate
  240. from wx_merchant mm
  241. left join wx_merchant_trade_daily mtd on mtd.merchant_id = mm.id
  242. left join wx_merchant_shop wmt on wmt.merchant_id = mm.id
  243. left join wx_shop ws on(wmt.shop_id = ws.id)
  244. where mm.business_id=#{id}
  245. <if test=" null != tenantId and '' != tenantId">
  246. and mm.`tenant_id` = #{tenantId}
  247. </if>
  248. <if test=" null != parentTenantId and '' != parentTenantId">
  249. and mm.`parent_tenant_id` = #{parentTenantId}
  250. </if>
  251. and mm.status = 1 and mm.is_del = 0
  252. and mtd.report_date between #{startdate} and #{enddate}
  253. group by mm.id
  254. order by devoteRate desc
  255. <if test="null != limitStart and null != limitEnd">
  256. limit #{limitStart},#{limitEnd}
  257. </if>
  258. </select>
  259. </mapper>