|
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.iformall.mapper.WxBusinessMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBusiness">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`title`,`type`,`create_date`,`update_date`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != title ">
- and `title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != type ">
- and `type` = #{type}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxBusiness" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_business
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findListAll" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_business
- order by create_date asc
- </select>
-
- <select id="findListForMerchant" resultMap="BaseResultMap">
- select <include refid="allColumns" />
- from wx_business b
- where
- (select count(*) from wx_merchant m
- where
- m.tenant_id = #{tenantId}
- and b.id = m.business_id
- and m.status = 1
- and m.is_public = 1) > 0
- order by create_date asc
- </select>
-
- <select id="findListForCoupon" resultMap="BaseResultMap">
- select <include refid="allColumns" />
- from wx_business b
- where
- (select count(*) from wx_coupon_channel cc
- where
- cc.tenant_id = #{tenantId}
- and b.id = cc.business
- and cc.status = 0
- and cc.target_ad = 1) > 0
- order by create_date asc
- </select>
-
- <select id="businessDataList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
- select b.id,b.title,
-
- round(
- (select sum(mtd.trade_amt)
- from wx_merchant m
- 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})
- /100,2) volume,
-
- round(
- (select sum(mtd.trade_amt)
- from wx_merchant m
- 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})
- /
- (select sum(ws.operation_area)
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = b.id and m.tenant_id=#{tenantId})
- /100,2) sale,
-
- round(
- (select
- (select sum(br.receive_pay) receive_pay from wx_merchant m
- 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})
- +
- (select sum(br.receive_pay) receive_pay from wx_merchant m
- 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})
- from dual) /
- (select sum(ws.operation_area)
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = b.id and m.tenant_id=#{tenantId} )
- /100,2) rent,
-
- round(
- round(
- (select sum(mtd.trade_amt)
- from wx_merchant m
- 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})
- /
- (select sum(ws.operation_area)
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = b.id and m.tenant_id=#{tenantId})
- /100,2)
- /
- round(
- (select
- (select sum(br.receive_pay) receive_pay from wx_merchant m
- 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})
- +
- (select sum(br.receive_pay) receive_pay from wx_merchant m
- 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})
- from dual) /
- (select sum(ws.operation_area)
- from wx_merchant m
- left join wx_merchant_shop mtd on mtd.merchant_id = m.id
- left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = b.id)
- /100,2)
- ,4)
- rentSaleRate,
-
- round(
- (select sum(mtd.trade_amt)
- from wx_merchant m
- 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}) /
- (select count(mtd.id)
- from wx_merchant m
- 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})
- /100,2) comPrice
-
- from wx_business b
- </select>
-
- <select id="devoteList" parameterType="com.iformall.domain.po.WxBusiness" resultType="hashmap">
- select m.name merchantName,round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2) sale,
-
- round(
- round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2)/
- (select round(sum(mtd.trade_amt)/sum(ws.operation_area) /100,2)
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
- left join wx_merchant_shop wmt on wmt.merchant_id = m.id
- left join wx_shop ws on(wmt.shop_id = ws.id)
- where m.business_id=#{id} and m.tenant_id=#{tenantId})
- ,2) devoteRate
-
- from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
- left join wx_merchant_shop wmt on wmt.merchant_id = m.id
- left join wx_shop ws on(wmt.shop_id = ws.id)
- where m.business_id=#{id} and m.tenant_id=#{tenantId}
- group by m.id
- order by devoteRate desc
- </select>
-
- </mapper>
|