<?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.StoreMemberListMapper">
  <resultMap id="BaseResultMap" type="com.ssm.manage.entity.StoreMemberList">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="member_num" jdbcType="VARCHAR" property="memberNum" />
    <result column="member_name" jdbcType="VARCHAR" property="memberName" />
    <result column="sex" jdbcType="INTEGER" property="sex" />
    <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
    <result column="opening_date" jdbcType="DATE" property="openingDate" />
    <result column="opening_year" jdbcType="INTEGER" property="openingYear" />
    <result column="end_date" jdbcType="DATE" property="endDate" />
    <result column="annual_fee" jdbcType="DECIMAL" property="annualFee" />
    <result column="label" jdbcType="VARCHAR" property="label" />
    <result column="store_id" jdbcType="BIGINT" property="storeId" />
    <result column="store_name" jdbcType="VARCHAR" property="storeName" />
    <result column="grade" jdbcType="VARCHAR" property="grade" />
    <result column="hair_long" jdbcType="INTEGER" property="hairLong" />
    <result column="skin_type" jdbcType="INTEGER" property="skinType" />
    <result column="staff_id" jdbcType="BIGINT" property="staffId" />
    <result column="staff_name" jdbcType="VARCHAR" property="staffName" />
    <result column="card" jdbcType="VARCHAR" property="card" />
    <result column="consume_date" jdbcType="DATE" property="consumeDate" />
    <result column="modify_by" jdbcType="VARCHAR" property="modifyBy" />
    <result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <result column="assign_state" jdbcType="INTEGER" property="assignState" />
    <result column="platform_member_id" jdbcType="BIGINT" property="platformMemberId" />
    <result column="integral" jdbcType="INTEGER" property="integral" />
    <result column="password" jdbcType="VARCHAR" property="password" />
    <result column="cash_password" jdbcType="VARCHAR" property="cashPassword" />
    <result column="input_id" jdbcType="BIGINT" property="inputId" />
    <result column="input_by" jdbcType="VARCHAR" property="inputBy" />
    <result column="input_date" jdbcType="TIMESTAMP" property="inputDate" />
    <result column="modify_id" jdbcType="BIGINT" property="modifyId" />
    <result column="conn_store_id" jdbcType="BIGINT" property="connStoreId" />
    <result column="conn_store_name" jdbcType="VARCHAR" property="connStoreName" />
    <result column="member_store_id" jdbcType="BIGINT" property="memberStoreId" />
    <result column="member_store_name" jdbcType="VARCHAR" property="memberStoreName" />
    <result column="member_store_num" jdbcType="VARCHAR" property="memberStoreNum" />
    <result column="class_id" jdbcType="BIGINT" property="classId" />
    <result column="class_num" jdbcType="VARCHAR" property="classNum" />
    <result column="class_name" jdbcType="VARCHAR" property="className" />
  </resultMap>


  <resultMap id="StoreDailyMap" type="com.ssm.manage.extendEntity.StoreDaily">
    <!--
      WARNING - @mbg.generated
    -->

    <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="start_member_num" jdbcType="INTEGER" property="startMemberNum" />
  </resultMap>

  <sql id="baseColumnList">
    member_num,
    member_name,
    sex,
    mobile_phone,
    opening_date,
    opening_year,
    end_date,
    annual_fee,
    label,
    store_id,
    store_name,
    grade,
    hair_long,
    skin_type,
    staff_id,
    staff_name,
    card,
    id,
    consume_date,
    modify_by,
    modify_date,
    state,
    assign_state,
    platform_member_id,
    integral,
    password,
    cash_password,
    input_by,
    input_date,
    input_id,
    modify_id,member_store_id,member_store_name,member_store_num,class_id,class_num,class_name
  </sql>

  <select id="selectDayRecord" parameterType="com.ssm.manage.query.StoreDailyRequest" resultMap="StoreDailyMap">
    select count(id)
    <if test="dateStr != null and state != null">
      as new_member_num
     </if>
    <if test="dateStr == null and state == null">
      as member_num
    </if>
    <if test="state != null and dateStr == null">
      as start_member_num
    </if>
    from store_member_list
    <where>
      store_id = #{storeId, jdbcType = BIGINT}
      <if test="state != null">
        and state = #{state, jdbcType = INTEGER}
      </if>
      <if test="dateStr != null">
        and input_date like concat( #{dateStr, jdbcType = VARCHAR}, '%')
      </if>
    </where>
  </select>


  <select id="selectPhone"  resultMap="BaseResultMap">
    select *
    from store_member_list
    where
     mobile_phone like  #{phone, jdbcType = VARCHAR}



  </select>

    <insert id="insertBatch" parameterType="java.util.ArrayList">
    insert into store_member_list (<include refid="baseColumnList" />) values
    <foreach collection="list" index="index" item="item" separator=",">
      (
      #{item.memberNum},
      #{item.memberName},
      #{item.sex},
      #{item.mobilePhone},
      #{item.openingDate},
      #{item.openingYear},
      #{item.endDate},
      #{item.annualFee},
      #{item.label},
      #{item.storeId},
      #{item.storeName},
      #{item.grade},
      #{item.hairLong},
      #{item.skinType},
      #{item.staffId},
      #{item.staffName},
      #{item.card},
      #{item.id},
      #{item.consumeDate},
      #{item.modifyBy},
      #{item.modifyDate},
      #{item.state},
      #{item.assignState},
      #{item.platformMemberId},
      #{item.integral},
      #{item.password},
      #{item.cashPassword},
      #{item.inputBy},
      #{item.inputDate},
      #{item.inputId},
      #{item.modifyId},
        #{item.memberStoreId},
      #{item.memberStoreName},
      #{item.memberStoreNum},
      #{item.classId},
      #{item.classNum},
      #{item.className}
      )
    </foreach>
  </insert>
</mapper>