<?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.goafanti.common.dao.UserIdentityMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.UserIdentity">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="uid" jdbcType="VARCHAR" property="uid" />
    <result column="username" jdbcType="VARCHAR" property="username" />
    <result column="sex" jdbcType="VARCHAR" property="sex" />
    <result column="date_of_birth_year" jdbcType="VARCHAR" property="dateOfBirthYear" />
    <result column="date_of_birth_month" jdbcType="VARCHAR" property="dateOfBirthMonth" />
    <result column="id_number" jdbcType="VARCHAR" property="idNumber" />
    <result column="positive_id_url" jdbcType="VARCHAR" property="positiveIdUrl" />
    <result column="opposite_id_url" jdbcType="VARCHAR" property="oppositeIdUrl" />
    <result column="province" jdbcType="INTEGER" property="province" />
    <result column="city" jdbcType="INTEGER" property="city" />
    <result column="area" jdbcType="INTEGER" property="area" />
    <result column="contact_mobile" jdbcType="VARCHAR" property="contactMobile" />
    <result column="bank_name" jdbcType="VARCHAR" property="bankName" />
    <result column="bank_account" jdbcType="VARCHAR" property="bankAccount" />
    <result column="bank_card_number" jdbcType="VARCHAR" property="bankCardNumber" />
    <result column="amount_money" jdbcType="DECIMAL" property="amountMoney" />
    <result column="audit_status" jdbcType="INTEGER" property="auditStatus" />
    <result column="process" jdbcType="INTEGER" property="process" />
    <result column="wrong_count" jdbcType="INTEGER" property="wrongCount" />
    <result column="payment_date" jdbcType="TIMESTAMP" property="paymentDate" />
    <result column="expert" jdbcType="INTEGER" property="expert" />
    <result column="international" jdbcType="INTEGER" property="international" />
    <result column="fixed_tel" jdbcType="VARCHAR" property="fixedTel" />
    <result column="qq" jdbcType="VARCHAR" property="qq" />
    <result column="postal_address" jdbcType="VARCHAR" property="postalAddress" />
    <result column="postcode" jdbcType="VARCHAR" property="postcode" />
    <result column="review_instructions" jdbcType="VARCHAR" property="reviewInstructions" />
    <result column="industry" jdbcType="INTEGER" property="industry" />
    <result column="contacts" jdbcType="VARCHAR" property="contacts" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="professional_title" jdbcType="VARCHAR" property="professionalTitle" />
    <result column="work_unit" jdbcType="VARCHAR" property="workUnit" />
    <result column="work_unit1" jdbcType="VARCHAR" property="workUnit1" />
    <result column="education" jdbcType="VARCHAR" property="education" />
    <result column="major_category" jdbcType="VARCHAR" property="majorCategory" />
    <result column="qualification" jdbcType="VARCHAR" property="qualification" />
    <result column="graduate_school" jdbcType="VARCHAR" property="graduateSchool" />
    <result column="consultant" jdbcType="INTEGER" property="consultant" />
    <result column="consultation_price" jdbcType="DECIMAL" property="consultationPrice" />
    <result column="expert_audit" jdbcType="INTEGER" property="expertAudit" />
    <result column="identify_name" jdbcType="VARCHAR" property="identifyName" />
    <result column="consultant_type" jdbcType="INTEGER" property="consultantType" />
    <result column="audit_info" jdbcType="VARCHAR" property="auditInfo" />
    <result column="society_tag" jdbcType="VARCHAR" property="societyTag" />
    <result column="introduction" jdbcType="VARCHAR" property="introduction" />
    <result column="head_portrait_url" jdbcType="VARCHAR" property="headPortraitUrl" />
    <result column="typical_case" jdbcType="VARCHAR" property="typicalCase" />
    <result column="consultant_certificate_url" jdbcType="VARCHAR" property="consultantCertificateUrl" />
    <result column="good_at_industry" jdbcType="VARCHAR" property="goodAtIndustry" />
    <result column="honer" jdbcType="VARCHAR" property="honer" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    id, uid, username, sex, date_of_birth_year, date_of_birth_month, id_number, positive_id_url, 
    opposite_id_url, province, city, area, contact_mobile, bank_name, bank_account, bank_card_number, 
    amount_money, audit_status, process, wrong_count, payment_date, expert, 
    international, fixed_tel, qq, postal_address, postcode, review_instructions, industry, 
    contacts, email, professional_title, work_unit, education, major_category, qualification,
    graduate_school, consultation_price , consultant_type, typical_case, consultant_certificate_url,
    good_at_industry
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.UserIdentityExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from user_identity
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    select 
    <include refid="Base_Column_List" />
    from user_identity
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    delete from user_identity
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.UserIdentityExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    delete from user_identity
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.UserIdentity">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    insert into user_identity (id, uid, username, 
      sex, date_of_birth_year, date_of_birth_month, 
      id_number, positive_id_url, opposite_id_url, 
      province, city, area, 
      contact_mobile, bank_name, bank_account, 
      bank_card_number, amount_money, audit_status, 
      process, wrong_count, payment_date, 
      expert, international, 
      fixed_tel, qq, postal_address, 
      postcode, review_instructions, industry, 
      contacts, email, professional_title, 
      work_unit, education, major_category, 
      qualification, graduate_school, 
      consultation_price,consultant_type,
      typical_case, consultant_certificate_url,
      good_at_industry)
    values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, 
      #{sex,jdbcType=VARCHAR}, #{dateOfBirthYear,jdbcType=VARCHAR}, #{dateOfBirthMonth,jdbcType=VARCHAR}, 
      #{idNumber,jdbcType=VARCHAR}, #{positiveIdUrl,jdbcType=VARCHAR}, #{oppositeIdUrl,jdbcType=VARCHAR}, 
      #{province,jdbcType=INTEGER}, #{city,jdbcType=INTEGER}, #{area,jdbcType=INTEGER}, 
      #{contactMobile,jdbcType=VARCHAR}, #{bankName,jdbcType=VARCHAR}, #{bankAccount,jdbcType=VARCHAR}, 
      #{bankCardNumber,jdbcType=VARCHAR}, #{amountMoney,jdbcType=DECIMAL}, #{auditStatus,jdbcType=INTEGER}, 
      #{process,jdbcType=INTEGER}, #{wrongCount,jdbcType=INTEGER}, #{paymentDate,jdbcType=TIMESTAMP}, 
      #{expert,jdbcType=INTEGER}, #{international,jdbcType=INTEGER}, 
      #{fixedTel,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{postalAddress,jdbcType=VARCHAR}, 
      #{postcode,jdbcType=VARCHAR}, #{reviewInstructions,jdbcType=VARCHAR}, #{industry,jdbcType=INTEGER}, 
      #{contacts,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{professionalTitle,jdbcType=VARCHAR}, 
      #{workUnit,jdbcType=VARCHAR}, #{education,jdbcType=VARCHAR}, #{majorCategory,jdbcType=VARCHAR}, 
      #{qualification,jdbcType=VARCHAR}, #{graduateSchool,jdbcType=VARCHAR}, 
      #{consultationPrice,jdbcType=DECIMAL},#{consultantType,jdbcType=VARCHAR},
      #{typicalCase,jdbcType=VARCHAR}, #{consultantCertificateUrl,jdbcType=VARCHAR},
      #{goodAtIndustry,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.UserIdentity">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    insert into user_identity
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="username != null">
        username,
      </if>
      <if test="sex != null">
        sex,
      </if>
      <if test="dateOfBirthYear != null">
        date_of_birth_year,
      </if>
      <if test="dateOfBirthMonth != null">
        date_of_birth_month,
      </if>
      <if test="idNumber != null">
        id_number,
      </if>
      <if test="positiveIdUrl != null">
        positive_id_url,
      </if>
      <if test="oppositeIdUrl != null">
        opposite_id_url,
      </if>
      <if test="province != null">
        province,
      </if>
      <if test="city != null">
        city,
      </if>
      <if test="area != null">
        area,
      </if>
      <if test="contactMobile != null">
        contact_mobile,
      </if>
      <if test="bankName != null">
        bank_name,
      </if>
      <if test="bankAccount != null">
        bank_account,
      </if>
      <if test="bankCardNumber != null">
        bank_card_number,
      </if>
      <if test="amountMoney != null">
        amount_money,
      </if>
      <if test="auditStatus != null">
        audit_status,
      </if>
      <if test="process != null">
        process,
      </if>
      <if test="wrongCount != null">
        wrong_count,
      </if>
      <if test="paymentDate != null">
        payment_date,
      </if>
      <if test="expert != null">
        expert,
      </if>
      <if test="international != null">
        international,
      </if>
      <if test="fixedTel != null">
        fixed_tel,
      </if>
      <if test="qq != null">
        qq,
      </if>
      <if test="postalAddress != null">
        postal_address,
      </if>
      <if test="postcode != null">
        postcode,
      </if>
      <if test="reviewInstructions != null">
        review_instructions,
      </if>
      <if test="industry != null">
        industry,
      </if>
      <if test="contacts != null">
        contacts,
      </if>
      <if test="email != null">
        email,
      </if>
      <if test="professionalTitle != null">
        professional_title,
      </if>
      <if test="workUnit != null">
        work_unit,
      </if>
      <if test="education != null">
        education,
      </if>
      <if test="majorCategory != null">
        major_category,
      </if>
      <if test="qualification != null">
        qualification,
      </if>
      <if test="graduateSchool != null">
        graduate_school,
      </if>
      <if test="consultationPrice != null">
        consultation_price,
      </if>
      <if test="typicalCase != null">
        typical_case
      </if>
      <if test="consultantCertificateUrl != null">
        consultant_certificate_url,
      </if>
      <if test="goodAtIndustry != null">
        good_at_industry,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="uid != null">
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="username != null">
        #{username,jdbcType=VARCHAR},
      </if>
      <if test="sex != null">
        #{sex,jdbcType=VARCHAR},
      </if>
      <if test="dateOfBirthYear != null">
        #{dateOfBirthYear,jdbcType=VARCHAR},
      </if>
      <if test="dateOfBirthMonth != null">
        #{dateOfBirthMonth,jdbcType=VARCHAR},
      </if>
      <if test="idNumber != null">
        #{idNumber,jdbcType=VARCHAR},
      </if>
      <if test="positiveIdUrl != null">
        #{positiveIdUrl,jdbcType=VARCHAR},
      </if>
      <if test="oppositeIdUrl != null">
        #{oppositeIdUrl,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        #{province,jdbcType=INTEGER},
      </if>
      <if test="city != null">
        #{city,jdbcType=INTEGER},
      </if>
      <if test="area != null">
        #{area,jdbcType=INTEGER},
      </if>
      <if test="contactMobile != null">
        #{contactMobile,jdbcType=VARCHAR},
      </if>
      <if test="bankName != null">
        #{bankName,jdbcType=VARCHAR},
      </if>
      <if test="bankAccount != null">
        #{bankAccount,jdbcType=VARCHAR},
      </if>
      <if test="bankCardNumber != null">
        #{bankCardNumber,jdbcType=VARCHAR},
      </if>
      <if test="amountMoney != null">
        #{amountMoney,jdbcType=DECIMAL},
      </if>
      <if test="auditStatus != null">
        #{auditStatus,jdbcType=INTEGER},
      </if>
      <if test="process != null">
        #{process,jdbcType=INTEGER},
      </if>
      <if test="wrongCount != null">
        #{wrongCount,jdbcType=INTEGER},
      </if>
      <if test="paymentDate != null">
        #{paymentDate,jdbcType=TIMESTAMP},
      </if>
      <if test="expert != null">
        #{expert,jdbcType=INTEGER},
      </if>
      <if test="international != null">
        #{international,jdbcType=INTEGER},
      </if>
      <if test="fixedTel != null">
        #{fixedTel,jdbcType=VARCHAR},
      </if>
      <if test="qq != null">
        #{qq,jdbcType=VARCHAR},
      </if>
      <if test="postalAddress != null">
        #{postalAddress,jdbcType=VARCHAR},
      </if>
      <if test="postcode != null">
        #{postcode,jdbcType=VARCHAR},
      </if>
      <if test="reviewInstructions != null">
        #{reviewInstructions,jdbcType=VARCHAR},
      </if>
      <if test="industry != null">
        #{industry,jdbcType=INTEGER},
      </if>
      <if test="contacts != null">
        #{contacts,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        #{email,jdbcType=VARCHAR},
      </if>
      <if test="professionalTitle != null">
        #{professionalTitle,jdbcType=VARCHAR},
      </if>
      <if test="workUnit != null">
        #{workUnit,jdbcType=VARCHAR},
      </if>
      <if test="education != null">
        #{education,jdbcType=VARCHAR},
      </if>
      <if test="majorCategory != null">
        #{majorCategory,jdbcType=VARCHAR},
      </if>
      <if test="qualification != null">
        #{qualification,jdbcType=VARCHAR},
      </if>
      <if test="graduateSchool != null">
        #{graduateSchool,jdbcType=VARCHAR},
      </if>
      <if test="consultationPrice != null">
        #{consultationPrice,jdbcType=DECIMAL},
      </if>
      <if test="typicalCase != null">
        #{typicalCase,jdbcType=VARCHAR},
      </if>
      <if test="consultantCertificateUrl != null">
        #{consultantCertificateUrl,jdbcType=VARCHAR},
      </if>
      <if test="goodAtIndustry != null">
        #{goodAtIndustry,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.UserIdentityExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    select count(*) from user_identity
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    update user_identity
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.uid != null">
        uid = #{record.uid,jdbcType=VARCHAR},
      </if>
      <if test="record.username != null">
        username = #{record.username,jdbcType=VARCHAR},
      </if>
      <if test="record.sex != null">
        sex = #{record.sex,jdbcType=VARCHAR},
      </if>
      <if test="record.dateOfBirthYear != null">
        date_of_birth_year = #{record.dateOfBirthYear,jdbcType=VARCHAR},
      </if>
      <if test="record.dateOfBirthMonth != null">
        date_of_birth_month = #{record.dateOfBirthMonth,jdbcType=VARCHAR},
      </if>
      <if test="record.idNumber != null">
        id_number = #{record.idNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.positiveIdUrl != null">
        positive_id_url = #{record.positiveIdUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.oppositeIdUrl != null">
        opposite_id_url = #{record.oppositeIdUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.province != null">
        province = #{record.province,jdbcType=INTEGER},
      </if>
      <if test="record.city != null">
        city = #{record.city,jdbcType=INTEGER},
      </if>
      <if test="record.area != null">
        area = #{record.area,jdbcType=INTEGER},
      </if>
      <if test="record.contactMobile != null">
        contact_mobile = #{record.contactMobile,jdbcType=VARCHAR},
      </if>
      <if test="record.bankName != null">
        bank_name = #{record.bankName,jdbcType=VARCHAR},
      </if>
      <if test="record.bankAccount != null">
        bank_account = #{record.bankAccount,jdbcType=VARCHAR},
      </if>
      <if test="record.bankCardNumber != null">
        bank_card_number = #{record.bankCardNumber,jdbcType=VARCHAR},
      </if>
      <if test="record.amountMoney != null">
        amount_money = #{record.amountMoney,jdbcType=DECIMAL},
      </if>
      <if test="record.auditStatus != null">
        audit_status = #{record.auditStatus,jdbcType=INTEGER},
      </if>
      <if test="record.process != null">
        process = #{record.process,jdbcType=INTEGER},
      </if>
      <if test="record.wrongCount != null">
        wrong_count = #{record.wrongCount,jdbcType=INTEGER},
      </if>
      <if test="record.paymentDate != null">
        payment_date = #{record.paymentDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.expert != null">
        expert = #{record.expert,jdbcType=INTEGER},
      </if>
      <if test="record.international != null">
        international = #{record.international,jdbcType=INTEGER},
      </if>
      <if test="record.fixedTel != null">
        fixed_tel = #{record.fixedTel,jdbcType=VARCHAR},
      </if>
      <if test="record.qq != null">
        qq = #{record.qq,jdbcType=VARCHAR},
      </if>
      <if test="record.postalAddress != null">
        postal_address = #{record.postalAddress,jdbcType=VARCHAR},
      </if>
      <if test="record.postcode != null">
        postcode = #{record.postcode,jdbcType=VARCHAR},
      </if>
      <if test="record.reviewInstructions != null">
        review_instructions = #{record.reviewInstructions,jdbcType=VARCHAR},
      </if>
      <if test="record.industry != null">
        industry = #{record.industry,jdbcType=INTEGER},
      </if>
      <if test="record.contacts != null">
        contacts = #{record.contacts,jdbcType=VARCHAR},
      </if>
      <if test="record.email != null">
        email = #{record.email,jdbcType=VARCHAR},
      </if>
      <if test="record.professionalTitle != null">
        professional_title = #{record.professionalTitle,jdbcType=VARCHAR},
      </if>
      <if test="record.workUnit != null">
        work_unit = #{record.workUnit,jdbcType=VARCHAR},
      </if>
      <if test="record.education != null">
        education = #{record.education,jdbcType=VARCHAR},
      </if>
      <if test="record.majorCategory != null">
        major_category = #{record.majorCategory,jdbcType=VARCHAR},
      </if>
      <if test="record.qualification != null">
        qualification = #{record.qualification,jdbcType=VARCHAR},
      </if>
      <if test="record.graduateSchool != null">
        graduate_school = #{record.graduateSchool,jdbcType=VARCHAR},
      </if>
      <if test="record.consultationPrice != null">
        consultation_price = #{record.consultationPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.typicalCase != null">
        typical_case = #{record.typicalCase,jdbcType=VARCHAR},
      </if>
      <if test="record.consultantCertificateUrl != null">
        consultant_certificate_url = #{record.consultantCertificateUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.goodAtIndustry != null">
        good_at_industry = #{record.goodAtIndustry,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    update user_identity
    set id = #{record.id,jdbcType=VARCHAR},
      uid = #{record.uid,jdbcType=VARCHAR},
      username = #{record.username,jdbcType=VARCHAR},
      sex = #{record.sex,jdbcType=VARCHAR},
      date_of_birth_year = #{record.dateOfBirthYear,jdbcType=VARCHAR},
      date_of_birth_month = #{record.dateOfBirthMonth,jdbcType=VARCHAR},
      id_number = #{record.idNumber,jdbcType=VARCHAR},
      positive_id_url = #{record.positiveIdUrl,jdbcType=VARCHAR},
      opposite_id_url = #{record.oppositeIdUrl,jdbcType=VARCHAR},
      province = #{record.province,jdbcType=INTEGER},
      city = #{record.city,jdbcType=INTEGER},
      area = #{record.area,jdbcType=INTEGER},
      contact_mobile = #{record.contactMobile,jdbcType=VARCHAR},
      bank_name = #{record.bankName,jdbcType=VARCHAR},
      bank_account = #{record.bankAccount,jdbcType=VARCHAR},
      bank_card_number = #{record.bankCardNumber,jdbcType=VARCHAR},
      amount_money = #{record.amountMoney,jdbcType=DECIMAL},
      audit_status = #{record.auditStatus,jdbcType=INTEGER},
      process = #{record.process,jdbcType=INTEGER},
      wrong_count = #{record.wrongCount,jdbcType=INTEGER},
      payment_date = #{record.paymentDate,jdbcType=TIMESTAMP},
      expert = #{record.expert,jdbcType=INTEGER},
      international = #{record.international,jdbcType=INTEGER},
      fixed_tel = #{record.fixedTel,jdbcType=VARCHAR},
      qq = #{record.qq,jdbcType=VARCHAR},
      postal_address = #{record.postalAddress,jdbcType=VARCHAR},
      postcode = #{record.postcode,jdbcType=VARCHAR},
      review_instructions = #{record.reviewInstructions,jdbcType=VARCHAR},
      industry = #{record.industry,jdbcType=INTEGER},
      contacts = #{record.contacts,jdbcType=VARCHAR},
      email = #{record.email,jdbcType=VARCHAR},
      professional_title = #{record.professionalTitle,jdbcType=VARCHAR},
      work_unit = #{record.workUnit,jdbcType=VARCHAR},
      education = #{record.education,jdbcType=VARCHAR},
      major_category = #{record.majorCategory,jdbcType=VARCHAR},
      qualification = #{record.qualification,jdbcType=VARCHAR},
      graduate_school = #{record.graduateSchool,jdbcType=VARCHAR},
      typical_case = #{record.typicalCase,jdbcType=VARCHAR},
      consultant_certificate_url = #{record.consultantCertificateUrl,jdbcType=VARCHAR},
      good_at_industry = #{record.goodAtIndustry,jdbcType=VARCHAR},
      consultation_price = #{record.consultationPrice,jdbcType=DECIMAL}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserIdentity">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    update user_identity
    <set>
      <if test="uid != null">
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="username != null">
        username = #{username,jdbcType=VARCHAR},
      </if>
      <if test="sex != null">
        sex = #{sex,jdbcType=VARCHAR},
      </if>
      <if test="dateOfBirthYear != null">
        date_of_birth_year = #{dateOfBirthYear,jdbcType=VARCHAR},
      </if>
      <if test="dateOfBirthMonth != null">
        date_of_birth_month = #{dateOfBirthMonth,jdbcType=VARCHAR},
      </if>
      <if test="idNumber != null">
        id_number = #{idNumber,jdbcType=VARCHAR},
      </if>
      <if test="positiveIdUrl != null">
        positive_id_url = #{positiveIdUrl,jdbcType=VARCHAR},
      </if>
      <if test="oppositeIdUrl != null">
        opposite_id_url = #{oppositeIdUrl,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        province = #{province,jdbcType=INTEGER},
      </if>
      <if test="city != null">
        city = #{city,jdbcType=INTEGER},
      </if>
      <if test="area != null">
        area = #{area,jdbcType=INTEGER},
      </if>
      <if test="contactMobile != null">
        contact_mobile = #{contactMobile,jdbcType=VARCHAR},
      </if>
      <if test="bankName != null">
        bank_name = #{bankName,jdbcType=VARCHAR},
      </if>
      <if test="bankAccount != null">
        bank_account = #{bankAccount,jdbcType=VARCHAR},
      </if>
      <if test="bankCardNumber != null">
        bank_card_number = #{bankCardNumber,jdbcType=VARCHAR},
      </if>
      <if test="amountMoney != null">
        amount_money = #{amountMoney,jdbcType=DECIMAL},
      </if>
      <if test="auditStatus != null">
        audit_status = #{auditStatus,jdbcType=INTEGER},
      </if>
      <if test="process != null">
        process = #{process,jdbcType=INTEGER},
      </if>
      <if test="wrongCount != null">
        wrong_count = #{wrongCount,jdbcType=INTEGER},
      </if>
      <if test="paymentDate != null">
        payment_date = #{paymentDate,jdbcType=TIMESTAMP},
      </if>
      <if test="expert != null">
        expert = #{expert,jdbcType=INTEGER},
      </if>
      <if test="international != null">
        international = #{international,jdbcType=INTEGER},
      </if>
      <if test="fixedTel != null">
        fixed_tel = #{fixedTel,jdbcType=VARCHAR},
      </if>
      <if test="qq != null">
        qq = #{qq,jdbcType=VARCHAR},
      </if>
      <if test="postalAddress != null">
        postal_address = #{postalAddress,jdbcType=VARCHAR},
      </if>
      <if test="postcode != null">
        postcode = #{postcode,jdbcType=VARCHAR},
      </if>
      <if test="reviewInstructions != null">
        review_instructions = #{reviewInstructions,jdbcType=VARCHAR},
      </if>
      <if test="industry != null">
        industry = #{industry,jdbcType=INTEGER},
      </if>
      <if test="contacts != null">
        contacts = #{contacts,jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        email = #{email,jdbcType=VARCHAR},
      </if>
      <if test="professionalTitle != null">
        professional_title = #{professionalTitle,jdbcType=VARCHAR},
      </if>
      <if test="workUnit != null">
        work_unit = #{workUnit,jdbcType=VARCHAR},
      </if>
      <if test="education != null">
        education = #{education,jdbcType=VARCHAR},
      </if>
      <if test="majorCategory != null">
        major_category = #{majorCategory,jdbcType=VARCHAR},
      </if>
      <if test="qualification != null">
        qualification = #{qualification,jdbcType=VARCHAR},
      </if>
      <if test="graduateSchool != null">
        graduate_school = #{graduateSchool,jdbcType=VARCHAR},
      </if>
      <if test="consultationPrice != null">
        consultation_price = #{consultationPrice,jdbcType=DECIMAL},
      </if>
      <if test="consultantType != null">
        consultant_type = #{consultantType,jdbcType=DECIMAL},
      </if>
      <if test="releaseStatus != null">
        release_status = #{releaseStatus,jdbcType=DECIMAL},
      </if>
      <if test="typicalCase != null">
        typical_case = #{typicalCase,jdbcType=VARCHAR},
      </if>
      <if test="consultantCertificateUrl != null">
        consultant_certificate_url = #{consultantCertificateUrl,jdbcType=VARCHAR},
      </if>
      <if test="goodAtIndustry != null">
        good_at_industry = #{goodAtIndustry,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.UserIdentity">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Dec 29 09:20:50 CST 2017.
    -->
    update user_identity
    set uid = #{uid,jdbcType=VARCHAR},
      username = #{username,jdbcType=VARCHAR},
      sex = #{sex,jdbcType=VARCHAR},
      date_of_birth_year = #{dateOfBirthYear,jdbcType=VARCHAR},
      date_of_birth_month = #{dateOfBirthMonth,jdbcType=VARCHAR},
      id_number = #{idNumber,jdbcType=VARCHAR},
      positive_id_url = #{positiveIdUrl,jdbcType=VARCHAR},
      opposite_id_url = #{oppositeIdUrl,jdbcType=VARCHAR},
      province = #{province,jdbcType=INTEGER},
      city = #{city,jdbcType=INTEGER},
      area = #{area,jdbcType=INTEGER},
      contact_mobile = #{contactMobile,jdbcType=VARCHAR},
      bank_name = #{bankName,jdbcType=VARCHAR},
      bank_account = #{bankAccount,jdbcType=VARCHAR},
      bank_card_number = #{bankCardNumber,jdbcType=VARCHAR},
      amount_money = #{amountMoney,jdbcType=DECIMAL},
      audit_status = #{auditStatus,jdbcType=INTEGER},
      process = #{process,jdbcType=INTEGER},
      wrong_count = #{wrongCount,jdbcType=INTEGER},
      payment_date = #{paymentDate,jdbcType=TIMESTAMP},
      expert = #{expert,jdbcType=INTEGER},
      international = #{international,jdbcType=INTEGER},
      fixed_tel = #{fixedTel,jdbcType=VARCHAR},
      qq = #{qq,jdbcType=VARCHAR},
      postal_address = #{postalAddress,jdbcType=VARCHAR},
      postcode = #{postcode,jdbcType=VARCHAR},
      review_instructions = #{reviewInstructions,jdbcType=VARCHAR},
      industry = #{industry,jdbcType=INTEGER},
      contacts = #{contacts,jdbcType=VARCHAR},
      email = #{email,jdbcType=VARCHAR},
      professional_title = #{professionalTitle,jdbcType=VARCHAR},
      work_unit = #{workUnit,jdbcType=VARCHAR},
      education = #{education,jdbcType=VARCHAR},
      major_category = #{majorCategory,jdbcType=VARCHAR},
      qualification = #{qualification,jdbcType=VARCHAR},
      graduate_school = #{graduateSchool,jdbcType=VARCHAR},
      typical_case = #{typicalCase,jdbcType=VARCHAR},
      consultant_certificate_url = #{consultantCertificateUrl,jdbcType=VARCHAR},
      good_at_industry = #{goodAtIndustry,jdbcType=VARCHAR},
      consultation_price = #{consultationPrice,jdbcType=DECIMAL}
    where id = #{id,jdbcType=VARCHAR}
  </update>
 
   <select id="selectUserIdentityByUserId" parameterType="java.lang.String" resultMap="BaseResultMap">
  	 select 
    <include refid="Base_Column_List" />
    from user_identity
    where uid = #{uid,jdbcType=VARCHAR}
  </select>
   
  <select id="selectUserIdentityBoByUserId" parameterType="java.lang.String" resultType="com.goafanti.user.bo.UserIdentityBo">
	 select
	 	a.id as uid,
		a.identify_name as identifyName,
		a.mobile,
		a.email,
		a.introduction,
		a.head_portrait_url as headPortraitUrl,
		a.society_tag as societyTag,
		a.type,
		a.authentication,
		b.id,
		b.industry,
		b.sex,
		b.date_of_birth_year as dateOfBirthYear,
		b.date_of_birth_month as dateOfBirthMonth,
		b.id_number as idNumber,
		b.positive_id_url as positiveIdUrl,
		b.opposite_id_url as oppositeIdUrl,
		b.province,
		b.city,
		b.area,
		b.postal_address as postalAddress,
		b.fixed_tel as fixedTel,
		b.qq,
		b.graduate_school as graduateSchool,
		b.major_category as majorCategory,
		b.qualification,
		b.professional_title as professionalTitle,
		b.audit_status as auditStatus,
		b.expert as expert,
		b.work_unit as workUnit,
		b.work_unit as workUnit1,
		b.consultant_type as consultantType,
		b.audit_info as auditInfo,
		b.typical_case as typicalCase, 
		b.consultant_certificate_url as consultantCertificateUrl,
		b.good_at_industry as goodAtIndustry,
		b.professional_title as honer
	from
		user a left join user_identity b on
		a.id = b.uid
	where
		a.id = #{uid,jdbcType=VARCHAR}
  </select>
  
  <select id="selectAuditorUserIdentityByUserId" parameterType="java.lang.String" resultType="com.goafanti.user.bo.AuditorUserIdentityDetailBo">
  	select 
  		u.aid, 
  		u.mid, 
  		u.lvl,
  		ui.id, 
  		ui.uid, 
  		ui.username, 
  		ui.sex, 
  		ui.date_of_birth_year as dateOfBirthYear,
  		ui.date_of_birth_month as dateOfBirthMonth, 
  		ui.id_number as idNumber, 
  		ui.positive_id_url as positiveIdUrl,
  		ui.opposite_id_url as oppositeIdUrl, 
  		ui.province, 
  		ui.city, 
  		ui.area, 
  		ui.contact_mobile as contactMobile,
  		ui.bank_name as bankName, 
  		ui.bank_account as bankAccount, 
  		ui.bank_card_number as bankCardNumber, 
  		ui.amount_money as amountMoney,
  		ui.audit_status as auditStatus, 
  		ui.payment_date as paymentDate, 
  		ui.expert
  	from user u 
  	LEFT JOIN user_identity ui on u.id = ui.uid
  	where u.id = #{uid,jdbcType=VARCHAR}
  </select>
  
  <select id="selectManagerUserNames" parameterType="java.lang.String" resultType="com.goafanti.user.bo.UserNames">
		select u.id as uid, i.username
		from user u INNER JOIN
		user_identity i on u.id = i.uid 
		where u.lvl = 1
		<if test="_parameter != null">
			and u.mid = #{aid,jdbcType=VARCHAR}
		</if>
 </select>
	
 <select id="selectAllUserNames" parameterType="java.lang.String" resultType="com.goafanti.user.bo.UserNames">
		select u.id as uid, i.username
		from user u INNER JOIN
		user_identity i on u.id = i.uid 
		where u.lvl = 1
		<if test="_parameter != null">
			and u.aid = #{aid,jdbcType=VARCHAR}
		</if>
 </select>
	
 <select id="selectManagerAchievementUserOwner" resultType="com.goafanti.user.bo.UserNames">
		select u.id as uid, ui.username, u.mobile
			from user u INNER JOIN 
			user_identity ui on u.id = ui.uid
			where u.lvl = 1 and ui.username like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
			<if test="aid != null">
				and u.mid = #{aid,jdbcType=VARCHAR}
			</if>
			
 </select>
	
 <select id="selectAchievementUserOwner" resultType="com.goafanti.user.bo.UserNames">
		select u.id as uid, ui.username, u.mobile
			from user u INNER JOIN 
			user_identity ui on u.id = ui.uid
			where u.lvl = 1 and ui.username like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
			<if test="aid != null">
				and u.aid = #{aid,jdbcType=VARCHAR}
			</if>
		
 </select>
	
 <select id="findSearchSubscriberListByPage" parameterType="String" resultType="com.goafanti.portal.bo.UserSubscriberListBo">
		SELECT
			u.id as uid, u.identify_name as username, u.number,
			ui.id as identityId, ui.province,
			u.head_portrait_url as personPortraitUrl,
			u.introduction as achievementNum,
			adc.demand_count as demandNum,
			uc.engaged_field as engagedField,
			uc.work_unit as workUnit,
			ui.professional_title as position,
			ui.international
		FROM
		 user  u
		LEFT JOIN user_identity ui ON ui.uid = u.id
		LEFT JOIN user_career uc ON uc.uid = u.id
		LEFT JOIN achievement_demand_count adc ON adc.uid = u.id
		WHERE
			ui.expert = 1 and u.source=0
		<if test="null != level and level==1 ">
			AND u.lvl <![CDATA[ >= ]]> 1 
		</if>
		<if test="null !=level and level==0">
			AND u.lvl = 0
		</if>
		<if test="international !=null">
			AND ui.international= #{international,jdbcType=INTEGER}
		</if>
		<if test="province != null">
			AND ui.province = #{province,jdbcType=INTEGER}
		</if>
		<if test="city != null">
			AND ui.city = #{city,jdbcType=INTEGER}
		</if>
		<if test="area != null">
			AND ui.area = #{area,jdbcType=INTEGER}
		</if>
		<if test="field != null">
			AND ui.industry= #{field,jdbcType=VARCHAR}
		</if>
		<if test="auditStatus != null">
			AND ui.audit_status= #{auditStatus,jdbcType=VARCHAR}
		</if>
		<if test="name != null">
			AND u.identify_name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
		</if>
	order by u.number asc
	<if test="page_sql!=null">
		${page_sql}
	</if>
 </select>
 
	 <select id="findSearchSubscriberCount" parameterType="String" resultType="java.lang.Integer">
	 	SELECT
			count(0)
		FROM
		 user  u
		LEFT JOIN user_identity ui ON ui.uid = u.id
		LEFT JOIN user_career uc ON uc.uid = u.id
		LEFT JOIN achievement_demand_count adc ON adc.uid = u.id
		WHERE
		 ui.expert = 1 and u.source=0
		<if test="null != level and level==1 ">
			AND u.lvl <![CDATA[ >= ]]> 1 
		</if>
		<if test="null !=level and level==0">
			AND u.lvl = 0
		</if>
		<if test="international !=null">
			AND ui.international= #{international,jdbcType=INTEGER}
		</if>
		<if test="province != null">
			AND ui.province = #{province,jdbcType=INTEGER}
		</if>
		<if test="city != null">
			AND ui.city = #{city,jdbcType=INTEGER}
		</if>
		<if test="area != null">
			AND ui.area = #{area,jdbcType=INTEGER}
		</if>
		<if test="field != null">
			AND ui.industry= #{field,jdbcType=VARCHAR}
		</if>
		<if test="name != null">
			AND u.identify_name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
		</if>
		<if test="auditStatus != null">
			AND ui.audit_status= #{auditStatus,jdbcType=VARCHAR}
		</if>
	 </select>
  	 <select id="selectInternationalUser" resultType="com.goafanti.portal.bo.InternationalListBo">
		select 
			a.id,
			b.username as ownerName,
			c.ability_label as abilityLabel,
			a.head_portrait_url as personPortraitUrl,
			e.education
		from user a 
		left join user_identity b 
			on a.id = b.uid
		left join user_ability c 
			on a.id = c.uid
		<!-- left join user_info d 
			on a.id = d.uid -->
		left join user_edu e 
			on a.id = e.uid
		where 1=1
		<!-- and b.international_flag and b.audit_status = 5 and b.expert = 1 -->
		order by 
			a.create_time desc 
		limit 0,6	
	</select> 
	 <select id="selectUserIdentityByUid" resultType="com.goafanti.user.bo.UserIdentityBo">
	 	  select 	t.id ,t.uid,u.nickname as username,t.work_unit as workUnit,t.province,t.area,t.professional_title as professionalTitle,
			t.industry,t.city,u.introduction,u.head_portrait_url as headPortraitUrl,ifnull(o.x,0) as reservationCount,j.easemob_name as easemobName
	from user_identity t left JOIN user u on t.uid = u.id
	left join jpush_easemob_account j on t.uid=j.uid
	left join (select count(0) as x,seller_id from t_order
				where order_status != 4
				group by  seller_id ) o on t.uid=o.seller_id
	where t.expert=1
	and t.uid=#{uid,jdbcType=VARCHAR}
	 </select>
	 <select id="getExperts" resultType="com.goafanti.user.bo.UserIdentityBo">
	 	select 	t.id ,t.uid,u.identify_name as username,t.work_unit as workUnit,t.province,t.area,t.professional_title as professionalTitle,t.industry,t.city,
			u.type,u.introduction,u.head_portrait_url as headPortraitUrl,ifnull(o.x,0) as reservationCount
	from user_identity t left JOIN user u on t.uid = u.id
	left join (select count(0) as x,seller_id from t_order
				where order_status != 4
				group by  seller_id ) o on t.uid=o.seller_id
	where expert=1
	and u.status !=1
	and t.audit_status =2
	and u.source=0
	order by u.update_time desc
	limit #{0}
	 </select>
 <select id="findUserIdentityListByPage" parameterType="String" resultType="com.goafanti.user.bo.UserIdentityBo">
  	select 	t.id ,t.uid,u.nickname as username,t.work_unit as workUnit,t.province,t.area,t.professional_title as professionalTitle,t.industry,t.city,
			u.introduction,u.head_portrait_url as headPortraitUrl,ifnull(o.x,0) as reservationCount
	from user_identity t left JOIN user u on t.uid = u.id
	left join (select count(0) as x,seller_id from t_order
				where order_status != 4
				group by  seller_id ) o on t.uid=o.seller_id
	where expert=1
	and u.status !=1
	and t.audit_status =2
	<if test="industry != null">
        and t.industry = #{industry,jdbcType=VARCHAR}
    </if>
    <if test="name != null">
        and u.nickname like concat('%',#{name},'%')
    </if>
    <if test="page_sql!=null">
        ${page_sql}
    </if>
  </select>
  
  <select id="findUserIdentityCount" parameterType="String" resultType="java.lang.Integer">
  	select count(0) 
   from user_identity t left JOIN user u on t.uid = u.id
	left join (select count(0) as x,seller_id from t_order
				where order_status != 4
				group by  seller_id ) o on t.uid=o.seller_id
	where expert=1
	and u.status !=1
    <if test="industry != null">
        and t.industry = #{industry,jdbcType=VARCHAR}
    </if>
    <if test="name != null">
        and u.nickname like concat('%',#{name},'%')
    </if>
  </select>
  
  <select id="countInterest" resultType="java.lang.Integer">
  select count(0)
  	from user_interest 
  	where to_uid=#{uid,jdbcType=VARCHAR}
  </select>
  
  <select id="findConsultantListByPage" resultType="com.goafanti.app.bo.consultantListBo">
	 	select t.uid as id,t.username as username ,u.head_portrait_url as headPortraitUrl,u.introduction ,
	  t.expert as consultant,ifnull(x.n,0) as reservationCount
	  from user_identity t
	  left join `user` u on t.uid=u.id
	  left join ( select y.x  as n, y.seller_id
	from (select count( 0 ) as x,seller_id from t_order
			where order_status != 4
			group by seller_id)y)x on t.uid=x.seller_id 
  where t.expert=2
   <if test="page_sql!=null">
			${page_sql}
	</if>
  </select>
  
  <select id="findConsultantCount" resultType="java.lang.Integer">
   	select count(0) 
  from user_identity t
  left join `user` u on t.uid=u.id
  where t.expert=2
  </select>
  
  
  <select id="selectconsultantByUid" parameterType="java.lang.String" resultType="com.goafanti.app.bo.consultantListBo">
  select 
  		t.uid as id ,t.username as username ,t.expert as consultant,u.head_portrait_url as headPortraitUrl,
  		u.introduction,ifnull(o.x,0) as reservationCount,j.easemob_name as easemobName
  	from  user_identity t 
  	left join user u on t.uid =u.id
  	 left join jpush_easemob_account j on t.uid=j.uid
  	left join (select count(0) as x,seller_id from t_order
				where order_status != 4
				group by  seller_id ) o on t.uid=o.seller_id
  	where t.expert=2
  	and t.uid = #{uid,jdbcType=VARCHAR}
  </select>
  <select id="getAppHomeRecommended" resultType="com.goafanti.user.bo.UserIdentityRecommended">
  		 select
	ep.expert_id as id, u.identify_name as name, ui.work_unit as workUnit ,ui.professional_title as professionalTitle, u.introduction as introduction,
	u.head_portrait_url as headPortraitUrl,ifnull(o.x,0) as reservationCount
from expert_publish ep
	left join user_identity ui on ep.expert_id = ui.uid
	left join user u on ep.expert_id = u.id
	left join (select count(0) as x,seller_id from t_order
				where order_status != 4
				group by  seller_id ) o on ep.expert_id=o.seller_id
where
	ep.publish_client = '1'
	and ep.publish_page = 'W01'
order by
	ep.if_top, ep.top_number, ep.show_number asc 
	limit 0,6
  </select>
  
    <select id="getConsultantList" resultType="com.goafanti.app.bo.consultantListBo">
	 	select t.uid as id,t.username as username ,u.head_portrait_url as headPortraitUrl,u.introduction ,
	  t.expert as consultant,ifnull(x.n,0) as reservationCount,work_unit as workUnit
	  from user_identity t
	  left join `user` u on t.uid=u.id
	  left join ( select y.x  as n, y.seller_id
	from (select count( 0 ) as x,seller_id from t_order
			where order_status != 4
			group by seller_id)y)x on t.uid=x.seller_id 
  where t.expert=2
  limit #{0}
  </select>
  
  <select id="listInterestedExpert" resultType="com.goafanti.user.bo.UserIdentityBo">
	 	select 	t.id ,t.uid,u.nickname as username,t.work_unit as workUnit,t.province,t.area,t.professional_title as professionalTitle,t.industry,t.city,
		u.type,u.introduction,t.expert,u.head_portrait_url as headPortraitUrl, t.consultant_type as consultantType
		from user_identity t left JOIN user u on t.uid = u.id
		left join user_interest ui on ui.to_uid=u.id
		where ui.from_uid=#{uid,jdbcType=VARCHAR}
	<if test="page_sql!=null">
        ${page_sql}
    </if>
</select>
  <select id="listInterestedExpertCount" resultType="java.lang.Integer">
	 	select count(0)
		from user_identity t left JOIN user u on t.uid = u.id
		left join user_interest ui on ui.to_uid=u.id
		where ui.from_uid=#{uid,jdbcType=VARCHAR}
</select>
<select id="appMyInterestedExpertList" resultType="com.goafanti.user.bo.MyInterestedBo">
	select t.uid as id,u.nickname as name,t.work_unit as workUnit,u.introduction,
    t.professional_title as professionalTitle,u.head_portrait_url as imgUrl,
    t.consultant_type as consultantType,
    if(isnull(a.count),0,a.count) as interestCount 
	from user_interest ui left JOIN `user` u on ui.to_uid = u.id
	left join user_identity t on ui.to_uid=t.uid
	left join (select to_uid,count(*) as count from user_interest 
		GROUP  by to_uid)a on ui.to_uid=a.to_uid
	where 1=1
	<if test="type==0">
	and t.expert=1 
	</if>
	<if test="type==1">
	and t.expert=2 
	</if>
	and ui.from_uid=#{uid,jdbcType=VARCHAR}
	<if test="page_sql!=null">
        ${page_sql}
    </if>
</select>
  <select id="appMyInterestedExpertCount" resultType="java.lang.Integer">
	 	select count(*)from user_interest ui 
	left join user_identity t on ui.to_uid=t.uid
	where 1=1
	<if test="type==0">
	and t.expert=1 
	</if>
	<if test="type==1">
	and t.expert=2 
	</if>
	and ui.from_uid=#{uid,jdbcType=VARCHAR}
</select>
<select id="selectCustomerAuditList" resultType="com.goafanti.app.bo.ExpertsListBo">
	select u.id as uid, u.nickname as username, u.head_portrait_url as personPortraitUrl,
	u.introduction, ui.industry, ui.work_unit as workUnit, ui.professional_title as professionalTitle,
	ifnull( a.count, 0 ) as countInterest, if( isnull(b.to_uid), 0, 1 ) as interested,ui.expert,
	ifnull( x.a, 0 ) as favorable, ifnull( x.b, 0 ) as general, ifnull( x.c, 0 ) as inferior,
	ifnull( x.d, 0 ) as commentCount, ifnull( cast(x.a*100 / x.d as decimal(18, 2)), 100 ) as favorableRate
from
	`user` u left join user_identity ui on ui.uid = u.id 
	left join( select
		b.seller_id as uid, sum( case when a.star &gt; 3 then 1 else 0 end ) as a,
		sum( case when a.star = 3 then 1 else 0 end ) as b,
		sum( case when a.star &lt; 3 then 1 else 0 end ) as c, count(*) as d
		from jt_commodity_comment a left join jt_consult_order b on
		a.order_no = b.order_no group by b.seller_id
		) x on u.id = x.uid 
	left join( select count(*) as count, to_uid from user_interest group by to_uid) a 
	on u.id = a.to_uid left join( select to_uid from user_interest where from_uid =#{uid,jdbcType=VARCHAR} GROUP by to_uid) b
	on u.id = b.to_uid 
	where u.status = 0 and u.source = 0 
	and ui.expert = 1 and ui.audit_status = 2
	<if test="industry != null">
	 and ui.industry= #{industry,jdbcType=VARCHAR}
	</if>
	<if test="name != null">
	and u.nickname like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
	</if>
	<if test="sortType == 0">
	order by u.create_time desc
	</if> 
	<if test="sortType == 1">
	order by favorableRate desc
	</if>
	<if test="page_sql!=null">
        ${page_sql}
    </if>
</select>
  <select id="selectCustomerAuditCount" resultType="java.lang.Integer">
	 	select count(0)from
	`user` u left join user_identity ui on ui.uid = u.id 
	  where u.status = 0 and u.source = 0 and ui.expert = 1 and ui.audit_status = 2
	  <if test="industry != null">
		and ui.industry= #{industry,jdbcType=VARCHAR}
	</if>
	<if test="name != null">
	and u.nickname like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
	</if>
</select>
<select id="selectAppExpertsDetail" resultType="com.goafanti.app.bo.ExpertsListBo">
select a.id as uid,a.nickname as username,a.head_portrait_url as personPortraitUrl,b.consultant_type as consultantType,
		b.industry,b.work_unit as workUnit,b.professional_title as professionalTitle,a.introduction,
		ifnull(c.count,0) as countInterest,b.expert,ifnull(x.a,0) as favorable,ifnull(x.b,0) as general,
		ifnull(x.c,0) as inferior,ifnull(x.d,0) as commentCount,ifnull( cast(x.a*100 / x.d as decimal(18, 2)), 100 ) as favorableRate,
		if(isnull(d.to_uid),0,1) as interested, b.typical_case as typicalCase, b.good_at_industry as goodAtIndustry
		from `user` a left join user_identity b on a.id=b.uid left join (select a.commodity_id as uid,
			sum(case when a.star &gt; 3 then 1 else 0 end) as a,
			sum(case when a.star=3 then 1 else 0 end) as b,
			sum(case when a.star &lt; 3 then 1 else 0 end) as c,count(*) as d
			from jt_commodity_comment a 
			left join jt_consult_order b on a.order_no=b.order_no
			group by a.commodity_id)x on a.id=x.uid
		left join (select count(*) as count,to_uid from  user_interest group by to_uid)c on a.id=c.to_uid
left join (select to_uid from  user_interest where from_uid= #{uid,jdbcType=VARCHAR} group by to_uid)d on a.id=d.to_uid
where a.id=#{id,jdbcType=VARCHAR}
</select>
<select id="appConsultantList" resultType="com.goafanti.app.bo.ExpertsListBo">
	select u.id as uid, u.nickname as username, u.head_portrait_url as personPortraitUrl,ui.consultant_type as consultantType,
	u.introduction, ui.industry, ui.work_unit as workUnit, ui.professional_title as professionalTitle,
	ifnull( a.count, 0 ) as countInterest, if( isnull(b.to_uid), 0, 1 ) as interested,ui.expert,
	ifnull( x.a, 0 ) as favorable, ifnull( x.b, 0 ) as general, ifnull( x.c, 0 ) as inferior,
	ifnull( x.d, 0 ) as commentCount, ifnull( cast(x.a*100 / x.d as decimal(18, 2)), 100 ) as favorableRate
	,ui.typical_case as typicalCase, ui.good_at_industry as goodAtIndustry
from
	`user` u left join user_identity ui on ui.uid = u.id 
	left join(select a.commodity_id as uid,
			sum(case when a.star &gt; 3 then 1 else 0 end) as a,
			sum(case when a.star=3 then 1 else 0 end) as b,
			sum(case when a.star &lt; 3 then 1 else 0 end) as c,count(*) as d
			from jt_commodity_comment a 
			left join jt_consult_order b on a.order_no=b.order_no
			group by a.commodity_id)x on u.id=x.uid
	left join( select count(*) as count, to_uid from user_interest group by to_uid) a 
	on u.id = a.to_uid left join( select to_uid from user_interest where from_uid =#{uid,jdbcType=VARCHAR} ) b
	on u.id = b.to_uid 
	where u.status = 0 and u.source = 0 
	and ui.expert = 2 and ui.audit_status=2
	<if test='consultantType == null or consultantType ==""'>
	and ui.consultant_type &lt; 4
	</if>
	<if test="consultantType != null">
	and ui.consultant_type=#{consultantType,jdbcType=INTEGER}
	</if>
	<if test="province != null">
	and ui.province= #{province,jdbcType=INTEGER}
	</if>
	<if test="city != null">
	and ui.city=#{city,jdbcType=INTEGER}
	</if>
	<if test="area != null">
	and ui.area=#{area,jdbcType=INTEGER}
	</if>
	<if test="name != null">
	and u.nickname like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
	</if>
	<if test="sortType == 0">
	order by u.create_time desc
	</if> 
	<if test="sortType == 1">
	order by favorableRate desc
	</if>
	<if test="page_sql!=null">
        ${page_sql}
    </if>
</select>
<select id="appConsultantCount" resultType="java.lang.Integer">
	select count(*)
from
	`user` u left join user_identity ui on ui.uid = u.id 
	where u.status = 0 and u.source = 0
	and ui.expert = 2 and ui.audit_status=2
	<if test='consultantType == null or consultantType ==""'>
	and ui.consultant_type &lt; 4
	</if>
	<if test="consultantType != null">
	and ui.consultant_type=#{consultantType,jdbcType=INTEGER}
	</if>
	<if test="province != null">
	and ui.province= #{consultantType,jdbcType=INTEGER}
	</if>
	<if test="city != null">
	and ui.city=#{consultantType,jdbcType=INTEGER}
	</if>
	<if test="area != null">
	and ui.area=#{consultantType,jdbcType=INTEGER}
	</if>
	<if test="name != null">
	and u.nickname like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
	</if>
</select>

<!-- 获得专家顾问审核列表数据  -->
<select id="getExpertAuditList" resultMap="BaseResultMap">
	select 
	i.id, i.uid, i.username,  id_number, positive_id_url,  i.audit_status, expert, i.audit_status, fixed_tel, industry,
    u.mobile as contact_mobile, c.name as contacts, identify_name, consultant_type
	from user_identity i 
	inner join user u on i.uid = u.id
	left join industry_category c on c.id = i.industry
	where u.source = 0
	<if test="auditStatus != null ">
	and  i.audit_status = #{auditStatus,jdbcType=VARCHAR}
	</if>
	<if test="industry != null ">
	and industry = #{industry,jdbcType=INTEGER}
	</if>
	<if test="expert != null ">
	and expert = #{expert,jdbcType=INTEGER}
	</if>
	<if test="expert == null ">
	and expert &gt; 0
	</if>
	<if test="consultantType != null ">
	and consultant_type = #{consultantType,jdbcType=INTEGER}
	</if>
	<if test='username != null and username != ""'>
	<bind name="un" value="'%' + username + '%'"/>
	and (i.username like #{un,jdbcType=VARCHAR} or u.identify_name like #{un,jdbcType=VARCHAR} or u.nickname like #{un,jdbcType=VARCHAR} or u.username like #{un,jdbcType=VARCHAR})
	</if>
	<if test="page_sql!=null">
        ${page_sql}
    </if>
</select>
<select id="getExpertAuditListCount" resultType="java.lang.Integer">
	select 
	count(0)
	from user_identity i 
	inner join user u on i.uid = u.id
	where u.source = 0 
	<if test="auditStatus != null ">
	and  i.audit_status = #{auditStatus,jdbcType=VARCHAR}
	</if>
	<if test="industry != null ">
	and industry = #{industry,jdbcType=INTEGER}
	</if>
	<if test="expert != null ">
	and expert = #{expert,jdbcType=INTEGER}
	</if>
	<if test="expert == null ">
	and expert &gt; 0
	</if>
	<if test="consultantType != null ">
	and consultant_type = #{consultantType,jdbcType=INTEGER}
	</if>
	<if test="username != null">
	<bind name="un" value="'%' + username + '%'"/>
	and (i.username like #{un,jdbcType=VARCHAR} or u.identify_name like #{un,jdbcType=VARCHAR} or u.nickname like #{un,jdbcType=VARCHAR} or u.username like #{un,jdbcType=VARCHAR})
	</if>
</select>

<!-- 获得用户认证信息数据  -->
<select id="getUserIdentityByUid" parameterType="java.lang.String" resultMap="BaseResultMap">
	select 
	u.identify_name as identify_name, i.industry as industry, 
	u.society_tag as society_tag, 
	i.sex, i.date_of_birth_year, i.date_of_birth_month,
	i.id_number, i.province, i.city, i.area, i.postal_address, i.fixed_tel, i.email, i.qq, 
	u.mobile as contact_mobile, 
	u.introduction, u.audit_opinion, 
	i.expert, i.audit_status, i.positive_id_url, i.opposite_id_url, u.head_portrait_url, 
	i.education, i.major_category, i.consultant_type, i.graduate_school, i.work_unit, 
	i.qualification, i.professional_title, i.process, i.id, i.uid, i.audit_info,
	i.typical_case, i.consultant_certificate_url, i.work_unit as work_unit1,
	i.good_at_industry as goodAtIndustry, i.professional_title as honer
	from `user` u
	inner join user_identity i on u.id = i.uid
	where u.id = #{uid,jdbcType=VARCHAR}
</select>
<select id="expertsCommentByUid" resultType="com.goafanti.comment.bo.CommentDetailResult">
select a.create_time as createTime,
  date_format(a.create_time,'%Y-%m-%d') as createTimeFormat,
  a.commodity_id,
  a.content,a.star,u.identify_name as commenter
  from jt_commodity_comment a 
  left join user u on a.uid=u.id
  <!-- left join jt_consult_order b on a.order_no=b.order_no -->
  where 1=1
  and a.commodity_id= #{id,jdbcType=VARCHAR}
  order by a.star desc,a.create_time desc
  limit 1

</select>

<!-- 更改用户认证(专家/顾问审核状态) -->
<update id="updateAuditing" parameterType="com.goafanti.common.model.UserIdentity">
	update user_identity 
	set audit_status = #{auditStatus,jdbcType=VARCHAR}
	<if test="auditInfo != null">
	 , audit_info = #{auditInfo,jdbcType=VARCHAR}
	</if>
	where id = #{id,jdbcType=VARCHAR}
</update>


<select id="selectByIdentityId" resultType="com.goafanti.app.bo.ExpertsListBo">
	select a.id,a.uid as uid,b.nickname as username,b.society_tag as keyword,a.expert,b.introduction,a.consultant_type as consultantType from user_identity a 
    left join user b on a.uid=b.id
    where a.id=#{id,jdbcType=VARCHAR}
</select>

<!-- 获得指定数量法律顾问随机数据 -->
<select id="getRandAdviserByType" resultType="com.goafanti.app.bo.ExpertsListBo">
	select u.id as uid, u.nickname as username, u.head_portrait_url as personPortraitUrl,ui.consultant_type as consultantType,
		ui.work_unit as workUnit, ui.professional_title as professionalTitle,
		ifnull( cast(x.a*100 / x.d as decimal(18, 2)), 100 ) as favorableRate
	from
		`user` u left join user_identity ui on ui.uid = u.id 
	left join(select a.commodity_id as uid,
			sum(case when a.star > 3 then 1 else 0 end) as a,
			count(*) as d
			from jt_commodity_comment a 
			left join jt_consult_order b on a.order_no=b.order_no
			group by a.commodity_id)x on u.id=x.uid
	where u.status = 0 and u.source = 0 
	and ui.expert = 2 and ui.audit_status=2 
	<if test="id != null">
	and u.id &lt;&gt; #{id,jdbcType=VARCHAR}
	</if>
	<if test="consultantType != null">
	and ui.consultant_type = #{consultantType,jdbcType=INTEGER}
	</if>
	ORDER BY RAND()
	<if test="size">
	 LIMIT #{size,jdbcType=INTEGER}
	</if>
</select>
</mapper>
