<?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.RefundCourseMapper">
  <resultMap id="BaseResultMap" type="com.ssm.manage.entity.RefundCourse">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="refund_num" jdbcType="VARCHAR" property="refundNum" />
    <result column="refund_date" jdbcType="TIMESTAMP" property="refundDate" />
    <result column="store_id" jdbcType="BIGINT" property="storeId" />
    <result column="store_name" jdbcType="VARCHAR" property="storeName" />
    <result column="member_id" jdbcType="BIGINT" property="memberId" />
    <result column="member_name" jdbcType="VARCHAR" property="memberName" />
    <result column="member_identity_card" jdbcType="VARCHAR" property="memberIdentityCard" />
    <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
    <result column="card" jdbcType="VARCHAR" property="card" />
    <result column="course_project_id" jdbcType="BIGINT" property="courseProjectId" />
    <result column="course_project_name" jdbcType="VARCHAR" property="courseProjectName" />
    <result column="course_project_money" jdbcType="DECIMAL" property="courseProjectMoney" />
    <result column="course_count" jdbcType="INTEGER" property="courseCount" />
    <result column="last_consume_time" jdbcType="TIMESTAMP" property="lastConsumeTime" />
    <result column="course_rest_count" jdbcType="INTEGER" property="courseRestCount" />
    <result column="course_consume_count" jdbcType="INTEGER" property="courseConsumeCount" />
    <result column="course_type" jdbcType="VARCHAR" property="courseType" />
    <result column="course_refund_money" jdbcType="DECIMAL" property="courseRefundMoney" />
    <result column="course_compensation" jdbcType="DECIMAL" property="courseCompensation" />
    <result column="course_account_id" jdbcType="BIGINT" property="courseAccountId" />
    <result column="sale_one_number" jdbcType="VARCHAR" property="saleOneNumber" />
    <result column="sale_two_number" jdbcType="VARCHAR" property="saleTwoNumber" />
    <result column="sale_three_number" jdbcType="VARCHAR" property="saleThreeNumber" />
    <result column="sale_four_number" jdbcType="VARCHAR" property="saleFourNumber" />
    <result column="sale_one_staff_id" jdbcType="BIGINT" property="saleOneStaffId" />
    <result column="sale_two_staff_id" jdbcType="BIGINT" property="saleTwoStaffId" />
    <result column="sale_three_staff_id" jdbcType="BIGINT" property="saleThreeStaffId" />
    <result column="sale_four_staff_id" jdbcType="BIGINT" property="saleFourStaffId" />
    <result column="sale_one_staff_name" jdbcType="VARCHAR" property="saleOneStaffName" />
    <result column="sale_two_staff_name" jdbcType="VARCHAR" property="saleTwoStaffName" />
    <result column="sale_three_staff_name" jdbcType="VARCHAR" property="saleThreeStaffName" />
    <result column="sale_four_staff_name" jdbcType="VARCHAR" property="saleFourStaffName" />
    <result column="sale_one_identity" jdbcType="VARCHAR" property="saleOneIdentity" />
    <result column="sale_two_identity" jdbcType="VARCHAR" property="saleTwoIdentity" />
    <result column="sale_three_identity" jdbcType="VARCHAR" property="saleThreeIdentity" />
    <result column="sale_four_identity" jdbcType="VARCHAR" property="saleFourIdentity" />
    <result column="sale_one_ratio" jdbcType="DECIMAL" property="saleOneRatio" />
    <result column="sale_two_ratio" jdbcType="DECIMAL" property="saleTwoRatio" />
    <result column="sale_three_ratio" jdbcType="DECIMAL" property="saleThreeRatio" />
    <result column="sale_four_ratio" jdbcType="DECIMAL" property="saleFourRatio" />
    <result column="sale_one_achievement_amount" jdbcType="DECIMAL" property="saleOneAchievementAmount" />
    <result column="sale_two_achievement_amount" jdbcType="DECIMAL" property="saleTwoAchievementAmount" />
    <result column="sale_three_achievement_amount" jdbcType="DECIMAL" property="saleThreeAchievementAmount" />
    <result column="sale_four_achievement_amount" jdbcType="DECIMAL" property="saleFourAchievementAmount" />
    <result column="sale_one_commission_amount" jdbcType="DECIMAL" property="saleOneCommissionAmount" />
    <result column="sale_two_commission_amount" jdbcType="DECIMAL" property="saleTwoCommissionAmount" />
    <result column="sale_three_commission_amount" jdbcType="DECIMAL" property="saleThreeCommissionAmount" />
    <result column="sale_four_commission_amount" jdbcType="DECIMAL" property="saleFourCommissionAmount" />
    <result column="achievement_amount" jdbcType="DECIMAL" property="achievementAmount" />
    <result column="commission_amount" jdbcType="DECIMAL" property="commissionAmount" />
    <result column="manage_staff_id" jdbcType="BIGINT" property="manageStaffId" />
    <result column="manage_staff_name" jdbcType="VARCHAR" property="manageStaffName" />
    <result column="manage_identity" jdbcType="VARCHAR" property="manageIdentity" />
    <result column="manage_number" jdbcType="VARCHAR" property="manageNumber" />
    <result column="sales_achievement" jdbcType="DECIMAL" property="salesAchievement" />
    <result column="sales_commission" jdbcType="DECIMAL" property="salesCommission" />
    <result column="card_sales_achievement" jdbcType="DECIMAL" property="cardSalesAchievement" />
    <result column="card_sales_commission" jdbcType="DECIMAL" property="cardSalesCommission" />
    <result column="refund_number" jdbcType="INTEGER" property="refundNumber" />
    <result property="beforePrice" column="before_rice" jdbcType="NUMERIC"/>
    <result property="beforeRestMoney" column="before_rest_money" jdbcType="NUMERIC"/>
    <result property="beforeConsumeMoney" column="before_consume_money" jdbcType="NUMERIC"/>
    <result property="beforeGiftRestMoney" column="before_gift_rest_money" jdbcType="NUMERIC"/>
    <result property="beforeGiftConsumeMoney" column="before_gift_consume_money" jdbcType="NUMERIC"/>
    <result property="beforeRestCount" column="before_rest_count" jdbcType="INTEGER"/>
    <result property="beforeConsumeCount" column="before_consume_count" jdbcType="INTEGER"/>

    <result property="backPrice" column="back_rice" jdbcType="NUMERIC"/>
    <result property="backRestMoney" column="back_rest_money" jdbcType="NUMERIC"/>
    <result property="backConsumeMoney" column="back_consume_money" jdbcType="NUMERIC"/>
    <result property="backGiftRestMoney" column="back_gift_rest_money" jdbcType="NUMERIC"/>
    <result property="backGiftConsumeMoney" column="back_gift_consume_money" jdbcType="NUMERIC"/>
    <result property="backRestCount" column="back_rest_count" jdbcType="INTEGER"/>
    <result property="backConsumeCount" column="back_consume_count" jdbcType="INTEGER"/>

    <result property="courseRefundAmount" column="course_refund_amount" jdbcType="NUMERIC"/>
    <result property="courseRefundNumber" column="course_refund_number" jdbcType="INTEGER"/>
    <result column="sale_five_number" jdbcType="VARCHAR" property="saleFiveNumber" />

    <result column="sale_five_staff_id" jdbcType="BIGINT" property="saleFiveStaffId" />

    <result column="sale_five_staff_name" jdbcType="VARCHAR" property="saleFiveStaffName" />

    <result column="sale_five_identity" jdbcType="VARCHAR" property="saleFiveIdentity" />

    <result column="sale_five_ratio" jdbcType="DECIMAL" property="saleFiveRatio" />

    <result column="sale_five_achievement_amount" jdbcType="DECIMAL" property="saleFiveAchievementAmount" />

    <result column="sale_five_commission_amount" jdbcType="DECIMAL" property="saleFiveCommissionAmount" />




    <result column="sale_seven_number" jdbcType="VARCHAR" property="saleSevenNumber" />

    <result column="sale_seven_staff_id" jdbcType="BIGINT" property="saleSevenStaffId" />

    <result column="sale_seven_staff_name" jdbcType="VARCHAR" property="saleSevenStaffName" />

    <result column="sale_seven_identity" jdbcType="VARCHAR" property="saleSevenIdentity" />

    <result column="sale_seven_ratio" jdbcType="DECIMAL" property="saleSevenRatio" />

    <result column="sale_seven_achievement_amount" jdbcType="DECIMAL" property="saleSevenAchievementAmount" />

    <result column="sale_seven_commission_amount" jdbcType="DECIMAL" property="saleSevenCommissionAmount" />



    <result column="sale_six_number" jdbcType="VARCHAR" property="saleSixNumber" />

    <result column="sale_six_staff_id" jdbcType="BIGINT" property="saleSixStaffId" />

    <result column="sale_six_staff_name" jdbcType="VARCHAR" property="saleSixStaffName" />

    <result column="sale_six_identity" jdbcType="VARCHAR" property="saleSixIdentity" />

    <result column="sale_six_ratio" jdbcType="DECIMAL" property="saleSixRatio" />

    <result column="sale_six_achievement_amount" jdbcType="DECIMAL" property="saleSixAchievementAmount" />

    <result column="sale_six_commission_amount" jdbcType="DECIMAL" property="saleSixCommissionAmount" />



    <result column="sale_eight_number" jdbcType="VARCHAR" property="saleEightNumber" />

    <result column="sale_eight_staff_id" jdbcType="BIGINT" property="saleEightStaffId" />

    <result column="sale_eight_staff_name" jdbcType="VARCHAR" property="saleEightStaffName" />

    <result column="sale_eight_identity" jdbcType="VARCHAR" property="saleEightIdentity" />

    <result column="sale_eight_ratio" jdbcType="DECIMAL" property="saleEightRatio" />

    <result column="sale_eight_achievement_amount" jdbcType="DECIMAL" property="saleEightAchievementAmount" />

    <result column="sale_eight_commission_amount" jdbcType="DECIMAL" property="saleEightCommissionAmount" />
    <result column="audit_date" jdbcType="TIMESTAMP" property="auditDate"/>
  </resultMap>
    <update id="updateById" parameterType="com.ssm.manage.entity.RefundCourse">
      update refund_course
      <set>
        <!--&lt;if test="saleOneNumber != null"&gt;-->
        sale_one_number = #{saleOneNumber, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleTwoNumber != null"&gt;-->
        sale_two_number = #{saleTwoNumber, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleThreeNumber != null"&gt;-->
        sale_three_number = #{saleThreeNumber, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleFourNumber != null"&gt;-->
        sale_four_number = #{saleFourNumber, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleOneStaffId != null"&gt;-->
        sale_one_staff_id = #{saleOneStaffId, jdbcType = BIGINT},
        <!--&lt;/if&gt;
        &lt;if test="saleTwoStaffId != null"&gt;-->
        sale_two_staff_id = #{saleTwoStaffId, jdbcType = BIGINT},
        <!--&lt;/if&gt;
        &lt;if test="saleThreeStaffId != null"&gt;-->
        sale_three_staff_id = #{saleThreeStaffId, jdbcType = BIGINT},
        <!--&lt;/if&gt;
        &lt;if test="saleFourStaffId != null"&gt;-->
        sale_four_staff_id = #{saleFourStaffId, jdbcType = BIGINT},
        <!--&lt;/if&gt;
        &lt;if test="saleOneStaffName != null"&gt;-->
        sale_one_staff_name = #{saleOneStaffName, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleTwoStaffName != null"&gt;-->
        sale_two_staff_name = #{saleTwoStaffName, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleThreeStaffName != null"&gt;-->
        sale_three_staff_name = #{saleThreeStaffName, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleFourStaffName != null"&gt;-->
        sale_four_staff_name = #{saleFourStaffName, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleOneIdentity != null"&gt;-->
        sale_one_identity = #{saleOneIdentity, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleTwoIdentity != null"&gt;-->
        sale_two_identity = #{saleTwoIdentity, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleThreeIdentity != null"&gt;-->
        sale_three_identity = #{saleThreeIdentity, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleFourIdentity != null"&gt;-->
        sale_four_identity = #{saleFourIdentity, jdbcType = VARCHAR},
        <!--&lt;/if&gt;
        &lt;if test="saleOneRatio != null"&gt;-->
        sale_one_ratio = #{saleOneRatio, jdbcType = DECIMAL},
        <!--&lt;/if&gt;
        &lt;if test="saleTwoRatio != null"&gt;-->
        sale_two_ratio = #{saleTwoRatio, jdbcType = DECIMAL},
        <!--&lt;/if&gt;
        &lt;if test="saleThreeRatio != null"&gt;-->
        sale_three_ratio = #{saleThreeRatio, jdbcType = DECIMAL},
        <!--&lt;/if&gt;
        &lt;if test="saleFourRatio != null"&gt; &lt;/if&gt;-->
        sale_four_ratio = #{saleFourRatio, jdbcType = DECIMAL},

        sale_five_number = #{saleFiveNumber, jdbcType = VARCHAR},
        sale_five_staff_id = #{saleFiveStaffId, jdbcType = BIGINT},
        sale_five_staff_name = #{saleFiveStaffName, jdbcType = VARCHAR},
        sale_five_identity = #{saleFiveIdentity, jdbcType = VARCHAR},
        sale_five_ratio = #{saleFiveRatio, jdbcType = DECIMAL},

        sale_six_number = #{saleSixNumber, jdbcType = VARCHAR},
        sale_six_staff_id = #{saleSixStaffId, jdbcType = BIGINT},
        sale_six_staff_name = #{saleSixStaffName, jdbcType = VARCHAR},
        sale_six_identity = #{saleSixIdentity, jdbcType = VARCHAR},
        sale_six_ratio = #{saleSixRatio, jdbcType = DECIMAL},

        sale_seven_number = #{saleSevenNumber, jdbcType = VARCHAR},
        sale_seven_staff_id = #{saleSevenStaffId, jdbcType = BIGINT},
        sale_seven_staff_name = #{saleSevenStaffName, jdbcType = VARCHAR},
        sale_seven_identity = #{saleSevenIdentity, jdbcType = VARCHAR},
        sale_seven_ratio = #{saleSevenRatio, jdbcType = DECIMAL},

        sale_eight_number = #{saleEightNumber, jdbcType = VARCHAR},
        sale_eight_staff_id = #{saleEightStaffId, jdbcType = BIGINT},
        sale_eight_staff_name = #{saleEightStaffName, jdbcType = VARCHAR},
        sale_eight_identity = #{saleEightIdentity, jdbcType = VARCHAR},
        sale_eight_ratio = #{saleEightRatio, jdbcType = DECIMAL},
        course_refund_money = #{courseRefundMoney},
        course_compensation = #{courseCompensation},
        course_refund_amount = #{courseRefundAmount},
        course_refund_number = #{courseRefundNumber},
        refund_number = #{courseRefundNumber}

      </set>
      <where>
        id = #{id, jdbcType = BIGINT}
      </where>
    </update>

    <select id="selectList" parameterType="com.ssm.manage.query.RefundOrderResquest" resultMap="BaseResultMap">
    select b.*,a.audit_date from refund_order_list a, refund_course b
    where b.store_id = #{storeId, jdbcType = BIGINT}
      and a.refund_num = b.refund_num and a.store_id=b.store_id
    and a.state = #{state, jdbcType = INTEGER}
    <if test="dateStr != null">
      and a.audit_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
    </if>
    <if test="startTime != null">
      and a.audit_date between #{startTime} and #{endTime}
    </if>
  </select>

  <select id="selectLists" parameterType="com.ssm.manage.query.RefundOrderResquest" resultMap="BaseResultMap">
    select b.* from refund_order_list a, refund_course b
    where b.store_id = #{storeId, jdbcType = BIGINT}
      and a.refund_num = b.refund_num
    and a.state = #{state, jdbcType = INTEGER}
    <if test="dateStr != null">
      and a.refund_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
    </if>
  </select>

  <select id="selectListsBetween" parameterType="com.ssm.manage.query.RefundOrderResquest" resultMap="BaseResultMap">
    select b.* from refund_order_list a, refund_course b
    where b.store_id = #{storeId, jdbcType = BIGINT}
    and a.refund_num = b.refund_num
      and a.refund_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
  </select>
    <select id="selectListNew" resultMap="BaseResultMap" >
      select * from refund_course where substring(refund_date,1,7) = #{strDate}
and  store_id in <foreach collection="storeIds" item="item" separator="," close=")" open="(">
      #{item}
    </foreach>
    </select>
</mapper>