|
- <?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.WxOfflineActivityGrantSettlementMapper">
-
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOfflineActivityGrantSettlement">
- <id property="id" column="id" jdbcType="BIGINT"/>
- <result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>
- <result property="parentTenantId" column="parent_tenant_id" jdbcType="VARCHAR"/>
- <result property="recordId" column="record_id" jdbcType="BIGINT"/>
- <result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
- <result property="orderMoney" column="order_money" jdbcType="DECIMAL"/>
- <result property="merchantId" column="merchant_id" jdbcType="BIGINT"/>
- <result property="activityId" column="activity_id" jdbcType="BIGINT"/>
- <result property="activityItemId" column="activity_item_id" jdbcType="BIGINT"/>
- <result property="awardItamId" column="award_itam_id" jdbcType="BIGINT"/>
- <result property="grantId" column="grant_id" jdbcType="BIGINT"/>
- <result property="grantPrice" column="grant_price" jdbcType="DECIMAL"/>
- <result property="mallShareRate" column="mall_share_rate" jdbcType="DECIMAL"/>
- <result property="merchantShareRate" column="merchant_share_rate" jdbcType="DECIMAL"/>
- <result property="orderRatio" column="order_ratio" jdbcType="DECIMAL"/>
- <result property="realGrantPrice" column="real_grant_price" jdbcType="DECIMAL"/>
- <result property="realMallSharePrice" column="real_mall_share_price" jdbcType="DECIMAL"/>
- <result property="realMerchantSharePrice" column="real_merchant_share_price" jdbcType="DECIMAL"/>
- <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
- <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
- </resultMap>
-
- <sql id="allColumns">
- id,tenant_id,parent_tenant_id,
- record_id,order_no,order_money,
- merchant_id,activity_id,activity_item_id,
- award_itam_id,grant_id,grant_price,
- mall_share_rate,merchant_share_rate,order_ratio,
- real_grant_price,real_mall_share_price,real_merchant_share_price,
- create_date,update_date
- </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 != recordId ">
- and `record_id` = #{recordId}
- </if>
- <if test=" null != orderNo and orderNo != '' ">
- and `order_no` like concat('%', #{orderNo},'%')
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
- <if test=" null != activityId ">
- and `activity_id` = #{activityId}
- </if>
- <if test=" null != activityItemId ">
- and `activity_item_id` = #{activityItemId}
- </if>
- <if test=" null != awardItamId ">
- and `award_itam_id` = #{awardItamId}
- </if>
- <if test=" null != grantId ">
- and `grant_id` = #{grantId}
- </if>
- <if test=" null != createDateBegin">
- and `create_date` >= #{createDateBegin}
- </if>
-
- <if test=" null != createDateEnd">
- and `create_date` <= #{createDateEnd}
- </if>
- <if test=" null != merchantIdList ">
- and merchant_id in
- <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
- #{midItem}
- </foreach>
- </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.WxOfflineActivityGrantSettlement" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_offline_activity_grant_settlement
- <include refid="dynamicWhereConditions" />
- </select>
-
- <insert id="insertList" parameterType="java.util.List">
- insert into wx_offline_activity_grant_settlement
- (id,
- record_id,order_no,order_money,
- merchant_id,activity_id,activity_item_id,
- award_itam_id,grant_id,grant_price,
- mall_share_rate,merchant_share_rate,order_ratio,
- real_grant_price,real_mall_share_price,real_merchant_share_price,
- create_date,update_date)
- values
- <foreach collection="settlementList" item="item" index="index" separator=",">
- (#{item.id,jdbcType=BIGINT},
- #{item.recordId,jdbcType=BIGINT},#{item.orderNo,jdbcType=VARCHAR},#{item.orderMoney,jdbcType=DECIMAL},
- #{item.merchantId,jdbcType=BIGINT},#{item.activityId,jdbcType=BIGINT},#{item.activityItemId,jdbcType=BIGINT},
- #{item.awardItamId,jdbcType=BIGINT},#{item.grantId,jdbcType=BIGINT},#{item.grantPrice,jdbcType=DECIMAL},
- #{item.mallShareRate,jdbcType=DECIMAL},#{item.merchantShareRate,jdbcType=DECIMAL},#{item.orderRatio,jdbcType=DECIMAL},
- #{item.realGrantPrice,jdbcType=DECIMAL},#{item.realMallSharePrice,jdbcType=DECIMAL},#{item.realMerchantSharePrice,jdbcType=DECIMAL},
- #{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP})
- </foreach>
- </insert>
-
- <select id="settlementStatistics" parameterType="com.iformall.domain.po.WxOfflineActivityGrantSettlement" resultType="com.iformall.domain.vo.OfflineActivitySettlementStatistics">
- SELECT IFNULL(sum(real_grant_price),0) as 'sumGrantPrice',
- count(DISTINCT record_id) as 'recordCount',
- count(DISTINCT merchant_id) as 'merchantCount',
- IFNULL(sum(real_mall_share_price),0) as 'sumMallPrice',
- IFNULL(sum(real_merchant_share_price),0) as 'sumMerchantPrice'
- FROM wx_offline_activity_grant_settlement
- where 1 = 1
- <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 != activityId">
- and `activity_id` = #{activityId}
- </if>
-
- <if test=" null != createDateBegin">
- and `create_date` >= #{createDateBegin}
- </if>
-
- <if test=" null != createDateEnd">
- and `create_date` <= #{createDateEnd}
- </if>
-
- </select>
-
-
- <select id="getActivitySettlement" parameterType="com.iformall.domain.vo.OfflineActivitySettlement" resultType="com.iformall.domain.vo.OfflineActivitySettlement">
- SELECT merchant_id as 'merchantId',
- activity_id as 'activityId',
- count(record_id) as 'recordCount',
- IFNULL(sum(order_money),0) as 'sumOrderMoney',
- IFNULL(sum(real_grant_price),0) as 'sumGrantPrice',
- IFNULL(sum(real_mall_share_price),0) as 'sumMallPrice',
- IFNULL(sum(real_merchant_share_price),0) as 'sumMerchantPrice'
- FROM wx_offline_activity_grant_settlement
- where `activity_id` = #{activityId}
- <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 != merchantIdList ">
- and merchant_id in
- <foreach collection="merchantIdList" index="index" item="midItem" open="(" separator="," close=")">
- #{midItem}
- </foreach>
- </if>
- group by merchant_id
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
-
- </mapper>
|