|
- <?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.WxOfflineActivityGrantItemMapper">
-
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOfflineActivityGrantItem">
- <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="grantId" column="grant_id" jdbcType="BIGINT"/>
- <result property="grantAwardsMode" column="grant_awards_mode" jdbcType="SMALLINT"/>
-
- <result property="activityId" column="activity_id" jdbcType="BIGINT"/>
- <result property="activityName" column="activity_name" jdbcType="VARCHAR"/>
- <result property="activityItemId" column="activity_item_id" jdbcType="BIGINT"/>
- <result property="activityItemName" column="activity_item_name" jdbcType="INTEGER"/>
- <result property="activityItemType" column="activity_item_type" jdbcType="SMALLINT"/>
- <result property="awardItamId" column="award_itam_id" jdbcType="BIGINT"/>
- <result property="awardName" column="award_name" jdbcType="VARCHAR"/>
- <result property="awardGrade" column="award_grade" jdbcType="INTEGER"/>
- <result property="awardMinAmount" column="award_min_amount" jdbcType="DECIMAL"/>
- <result property="awardMaxAmount" column="award_max_amount" jdbcType="DECIMAL"/>
- <result property="awardsItemRule" column="awards_item_rule" jdbcType="INTEGER"/>
- <result property="cashBackRatio" column="cash_back_ratio" jdbcType="DECIMAL"/>
- <result property="awardPrice" column="award_price" jdbcType="DECIMAL"/>
- <result property="awardCount" column="award_count" jdbcType="INTEGER"/>
- <result property="moneyRule" column="money_rule" jdbcType="SMALLINT"/>
- <result property="mallShareRate" column="mall_share_rate" jdbcType="DECIMAL"/>
- <result property="merchantShareRate" column="merchant_share_rate" jdbcType="DECIMAL"/>
- <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
- <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
- <result property="recordId" column="record_id" jdbcType="BIGINT"/>
- <result property="status" column="status" jdbcType="INTEGER"/>
- </resultMap>
-
- <sql id="allColumns">
- id,tenant_id,parent_tenant_id,
- grant_id,grant_awards_mode,activity_id,activity_name,
- activity_item_id,activity_item_name,activity_item_type,
- award_itam_id,award_name,award_grade,
- award_min_amount,award_max_amount,awards_item_rule,cash_back_ratio,
- award_price,award_count,money_rule,
- mall_share_rate,merchant_share_rate,
- create_date,update_date,record_id
- </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 != grantId">
- and `grant_id` = #{grantId}
- </if>
-
- <if test=" null != grantAwardsMode">
- and `grant_awards_mode` = #{grantAwardsMode}
- </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 != status">
- and `status` = #{status}
- </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.WxOfflineActivityGrantItem" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_offline_activity_grant_item
- <include refid="dynamicWhereConditions" />
- </select>
-
- <insert id="insertList" parameterType="java.util.List">
- insert into wx_offline_activity_grant_item
- (id,
- grant_id,grant_awards_mode,activity_id,activity_name,
- activity_item_id,activity_item_name,activity_item_type,
- award_itam_id,award_name,award_grade,
- award_min_amount,award_max_amount,awards_item_rule,cash_back_ratio,
- award_price,award_count,money_rule,
- mall_share_rate,merchant_share_rate,
- create_date,update_date,record_id)
- values
- <foreach collection="grantItemList" item="item" index="index" separator=",">
- (#{item.id,jdbcType=BIGINT},
- #{item.grantId,jdbcType=BIGINT},#{item.grantAwardsMode,jdbcType=INTEGER},#{item.activityId,jdbcType=BIGINT},#{item.activityName,jdbcType=VARCHAR},
- #{item.activityItemId,jdbcType=BIGINT},#{item.activityItemName,jdbcType=VARCHAR},#{item.activityItemType,jdbcType=INTEGER},
- #{item.awardItamId,jdbcType=BIGINT},#{item.awardName,jdbcType=VARCHAR},#{item.awardGrade,jdbcType=INTEGER},
- #{item.awardMinAmount,jdbcType=DECIMAL},#{item.awardMaxAmount,jdbcType=DECIMAL},#{item.awardsItemRule,jdbcType=INTEGER},#{item.cashBackRatio,jdbcType=DECIMAL},
- #{item.awardPrice,jdbcType=DECIMAL},#{item.awardCount,jdbcType=INTEGER},#{item.moneyRule,jdbcType=INTEGER},
- #{item.mallShareRate,jdbcType=DECIMAL},#{item.merchantShareRate,jdbcType=DECIMAL},
- #{item.createDate,jdbcType=TIMESTAMP},#{item.updateDate,jdbcType=TIMESTAMP},#{item.recordId,jdbcType=BIGINT})
- </foreach>
- </insert>
-
- <select id="getSumAwardCount" parameterType="com.iformall.domain.po.WxOfflineActivityGrantItem" resultType="Integer">
- SELECT IFNULL(sum(award_count),0) FROM wx_offline_activity_grant_item
- 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 != status">
- and `status` = #{status}
- </if>
- </select>
- <select id="activityItemStatistics" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineActivityItemStatistics">
- SELECT IFNULL(sum(award_count),0) as 'itemCount',
- IFNULL(sum(award_price),0) as 'itemSumMoney'
- FROM wx_offline_activity_grant_item
- 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,
- IFNULL(sum(award_count),0) as 'itemCount',
- IFNULL(sum(award_price),0) as 'itemSumMoney'
- FROM wx_offline_activity_grant_item
- 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>
- <select id="awardsItemStatistics" parameterType="com.iformall.domain.vo.OfflineActivityItemStatisticsBVo" resultType="com.iformall.domain.vo.OfflineGantItemStatistics">
- SELECT award_itam_id as 'awardItamId',
- IFNULL(sum(award_count),0) as 'awardItamCount',
- IFNULL(sum(award_price),0) as 'sumPrice'
- FROM wx_offline_activity_grant_item
- 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>
- group by award_itam_id
- </select>
-
- <update id="updateStatusNo" parameterType="com.iformall.domain.po.WxOfflineActivityGrantAward" >
- update wx_offline_activity_grant_item 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>
-
- </mapper>
|