后台服务
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.

WxBusinessMapper.xml 9.7 KiB

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