<?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">
<!--suppress ALL -->
<mapper namespace="com.ssm.manage.mapper.RechargeListMapper">
  <resultMap id="BaseResultMap" type="com.ssm.manage.entity.RechargeList">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="recharge_num" jdbcType="VARCHAR" property="rechargeNum" />
    <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="recharge_type_id" jdbcType="BIGINT" property="rechargeTypeId" />
    <result column="recharge_type_name" jdbcType="VARCHAR" property="rechargeTypeName" />
    <result column="discount" jdbcType="DECIMAL" property="discount" />
    <result column="recharge_date" jdbcType="TIMESTAMP" property="rechargeDate" />
    <result column="recharge_amount" jdbcType="DECIMAL" property="rechargeAmount" />
    <result column="collection_cash_amount" jdbcType="DECIMAL" property="collectionCashAmount" />
    <result column="collection_integral_amount" jdbcType="DECIMAL" property="collectionIntegralAmount" />
    <result column="integral" jdbcType="INTEGER" property="integral" />
    <result column="collection_amount" jdbcType="DECIMAL" property="collectionAmount" />
    <result column="is_debt" jdbcType="INTEGER" property="isDebt" />
    <result column="debt_money" jdbcType="DECIMAL" property="debtMoney" />
    <result column="type_ratio" jdbcType="DECIMAL" property="typeRatio" />
    <result column="card" jdbcType="VARCHAR" property="card" />
    <result column="brand_number_one" jdbcType="VARCHAR" property="brandNumberOne" />
    <result column="sale_one_staff_id" jdbcType="BIGINT" property="saleOneStaffId" />
    <result column="sale_one_staff_name" jdbcType="VARCHAR" property="saleOneStaffName" />
    <result column="sale_one_ratio" jdbcType="DECIMAL" property="saleOneRatio" />
    <result column="sale_one_achievement_amount" jdbcType="DECIMAL" property="saleOneAchievementAmount" />
    <result column="sale_one_commission_amount" jdbcType="DECIMAL" property="saleOneCommissionAmount" />
    <result column="sale_one_identity_card" jdbcType="VARCHAR" property="saleOneIdentityCard" />
    <result column="sale_two_staff_id" jdbcType="BIGINT" property="saleTwoStaffId" />
    <result column="sale_two_staff_name" jdbcType="VARCHAR" property="saleTwoStaffName" />
    <result column="sale_two_identity_card" jdbcType="VARCHAR" property="saleTwoIdentityCard" />
    <result column="sale_two_ratio" jdbcType="DECIMAL" property="saleTwoRatio" />
    <result column="sale_two_achievement_amount" jdbcType="DECIMAL" property="saleTwoAchievementAmount" />
    <result column="sale_two_commission_amount" jdbcType="DECIMAL" property="saleTwoCommissionAmount" />
    <result column="sale_three_staff_id" jdbcType="BIGINT" property="saleThreeStaffId" />
    <result column="sale_three_staff_name" jdbcType="VARCHAR" property="saleThreeStaffName" />
    <result column="sale_three_identity_card" jdbcType="VARCHAR" property="saleThreeIdentityCard" />
    <result column="sale_three_ratio" jdbcType="DECIMAL" property="saleThreeRatio" />
    <result column="sale_three_achievement_amount" jdbcType="DECIMAL" property="saleThreeAchievementAmount" />
    <result column="sale_three_commission_amount" jdbcType="DECIMAL" property="saleThreeCommissionAmount" />
    <result column="brand_number_two" jdbcType="VARCHAR" property="brandNumberTwo" />
    <result column="brand_number_three" jdbcType="VARCHAR" property="brandNumberThree" />
    <result column="recharge_account_id" jdbcType="BIGINT" property="rechargeAccountId" />
    <result column="sale_four_staff_id" jdbcType="BIGINT" property="saleFourStaffId" />
    <result column="sale_four_staff_name" jdbcType="VARCHAR" property="saleFourStaffName" />
    <result column="brand_number_four" jdbcType="VARCHAR" property="brandNumberFour" />
    <result column="sale_four_identity_card" jdbcType="VARCHAR" property="saleFourIdentityCard" />
    <result column="sale_four_ratio" jdbcType="DECIMAL" property="saleFourRatio" />
    <result column="sale_four_achievement_amount" jdbcType="DECIMAL" property="saleFourAchievementAmount" />
    <result column="sale_four_commission_amount" jdbcType="DECIMAL" property="saleFourCommissionAmount" />

    <result column="brand_number_five" jdbcType="VARCHAR" property="brandNumberFive" />
    <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_card" jdbcType="VARCHAR" property="saleFiveIdentityCard" />
    <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="brand_number_six" jdbcType="VARCHAR" property="brandNumberSix" />
    <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_card" jdbcType="VARCHAR" property="saleSixIdentityCard" />
    <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="brand_number_seven" jdbcType="VARCHAR" property="brandNumberSeven" />
    <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_card" jdbcType="VARCHAR" property="saleSevenIdentityCard" />
    <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="brand_number_eight" jdbcType="VARCHAR" property="brandNumberEight" />
    <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_card" jdbcType="VARCHAR" property="saleEightIdentityCard" />
    <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="manage_staff_id" jdbcType="BIGINT" property="manageStaffId" />
    <result column="manage_staff_name" jdbcType="VARCHAR" property="manageStaffName" />
    <result column="manage_identity_card" jdbcType="VARCHAR" property="manageIdentityCard" />
    <result column="manage_brand_number" jdbcType="VARCHAR" property="manageBrandNumber" />
    <result column="before_money" jdbcType="DECIMAL" property="beforeMoney" />
    <result column="after_money" jdbcType="DECIMAL" property="afterMoney" />
    <result column="is_cancel" jdbcType="INTEGER" property="isCancel" />
    <result column="cancel_date" jdbcType="TIMESTAMP" property="cancelDate" />
    <result column="gift_before_money" jdbcType="DECIMAL" property="giftBeforeMoney" />
    <result column="gift_after_money" jdbcType="DECIMAL" property="giftAfterMoney" />
    <result column="sale_achievement" jdbcType="DECIMAL" property="saleAchievement" />
    <result column="sale_commission" jdbcType="DECIMAL" property="saleCommission" />
    <result column="input_id" jdbcType="BIGINT" property="inputId" />
    <result column="input_by" jdbcType="VARCHAR" property="inputBy" />
    <result column="cancel_id" jdbcType="BIGINT" property="cancelId" />
    <result column="cancel_by" jdbcType="VARCHAR" property="cancelBy" />
    <result column="addition_date" jdbcType="DATE" property="additionDate" />
    <result column="is_addition" jdbcType="INTEGER" property="isAddition" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="lift_type" jdbcType="INTEGER" property="liftType" />
    <result column="raw_recharge_type_id" jdbcType="BIGINT" property="rawRechargeTypeId" />
    <result column="lift_gift_money" jdbcType="DECIMAL" property="liftGiftMoney" />
    <result column="lift_money" jdbcType="DECIMAL" property="liftMoney" />
    <result column="recharge_type_num" jdbcType="DECIMAL" property="rechargeTypeNum" />
    <result column="raw_recharge_type_num" jdbcType="DECIMAL" property="rawRechargeTypeNum" />
    <result column="raw_recharge_type_name" jdbcType="DECIMAL" property="rawRechargeTypeName" />
    <result column="donate_type" jdbcType="INTEGER" property="donateType" />
    <result column="store_recDebtUsable" jdbcType="VARCHAR" property="storeRecDebtUsable" />

  </resultMap>

  <resultMap type="com.ssm.manage.entity.BaseGrouponCard" id="BaseGrouponCardMap">
    <result property="id" column="id" jdbcType="INTEGER"/>
    <result property="state" column="state" jdbcType="INTEGER"/>
    <result property="docNum" column="doc_num" jdbcType="VARCHAR"/>
    <result property="docDate" column="doc_date" jdbcType="TIMESTAMP"/>
    <result property="rechargeTypeId" column="recharge_type_id" jdbcType="INTEGER"/>
    <result property="rechargeTypeNum" column="recharge_type_num" jdbcType="VARCHAR"/>
    <result property="rechargeTypeName" column="recharge_type_name" jdbcType="VARCHAR"/>
    <result property="storeId" column="store_id" jdbcType="INTEGER"/>
    <result property="storeName" column="store_name" jdbcType="VARCHAR"/>
    <result property="expireDate" column="expire_date" jdbcType="TIMESTAMP"/>
    <result property="discount" column="discount" jdbcType="NUMERIC"/>
    <result property="rechargeMoney" column="recharge_money" jdbcType="NUMERIC"/>
    <result property="quantity" column="quantity" jdbcType="INTEGER"/>
    <result property="inputBy" column="input_by" jdbcType="VARCHAR"/>
    <result property="inputDate" column="input_date" jdbcType="TIMESTAMP"/>
    <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
    <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
    <result property="auditBy" column="audit_by" jdbcType="VARCHAR"/>
    <result property="auditDate" column="audit_date" jdbcType="TIMESTAMP"/>
    <result property="remark" column="remark" jdbcType="VARCHAR"/>
    <result property="typeRatio" column="type_ratio" jdbcType="DECIMAL"/>

    <result property="saleOneNumber" column="sale_one_number" jdbcType="VARCHAR"/>
    <result property="saleTwoNumber" column="sale_two_number" jdbcType="VARCHAR"/>
    <result property="saleThreeNumber" column="sale_three_number" jdbcType="VARCHAR"/>
    <result property="saleFourNumber" column="sale_four_number" jdbcType="VARCHAR"/>


    <result property="saleOneStaffId" column="sale_one_staff_id" jdbcType="BIGINT"/>
    <result property="saleTwoStaffId" column="sale_two_staff_id" jdbcType="BIGINT"/>
    <result property="saleThreeStaffId" column="sale_three_staff_id" jdbcType="BIGINT"/>
    <result property="saleFourStaffId" column="sale_four_staff_id" jdbcType="BIGINT"/>

    <result property="saleOneStaffName" column="sale_one_staff_name" jdbcType="VARCHAR"/>
    <result property="saleTwoStaffName" column="sale_two_staff_name" jdbcType="VARCHAR"/>
    <result property="saleThreeStaffName" column="sale_three_staff_name" jdbcType="VARCHAR"/>
    <result property="saleFourStaffName" column="sale_four_staff_name" jdbcType="VARCHAR"/>

    <result property="saleOneIdentity" column="sale_one_identity" jdbcType="VARCHAR"/>
    <result property="saleTwoIdentity" column="sale_two_identity" jdbcType="VARCHAR"/>
    <result property="saleThreeIdentity" column="sale_three_identity" jdbcType="VARCHAR"/>
    <result property="saleFourIdentity" column="sale_four_identity" jdbcType="VARCHAR"/>

    <result property="saleOneRatio" column="sale_one_ratio" jdbcType="DECIMAL"/>
    <result property="saleTwoRatio" column="sale_two_ratio" jdbcType="DECIMAL"/>
    <result property="saleThreeRatio" column="sale_three_ratio" jdbcType="DECIMAL"/>
    <result property="saleFourRatio" column="sale_four_ratio" jdbcType="DECIMAL"/>


  </resultMap>


  <resultMap id="StoreDailyMap" type="com.ssm.manage.extendEntity.StoreDaily">
    <!--
      WARNING - @mbg.generated
    -->
    <result column="recharge_gif_money" property="rechargeGifMoney" jdbcType="DECIMAL"/>
    <result column="date" property="date" jdbcType="TIMESTAMP"/>
    <result column="cash_people_num" jdbcType="INTEGER" property="cashPeopleNum" />
    <result column="cash_money" jdbcType="DECIMAL" property="cashMoney" />
    <result column="recharge_money" jdbcType="DECIMAL" property="rechargeMoney" />
    <result column="recharge_order_num" jdbcType="INTEGER" property="rechargeOrderNum" />
    <result column="repay_money" jdbcType="DECIMAL" property="repayMoney" />
    <result column="refund_money" jdbcType="DECIMAL" property="refundMoney" />
    <result column="rec_negative_money" jdbcType="BIGINT" property="recNegativeMoney" />
    <result column="member_num" jdbcType="INTEGER" property="memberNum" />
    <result column="new_member_num" jdbcType="INTEGER" property="newMemberNum" />

    <result column="id" jdbcType="VARCHAR" property="id" />
    <result column="groupon_counts" jdbcType="INTEGER" property="grouponCounts" />
    <result column="groupon_money" jdbcType="DECIMAL" property="grouponMoney" />
  </resultMap>

  <sql id="BaseColumnList">
    a.id,
    a.recharge_num,
    a.store_id,
    a.store_name,
    a.member_id,
    a.member_name,
    a.member_identity_card,
    a.mobile_phone,
    a.recharge_type_id,
    a.recharge_type_name,
    a.discount,
    a.recharge_date,
    a.recharge_amount,
    a.collection_cash_amount,
    a.collection_integral_amount,
    a.integral,
    a.collection_amount,
    a.type_ratio,
    a.card,
    a.brand_number_one,
    a.sale_one_staff_id,
    a.sale_one_staff_name,
    a.sale_one_ratio,
    a.sale_one_achievement_amount,
    a.sale_one_commission_amount,
    a.sale_one_identity_card,
    a.sale_two_staff_id,
    a.sale_two_staff_name,
    a.sale_two_identity_card,
    a.sale_two_ratio,
    a.sale_two_achievement_amount,
    a.sale_two_commission_amount,
    a.sale_three_staff_id,
    a.sale_three_staff_name,
    a.sale_three_identity_card,
    a.sale_three_ratio,
    a.sale_three_achievement_amount,
    a.sale_three_commission_amount,
    a.brand_number_two,
    a.brand_number_three,
    a.recharge_account_id,
    a.debt_money,
    a.is_debt,
    a.sale_four_staff_id,
    a.sale_four_staff_name,
    a.brand_number_four,
    a.sale_four_identity_card,
    a.sale_four_ratio,
    a.sale_four_achievement_amount,
    a.sale_four_commission_amount,

    a.brand_number_five,
    a.sale_five_staff_id,
    a.sale_five_staff_name,
    a.sale_five_identity_card,
    a.sale_five_ratio,
    a.sale_five_achievement_amount,
    a.sale_five_commission_amount,

    a.brand_number_six,
    a.sale_six_staff_id,
    a.sale_six_staff_name,
    a.sale_six_identity_card,
    a.sale_six_ratio,
    a.sale_six_achievement_amount,
    a.sale_six_commission_amount,

    a.brand_number_seven,
    a.sale_seven_staff_id,
    a.sale_seven_staff_name,
    a.sale_seven_identity_card,
    a.sale_seven_ratio,
    a.sale_seven_achievement_amount,
    a.sale_seven_commission_amount,

    a.brand_number_eight,
    a.sale_eight_staff_id,
    a.sale_eight_staff_name,
    a.sale_eight_identity_card,
    a.sale_eight_ratio,
    a.sale_eight_achievement_amount,
    a.sale_eight_commission_amount,

    a.manage_staff_id,
    a.manage_staff_name,
    a.manage_identity_card,
    a.manage_brand_number,
    a.before_money,
    a.after_money,
    a.is_cancel,
    a.cancel_date,
    a.gift_before_money,
    a.gift_after_money,
    a.sale_achievement,
    a.sale_commission,
    a.description,
    a.input_id,
    a.input_by,
    a.cancel_id,
    a.cancel_by,
    a.addition_date,
    a.is_addition,
    a.lift_type,
    a.raw_recharge_type_id,
    a.lift_gift_money,
    a.lift_money,
    a.recharge_type_num,
    a.raw_recharge_type_num,
    a.raw_recharge_type_name,
    a.store_recDebtUsable,
    a.donate_type
  </sql>

  <select id="selectPage" parameterType="com.ssm.manage.query.RechargeListRequest" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    <where>
      <if test="id != null">
        and  a.id = #{id,jdbcType = BIGINT}
      </if>
    <if test="storeId != null">
      and  a.store_id = #{storeId,jdbcType = BIGINT}
    </if>
    <if test="rechargeAccountId != null">
      and  a.recharge_account_id = #{rechargeAccountId,jdbcType = BIGINT}
    </if>
      <if test="isCancel != null">
        and is_cancel = #{isCancel, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
      <if test="rechargeNum != null">
        and recharge_num like concat('%',concat( #{rechargeNum, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="memberName != null">
        and member_name like concat('%',concat( #{memberName, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="mobilePhone != null">
        and mobile_phone like concat('%',concat( #{mobilePhone, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="startTime != null and endTime != null">
        and recharge_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
      </if>
    </where>
    order by recharge_num desc
  </select>

  <select id="selectPageNew" parameterType="com.ssm.manage.query.RechargeListRequest" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    <where>
      <if test="id != null">
        and  a.id = #{id,jdbcType = BIGINT}
      </if>
      <if test="storeList!= null and storeList.size() >0">
        and a.store_id  in
        <foreach collection="storeList" item="storeId" index="index" open="(" close=")" separator=",">
          #{storeId}
        </foreach>
      </if>
      <if test="rechargeAccountId != null">
        and  a.recharge_account_id = #{rechargeAccountId,jdbcType = BIGINT}
      </if>
      <if test="isCancel != null">
        and is_cancel = #{isCancel, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
      <if test="rechargeNum != null">
        and recharge_num like concat('%',concat( #{rechargeNum, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="memberName != null">
        and member_name like concat('%',concat( #{memberName, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="mobilePhone != null">
        and mobile_phone like concat('%',concat( #{mobilePhone, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="startTime != null and endTime != null">
        and recharge_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
      </if>
    </where>
    order by recharge_num desc
  </select>

  <select id="selectPages" parameterType="com.ssm.manage.query.RechargeListRequest" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    <where>
      <if test="storeId != null">
        and  a.store_id = #{storeId,jdbcType = BIGINT}
      </if>
      <if test="rechargeAccountId != null">
        and  a.recharge_account_id = #{rechargeAccountId,jdbcType = BIGINT}
      </if>
      <if test="isCancel != null">
        and is_cancel = #{isCancel, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>

      <if test="rechargeNum != null">
        and recharge_num like concat('%',concat( #{rechargeNum, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="memberName != null">
        and member_name like concat('%',concat( #{memberName, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="mobilePhone != null">
        and mobile_phone like concat('%',concat( #{mobilePhone, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="startTime != null and endTime != null">
        and recharge_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
      </if>
    </where>
    order by recharge_num desc
  </select>

  <select id="createTable">
    create table IF NOT EXISTS recharge_list_${tab} like recharge_list
  </select>

  <select id="createTable1">
    create table IF NOT EXISTS service_orders_${tab} like service_orders
  </select>

  <insert id="addRecharge" parameterType="com.ssm.manage.entity.RechargeList">
    insert into recharge_list_${tab}(
      id,
      recharge_num,
      store_id,
      store_name,
      member_id,
      member_name,
      member_identity_card,
      mobile_phone,
      recharge_type_id,
      recharge_type_name,
      discount,
      recharge_date,
      recharge_amount,
      collection_cash_amount,
      collection_integral_amount,
      integral,
      collection_amount,
      type_ratio,
      card,
      brand_number_one,
      sale_one_staff_id,
      sale_one_staff_name,
      sale_one_ratio,
      sale_one_achievement_amount,
      sale_one_commission_amount,
      sale_one_identity_card,
      sale_two_staff_id,
      sale_two_staff_name,
      sale_two_identity_card,
      sale_two_ratio,
      sale_two_achievement_amount,
      sale_two_commission_amount,
      sale_three_staff_id,
      sale_three_staff_name,
      sale_three_identity_card,
      sale_three_ratio,
      sale_three_achievement_amount,
      sale_three_commission_amount,
      brand_number_two,
      brand_number_three,
      recharge_account_id,
      debt_money,
      is_debt,
      sale_four_staff_id,
      sale_four_staff_name,
      brand_number_four,
      sale_four_identity_card,
      sale_four_ratio,
      sale_four_achievement_amount,
      sale_four_commission_amount,

      brand_number_five,
      sale_five_staff_id,
      sale_five_staff_name,
      sale_five_identity_card,
      sale_five_ratio,
      sale_five_achievement_amount,
      sale_five_commission_amount,

      brand_number_six,
      sale_six_staff_id,
      sale_six_staff_name,
      sale_six_identity_card,
      sale_six_ratio,
      sale_six_achievement_amount,
      sale_six_commission_amount,

      brand_number_seven,
      sale_seven_staff_id,
      sale_seven_staff_name,
      sale_seven_identity_card,
      sale_seven_ratio,
      sale_seven_achievement_amount,
      sale_seven_commission_amount,

      brand_number_eight,
      sale_eight_staff_id,
      sale_eight_staff_name,
      sale_eight_identity_card,
      sale_eight_ratio,
      sale_eight_achievement_amount,
      sale_eight_commission_amount,



      manage_staff_id,
      manage_staff_name,
      manage_identity_card,
      manage_brand_number,
      before_money,
      after_money,
      is_cancel,
      cancel_date,
      gift_before_money,
      gift_after_money,
      sale_achievement,
      sale_commission,
      description,
      input_id,
      input_by,
      cancel_id,
      cancel_by,
      addition_date,
      is_addition,
      lift_type,
      raw_recharge_type_id,
      lift_gift_money,
      lift_money,
      recharge_type_num,
      raw_recharge_type_num,
      raw_recharge_type_name,
      store_recDebtUsable,
      donate_type
    )values (
              #{id,jdbcType = BIGINT},
              #{rechargeNum,jdbcType = VARCHAR},
              #{storeId,jdbcType = BIGINT},
              #{storeName,jdbcType = VARCHAR},
              #{memberId,jdbcType = BIGINT},
              #{memberName,jdbcType = VARCHAR},
              #{memberIdentityCard,jdbcType = VARCHAR},
              #{mobilePhone,jdbcType = VARCHAR},
              #{rechargeTypeId,jdbcType = BIGINT},
              #{rechargeTypeName,jdbcType = VARCHAR},
              #{discount,jdbcType = DECIMAL},
              #{rechargeDate,jdbcType = TIMESTAMP},
              #{rechargeAmount,jdbcType = DECIMAL},
              #{collectionCashAmount,jdbcType = DECIMAL},
              #{collectionIntegralAmount,jdbcType = DECIMAL},
              #{integral,jdbcType = INTEGER},
              #{collectionAmount,jdbcType = DECIMAL},
              #{typeRatio,jdbcType = DECIMAL},
              #{card,jdbcType = VARCHAR},
              #{brandNumberOne,jdbcType = VARCHAR},
              #{saleOneStaffId,jdbcType = BIGINT},
              #{saleOneStaffName,jdbcType = VARCHAR},
              #{saleOneRatio,jdbcType = DECIMAL},
              #{saleOneAchievementAmount,jdbcType = DECIMAL},
              #{saleOneCommissionAmount,jdbcType = DECIMAL},
              #{saleOneIdentityCard,jdbcType = VARCHAR},
              #{saleTwoStaffId,jdbcType = BIGINT},
              #{saleTwoStaffName,jdbcType = VARCHAR},
              #{saleTwoIdentityCard,jdbcType = VARCHAR},
              #{saleTwoRatio,jdbcType = DECIMAL},
              #{saleTwoAchievementAmount,jdbcType = DECIMAL},
              #{saleTwoCommissionAmount,jdbcType = DECIMAL},
              #{saleThreeStaffId,jdbcType = BIGINT},
              #{saleThreeStaffName,jdbcType = VARCHAR},
              #{saleThreeIdentityCard,jdbcType = VARCHAR},
              #{saleThreeRatio,jdbcType = DECIMAL},
              #{saleThreeAchievementAmount,jdbcType = DECIMAL},
              #{saleThreeCommissionAmount,jdbcType = DECIMAL},
              #{brandNumberTwo,jdbcType = VARCHAR},
              #{brandNumberThree,jdbcType = VARCHAR},
              #{rechargeAccountId,jdbcType = BIGINT},
              #{debtMoney,jdbcType = DECIMAL},
              #{isDebt,jdbcType = INTEGER},
              #{saleFourStaffId,jdbcType = BIGINT},
              #{saleFourStaffName,jdbcType = VARCHAR},
              #{brandNumberFour,jdbcType = VARCHAR},
              #{saleFourIdentityCard,jdbcType = VARCHAR},
              #{saleFourRatio,jdbcType = DECIMAL},
              #{saleFourAchievementAmount,jdbcType = DECIMAL},
              #{saleFourCommissionAmount,jdbcType = DECIMAL},

              #{brandNumberFive,jdbcType = VARCHAR},
              #{saleFiveStaffId,jdbcType = BIGINT},
              #{saleFiveStaffName,jdbcType = VARCHAR},
              #{saleFiveIdentityCard,jdbcType = VARCHAR},
              #{saleFiveRatio,jdbcType = DECIMAL},
              #{saleFiveAchievementAmount,jdbcType = DECIMAL},
              #{saleFiveCommissionAmount,jdbcType = DECIMAL},

              #{brandNumberSix,jdbcType = VARCHAR},
              #{saleSixStaffId,jdbcType = BIGINT},
              #{saleSixStaffName,jdbcType = VARCHAR},
              #{saleSixIdentityCard,jdbcType = VARCHAR},
              #{saleSixRatio,jdbcType = DECIMAL},
              #{saleSixAchievementAmount,jdbcType = DECIMAL},
              #{saleSixCommissionAmount,jdbcType = DECIMAL},

              #{brandNumberSeven,jdbcType = VARCHAR},
              #{saleSevenStaffId,jdbcType = BIGINT},
              #{saleSevenStaffName,jdbcType = VARCHAR},
              #{saleSevenIdentityCard,jdbcType = VARCHAR},
              #{saleSevenRatio,jdbcType = DECIMAL},
              #{saleSevenAchievementAmount,jdbcType = DECIMAL},
              #{saleSevenCommissionAmount,jdbcType = DECIMAL},

              #{brandNumberEight,jdbcType = VARCHAR},
              #{saleEightStaffId,jdbcType = BIGINT},
              #{saleEightStaffName,jdbcType = VARCHAR},
              #{saleEightIdentityCard,jdbcType = VARCHAR},
              #{saleEightRatio,jdbcType = DECIMAL},
              #{saleEightAchievementAmount,jdbcType = DECIMAL},
              #{saleEightCommissionAmount,jdbcType = DECIMAL},

              #{manageStaffId,jdbcType = BIGINT},
              #{manageStaffName,jdbcType = VARCHAR},
              #{manageIdentityCard,jdbcType = VARCHAR},
              #{manageBrandNumber,jdbcType = VARCHAR},
              #{beforeMoney,jdbcType = DECIMAL},
              #{afterMoney,jdbcType = DECIMAL},
              #{isCancel,jdbcType = INTEGER},
              #{cancelDate, jdbcType=TIMESTAMP},
              #{giftBeforeMoney,jdbcType = DECIMAL},
              #{giftAfterMoney,jdbcType = DECIMAL},
              #{saleAchievement,jdbcType = DECIMAL},
              #{saleCommission,jdbcType = DECIMAL},
              #{description,jdbcType = LONGVARCHAR},
              #{inputId, jdbcType=BIGINT},
              #{inputBy, jdbcType=VARCHAR},
              #{cancelId, jdbcType=BIGINT},
              #{cancelBy, jdbcType=VARCHAR},
              #{additionDate, jdbcType=TIMESTAMP},
              #{isAddition,jdbcType = INTEGER},
              #{liftType, jdbcType=INTEGER},
              #{rawRechargeTypeId,jdbcType = BIGINT},
              #{liftGiftMoney,jdbcType = DECIMAL},
              #{liftMoney,jdbcType = DECIMAL},
              #{rechargeTypeNum,jdbcType = VARCHAR},
              #{rawRechargeTypeNum,jdbcType = VARCHAR},
              #{rawRechargeTypeName,jdbcType = VARCHAR},
              #{storeRecDebtUsable,jdbcType = VARCHAR},
              #{donateType,jdbcType = INTEGER}
            )
  </insert>

  <select id="getDocNum" parameterType="com.ssm.manage.query.RechargeListRequest" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    where store_id = #{storeId,jdbcType = BIGINT} and recharge_num like concat(#{selectDate,jdbcType = VARCHAR},'%')
    order by recharge_num desc
  </select>

  <update id="cancel" parameterType="com.ssm.manage.entity.RechargeList">
    update recharge_list_${tab} a
    <set>
      <if test="isCancel != null">
        a.is_cancel = #{isCancel, jdbcType = INTEGER},
      </if>
      <if test="cancelDate != null">
        a.cancel_date = #{cancelDate, jdbcType=TIMESTAMP},
      </if>
      <if test="cancelId != null">
        cancel_id = #{cancelId, jdbcType = BIGINT},
      </if>
      <if test="cancelBy != null">
        cancel_by = #{cancelBy, jdbcType = VARCHAR},
      </if>
<!--      &amp;amp;lt;if test="saleOneStaffId != null"&amp;amp;gt;-->
<!--        a.sale_one_achievement_amount = #{saleOneAchievementAmount, jdbcType = DECIMAL},-->
<!--        a.sale_one_commission_amount = #{saleOneCommissionAmount, jdbcType = DECIMAL},-->
<!--      &amp;amp;lt;/if&amp;amp;gt;-->
<!--      &amp;amp;lt;if test="saleTwoStaffId != null"&amp;amp;gt;-->
<!--        a.sale_two_achievement_amount = #{saleTwoAchievementAmount, jdbcType = DECIMAL},-->
<!--        a.sale_two_commission_amount = #{saleTwoCommissionAmount, jdbcType = DECIMAL},-->
<!--      &amp;amp;lt;/if&amp;amp;gt;-->
<!--      &amp;amp;lt;if test="saleThreeStaffId != null"&amp;amp;gt;-->
<!--        a.sale_three_achievement_amount = #{saleThreeAchievementAmount, jdbcType = DECIMAL},-->
<!--        a.sale_three_commission_amount = #{saleThreeCommissionAmount, jdbcType = DECIMAL},-->
<!--      &amp;amp;lt;/if&amp;amp;gt;-->
<!--      &amp;amp;lt;if test="saleFourStaffId != null"&amp;amp;gt;-->
<!--        a.sale_four_achievement_amount = #{saleFourAchievementAmount, jdbcType = DECIMAL},-->
<!--        a.sale_four_commission_amount = #{saleFourCommissionAmount, jdbcType = DECIMAL},-->
<!--      &amp;amp;lt;/if&amp;amp;gt;-->

      <if test="saleAchievement != null">
        a.sale_achievement = #{saleAchievement, jdbcType = DECIMAL},
      </if>
      <if test="saleCommission != null">
        a.sale_commission = #{saleCommission, jdbcType = DECIMAL},
      </if>
    </set>  where a.id = #{id, jdbcType = BIGINT}
  </update>

  <select id="getRecDoc" parameterType="com.ssm.manage.query.RechargeListRequest" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    where
    a.store_id = #{storeId,jdbcType = BIGINT}
    and a.member_id = #{memberId,jdbcType = BIGINT}
    and a.recharge_account_id = #{rechargeAccountId,jdbcType = BIGINT}
    order by a.recharge_date desc
  </select>

  <update id="updateStaff" parameterType="com.ssm.manage.entity.RechargeList">
    update recharge_list_${tab}
    <set>
      <if test="description !=null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <!--&lt;if test="saleOneStaffId != null"&gt;-->
        sale_one_staff_id = #{saleOneStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleOneStaffName != null"&gt;-->
        sale_one_staff_name = #{saleOneStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleOneIdentityCard != null"&gt;-->
        sale_one_identity_card = #{saleOneIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberOne != null"&gt;-->
        brand_number_one = #{brandNumberOne, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleOneRatio != null"&gt;-->
        sale_one_ratio = #{saleOneRatio, jdbcType = DECIMAL},
      <!--&lt;/if&gt;
      &lt;if test="saleTwoStaffId != null"&gt;-->
        sale_two_staff_id = #{saleTwoStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleTwoStaffName != null"&gt;-->
        sale_two_staff_name = #{saleTwoStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleTwoIdentityCard != null"&gt;-->
        sale_two_identity_card = #{saleTwoIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberTwo != null"&gt;-->
        brand_number_two = #{brandNumberTwo, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleTwoRatio != null"&gt;-->
        sale_two_ratio = #{saleTwoRatio, jdbcType = DECIMAL},
      <!--&lt;/if&gt;
      &lt;if test="saleThreeStaffId != null"&gt;-->
        sale_three_staff_id = #{saleThreeStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleThreeStaffName != null"&gt;-->
        sale_three_staff_name = #{saleThreeStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleThreeIdentityCard != null"&gt;-->
        sale_three_identity_card = #{saleThreeIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberThree != null"&gt;-->
        brand_number_three = #{brandNumberThree, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleThreeRatio != null"&gt;-->
        sale_three_ratio = #{saleThreeRatio, jdbcType = DECIMAL},
      <!--&lt;/if&gt;
      &lt;if test="saleFourStaffId != null"&gt;-->
        sale_four_staff_id = #{saleFourStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleFourStaffName != null"&gt;-->
        sale_four_staff_name = #{saleFourStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleFourIdentityCard != null"&gt;-->
        sale_four_identity_card = #{saleFourIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberFour != null"&gt;-->
        brand_number_four = #{brandNumberFour, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleFourRatio != null"&gt; &lt;/if&gt; -->
        sale_four_ratio = #{saleFourRatio, jdbcType = DECIMAL},


      /*五*/
      <!--&lt;/if&gt;
         &lt;if test="saleFiveStaffId != null"&gt;-->
      sale_five_staff_id = #{saleFiveStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleFiveStaffName != null"&gt;-->
      sale_five_staff_name = #{saleFiveStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleFiveIdentityCard != null"&gt;-->
      sale_five_identity_card = #{saleFiveIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberFive != null"&gt;-->
      brand_number_five = #{brandNumberFive, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleFiveRatio != null"&gt;-->
      sale_five_ratio = #{saleFiveRatio, jdbcType = DECIMAL},

      /*六*/
      <!--&lt;/if&gt;
         &lt;if test="saleSixStaffId != null"&gt;-->
      sale_six_staff_id = #{saleSixStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleSixStaffName != null"&gt;-->
      sale_six_staff_name = #{saleSixStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleSixIdentityCard != null"&gt;-->
      sale_six_identity_card = #{saleSixIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberSix != null"&gt;-->
      brand_number_six = #{brandNumberSix, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleSixRatio != null"&gt;-->
      sale_six_ratio = #{saleSixRatio, jdbcType = DECIMAL},

      /*七*/
      <!--&lt;/if&gt;
         &lt;if test="saleSevenStaffId != null"&gt;-->
      sale_seven_staff_id = #{saleSevenStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleSevenStaffName != null"&gt;-->
      sale_seven_staff_name = #{saleSevenStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleSevenIdentityCard != null"&gt;-->
      sale_seven_identity_card = #{saleSevenIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberSeven != null"&gt;-->
      brand_number_seven = #{brandNumberSeven, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleSevenRatio != null"&gt;-->
      sale_seven_ratio = #{saleSevenRatio, jdbcType = DECIMAL},

      /*八*/
      <!--&lt;/if&gt;
         &lt;if test="saleEightStaffId != null"&gt;-->
      sale_eight_staff_id = #{saleEightStaffId, jdbcType = BIGINT},
      <!--&lt;/if&gt;
      &lt;if test="saleEightStaffName != null"&gt;-->
      sale_eight_staff_name = #{saleEightStaffName, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleEightIdentityCard != null"&gt;-->
      sale_eight_identity_card = #{saleEightIdentityCard, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="brandNumberEight != null"&gt;-->
      brand_number_eight = #{brandNumberEight, jdbcType = VARCHAR},
      <!--&lt;/if&gt;
      &lt;if test="saleEightatio != null"&gt;-->
      sale_eight_ratio = #{saleEightRatio, jdbcType = DECIMAL}


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

  <select id="selectDayRecord" resultMap="StoreDailyMap" parameterType="com.ssm.manage.query.StoreDailyRequest">
    select count(id) as recharge_order_num, sum(collection_amount) as recharge_money from recharge_list_${tab}
    <where>
      store_id = #{storeId, jdbcType = BIGINT}
      <if test="isCancel != null">
        and is_cancel = #{isCancel, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
    </where>
  </select>

  <select id="selectDayRecord1" resultMap="StoreDailyMap" parameterType="com.ssm.manage.query.StoreDailyRequest">
    select recharge_num as id from recharge_list_${tab}
    <where>
      store_id = #{storeId, jdbcType = BIGINT}
      <if test="isCancel != null">
        and is_cancel = #{isCancel, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
    </where>
  </select>

  <select id="selectListSalem" parameterType="com.ssm.manage.entity.RechargeList" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    <where>
      <if test="id != null">
        and  a.id = #{id,jdbcType = BIGINT}
      </if>
      <if test="memberId != null">
        and member_id = #{memberId, jdbcType = BIGINT}
      </if>
      <if test="isCancel != null">
        and a.is_cancel = #{isCancel,jdbcType = BIGINT}
      </if>
    </where>
  </select>

<select id="NegativeKazin"  parameterType="com.ssm.manage.query.StoreDailyRequest" resultMap="StoreDailyMap">
    select  sum(collection_amount) as recharge_money  from recharge_list_${tab} a
    <where>
      <if test="isCancel != null">
        and a.is_cancel = #{isCancel,jdbcType = BIGINT}
      </if>
      <if test="storeId != null">
        and a.store_id = #{storeId,jdbcType = BIGINT}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
    </where>
  </select>

  <update id="updateRatio" parameterType="com.ssm.manage.entity.RechargeList">
    update recharge_list_${tab}
    <set>
      type_ratio = #{typeRatio, jdbcType = DECIMAL},
    </set>
    <where>
      id = #{id, jdbcType = BIGINT}
    </where>
  </update>

  <select id="grouponTuan" resultMap="StoreDailyMap" parameterType="com.ssm.manage.query.StoreDailyRequest">
    select sum(quantity) as groupon_counts, sum(recharge_money*quantity) as groupon_money from base_groupon_card
    <where>
      store_id = #{storeId, jdbcType = BIGINT}

        and state = 3

      <if test="dateStr != null">
        and audit_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
    </where>
  </select>

  <select id="grouponTuan1" resultMap="BaseGrouponCardMap" parameterType="com.ssm.manage.query.StoreDailyRequest">
    select * from base_groupon_card
    <where>
      store_id = #{storeId, jdbcType = BIGINT}

      and state = 3

      <if test="startTime != null and endTime != null">
        and input_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
      </if>
    </where>
  </select>
    <select id="selectAchiEntities" resultType="com.ssm.manage.entity.RechargeList" resultMap="BaseResultMap" parameterType="com.ssm.manage.entity.RechargeList">
      select * from recharge_list_${tab}
      <where>
        recharge_num = #{rechargeNum}
      </where>
    </select>
  <select id="selectByDay" resultMap="selectByDay">
    select store_id,date(recharge_date) as date,sum(ifnull(collection_amount,0)) as collection_amount,sum(ifnull(debt_money,0)) as debt_money,count(*) as recharge_rows
    from recharge_list_${tab}  where
      is_cancel ='0' and store_id in
    <foreach collection="storeIds" separator="," item="item" open="(" close=")" >
                     #{item}
    </foreach>
           and  recharge_date between #{startTime,jdbcType=TIMESTAMP} and #{endTime,jdbcType=TIMESTAMP}
                               group by store_id,date(recharge_date)
  </select>
    <select id="selectByDayGroupByDateAndStoreId" resultMap="StoreDailyMap" parameterType="com.ssm.manage.query.StoreDailyRequest">
      select SUBSTRING(recharge_date,1,10) as date,store_id,store_name,count(id) as recharge_order_num, sum(collection_amount) as recharge_money from recharge_list_${tab}
      where is_cancel = 0
        and recharge_date between #{startDate} and #{endDate}
        group   by
          SUBSTRING( recharge_date, 1, 10 ),
          store_id
    </select>
    <select id="selectList" resultMap="BaseResultMap" parameterType="com.ssm.manage.query.RechargeListRequest">
      select * from recharge_list_${tab} where 1=1
    <if test="storeIds!=null">
      and store_id in <foreach collection="storeIds" open="(" close=")" separator="," item="item">
      #{item}
    </foreach>
    </if>
    </select>
    <select id="NegativeKazinByDate"  parameterType="com.ssm.manage.query.StoreDailyRequest" resultMap="StoreDailyMap">
      select  sum(collection_amount) as recharge_money,
              sum(case is_debt when 0 then ifnull(gift_after_money,0)-ifnull(gift_before_money,0)
                            else 0 end) as recharge_gif_money
      from recharge_list_${tab} a
      <where>
        <if test="isCancel != null">
          and a.is_cancel = #{isCancel,jdbcType = BIGINT}
        </if>
        <if test="storeId != null">
          and a.store_id = #{storeId,jdbcType = BIGINT}
        </if>
        <if test="dateStr != null">
          and recharge_date between #{startTime} and #{endTime}
        </if>
      </where>
    </select>
  <select id="grouponTuanNew"  resultMap="StoreDailyMap" parameterType="com.ssm.manage.query.StoreDailyRequest">
    select sum(quantity) as groupon_counts, sum(recharge_money*quantity) as groupon_money from base_groupon_card
    <where>
      store_id = #{storeId, jdbcType = BIGINT}
      and state = 3
        and audit_date between #{startTime} and #{endTime}
    </where>
  </select>
  <select id="rechargeGifList" parameterType="com.ssm.manage.query.RechargeListRequest" resultMap="BaseResultMap">
    select <include refid="BaseColumnList" /> from recharge_list_${tab} a
    <where>
      <if test="isDebt!=null">
        is_debt = 0 and (gift_after_money-gift_before_money)>0
      </if>
      <if test="id != null">
        and  a.id = #{id,jdbcType = BIGINT}
      </if>
      <if test="storeList!= null and storeList.size() >0">
        and a.store_id  in
        <foreach collection="storeList" item="storeId" index="index" open="(" close=")" separator=",">
          #{storeId}
        </foreach>
      </if>
      <if test="rechargeAccountId != null">
        and  a.recharge_account_id = #{rechargeAccountId,jdbcType = BIGINT}
      </if>
      <if test="isCancel != null">
        and is_cancel = #{isCancel, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and recharge_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
      <if test="rechargeNum != null">
        and recharge_num like concat('%',concat( #{rechargeNum, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="memberName != null">
        and member_name like concat('%',concat( #{memberName, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="mobilePhone != null">
        and mobile_phone like concat('%',concat( #{mobilePhone, jdbcType = VARCHAR}, '%'))
      </if>
      <if test="startTime != null and endTime != null">
        and recharge_date between #{startTime, jdbcType = TIMESTAMP} and #{endTime, jdbcType = TIMESTAMP}
      </if>
    </where>
    order by recharge_num desc
  </select>
  <select id="selectById" resultMap="BaseResultMap" parameterType="com.ssm.manage.entity.RechargeList">
    select  * from recharge_list_${tab} where id = #{id}
  </select>


  <resultMap id="selectByDay" type="com.ssm.manage.response.RechargeVo">
    <result column="store_id" property="storeId"/>
    <result column="date" property="date"/>
    <result column="collection_amount" property="collectionAmount"/>
    <result column="debt_money" property="debtMoney"/>
    <result column="recharge_rows" property="rechargeRows"/>
  </resultMap>

</mapper>