|
- <?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.WxMerchantTradeDailyMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantTradeDaily">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
- <result column="trade_count" property="tradeCount" />
- <result column="proof" property="proof"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`,trade_count,proof
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != bUserId ">
- and `b_user_id` = #{bUserId}
- </if>
-
- <if test=" null != tradeAmt ">
- and `trade_amt` = #{tradeAmt}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
-
- <if test=" null != reportDate ">
- and `report_date` = #{reportDate}
- </if>
-
- <if test=" null != month ">
- and date_format(create_date,'%Y-%m')=#{month}
- </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>
- <if test=" null == sortColumns"> order by report_date desc </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_merchant_trade_daily
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findListOfWeek" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_merchant_trade_daily
-
- where 1=1
- <if test="reportDate!=null">
- and `report_date` != #{reportDate}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
- order by create_date desc LIMIT 7
- </select>
-
-
- <resultMap id="BaseResultMapVo" type="com.iformall.domain.vo.WxMerchantTradeDailyVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
- <result column="trade_count" property="tradeCount" />
- <result column="proof" property="proof"/>
-
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
- <result column="business_id" jdbcType="VARCHAR" property="businessId" />
- <result column="sub_business_id" jdbcType="VARCHAR" property="subBusinessId" />
-
- <result column="b_user_name" jdbcType="VARCHAR" property="bUserName" />
- <result column="b_user_phone" jdbcType="VARCHAR" property="bUserPhone"/>
-
- </resultMap>
-
- <sql id="allColumnsVo">
- mtd.id as id, mtd.b_user_id as b_user_id, ifnull(mtd.trade_amt,0) as trade_amt, mtd.report_date,
- ifnull(mtd.trade_count,0) as trade_count, mtd.proof,mtd.create_date as create_date, mtd.update_date as update_date,
- m.tenant_id as tenant_id,m.parent_tenant_id as parent_tenant_id,
- m.id as merchant_id, m.name as merchant_name, m.business_id, m.sub_business_id,
- mbu.name as b_user_name, mbu.phone as b_user_phone
- </sql>
-
- <select id="findVoList" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMapVo">
- select
- <include refid="allColumnsVo"/>
- from wx_merchant_trade_daily mtd
- inner join wx_merchant m on mtd.merchant_id = m.id
- left join wx_merchant_b_user mbu on mtd.b_user_id = mbu.id
- where 1 = 1
-
- <if test=" null != tenantId and '' != tenantId">
- and mtd.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and mtd.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != merchantId ">
- and mtd.merchant_id = #{merchantId}
- </if>
-
- <if test=" null != merchantName and ''!=merchantName">
- and m.name like concat('%', #{merchantName},'%')
- </if>
-
- <if test=" null != startTime and null != endTime">
- and mtd.report_date >= date_format(#{startTime},'%Y-%m-%d')
- and mtd.report_date <= date_format(#{endTime},'%Y-%m-%d')
- </if>
-
- <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)">
- and mtd.merchant_id in(
- select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
- inner join wx_merchant m on ms.merchant_id = m.id
- inner join wx_shop s on s.id=ms.shop_id
- where s.is_del=0
- <if test=" null != tenantId and '' != tenantId">
- and m.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and m.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != businessForRule and '' != businessForRule ">
- and m.business_id in (${businessForRule})
- </if>
- <if test=" null != floorForRule and '' != floorForRule ">
- and s.`floor` in (${floorForRule})
- </if>
- )
- </if>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="findSumMoney" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultType="String">
- select IFNULL(sum(mtd.trade_amt),0)
- from wx_merchant_trade_daily mtd
- where mtd.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and mtd.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != merchantId ">
- and mtd.merchant_id = #{merchantId}
- </if>
- <if test=" null != reportDate ">
- and mtd.report_date = #{reportDate}
- </if>
-
- <if test=" null != startTime and null != endTime">
- and mtd.report_date >= date_format(#{startTime},'%Y-%m-%d')
- and mtd.report_date <= date_format(#{endTime},'%Y-%m-%d')
- </if>
- </select>
-
-
- <resultMap id="BaseTotalResultMap" type="com.iformall.domain.po.WxMerchantTradeDaily">
- <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" />
- <result column="report_date" jdbcType="VARCHAR" property="reportDate" />
- </resultMap>
-
- <select id="findTotalListOfMonth" parameterType="com.iformall.domain.po.WxMerchantTradeDaily"
- resultMap="BaseTotalResultMap">
- select report_date, IFNULL(sum(mtd.trade_amt),0) as trade_amt
- from wx_merchant_trade_daily mtd
- where mtd.`tenant_id` = #{tenantId}
- <if test=" null != parentTenantId and '' != parentTenantId">
- and mtd.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != reportDate ">
- and mtd.report_date = #{reportDate}
- </if>
- group by mtd.report_date
- order by mtd.report_date desc
- LIMIT 30
- </select>
-
- </mapper>
|