<?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.ssm.manage.mapper.PlatformCouponMapper">

    <resultMap id="BaseResultMap" type="com.ssm.manage.entity.PlatformCoupon">
        <result property="id" column="id"/>
        <result property="couponNum" column="coupon_num"/>
        <result property="couponName" column="coupon_name"/>
        <result property="couponNumber" column="coupon_number"/>
        <result property="couponType" column="coupon_type"/>
        <result property="serviceConditions" column="service_conditions"/>
        <result property="fullReductionMoney" column="full_reduction_money"/>
        <result property="fullDiscountMoney" column="full_discount_money"/>
        <result property="fullKimsMoney" column="full_kims_money"/>
        <result property="suitableStore" column="suitable_store"/>
        <result property="suitableProject" column="suitable_project"/>
        <result property="indateType" column="indate_type"/>
        <result property="startDay" column="start_day"/>
        <result property="endDay" column="end_day"/>
        <result property="startDate" column="start_date"/>
        <result property="endDate" column="end_date"/>
        <result property="remark" column="remark"/>
        <result property="storeId" column="store_id"/>
        <result property="storeNum" column="store_num"/>
        <result property="storeName" column="store_name"/>
        <result property="inputId" column="input_id"/>
        <result property="inputNum" column="input_num"/>
        <result property="inputName" column="input_name"/>
        <result property="inputDate" column="input_date"/>
        <result property="updateId" column="update_id"/>
        <result property="updateNum" column="update_num"/>
        <result property="updateName" column="update_name"/>
        <result property="updateDate" column="update_date"/>
        <result property="state" column="state"/>
        <result property="guaranteeMoney" column="guarantee_money"/>
        <result property="storeAuditId" column="store_audit_id"/>
        <result property="storeAuditNum" column="store_audit_num"/>
        <result property="storeAuditName" column="store_audit_name"/>
        <result property="storeAuditDate" column="store_audit_date"/>
        <result property="storeAuditeeId" column="store_auditee_id"/>
        <result property="storeAuditeeNum" column="store_auditee_num"/>
        <result property="storeAuditeeName" column="store_auditee_name"/>
        <result property="storeAuditeeDate" column="store_auditee_date"/>
        <result property="confirmPaymentId" column="confirm_payment_id"/>
        <result property="confirmPaymentNum" column="confirm_payment_num"/>
        <result property="confirmPaymentName" column="confirm_payment_name"/>
        <result property="confirmPaymentDate" column="confirm_payment_date"/>
        <result property="platformAuditId" column="platform_audit_id"/>
        <result property="platformAuditNum" column="platform_audit_num"/>
        <result property="platformAuditName" column="platform_audit_name"/>
        <result property="platformAuditDate" column="platform_audit_date"/>
        <result property="platformAuditeeId" column="platform_auditee_id"/>
        <result property="platformAuditeeNum" column="platform_auditee_num"/>
        <result property="platformAuditeeName" column="platform_auditee_name"/>
        <result property="platformAuditeeDate" column="platform_auditee_date"/>
        <result property="platformReleaseId" column="platform_release_id"/>
        <result property="platformReleaseNum" column="platform_release_num"/>
        <result property="platformReleaseName" column="platform_release_name"/>
        <result property="platformReleaseDate" column="platform_release_date"/>
        <result property="platformRecycleId" column="platform_recycle_id"/>
        <result property="platformRecycleNum" column="platform_recycle_num"/>
        <result property="platformRecycleName" column="platform_recycle_name"/>
        <result property="platformRecycleDate" column="platform_recycle_date"/>
        <result property="closeId" column="close_id"/>
        <result property="closeNum" column="close_num"/>
        <result property="closeName" column="close_name"/>
        <result property="closeDate" column="close_date"/>
        <result property="shareCommissionRules" column="Share_commission_rules"/>
        <result property="fixedAmount" column="fixed_amount"/>
        <result property="orderCommission" column="order_commission"/>
        <result property="inputPhone" column="input_phone"/>
        <result property="shareMargin" column="share_margin"/>
        <result property="openId" column="open_id"/>
    </resultMap>

    <sql id="Base_Column_List">
        id
        , coupon_num, coupon_name, coupon_number, coupon_type, service_conditions, full_reduction_money,
