|
- <?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="grantItemId" column="grant_item_id" jdbcType="BIGINT"/>
- <result property="grantAwardsMode" column="grant_awards_mode" jdbcType="SMALLINT"/>
- <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"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- </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_item_id,grant_awards_mode,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 != grantItemId ">
- and `grant_item_id` = #{grantItemId}
- </if>
- <if test=" null != grantAwardsMode">
- and `grant_awards_mode` = #{grantAwardsMode}
- </if>
- <if test=" null != createDateBegin">
- and `create_date` >= #{createDateBegin}
- </if>
-
- <if test=" null != createDateEnd">
- and `create_date` <= #{createDateEnd}
- </if>
- <if test=" null != status">
- and `status` = #{status}
- </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_item_id,grant_awards_mode,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.grantItemId,jdbcType=BIGINT},#{item.grantAwardsMode,jdbcType=INTEGER},#{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 != activityItemId ">
- and `activity_item_id` = #{activityItemId}
- </if>
-
- <if test=" null != createDateBegin">
- and `create_date` >= #{createDateBegin}
- </if>
-
- <if test=" null != createDateEnd">
- and `create_date` <= #{createDateEnd}
- </if>
-
- <if test=" null != status">
- and `status` = #{status}
- </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 != status">
- and `status` = #{status}
- </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>
-
- <select id="activityItemStatistics" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
- SELECT count(DISTINCT grant_id) as 'grantCount',
- count(DISTINCT record_id) as 'orderCount',
- IFNULL(sum(real_grant_price),0) as 'itemSumMoney',
- IFNULL(sum(real_mall_share_price),0) as 'mallSumPrice',
- IFNULL(sum(real_merchant_share_price),0) as 'merchantSumPrice'
- 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 != activityItemId ">
- and `activity_item_id` = #{activityItemId}
- </if>
-
- <if test=" null != createDateBegin">
- and `create_date` >= #{createDateBegin}
- </if>
-
- <if test=" null != createDateEnd">
- and `create_date` <= #{createDateEnd}
- </if>
-
- <if test=" null != status">
- and `status` = #{status}
- </if>
-
- <if test=" null != awardsItemIdList ">
- and award_itam_id in
- <foreach collection="awardsItemIdList" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
- <select id="activityItemStatisticsChart" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
- SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,
- count(DISTINCT grant_id) as 'grantCount',
- count(DISTINCT record_id) as 'orderCount',
- IFNULL(sum(real_grant_price),0) as 'itemSumMoney',
- IFNULL(sum(real_mall_share_price),0) as 'mallSumPrice',
- IFNULL(sum(real_merchant_share_price),0) as 'merchantSumPrice'
- 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 != activityItemId ">
- and `activity_item_id` = #{activityItemId}
- </if>
-
- <if test=" null != createDateBegin">
- and `create_date` >= #{createDateBegin}
- </if>
-
- <if test=" null != createDateEnd">
- and `create_date` <= #{createDateEnd}
- </if>
-
- <if test=" null != status">
- and `status` = #{status}
- </if>
-
- <if test=" null != awardsItemIdList ">
- and award_itam_id in
- <foreach collection="awardsItemIdList" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- group by xTime
- </select>
-
- <update id="updateStatusNo" parameterType="com.iformall.domain.po.WxOfflineActivityGrantAward" >
- update wx_offline_activity_grant_settlement set status = 0,update_date = now()
- where grant_id in (
- select id from wx_offline_activity_grant_award
- where `activity_id` = #{activityId} and `cus_phone` = #{cusPhone} and `id` != #{id})
- </update>
-
- <!-- <select id="findAwardItemGrantList" parameterType="com.iformall.domain.po.WxOfflineActivityGrantSettlement" resultType="com.iformall.domain.vo.OfflineActivityGrantItemVo">-->
- <!-- select gi.grant_id,-->
- <!-- gi.activity_id,gi.activity_name,-->
- <!-- gi.activity_item_id,gi.activity_item_name,-->
- <!-- gi.award_itam_id,gi.award_name,-->
- <!-- gi.cash_back_ratio,gi.award_price,gi.award_count,-->
- <!-- gi.starting_tax_point,gi.tax_points,gi.tax_points_amount,-->
- <!-- gi.mall_share_rate,gi.merchant_share_rate,-->
- <!-- gs.record_id,-->
- <!-- gs.grant_item_id,-->
- <!-- gs.order_no,gs.order_money,-->
- <!-- gs.merchant_id,-->
- <!-- gs.real_grant_price,-->
- <!-- gs.real_mall_share_price,gs.real_merchant_share_price-->
- <!-- from wx_offline_activity_grant_item gi-->
- <!-- inner join wx_offline_activity_grant_settlement gs on gs.grant_item_id = gi.id and gs.record_id = gi.record_id-->
- <!-- where gi.status = 1 and gi.grant_awards_mode = 1 and gi.record_id is not null-->
- <!-- <if test=" null != tenantId and '' != tenantId">-->
- <!-- and gi.`tenant_id` = #{tenantId}-->
- <!-- </if>-->
- <!-- <if test=" null != parentTenantId and '' != parentTenantId">-->
- <!-- and gi.`parent_tenant_id` = #{parentTenantId}-->
- <!-- </if>-->
- <!-- <if test=" null != activityItemId ">-->
- <!-- and gi.`activity_item_id` = #{activityItemId}-->
- <!-- </if>-->
- <!-- <if test=" null != awardItamId ">-->
- <!-- and gi.`award_itam_id` = #{awardItamId}-->
- <!-- </if>-->
- <!-- <if test=" null != minMoney">-->
- <!-- and gs.`order_money` >= #{minMoney}-->
- <!-- </if>-->
-
- <!-- <if test=" null != maxMoney">-->
- <!-- and gs.`order_money` < #{maxMoney}-->
- <!-- </if>-->
- <!-- order by gi.`create_date` desc-->
- <!-- </select>-->
-
- <select id="findAwardItemGrantList" resultType="com.iformall.domain.vo.OfflineActivityGrantItemVo">
- select gi.grant_id,
- gi.activity_id,gi.activity_name,
- gi.activity_item_id,gi.activity_item_name,
- gi.award_itam_id,gi.award_name,
- gi.cash_back_ratio,gi.award_price,gi.award_count,
- gi.starting_tax_point,gi.tax_points,gi.tax_points_amount,
- gi.mall_share_rate,gi.merchant_share_rate,
- gs.record_id,
- gs.grant_item_id,
- gs.order_no,gs.order_money,
- gs.merchant_id,
- gs.real_grant_price,
- gs.real_mall_share_price,gs.real_merchant_share_price
- from wx_offline_activity_grant_settlement gs
- left join wx_offline_activity_grant_item gi on gs.grant_item_id = gi.id
- where gi.status = 1
- and gi.grant_awards_mode = #{grantAwardsMode}
- <if test=" null != tenantId and '' != tenantId">
- and gi.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and gi.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != activityItemId ">
- and gi.`activity_item_id` = #{activityItemId}
- </if>
- <if test=" null != awardItamId ">
- and gi.`award_itam_id` = #{awardItamId}
- </if>
- <if test=" null != minMoney">
- and gs.`order_money` >= #{minMoney}
- </if>
-
- <if test=" null != maxMoney">
- and gs.`order_money` < #{maxMoney}
- </if>
- order by gi.`create_date` desc
- </select>
-
- </mapper>
|