<?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.fuxi.ws.data.dao.WReturnMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WReturn">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    <id column="ReturnID" jdbcType="BIGINT" property="returnid" />
    <result column="ReTurnNo" jdbcType="VARCHAR" property="returnno" />
    <result column="EShopOrderID" jdbcType="INTEGER" property="eshoporderid" />
    <result column="DepartmentID" jdbcType="VARCHAR" property="departmentid" />
    <result column="No" jdbcType="VARCHAR" property="no" />
    <result column="Vipid" jdbcType="VARCHAR" property="vipid" />
    <result column="ReasonID" jdbcType="TINYINT" property="reasonid" />
    <result column="Resean" jdbcType="NVARCHAR" property="resean" />
    <result column="RejectReason" jdbcType="NCHAR" property="rejectreason" />
    <result column="RecieveShop" jdbcType="VARCHAR" property="recieveshop" />
    <result column="ReturnMoney" jdbcType="DECIMAL" property="returnmoney" />
    <result column="ExchangedPoint" jdbcType="DECIMAL" property="exchangedpoint" />
    <result column="ReturnPoint" jdbcType="INTEGER" property="returnpoint" />
    <result column="DepositAmount" jdbcType="DECIMAL" property="depositamount" />
    <result column="PaymentType" jdbcType="VARCHAR" property="paymenttype" />
    <result column="Payed" jdbcType="DECIMAL" property="payed" />
    <result column="TicketMony" jdbcType="DECIMAL" property="ticketmony" />
    <result column="DiscountMoney" jdbcType="DECIMAL" property="discountmoney" />
    <result column="DeliveryType" jdbcType="VARCHAR" property="deliverytype" />
    <result column="State" jdbcType="NVARCHAR" property="state" />
    <result column="City" jdbcType="NVARCHAR" property="city" />
    <result column="Direct" jdbcType="NVARCHAR" property="direct" />
    <result column="Adress" jdbcType="NVARCHAR" property="adress" />
    <result column="post_companyname" jdbcType="VARCHAR" property="postCompanyname" />
    <result column="post_no" jdbcType="VARCHAR" property="postNo" />
    <result column="post_fee" jdbcType="DECIMAL" property="postFee" />
    <result column="CreateDate" jdbcType="TIMESTAMP" property="createdate" />
    <result column="ConfirmDate" jdbcType="TIMESTAMP" property="confirmdate" />
    <result column="Comfrimer" jdbcType="VARCHAR" property="comfrimer" />
    <result column="deliverDate" jdbcType="TIMESTAMP" property="deliverdate" />
    <result column="RecieveDate" jdbcType="TIMESTAMP" property="recievedate" />
    <result column="Reciever" jdbcType="VARCHAR" property="reciever" />
    <result column="FinishDate" jdbcType="TIMESTAMP" property="finishdate" />
    <result column="Finisher" jdbcType="VARCHAR" property="finisher" />
    <result column="CancelDate" jdbcType="TIMESTAMP" property="canceldate" />
    <result column="CancelPerson" jdbcType="VARCHAR" property="cancelperson" />
    <result column="Status" jdbcType="TINYINT" property="status" />
    <result column="return_sn" jdbcType="VARCHAR" property="returnSn" />
    <result column="RecPointRate" jdbcType="DECIMAL" property="recpointrate" />
    <result column="RecPoint" jdbcType="DECIMAL" property="recpoint" />
    <result column="SendTimes" jdbcType="DECIMAL" property="sendtimes" />
    <result column="SendPoint" jdbcType="INTEGER" property="sendpoint" />
    <result column="TicketToAmount" jdbcType="TINYINT" property="tickettoamount" />
    <result column="PointOrder" jdbcType="TINYINT" property="pointorder" />
    <result column="returnPointmemo" jdbcType="TINYINT" property="returnpointmemo" />
    <result column="returnPointNum" jdbcType="DECIMAL" property="returnpointnum" />
    <result column="returnDepositmemo" jdbcType="TINYINT" property="returndepositmemo" />
    <result column="returnDepositNum" jdbcType="DECIMAL" property="returndepositnum" />
    <result column="payTicketmemo" jdbcType="TINYINT" property="payticketmemo" />
    <result column="Interfacememo" jdbcType="TINYINT" property="interfacememo" />
  </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 Nov 16 10:22:01 CST 2018.
    -->
    <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="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    ReturnID, ReTurnNo, EShopOrderID, DepartmentID, No, Vipid, ReasonID, Resean, RejectReason, 
    RecieveShop, ReturnMoney, ExchangedPoint, ReturnPoint, DepositAmount, PaymentType, 
    Payed, TicketMony, DiscountMoney, DeliveryType, State, City, Direct, Adress, post_companyname, 
    post_no, post_fee, CreateDate, ConfirmDate, Comfrimer, deliverDate, RecieveDate, 
    Reciever, FinishDate, Finisher, CancelDate, CancelPerson, Status, return_sn, RecPointRate, 
    RecPoint, SendTimes, SendPoint, TicketToAmount, PointOrder, returnPointmemo, returnPointNum, 
    returnDepositmemo, returnDepositNum, payTicketmemo, Interfacememo
  </sql>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WReturnExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_Return
    <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.Long" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_Return
    where ReturnID = #{returnid,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    delete from W_Return
    where ReturnID = #{returnid,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WReturn">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    insert into W_Return (ReturnID, ReTurnNo, EShopOrderID, 
      DepartmentID, No, Vipid, 
      ReasonID, Resean, RejectReason, 
      RecieveShop, ReturnMoney, ExchangedPoint, 
      ReturnPoint, DepositAmount, PaymentType, 
      Payed, TicketMony, DiscountMoney, 
      DeliveryType, State, City, 
      Direct, Adress, post_companyname, 
      post_no, post_fee, CreateDate, 
      ConfirmDate, Comfrimer, deliverDate, 
      RecieveDate, Reciever, FinishDate, 
      Finisher, CancelDate, CancelPerson, 
      Status, return_sn, RecPointRate, 
      RecPoint, SendTimes, SendPoint, 
      TicketToAmount, PointOrder, returnPointmemo, 
      returnPointNum, returnDepositmemo, returnDepositNum, 
      payTicketmemo, Interfacememo)
    values (#{returnid,jdbcType=BIGINT}, #{returnno,jdbcType=VARCHAR}, #{eshoporderid,jdbcType=INTEGER}, 
      #{departmentid,jdbcType=VARCHAR}, #{no,jdbcType=VARCHAR}, #{vipid,jdbcType=VARCHAR}, 
      #{reasonid,jdbcType=TINYINT}, #{resean,jdbcType=NVARCHAR}, #{rejectreason,jdbcType=NCHAR}, 
      #{recieveshop,jdbcType=VARCHAR}, #{returnmoney,jdbcType=DECIMAL}, #{exchangedpoint,jdbcType=DECIMAL}, 
      #{returnpoint,jdbcType=INTEGER}, #{depositamount,jdbcType=DECIMAL}, #{paymenttype,jdbcType=VARCHAR}, 
      #{payed,jdbcType=DECIMAL}, #{ticketmony,jdbcType=DECIMAL}, #{discountmoney,jdbcType=DECIMAL}, 
      #{deliverytype,jdbcType=VARCHAR}, #{state,jdbcType=NVARCHAR}, #{city,jdbcType=NVARCHAR}, 
      #{direct,jdbcType=NVARCHAR}, #{adress,jdbcType=NVARCHAR}, #{postCompanyname,jdbcType=VARCHAR}, 
      #{postNo,jdbcType=VARCHAR}, #{postFee,jdbcType=DECIMAL}, #{createdate,jdbcType=TIMESTAMP}, 
      #{confirmdate,jdbcType=TIMESTAMP}, #{comfrimer,jdbcType=VARCHAR}, #{deliverdate,jdbcType=TIMESTAMP}, 
      #{recievedate,jdbcType=TIMESTAMP}, #{reciever,jdbcType=VARCHAR}, #{finishdate,jdbcType=TIMESTAMP}, 
      #{finisher,jdbcType=VARCHAR}, #{canceldate,jdbcType=TIMESTAMP}, #{cancelperson,jdbcType=VARCHAR}, 
      #{status,jdbcType=TINYINT}, #{returnSn,jdbcType=VARCHAR}, #{recpointrate,jdbcType=DECIMAL}, 
      #{recpoint,jdbcType=DECIMAL}, #{sendtimes,jdbcType=DECIMAL}, #{sendpoint,jdbcType=INTEGER}, 
      #{tickettoamount,jdbcType=TINYINT}, #{pointorder,jdbcType=TINYINT}, #{returnpointmemo,jdbcType=TINYINT}, 
      #{returnpointnum,jdbcType=DECIMAL}, #{returndepositmemo,jdbcType=TINYINT}, #{returndepositnum,jdbcType=DECIMAL}, 
      #{payticketmemo,jdbcType=TINYINT}, #{interfacememo,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WReturn">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    insert into W_Return
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="returnid != null">
        ReturnID,
      </if>
      <if test="returnno != null">
        ReTurnNo,
      </if>
      <if test="eshoporderid != null">
        EShopOrderID,
      </if>
      <if test="departmentid != null">
        DepartmentID,
      </if>
      <if test="no != null">
        No,
      </if>
      <if test="vipid != null">
        Vipid,
      </if>
      <if test="reasonid != null">
        ReasonID,
      </if>
      <if test="resean != null">
        Resean,
      </if>
      <if test="rejectreason != null">
        RejectReason,
      </if>
      <if test="recieveshop != null">
        RecieveShop,
      </if>
      <if test="returnmoney != null">
        ReturnMoney,
      </if>
      <if test="exchangedpoint != null">
        ExchangedPoint,
      </if>
      <if test="returnpoint != null">
        ReturnPoint,
      </if>
      <if test="depositamount != null">
        DepositAmount,
      </if>
      <if test="paymenttype != null">
        PaymentType,
      </if>
      <if test="payed != null">
        Payed,
      </if>
      <if test="ticketmony != null">
        TicketMony,
      </if>
      <if test="discountmoney != null">
        DiscountMoney,
      </if>
      <if test="deliverytype != null">
        DeliveryType,
      </if>
      <if test="state != null">
        State,
      </if>
      <if test="city != null">
        City,
      </if>
      <if test="direct != null">
        Direct,
      </if>
      <if test="adress != null">
        Adress,
      </if>
      <if test="postCompanyname != null">
        post_companyname,
      </if>
      <if test="postNo != null">
        post_no,
      </if>
      <if test="postFee != null">
        post_fee,
      </if>
      <if test="createdate != null">
        CreateDate,
      </if>
      <if test="confirmdate != null">
        ConfirmDate,
      </if>
      <if test="comfrimer != null">
        Comfrimer,
      </if>
      <if test="deliverdate != null">
        deliverDate,
      </if>
      <if test="recievedate != null">
        RecieveDate,
      </if>
      <if test="reciever != null">
        Reciever,
      </if>
      <if test="finishdate != null">
        FinishDate,
      </if>
      <if test="finisher != null">
        Finisher,
      </if>
      <if test="canceldate != null">
        CancelDate,
      </if>
      <if test="cancelperson != null">
        CancelPerson,
      </if>
      <if test="status != null">
        Status,
      </if>
      <if test="returnSn != null">
        return_sn,
      </if>
      <if test="recpointrate != null">
        RecPointRate,
      </if>
      <if test="recpoint != null">
        RecPoint,
      </if>
      <if test="sendtimes != null">
        SendTimes,
      </if>
      <if test="sendpoint != null">
        SendPoint,
      </if>
      <if test="tickettoamount != null">
        TicketToAmount,
      </if>
      <if test="pointorder != null">
        PointOrder,
      </if>
      <if test="returnpointmemo != null">
        returnPointmemo,
      </if>
      <if test="returnpointnum != null">
        returnPointNum,
      </if>
      <if test="returndepositmemo != null">
        returnDepositmemo,
      </if>
      <if test="returndepositnum != null">
        returnDepositNum,
      </if>
      <if test="payticketmemo != null">
        payTicketmemo,
      </if>
      <if test="interfacememo != null">
        Interfacememo,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="returnid != null">
        #{returnid,jdbcType=BIGINT},
      </if>
      <if test="returnno != null">
        #{returnno,jdbcType=VARCHAR},
      </if>
      <if test="eshoporderid != null">
        #{eshoporderid,jdbcType=INTEGER},
      </if>
      <if test="departmentid != null">
        #{departmentid,jdbcType=VARCHAR},
      </if>
      <if test="no != null">
        #{no,jdbcType=VARCHAR},
      </if>
      <if test="vipid != null">
        #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="reasonid != null">
        #{reasonid,jdbcType=TINYINT},
      </if>
      <if test="resean != null">
        #{resean,jdbcType=NVARCHAR},
      </if>
      <if test="rejectreason != null">
        #{rejectreason,jdbcType=NCHAR},
      </if>
      <if test="recieveshop != null">
        #{recieveshop,jdbcType=VARCHAR},
      </if>
      <if test="returnmoney != null">
        #{returnmoney,jdbcType=DECIMAL},
      </if>
      <if test="exchangedpoint != null">
        #{exchangedpoint,jdbcType=DECIMAL},
      </if>
      <if test="returnpoint != null">
        #{returnpoint,jdbcType=INTEGER},
      </if>
      <if test="depositamount != null">
        #{depositamount,jdbcType=DECIMAL},
      </if>
      <if test="paymenttype != null">
        #{paymenttype,jdbcType=VARCHAR},
      </if>
      <if test="payed != null">
        #{payed,jdbcType=DECIMAL},
      </if>
      <if test="ticketmony != null">
        #{ticketmony,jdbcType=DECIMAL},
      </if>
      <if test="discountmoney != null">
        #{discountmoney,jdbcType=DECIMAL},
      </if>
      <if test="deliverytype != null">
        #{deliverytype,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        #{state,jdbcType=NVARCHAR},
      </if>
      <if test="city != null">
        #{city,jdbcType=NVARCHAR},
      </if>
      <if test="direct != null">
        #{direct,jdbcType=NVARCHAR},
      </if>
      <if test="adress != null">
        #{adress,jdbcType=NVARCHAR},
      </if>
      <if test="postCompanyname != null">
        #{postCompanyname,jdbcType=VARCHAR},
      </if>
      <if test="postNo != null">
        #{postNo,jdbcType=VARCHAR},
      </if>
      <if test="postFee != null">
        #{postFee,jdbcType=DECIMAL},
      </if>
      <if test="createdate != null">
        #{createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="confirmdate != null">
        #{confirmdate,jdbcType=TIMESTAMP},
      </if>
      <if test="comfrimer != null">
        #{comfrimer,jdbcType=VARCHAR},
      </if>
      <if test="deliverdate != null">
        #{deliverdate,jdbcType=TIMESTAMP},
      </if>
      <if test="recievedate != null">
        #{recievedate,jdbcType=TIMESTAMP},
      </if>
      <if test="reciever != null">
        #{reciever,jdbcType=VARCHAR},
      </if>
      <if test="finishdate != null">
        #{finishdate,jdbcType=TIMESTAMP},
      </if>
      <if test="finisher != null">
        #{finisher,jdbcType=VARCHAR},
      </if>
      <if test="canceldate != null">
        #{canceldate,jdbcType=TIMESTAMP},
      </if>
      <if test="cancelperson != null">
        #{cancelperson,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
      <if test="returnSn != null">
        #{returnSn,jdbcType=VARCHAR},
      </if>
      <if test="recpointrate != null">
        #{recpointrate,jdbcType=DECIMAL},
      </if>
      <if test="recpoint != null">
        #{recpoint,jdbcType=DECIMAL},
      </if>
      <if test="sendtimes != null">
        #{sendtimes,jdbcType=DECIMAL},
      </if>
      <if test="sendpoint != null">
        #{sendpoint,jdbcType=INTEGER},
      </if>
      <if test="tickettoamount != null">
        #{tickettoamount,jdbcType=TINYINT},
      </if>
      <if test="pointorder != null">
        #{pointorder,jdbcType=TINYINT},
      </if>
      <if test="returnpointmemo != null">
        #{returnpointmemo,jdbcType=TINYINT},
      </if>
      <if test="returnpointnum != null">
        #{returnpointnum,jdbcType=DECIMAL},
      </if>
      <if test="returndepositmemo != null">
        #{returndepositmemo,jdbcType=TINYINT},
      </if>
      <if test="returndepositnum != null">
        #{returndepositnum,jdbcType=DECIMAL},
      </if>
      <if test="payticketmemo != null">
        #{payticketmemo,jdbcType=TINYINT},
      </if>
      <if test="interfacememo != null">
        #{interfacememo,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WReturnExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    select count(*) from W_Return
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WReturn">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    update W_Return
    <set>
      <if test="returnno != null">
        ReTurnNo = #{returnno,jdbcType=VARCHAR},
      </if>
      <if test="eshoporderid != null">
        EShopOrderID = #{eshoporderid,jdbcType=INTEGER},
      </if>
      <if test="departmentid != null">
        DepartmentID = #{departmentid,jdbcType=VARCHAR},
      </if>
      <if test="no != null">
        No = #{no,jdbcType=VARCHAR},
      </if>
      <if test="vipid != null">
        Vipid = #{vipid,jdbcType=VARCHAR},
      </if>
      <if test="reasonid != null">
        ReasonID = #{reasonid,jdbcType=TINYINT},
      </if>
      <if test="resean != null">
        Resean = #{resean,jdbcType=NVARCHAR},
      </if>
      <if test="rejectreason != null">
        RejectReason = #{rejectreason,jdbcType=NCHAR},
      </if>
      <if test="recieveshop != null">
        RecieveShop = #{recieveshop,jdbcType=VARCHAR},
      </if>
      <if test="returnmoney != null">
        ReturnMoney = #{returnmoney,jdbcType=DECIMAL},
      </if>
      <if test="exchangedpoint != null">
        ExchangedPoint = #{exchangedpoint,jdbcType=DECIMAL},
      </if>
      <if test="returnpoint != null">
        ReturnPoint = #{returnpoint,jdbcType=INTEGER},
      </if>
      <if test="depositamount != null">
        DepositAmount = #{depositamount,jdbcType=DECIMAL},
      </if>
      <if test="paymenttype != null">
        PaymentType = #{paymenttype,jdbcType=VARCHAR},
      </if>
      <if test="payed != null">
        Payed = #{payed,jdbcType=DECIMAL},
      </if>
      <if test="ticketmony != null">
        TicketMony = #{ticketmony,jdbcType=DECIMAL},
      </if>
      <if test="discountmoney != null">
        DiscountMoney = #{discountmoney,jdbcType=DECIMAL},
      </if>
      <if test="deliverytype != null">
        DeliveryType = #{deliverytype,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        State = #{state,jdbcType=NVARCHAR},
      </if>
      <if test="city != null">
        City = #{city,jdbcType=NVARCHAR},
      </if>
      <if test="direct != null">
        Direct = #{direct,jdbcType=NVARCHAR},
      </if>
      <if test="adress != null">
        Adress = #{adress,jdbcType=NVARCHAR},
      </if>
      <if test="postCompanyname != null">
        post_companyname = #{postCompanyname,jdbcType=VARCHAR},
      </if>
      <if test="postNo != null">
        post_no = #{postNo,jdbcType=VARCHAR},
      </if>
      <if test="postFee != null">
        post_fee = #{postFee,jdbcType=DECIMAL},
      </if>
      <if test="createdate != null">
        CreateDate = #{createdate,jdbcType=TIMESTAMP},
      </if>
      <if test="confirmdate != null">
        ConfirmDate = #{confirmdate,jdbcType=TIMESTAMP},
      </if>
      <if test="comfrimer != null">
        Comfrimer = #{comfrimer,jdbcType=VARCHAR},
      </if>
      <if test="deliverdate != null">
        deliverDate = #{deliverdate,jdbcType=TIMESTAMP},
      </if>
      <if test="recievedate != null">
        RecieveDate = #{recievedate,jdbcType=TIMESTAMP},
      </if>
      <if test="reciever != null">
        Reciever = #{reciever,jdbcType=VARCHAR},
      </if>
      <if test="finishdate != null">
        FinishDate = #{finishdate,jdbcType=TIMESTAMP},
      </if>
      <if test="finisher != null">
        Finisher = #{finisher,jdbcType=VARCHAR},
      </if>
      <if test="canceldate != null">
        CancelDate = #{canceldate,jdbcType=TIMESTAMP},
      </if>
      <if test="cancelperson != null">
        CancelPerson = #{cancelperson,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        Status = #{status,jdbcType=TINYINT},
      </if>
      <if test="returnSn != null">
        return_sn = #{returnSn,jdbcType=VARCHAR},
      </if>
      <if test="recpointrate != null">
        RecPointRate = #{recpointrate,jdbcType=DECIMAL},
      </if>
      <if test="recpoint != null">
        RecPoint = #{recpoint,jdbcType=DECIMAL},
      </if>
      <if test="sendtimes != null">
        SendTimes = #{sendtimes,jdbcType=DECIMAL},
      </if>
      <if test="sendpoint != null">
        SendPoint = #{sendpoint,jdbcType=INTEGER},
      </if>
      <if test="tickettoamount != null">
        TicketToAmount = #{tickettoamount,jdbcType=TINYINT},
      </if>
      <if test="pointorder != null">
        PointOrder = #{pointorder,jdbcType=TINYINT},
      </if>
      <if test="returnpointmemo != null">
        returnPointmemo = #{returnpointmemo,jdbcType=TINYINT},
      </if>
      <if test="returnpointnum != null">
        returnPointNum = #{returnpointnum,jdbcType=DECIMAL},
      </if>
      <if test="returndepositmemo != null">
        returnDepositmemo = #{returndepositmemo,jdbcType=TINYINT},
      </if>
      <if test="returndepositnum != null">
        returnDepositNum = #{returndepositnum,jdbcType=DECIMAL},
      </if>
      <if test="payticketmemo != null">
        payTicketmemo = #{payticketmemo,jdbcType=TINYINT},
      </if>
      <if test="interfacememo != null">
        Interfacememo = #{interfacememo,jdbcType=TINYINT},
      </if>
    </set>
    where ReturnID = #{returnid,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WReturn">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Fri Nov 16 10:22:01 CST 2018.
    -->
    update W_Return
    set ReTurnNo = #{returnno,jdbcType=VARCHAR},
      EShopOrderID = #{eshoporderid,jdbcType=INTEGER},
      DepartmentID = #{departmentid,jdbcType=VARCHAR},
      No = #{no,jdbcType=VARCHAR},
      Vipid = #{vipid,jdbcType=VARCHAR},
      ReasonID = #{reasonid,jdbcType=TINYINT},
      Resean = #{resean,jdbcType=NVARCHAR},
      RejectReason = #{rejectreason,jdbcType=NCHAR},
      RecieveShop = #{recieveshop,jdbcType=VARCHAR},
      ReturnMoney = #{returnmoney,jdbcType=DECIMAL},
      ExchangedPoint = #{exchangedpoint,jdbcType=DECIMAL},
      ReturnPoint = #{returnpoint,jdbcType=INTEGER},
      DepositAmount = #{depositamount,jdbcType=DECIMAL},
      PaymentType = #{paymenttype,jdbcType=VARCHAR},
      Payed = #{payed,jdbcType=DECIMAL},
      TicketMony = #{ticketmony,jdbcType=DECIMAL},
      DiscountMoney = #{discountmoney,jdbcType=DECIMAL},
      DeliveryType = #{deliverytype,jdbcType=VARCHAR},
      State = #{state,jdbcType=NVARCHAR},
      City = #{city,jdbcType=NVARCHAR},
      Direct = #{direct,jdbcType=NVARCHAR},
      Adress = #{adress,jdbcType=NVARCHAR},
      post_companyname = #{postCompanyname,jdbcType=VARCHAR},
      post_no = #{postNo,jdbcType=VARCHAR},
      post_fee = #{postFee,jdbcType=DECIMAL},
      CreateDate = #{createdate,jdbcType=TIMESTAMP},
      ConfirmDate = #{confirmdate,jdbcType=TIMESTAMP},
      Comfrimer = #{comfrimer,jdbcType=VARCHAR},
      deliverDate = #{deliverdate,jdbcType=TIMESTAMP},
      RecieveDate = #{recievedate,jdbcType=TIMESTAMP},
      Reciever = #{reciever,jdbcType=VARCHAR},
      FinishDate = #{finishdate,jdbcType=TIMESTAMP},
      Finisher = #{finisher,jdbcType=VARCHAR},
      CancelDate = #{canceldate,jdbcType=TIMESTAMP},
      CancelPerson = #{cancelperson,jdbcType=VARCHAR},
      Status = #{status,jdbcType=TINYINT},
      return_sn = #{returnSn,jdbcType=VARCHAR},
      RecPointRate = #{recpointrate,jdbcType=DECIMAL},
      RecPoint = #{recpoint,jdbcType=DECIMAL},
      SendTimes = #{sendtimes,jdbcType=DECIMAL},
      SendPoint = #{sendpoint,jdbcType=INTEGER},
      TicketToAmount = #{tickettoamount,jdbcType=TINYINT},
      PointOrder = #{pointorder,jdbcType=TINYINT},
      returnPointmemo = #{returnpointmemo,jdbcType=TINYINT},
      returnPointNum = #{returnpointnum,jdbcType=DECIMAL},
      returnDepositmemo = #{returndepositmemo,jdbcType=TINYINT},
      returnDepositNum = #{returndepositnum,jdbcType=DECIMAL},
      payTicketmemo = #{payticketmemo,jdbcType=TINYINT},
      Interfacememo = #{interfacememo,jdbcType=TINYINT}
    where ReturnID = #{returnid,jdbcType=BIGINT}
  </update>

	<!-- 退货单列表 -->
	<select id="returnlist" resultType="java.util.LinkedHashMap">
		select r.ReturnID,r.ReTurnNo,r.State,r.City,r.Direct,r.Adress,r.RecieveShop,
		CONVERT(varchar(10),r.CreateDate, 121) +
		'<![CDATA[<br/>]]>'
		+ CONVERT(varchar(10),r.CreateDate, 108) AS CreateDate,
		isnull(v.VIP,'') + '<![CDATA[<br/>]]>'
		+ isnull(v.MobilePhone,'') as vip,v.wxid,
		r.ReturnMoney,r.No,d.Department,r.post_companyname,r.post_no,
		case
		r.Status when 0 then '待审核' when 1 then '已取消' when 2 then '已拒绝' when 3
		then '待退货' when 4 then '待收货'
		when 5 then '待退款' when 6 then '已退款' end as
		Status,r.Status as statusflag,rd.Qty,r.PointOrder,r.ReturnPoint 
		from W_Return as r 
		inner join (select Returnid,SUM(Quantity) as Qty from W_ReturnDtl group by Returnid) as rd on r.ReturnID=rd.ReturnID
		inner join VIP as v on
		r.Vipid=v.VIPID
		left join Department as d on
		r.RecieveShop=d.DepartmentID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		order by r.CreateDate desc
	</select>

	<!-- 单个退货单信息 -->
	<select id="SelecteReturned" resultType="java.util.LinkedHashMap">
	select r.*,r.ReTurnNo as rno,CONVERT(varchar(19),r.CreateDate, 121) AS Created,ey.EmployeeID as EmployeeID,ey.Name AS EmployeeName,r.Resean,
		v.VIP,v.MobilePhone,d.Department,d.Tel,v.wxid,ey.MobilPhone  AS EmployeeMobilPhone,
		case r.Status when 0 then '待审核' when 1 then '已取消' when 2 then '已拒绝'
		when 3 then '待退货' when 4 then '待收货' when 5 then '待退款' when 6 then '已退款' end as statusflag,
		e.PaymentType,e.pay_no,e.sales_time 
		from W_Return as r
		inner join EShopOrder as e on
		r.EShopOrderID=e.EShopOrderID
		left join
		VIP as v on r.Vipid=v.VIPID
		left join Department as d on
		r.RecieveShop=d.DepartmentID
		left join Employee as ey on ey.EmployeeID=e.EmployeeID
		where
		r.ReturnID=#{returnid,jdbcType=VARCHAR}
		
	</select>
	

	
	<!-- 退货单明细 -->
	<select id="returndtl" resultType="java.util.LinkedHashMap">
		select a.ReturnID,
		(select top
		1 Code from W_Goods g where g.GoodsID=b.GoodsID) as Code,
		a.GoodsID,b.ImgPath,b.GoodName,a.Quantity,a.UnitPrice,a.Amount,b.code
		as GoodCode,c.Color,s.Size,a.Integral,ISNULL(a.AllotSales,0) as AllotSales 
		from W_ReturnDtl a
		inner join W_Goods b on
		a.GoodsID=b.GoodsID
		inner join Color c on c.ColorID=a.ColorID
		inner join
		Size s on s.SizeID=a.SizeID
		where
		a.ReturnID=#{returnid,jdbcType=VARCHAR}
	</select>

	<!-- 退货单批量同意/收货 -->
	<update id="changereturn">
		${paramSQL}
	</update>

	<!--退货单列表导出信息 -->
	<select id="returnedOut" resultType="java.util.LinkedHashMap">
		select r.ReturnID,
		r.ReTurnNo,CONVERT(varchar(19),r.CreateDate, 121) AS
		CreateDate,
		isnull(v.VIP,'')+' '+isnull(v.MobilePhone,'') as
		Vip,r.No,d.Department,d.Tel,r.post_companyname,r.post_no,
		case r.Status when
		0 then '待审核' when 1 then '已取消' when 2 then '已拒绝'
		when 3
		then '待退货' when
		4 then '待收货'
		when 5 then '待退款' when 6 then '已退款'
		end as
		Status,r.Resean,r.ReturnMoney,
		case when r.PaymentType='微信支付' then
		r.Payed else 0.00 end as wxpay,
		case when r.PaymentType='支付宝支付' then
		r.Payed else 0.00 end as alipay,
		r.DepositAmount,r.ExchangedPoint,r.ReturnPoint,r.post_fee,v.wxid,r.PointOrder 
		from W_Return as r 
		inner
		join
		VIP as v on r.Vipid=v.VIPID
		left join
		Department as d on
		r.RecieveShop=d.DepartmentID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		order by r.CreateDate desc
	</select>

	<!--退货单明细导出信息 -->
	<select id="returneddtlOut" resultType="java.util.LinkedHashMap">
		select a.ReturnID,
		(select top 1 Code from W_Goods g where
		g.GoodsID=b.GoodsID) as Code,
		a.Quantity,a.UnitPrice,a.Amount,b.code
		as
		GoodCode,c.Color,s.Size,r.ReTurnNo,v.VIP+' '+v.MobilePhone as Vip,v.wxid,r.PointOrder,a.Integral,ISNULL(a.AllotSales,0) as AllotSales 
		from
		W_ReturnDtl a
		inner join W_Return as r on a.ReturnID=r.ReturnID
		inner
		join W_Goods b on a.GoodsID=b.GoodsID
		inner join Color c on
		c.ColorID=a.ColorID
		inner join Size s on s.SizeID=a.SizeID
		inner join
		VIP as v on r.Vipid=v.VIPID
		left join Department as d on
		r.RecieveShop=d.DepartmentID
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>
		order by r.CreateDate desc
	</select>
	
	<select id="getreturn" parameterType="java.util.HashMap" resultType="java.util.LinkedHashMap"> 
  		select r.ReturnID,r.ReTurnNo,r.EShopOrderID,r.DepartmentID,r.No,r.Vipid,v.VIP,r.ReasonID,rr.Reason,r.Resean ReseanDec,
		r.RejectReason,r.RecieveShop,d.Department as Name,r.ReturnMoney,r.ExchangedPoint,r.ReturnPoint,r.DepositAmount,
		r.PaymentType,r.Payed,r.TicketMony,r.DeliveryType,r.State,r.City,r.Direct,r.Adress,r.post_companyname,
		r.post_no,r.post_fee,convert(varchar(19),r.CreateDate,121) CreateDate,convert(varchar(19),r.ConfirmDate,121) ConfirmDate,
		r.Comfrimer,convert(varchar(19),r.deliverDate,121) deliverDate,convert(varchar(19),r.RecieveDate,121) RecieveDate,r.Reciever,
		convert(varchar(19),r.FinishDate,121) FinishDate,
		r.Finisher,r.CancelDate,r.Status,r.PointOrder 
		from W_Return as r 
		left join VIP as v on r.Vipid=v.Vipid 
		left join W_ReturnReason as rr on r.ReasonID=rr.ReasonID 
		left join Department as d on r.RecieveShop=d.DepartmentID
    <if test="conditions != null and conditions != ''">
		where			
		${conditions}
	</if>
	order by r.ReturnID desc
  </select>
  <!-- 导购员订单管理 -->
	<select id="returnorders" resultType="java.util.LinkedHashMap">
		${ sql }
	</select>
  
  <select id="returnbybaison" resultType="java.util.LinkedHashMap">
  	select a.ReturnID,a.EShopOrderID,c.No,c.SalesNo,isnull(a.Resean,'') as Resean,
	b.Quantity,b.Amount,b.GoodsID,e.BarCode,f.VIP,f.MobilePhone 
	from W_Return as a 
	inner join W_ReturnDtl as b on a.ReturnID=b.ReturnID
	inner join EShopOrder as c on a.EShopOrderID=c.EShopOrderID 
	left join Barcode as e on b.GoodsID=e.GoodsID and b.ColorID=e.ColorID and b.SizeID=e.SizeID
	left join VIP as f on a.Vipid=f.VIPID
	where a.ReturnID=#{returnid,jdbcType=VARCHAR}
  </select>
  
  <update id="updatebybaison">
  	update W_Return set Status=5,RecieveDate=GETDATE(),Reciever='系统' where Status=4 and Finisher='BaisonConfirm' and return_sn not in (${no})
  </update>
  


  
</mapper>