suitable_store, suitable_project, indate_type, start_day, end_day, start_date, end_date, remark, store_id,
store_num, store_name, input_id, input_num, input_name, input_date, update_id, update_num, update_name,
update_date, state, guarantee_money, store_audit_id, store_audit_num, store_audit_name, store_audit_date,
store_auditee_id, store_auditee_num, store_auditee_name, store_auditee_date, confirm_payment_id,
confirm_payment_num, confirm_payment_name, confirm_payment_date, platform_audit_id, platform_audit_num,
platform_audit_name,platform_audit_date,platform_auditee_id,platform_auditee_num
platform_auditee_name, platform_auditee_date, platform_release_id, platform_release_num,
platform_release_name, platform_release_date, platform_recycle_id, platform_recycle_num,
platform_recycle_name, platform_recycle_date, close_id, close_num, close_name, close_date,
Share_commission_rules, fixed_amount, order_commission,input_phone,share_margin,open_id
    </sql>
    <update id="audit">
        update platform_coupon
        set state = #{state}
        where coupon_num = #{couponNum}
    </update>
    <update id="incremental">
        update platform_coupon
        set coupon_number = (coupon_number + #{couponNumber})
        where coupon_num = #{couponNum}
    </update>
    <update id="invalid">
        update platform_coupon
        set state = #{state}
        where coupon_num = #{couponNum}
    </update>

    <select id="queryAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from platform_coupon
        <where>
            <if test="id != null">
                and id = #{id}
            </if>
            <if test="couponNum != null and couponNum != ''">
                and coupon_num = #{couponNum}
            </if>
            <if test="couponName != null and couponName != ''">
                and coupon_name = #{couponName}
            </if>
            <if test="couponNumber != null">
                and coupon_number = #{couponNumber}
            </if>
            <if test="couponType != null">
                and coupon_type = #{couponType}
            </if>
            <if test="serviceConditions != null">
                and service_conditions = #{serviceConditions}
            </if>
            <if test="fullReductionMoney != null">
                and full_reduction_money = #{fullReductionMoney}
            </if>
            <if test="suitableStore != null">
                and suitable_store = #{suitableStore}
            </if>
            <if test="suitableProject != null">
                and suitable_project = #{suitableProject}
            </if>
            <if test="indateType != null">
                and indate_type = #{indateType}
            </if>
            <if test="startDay != null">
                and start_day = #{startDay}
            </if>
            <if test="endDay != null">
                and end_day = #{endDay}
            </if>
            <if test="startDate != null">
                and start_date = #{startDate}
            </if>
            <if test="endDate != null">
                and end_date = #{endDate}
            </if>
            <if test="remark != null and remark != ''">
                and remark = #{remark}
            </if>
            <if test="storeId != null">
                and store_id = #{storeId}
            </if>
            <if test="storeNum != null and storeNum != ''">
                and store_num = #{storeNum}
            </if>
            <if test="storeName != null and storeName != ''">
                and store_name = #{storeName}
            </if>
            <if test="inputId != null">
                and input_id = #{inputId}
            </if>
            <if test="inputNum != null and inputNum != ''">
                and input_num = #{inputNum}
            </if>
            <if test="inputName != null and inputName != ''">
                and input_name = #{inputName}
            </if>
            <if test="inputDate != null">
                and input_date = #{inputDate}
            </if>
            <if test="updateId != null">
                and update_id = #{updateId}
            </if>
            <if test="updateNum != null and updateNum != ''">
                and update_num = #{updateNum}
            </if>
            <if test="updateName != null and updateName != ''">
                and update_name = #{updateName}
            </if>
            <if test="updateDate != null">
                and update_date = #{updateDate}
            </if>
            <if test="state != null">
                and state = #{state}
            </if>
            <if test="guaranteeMoney != null">
                and guarantee_money = #{guaranteeMoney}
            </if>
            <if test="storeAuditId != null">
                and store_audit_id = #{storeAuditId}
            </if>
            <if test="storeAuditNum != null and storeAuditNum != ''">
                and store_audit_num = #{storeAuditNum}
            </if>
            <if test="storeAuditName != null and storeAuditName != ''">
                and store_audit_name = #{storeAuditName}
            </if>
            <if test="storeAuditDate != null">
                and store_audit_date = #{storeAuditDate}
            </if>
            <if test="storeAuditeeId != null">
                and store_auditee_id = #{storeAuditeeId}
            </if>
            <if test="storeAuditeeNum != null and storeAuditeeNum != ''">
                and store_auditee_num = #{storeAuditeeNum}
            </if>
            <if test="storeAuditeeName != null and storeAuditeeName != ''">
                and store_auditee_name = #{storeAuditeeName}
            </if>
            <if test="storeAuditeeDate != null">
                and store_auditee_date = #{storeAuditeeDate}
            </if>
            <if test="confirmPaymentId != null">
                and confirm_payment_id = #{confirmPaymentId}
            </if>
            <if test="confirmPaymentNum != null and confirmPaymentNum != ''">
                and confirm_payment_num = #{confirmPaymentNum}
            </if>
            <if test="confirmPaymentName != null and confirmPaymentName != ''">
                and confirm_payment_name = #{confirmPaymentName}
            </if>
            <if test="confirmPaymentDate != null">
                and confirm_payment_date = #{confirmPaymentDate}
            </if>
            <if test="platformAuditId != null">
                and platform_audit_id = #{platformAuditId}
            </if>
            <if test="platformAuditNum != null and platformAuditNum != ''">
                and platform_audit_num = #{platformAuditNum}
            </if>
            <if test="platformAuditeeName != null and platformAuditeeName != ''">
                and platform_auditee_name = #{platformAuditeeName}
            </if>
            <if test="platformAuditeeDate != null">
                and platform_auditee_date = #{platformAuditeeDate}
            </if>
            <if test="platformReleaseId != null">
                and platform_release_id = #{platformReleaseId}
            </if>
            <if test="platformReleaseNum != null and platformReleaseNum != ''">
                and platform_release_num = #{platformReleaseNum}
            </if>
            <if test="platformReleaseName != null and platformReleaseName != ''">
                and platform_release_name = #{platformReleaseName}
            </if>
            <if test="platformReleaseDate != null">
                and platform_release_date = #{platformReleaseDate}
            </if>
            <if test="platformRecycleId != null">
                and platform_recycle_id = #{platformRecycleId}
            </if>
            <if test="platformRecycleNum != null and platformRecycleNum != ''">
                and platform_recycle_num = #{platformRecycleNum}
            </if>
            <if test="platformRecycleName != null and platformRecycleName != ''">
                and platform_recycle_name = #{platformRecycleName}
            </if>
            <if test="platformRecycleDate != null">
                and platform_recycle_date = #{platformRecycleDate}
            </if>
            <if test="closeId != null">
                and close_id = #{closeId}
            </if>
            <if test="closeNum != null and closeNum != ''">
                and close_num = #{closeNum}
            </if>
            <if test="closeName != null and closeName != ''">
                and close_name = #{closeName}
            </if>
            <if test="closeDate != null">
                and close_date = #{closeDate}
            </if>
            <if test="shareCommissionRules != null">
                and Share_commission_rules = #{shareCommissionRules}
            </if>
            <if test="fixedAmount != null">
                and fixed_amount = #{fixedAmount}
            </if>
            <if test="orderCommission != null">
                and order_commission = #{orderCommission}
            </if>
            <if test="platformReleasePhone != null">
                and platform_release_phone = #{platformReleasePhone}
            </if>
        </where>
    </select>


</mapper>