<?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.chaozhanggui.dao.system.dao.TbPlussUserAppMapper">
  <resultMap id="BaseResultMap" type="com.chaozhanggui.dao.system.entity.TbPlussUserApp">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="loginName" jdbcType="VARCHAR" property="loginname" />
    <result column="userId" jdbcType="INTEGER" property="userid" />
    <result column="userName" jdbcType="VARCHAR" property="username" />
    <result column="userType" jdbcType="VARCHAR" property="usertype" />
    <result column="staffType" jdbcType="INTEGER" property="stafftype" />
    <result column="logo" jdbcType="VARCHAR" property="logo" />
    <result column="level" jdbcType="INTEGER" property="level" />
    <result column="createDt" jdbcType="TIMESTAMP" property="createdt" />
    <result column="updateDt" jdbcType="TIMESTAMP" property="updatedt" />
    <result column="extendProfit" jdbcType="DOUBLE" property="extendprofit" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="fansProfit" jdbcType="DOUBLE" property="fansprofit" />
    <result column="cashProfit" jdbcType="DOUBLE" property="cashprofit" />
    <result column="parentId" jdbcType="INTEGER" property="parentid" />
    <result column="agentStaffId" jdbcType="INTEGER" property="agentstaffid" />
    <result column="inviteNum" jdbcType="VARCHAR" property="invitenum" />
    <result column="tradeMoney" jdbcType="DOUBLE" property="trademoney" />
    <result column="certReason" jdbcType="VARCHAR" property="certreason" />
    <result column="bankStatus" jdbcType="INTEGER" property="bankstatus" />
    <result column="bankReason" jdbcType="VARCHAR" property="bankreason" />
    <result column="merchantCode" jdbcType="VARCHAR" property="merchantcode" />
    <result column="merchantName" jdbcType="VARCHAR" property="merchantname" />
    <result column="aisleSwitch" jdbcType="INTEGER" property="aisleswitch" />
    <result column="token" jdbcType="VARCHAR" property="token" />
    <result column="IsVoice" jdbcType="VARCHAR" property="isvoice" />
    <result column="pIdArr" jdbcType="VARCHAR" property="pidarr" />
    <result column="isFixedRate" jdbcType="CHAR" property="isfixedrate" />
    <result column="autoAudit" jdbcType="VARCHAR" property="autoaudit" />
    <result column="payEcdemicSwitch" jdbcType="VARCHAR" property="payecdemicswitch" />
    <result column="isDirectSeller" jdbcType="VARCHAR" property="isdirectseller" />
    <result column="isMarket" jdbcType="VARCHAR" property="ismarket" />
    <result column="isUnionPay" jdbcType="VARCHAR" property="isunionpay" />
    <result column="roleCode" jdbcType="VARCHAR" property="rolecode" />
    <result column="levelCode" jdbcType="VARCHAR" property="levelcode" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="spreadFlag" jdbcType="VARCHAR" property="spreadflag" />
    <result column="userNo" jdbcType="VARCHAR" property="userno" />
    <result column="typeMark" jdbcType="INTEGER" property="typemark" />
    <result column="areaMark" jdbcType="INTEGER" property="areamark" />
    <result column="evasionVoiceFlag" jdbcType="VARCHAR" property="evasionvoiceflag" />
    <result column="memberVoiceFlag" jdbcType="VARCHAR" property="membervoiceflag" />
    <result column="jfShopKey" jdbcType="VARCHAR" property="jfshopkey" />
  </resultMap>
  <sql id="Base_Column_List">
    id, loginName, userId, userName, userType, staffType, logo, level, createDt, updateDt, 
    extendProfit, status, fansProfit, cashProfit, parentId, agentStaffId, inviteNum, 
    tradeMoney, certReason, bankStatus, bankReason, merchantCode, merchantName, aisleSwitch, 
    token, IsVoice, pIdArr, isFixedRate, autoAudit, payEcdemicSwitch, isDirectSeller, 
    isMarket, isUnionPay, roleCode, levelCode, sort, spreadFlag, userNo, typeMark, areaMark, 
    evasionVoiceFlag, memberVoiceFlag, jfShopKey
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tb_pluss_user_app
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tb_pluss_user_app
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.chaozhanggui.dao.system.entity.TbPlussUserApp">
    insert into tb_pluss_user_app (id, loginName, userId, 
      userName, userType, staffType, 
      logo, level, createDt, 
      updateDt, extendProfit, status, 
      fansProfit, cashProfit, parentId, 
      agentStaffId, inviteNum, tradeMoney, 
      certReason, bankStatus, bankReason, 
      merchantCode, merchantName, aisleSwitch, 
      token, IsVoice, pIdArr, 
      isFixedRate, autoAudit, payEcdemicSwitch, 
      isDirectSeller, isMarket, isUnionPay, 
      roleCode, levelCode, sort, 
      spreadFlag, userNo, typeMark, 
      areaMark, evasionVoiceFlag, memberVoiceFlag, 
      jfShopKey)
    values (#{id,jdbcType=INTEGER}, #{loginname,jdbcType=VARCHAR}, #{userid,jdbcType=INTEGER}, 
      #{username,jdbcType=VARCHAR}, #{usertype,jdbcType=VARCHAR}, #{stafftype,jdbcType=INTEGER}, 
      #{logo,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{createdt,jdbcType=TIMESTAMP}, 
      #{updatedt,jdbcType=TIMESTAMP}, #{extendprofit,jdbcType=DOUBLE}, #{status,jdbcType=INTEGER}, 
      #{fansprofit,jdbcType=DOUBLE}, #{cashprofit,jdbcType=DOUBLE}, #{parentid,jdbcType=INTEGER}, 
      #{agentstaffid,jdbcType=INTEGER}, #{invitenum,jdbcType=VARCHAR}, #{trademoney,jdbcType=DOUBLE}, 
      #{certreason,jdbcType=VARCHAR}, #{bankstatus,jdbcType=INTEGER}, #{bankreason,jdbcType=VARCHAR}, 
      #{merchantcode,jdbcType=VARCHAR}, #{merchantname,jdbcType=VARCHAR}, #{aisleswitch,jdbcType=INTEGER}, 
      #{token,jdbcType=VARCHAR}, #{isvoice,jdbcType=VARCHAR}, #{pidarr,jdbcType=VARCHAR}, 
      #{isfixedrate,jdbcType=CHAR}, #{autoaudit,jdbcType=VARCHAR}, #{payecdemicswitch,jdbcType=VARCHAR}, 
      #{isdirectseller,jdbcType=VARCHAR}, #{ismarket,jdbcType=VARCHAR}, #{isunionpay,jdbcType=VARCHAR}, 
      #{rolecode,jdbcType=VARCHAR}, #{levelcode,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, 
      #{spreadflag,jdbcType=VARCHAR}, #{userno,jdbcType=VARCHAR}, #{typemark,jdbcType=INTEGER}, 
      #{areamark,jdbcType=INTEGER}, #{evasionvoiceflag,jdbcType=VARCHAR}, #{membervoiceflag,jdbcType=VARCHAR}, 
      #{jfshopkey,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.chaozhanggui.dao.system.entity.TbPlussUserApp">
    insert into tb_pluss_user_app
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="loginname != null">
        loginName,
      </if>
      <if test="userid != null">
        userId,
      </if>
      <if test="username != null">
        userName,
      </if>
      <if test="usertype != null">
        userType,
      </if>
      <if test="stafftype != null">
        staffType,
      </if>
      <if test="logo != null">
        logo,
      </if>
      <if test="level != null">
        level,
      </if>
      <if test="createdt != null">
        createDt,
      </if>
      <if test="updatedt != null">
        updateDt,
      </if>
      <if test="extendprofit != null">
        extendProfit,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="fansprofit != null">
        fansProfit,
      </if>
      <if test="cashprofit != null">
        cashProfit,
      </if>
      <if test="parentid != null">
        parentId,
      </if>
      <if test="agentstaffid != null">
        agentStaffId,
      </if>
      <if test="invitenum != null">
        inviteNum,
      </if>
      <if test="trademoney != null">
        tradeMoney,
      </if>
      <if test="certreason != null">
        certReason,
      </if>
      <if test="bankstatus != null">
        bankStatus,
      </if>
      <if test="bankreason != null">
        bankReason,
      </if>
      <if test="merchantcode != null">
        merchantCode,
      </if>
      <if test="merchantname != null">
        merchantName,
      </if>
      <if test="aisleswitch != null">
        aisleSwitch,
      </if>
      <if test="token != null">
        token,
      </if>
      <if test="isvoice != null">
        IsVoice,
      </if>
      <if test="pidarr != null">
        pIdArr,
      </if>
      <if test="isfixedrate != null">
        isFixedRate,
      </if>
      <if test="autoaudit != null">
        autoAudit,
      </if>
      <if test="payecdemicswitch != null">
        payEcdemicSwitch,
      </if>
      <if test="isdirectseller != null">
        isDirectSeller,
      </if>
      <if test="ismarket != null">
        isMarket,
      </if>
      <if test="isunionpay != null">
        isUnionPay,
      </if>
      <if test="rolecode != null">
        roleCode,
      </if>
      <if test="levelcode != null">
        levelCode,
      </if>
      <if test="sort != null">
        sort,
      </if>
      <if test="spreadflag != null">
        spreadFlag,
      </if>
      <if test="userno != null">
        userNo,
      </if>
      <if test="typemark != null">
        typeMark,
      </if>
      <if test="areamark != null">
        areaMark,
      </if>
      <if test="evasionvoiceflag != null">
        evasionVoiceFlag,
      </if>
      <if test="membervoiceflag != null">
        memberVoiceFlag,
      </if>
      <if test="jfshopkey != null">
        jfShopKey,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="loginname != null">
        #{loginname,jdbcType=VARCHAR},
      </if>
      <if test="userid != null">
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="username != null">
        #{username,jdbcType=VARCHAR},
      </if>
      <if test="usertype != null">
        #{usertype,jdbcType=VARCHAR},
      </if>
      <if test="stafftype != null">
        #{stafftype,jdbcType=INTEGER},
      </if>
      <if test="logo != null">
        #{logo,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        #{level,jdbcType=INTEGER},
      </if>
      <if test="createdt != null">
        #{createdt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedt != null">
        #{updatedt,jdbcType=TIMESTAMP},
      </if>
      <if test="extendprofit != null">
        #{extendprofit,jdbcType=DOUBLE},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="fansprofit != null">
        #{fansprofit,jdbcType=DOUBLE},
      </if>
      <if test="cashprofit != null">
        #{cashprofit,jdbcType=DOUBLE},
      </if>
      <if test="parentid != null">
        #{parentid,jdbcType=INTEGER},
      </if>
      <if test="agentstaffid != null">
        #{agentstaffid,jdbcType=INTEGER},
      </if>
      <if test="invitenum != null">
        #{invitenum,jdbcType=VARCHAR},
      </if>
      <if test="trademoney != null">
        #{trademoney,jdbcType=DOUBLE},
      </if>
      <if test="certreason != null">
        #{certreason,jdbcType=VARCHAR},
      </if>
      <if test="bankstatus != null">
        #{bankstatus,jdbcType=INTEGER},
      </if>
      <if test="bankreason != null">
        #{bankreason,jdbcType=VARCHAR},
      </if>
      <if test="merchantcode != null">
        #{merchantcode,jdbcType=VARCHAR},
      </if>
      <if test="merchantname != null">
        #{merchantname,jdbcType=VARCHAR},
      </if>
      <if test="aisleswitch != null">
        #{aisleswitch,jdbcType=INTEGER},
      </if>
      <if test="token != null">
        #{token,jdbcType=VARCHAR},
      </if>
      <if test="isvoice != null">
        #{isvoice,jdbcType=VARCHAR},
      </if>
      <if test="pidarr != null">
        #{pidarr,jdbcType=VARCHAR},
      </if>
      <if test="isfixedrate != null">
        #{isfixedrate,jdbcType=CHAR},
      </if>
      <if test="autoaudit != null">
        #{autoaudit,jdbcType=VARCHAR},
      </if>
      <if test="payecdemicswitch != null">
        #{payecdemicswitch,jdbcType=VARCHAR},
      </if>
      <if test="isdirectseller != null">
        #{isdirectseller,jdbcType=VARCHAR},
      </if>
      <if test="ismarket != null">
        #{ismarket,jdbcType=VARCHAR},
      </if>
      <if test="isunionpay != null">
        #{isunionpay,jdbcType=VARCHAR},
      </if>
      <if test="rolecode != null">
        #{rolecode,jdbcType=VARCHAR},
      </if>
      <if test="levelcode != null">
        #{levelcode,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=INTEGER},
      </if>
      <if test="spreadflag != null">
        #{spreadflag,jdbcType=VARCHAR},
      </if>
      <if test="userno != null">
        #{userno,jdbcType=VARCHAR},
      </if>
      <if test="typemark != null">
        #{typemark,jdbcType=INTEGER},
      </if>
      <if test="areamark != null">
        #{areamark,jdbcType=INTEGER},
      </if>
      <if test="evasionvoiceflag != null">
        #{evasionvoiceflag,jdbcType=VARCHAR},
      </if>
      <if test="membervoiceflag != null">
        #{membervoiceflag,jdbcType=VARCHAR},
      </if>
      <if test="jfshopkey != null">
        #{jfshopkey,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.dao.system.entity.TbPlussUserApp">
    update tb_pluss_user_app
    <set>
      <if test="loginname != null">
        loginName = #{loginname,jdbcType=VARCHAR},
      </if>
      <if test="userid != null">
        userId = #{userid,jdbcType=INTEGER},
      </if>
      <if test="username != null">
        userName = #{username,jdbcType=VARCHAR},
      </if>
      <if test="usertype != null">
        userType = #{usertype,jdbcType=VARCHAR},
      </if>
      <if test="stafftype != null">
        staffType = #{stafftype,jdbcType=INTEGER},
      </if>
      <if test="logo != null">
        logo = #{logo,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        level = #{level,jdbcType=INTEGER},
      </if>
      <if test="createdt != null">
        createDt = #{createdt,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedt != null">
        updateDt = #{updatedt,jdbcType=TIMESTAMP},
      </if>
      <if test="extendprofit != null">
        extendProfit = #{extendprofit,jdbcType=DOUBLE},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="fansprofit != null">
        fansProfit = #{fansprofit,jdbcType=DOUBLE},
      </if>
      <if test="cashprofit != null">
        cashProfit = #{cashprofit,jdbcType=DOUBLE},
      </if>
      <if test="parentid != null">
        parentId = #{parentid,jdbcType=INTEGER},
      </if>
      <if test="agentstaffid != null">
        agentStaffId = #{agentstaffid,jdbcType=INTEGER},
      </if>
      <if test="invitenum != null">
        inviteNum = #{invitenum,jdbcType=VARCHAR},
      </if>
      <if test="trademoney != null">
        tradeMoney = #{trademoney,jdbcType=DOUBLE},
      </if>
      <if test="certreason != null">
        certReason = #{certreason,jdbcType=VARCHAR},
      </if>
      <if test="bankstatus != null">
        bankStatus = #{bankstatus,jdbcType=INTEGER},
      </if>
      <if test="bankreason != null">
        bankReason = #{bankreason,jdbcType=VARCHAR},
      </if>
      <if test="merchantcode != null">
        merchantCode = #{merchantcode,jdbcType=VARCHAR},
      </if>
      <if test="merchantname != null">
        merchantName = #{merchantname,jdbcType=VARCHAR},
      </if>
      <if test="aisleswitch != null">
        aisleSwitch = #{aisleswitch,jdbcType=INTEGER},
      </if>
      <if test="token != null">
        token = #{token,jdbcType=VARCHAR},
      </if>
      <if test="isvoice != null">
        IsVoice = #{isvoice,jdbcType=VARCHAR},
      </if>
      <if test="pidarr != null">
        pIdArr = #{pidarr,jdbcType=VARCHAR},
      </if>
      <if test="isfixedrate != null">
        isFixedRate = #{isfixedrate,jdbcType=CHAR},
      </if>
      <if test="autoaudit != null">
        autoAudit = #{autoaudit,jdbcType=VARCHAR},
      </if>
      <if test="payecdemicswitch != null">
        payEcdemicSwitch = #{payecdemicswitch,jdbcType=VARCHAR},
      </if>
      <if test="isdirectseller != null">
        isDirectSeller = #{isdirectseller,jdbcType=VARCHAR},
      </if>
      <if test="ismarket != null">
        isMarket = #{ismarket,jdbcType=VARCHAR},
      </if>
      <if test="isunionpay != null">
        isUnionPay = #{isunionpay,jdbcType=VARCHAR},
      </if>
      <if test="rolecode != null">
        roleCode = #{rolecode,jdbcType=VARCHAR},
      </if>
      <if test="levelcode != null">
        levelCode = #{levelcode,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        sort = #{sort,jdbcType=INTEGER},
      </if>
      <if test="spreadflag != null">
        spreadFlag = #{spreadflag,jdbcType=VARCHAR},
      </if>
      <if test="userno != null">
        userNo = #{userno,jdbcType=VARCHAR},
      </if>
      <if test="typemark != null">
        typeMark = #{typemark,jdbcType=INTEGER},
      </if>
      <if test="areamark != null">
        areaMark = #{areamark,jdbcType=INTEGER},
      </if>
      <if test="evasionvoiceflag != null">
        evasionVoiceFlag = #{evasionvoiceflag,jdbcType=VARCHAR},
      </if>
      <if test="membervoiceflag != null">
        memberVoiceFlag = #{membervoiceflag,jdbcType=VARCHAR},
      </if>
      <if test="jfshopkey != null">
        jfShopKey = #{jfshopkey,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.chaozhanggui.dao.system.entity.TbPlussUserApp">
    update tb_pluss_user_app
    set loginName = #{loginname,jdbcType=VARCHAR},
      userId = #{userid,jdbcType=INTEGER},
      userName = #{username,jdbcType=VARCHAR},
      userType = #{usertype,jdbcType=VARCHAR},
      staffType = #{stafftype,jdbcType=INTEGER},
      logo = #{logo,jdbcType=VARCHAR},
      level = #{level,jdbcType=INTEGER},
      createDt = #{createdt,jdbcType=TIMESTAMP},
      updateDt = #{updatedt,jdbcType=TIMESTAMP},
      extendProfit = #{extendprofit,jdbcType=DOUBLE},
      status = #{status,jdbcType=INTEGER},
      fansProfit = #{fansprofit,jdbcType=DOUBLE},
      cashProfit = #{cashprofit,jdbcType=DOUBLE},
      parentId = #{parentid,jdbcType=INTEGER},
      agentStaffId = #{agentstaffid,jdbcType=INTEGER},
      inviteNum = #{invitenum,jdbcType=VARCHAR},
      tradeMoney = #{trademoney,jdbcType=DOUBLE},
      certReason = #{certreason,jdbcType=VARCHAR},
      bankStatus = #{bankstatus,jdbcType=INTEGER},
      bankReason = #{bankreason,jdbcType=VARCHAR},
      merchantCode = #{merchantcode,jdbcType=VARCHAR},
      merchantName = #{merchantname,jdbcType=VARCHAR},
      aisleSwitch = #{aisleswitch,jdbcType=INTEGER},
      token = #{token,jdbcType=VARCHAR},
      IsVoice = #{isvoice,jdbcType=VARCHAR},
      pIdArr = #{pidarr,jdbcType=VARCHAR},
      isFixedRate = #{isfixedrate,jdbcType=CHAR},
      autoAudit = #{autoaudit,jdbcType=VARCHAR},
      payEcdemicSwitch = #{payecdemicswitch,jdbcType=VARCHAR},
      isDirectSeller = #{isdirectseller,jdbcType=VARCHAR},
      isMarket = #{ismarket,jdbcType=VARCHAR},
      isUnionPay = #{isunionpay,jdbcType=VARCHAR},
      roleCode = #{rolecode,jdbcType=VARCHAR},
      levelCode = #{levelcode,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=INTEGER},
      spreadFlag = #{spreadflag,jdbcType=VARCHAR},
      userNo = #{userno,jdbcType=VARCHAR},
      typeMark = #{typemark,jdbcType=INTEGER},
      areaMark = #{areamark,jdbcType=INTEGER},
      evasionVoiceFlag = #{evasionvoiceflag,jdbcType=VARCHAR},
      memberVoiceFlag = #{membervoiceflag,jdbcType=VARCHAR},
      jfShopKey = #{jfshopkey,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="countByInviteNum" resultType="int">
    select count(0) from tb_pluss_user_app where inviteNum=#{inviteNum}
    </select>



  <select id="selectProfit" resultType="com.chaozhanggui.dao.system.model.ProfitPO">
    SELECT
    p.orderNumber,
    p.merchantCode,
    p.merchantName,
    p.price,
    p.consumeFee,
    p.createDt,
    b.userId
    FROM
    tb_pluss_merchant_profit p left join tb_pluss_merchant_base_info b on p.merchantCode=b.merchantCode
    where p.userId=#{userId}
    and p.price!=0
    <if test="orderNumber !=null and orderNumber != ''">
      and p.orderNumber=#{orderNumber}
    </if>

    <if test="merchantCode !=null and merchantCode != ''">
      and p.merchantCode=#{merchantCode}
    </if>
    ORDER BY
    p.id DESC
  </select>
</mapper>