<?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.slodon.b2b2c.dao.write.business.OrderReturnWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.business.pojo.OrderReturn">
    <id column="return_id" property="returnId" />
    <result column="afs_sn" property="afsSn" />
    <result column="order_sn" property="orderSn" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="member_id" property="memberId" />
    <result column="member_name" property="memberName" />
    <result column="return_money_type" property="returnMoneyType" />
    <result column="return_type" property="returnType" />
    <result column="return_num" property="returnNum" />
    <result column="return_money_amount" property="returnMoneyAmount" />
    <result column="return_integral_amount" property="returnIntegralAmount" />
    <result column="deduct_integral_amount" property="deductIntegralAmount" />
    <result column="return_express_amount" property="returnExpressAmount" />
    <result column="return_voucher_code" property="returnVoucherCode" />
    <result column="return_coupon_code" property="returnCouponCode" />
    <result column="commission_rate" property="commissionRate" />
    <result column="commission_amount" property="commissionAmount" />
    <result column="state" property="state" />
    <result column="apply_time" property="applyTime" />
    <result column="complete_time" property="completeTime" />
    <result column="refuse_reason" property="refuseReason" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="afsSn != null">
        `afs_sn`,
      </if>
      <if test="orderSn != null">
        `order_sn`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="storeName != null">
        `store_name`,
      </if>
      <if test="memberId != null">
        `member_id`,
      </if>
      <if test="memberName != null">
        `member_name`,
      </if>
      <if test="returnMoneyType != null">
        `return_money_type`,
      </if>
      <if test="returnType != null">
        `return_type`,
      </if>
      <if test="returnNum != null">
        `return_num`,
      </if>
      <if test="returnMoneyAmount != null">
        `return_money_amount`,
      </if>
      <if test="returnIntegralAmount != null">
        `return_integral_amount`,
      </if>
      <if test="deductIntegralAmount != null">
        `deduct_integral_amount`,
      </if>
      <if test="returnExpressAmount != null">
        `return_express_amount`,
      </if>
      <if test="returnVoucherCode != null">
        `return_voucher_code`,
      </if>
      <if test="returnCouponCode != null">
        `return_coupon_code`,
      </if>
      <if test="commissionRate != null">
        `commission_rate`,
      </if>
      <if test="commissionAmount != null">
        `commission_amount`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="applyTime != null">
        `apply_time`,
      </if>
      <if test="completeTime != null">
        `complete_time`,
      </if>
      <if test="refuseReason != null">
        `refuse_reason`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `return_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.returnIdNotEquals != null">
          AND `return_id` != #{example.returnIdNotEquals}
        </if>
        <if test="example.returnIdIn != null">
          AND `return_id` in (${example.returnIdIn})
        </if>
        <if test="example.afsSn != null">
          AND `afs_sn` = #{example.afsSn}
        </if>
        <if test="example.afsSnLike != null">
          AND `afs_sn` like concat('%',#{example.afsSnLike},'%')
        </if>
        <if test="example.orderSn != null">
          AND `order_sn` = #{example.orderSn}
        </if>
        <if test="example.orderSnLike != null">
          AND `order_sn` like concat('%',#{example.orderSnLike},'%')
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.storeName != null">
          AND `store_name` = #{example.storeName}
        </if>
        <if test="example.storeNameLike != null">
          AND `store_name` like concat('%',#{example.storeNameLike},'%')
        </if>
        <if test="example.memberId != null">
          AND `member_id` = #{example.memberId}
        </if>
        <if test="example.memberName != null">
          AND `member_name` = #{example.memberName}
        </if>
        <if test="example.memberNameLike != null">
          AND `member_name` like concat('%',#{example.memberNameLike},'%')
        </if>
        <if test="example.returnMoneyType != null">
          AND `return_money_type` = #{example.returnMoneyType}
        </if>
        <if test="example.returnType != null">
          AND `return_type` = #{example.returnType}
        </if>
        <if test="example.returnNum != null">
          AND `return_num` = #{example.returnNum}
        </if>
        <if test="example.returnMoneyAmount != null">
          AND `return_money_amount` = #{example.returnMoneyAmount}
        </if>
        <if test="example.returnIntegralAmount != null">
          AND `return_integral_amount` = #{example.returnIntegralAmount}
        </if>
        <if test="example.deductIntegralAmount != null">
          AND `deduct_integral_amount` = #{example.deductIntegralAmount}
        </if>
        <if test="example.returnExpressAmount != null">
          AND `return_express_amount` = #{example.returnExpressAmount}
        </if>
        <if test="example.returnVoucherCode != null">
          AND `return_voucher_code` = #{example.returnVoucherCode}
        </if>
        <if test="example.returnCouponCode != null">
          AND `return_coupon_code` = #{example.returnCouponCode}
        </if>
        <if test="example.commissionRate != null">
          AND `commission_rate` = #{example.commissionRate}
        </if>
        <if test="example.commissionAmount != null">
          AND `commission_amount` = #{example.commissionAmount}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.applyTimeAfter != null">
          AND `apply_time` <![CDATA[ >= ]]> #{example.applyTimeAfter}
        </if>
        <if test="example.applyTimeBefore != null">
          AND `apply_time` <![CDATA[ <= ]]> #{example.applyTimeBefore}
        </if>
        <if test="example.completeTimeAfter != null">
          AND `complete_time` <![CDATA[ >= ]]> #{example.completeTimeAfter}
        </if>
        <if test="example.completeTimeBefore != null">
          AND `complete_time` <![CDATA[ <= ]]> #{example.completeTimeBefore}
        </if>
        <if test="example.refuseReason != null">
          AND `refuse_reason` = #{example.refuseReason}
        </if>
        <if test="example.refuseReasonLike != null">
          AND `refuse_reason` like concat('%',#{example.refuseReasonLike},'%')
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `return_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.business.example.OrderReturnExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `bz_order_return`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `bz_order_return`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `bz_order_return`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `bz_order_return`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `bz_order_return`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `bz_order_return`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `bz_order_return`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `bz_order_return`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="return_id" keyProperty="returnId" parameterType="com.slodon.b2b2c.business.pojo.OrderReturn" useGeneratedKeys="true">
    INSERT INTO `bz_order_return`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="afsSn != null">
        #{afsSn},
      </if>
      <if test="orderSn != null">
        #{orderSn},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="storeName != null">
        #{storeName},
      </if>
      <if test="memberId != null">
        #{memberId},
      </if>
      <if test="memberName != null">
        #{memberName},
      </if>
      <if test="returnMoneyType != null">
        #{returnMoneyType},
      </if>
      <if test="returnType != null">
        #{returnType},
      </if>
      <if test="returnNum != null">
        #{returnNum},
      </if>
      <if test="returnMoneyAmount != null">
        #{returnMoneyAmount},
      </if>
      <if test="returnIntegralAmount != null">
        #{returnIntegralAmount},
      </if>
      <if test="deductIntegralAmount != null">
        #{deductIntegralAmount},
      </if>
      <if test="returnExpressAmount != null">
        #{returnExpressAmount},
      </if>
      <if test="returnVoucherCode != null">
        #{returnVoucherCode},
      </if>
      <if test="returnCouponCode != null">
        #{returnCouponCode},
      </if>
      <if test="commissionRate != null">
        #{commissionRate},
      </if>
      <if test="commissionAmount != null">
        #{commissionAmount},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="applyTime != null">
        #{applyTime},
      </if>
      <if test="completeTime != null">
        #{completeTime},
      </if>
      <if test="refuseReason != null">
        #{refuseReason},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `bz_order_return`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.afsSn != null">
        `afs_sn` = #{record.afsSn},
      </if>
      <if test="record.orderSn != null">
        `order_sn` = #{record.orderSn},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.storeName != null">
        `store_name` = #{record.storeName},
      </if>
      <if test="record.memberId != null">
        `member_id` = #{record.memberId},
      </if>
      <if test="record.memberName != null">
        `member_name` = #{record.memberName},
      </if>
      <if test="record.returnMoneyType != null">
        `return_money_type` = #{record.returnMoneyType},
      </if>
      <if test="record.returnType != null">
        `return_type` = #{record.returnType},
      </if>
      <if test="record.returnNum != null">
        `return_num` = #{record.returnNum},
      </if>
      <if test="record.returnMoneyAmount != null">
        `return_money_amount` = #{record.returnMoneyAmount},
      </if>
      <if test="record.returnIntegralAmount != null">
        `return_integral_amount` = #{record.returnIntegralAmount},
      </if>
      <if test="record.deductIntegralAmount != null">
        `deduct_integral_amount` = #{record.deductIntegralAmount},
      </if>
      <if test="record.returnExpressAmount != null">
        `return_express_amount` = #{record.returnExpressAmount},
      </if>
      <if test="record.returnVoucherCode != null">
        `return_voucher_code` = #{record.returnVoucherCode},
      </if>
      <if test="record.returnCouponCode != null">
        `return_coupon_code` = #{record.returnCouponCode},
      </if>
      <if test="record.commissionRate != null">
        `commission_rate` = #{record.commissionRate},
      </if>
      <if test="record.commissionAmount != null">
        `commission_amount` = #{record.commissionAmount},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.applyTime != null">
        `apply_time` = #{record.applyTime},
      </if>
      <if test="record.completeTime != null">
        `complete_time` = #{record.completeTime},
      </if>
      <if test="record.refuseReason != null">
        `refuse_reason` = #{record.refuseReason},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `bz_order_return`
    <trim prefix="SET" suffixOverrides=",">
      <if test="afsSn != null">
        `afs_sn` = #{afsSn},
      </if>
      <if test="orderSn != null">
        `order_sn` = #{orderSn},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="storeName != null">
        `store_name` = #{storeName},
      </if>
      <if test="memberId != null">
        `member_id` = #{memberId},
      </if>
      <if test="memberName != null">
        `member_name` = #{memberName},
      </if>
      <if test="returnMoneyType != null">
        `return_money_type` = #{returnMoneyType},
      </if>
      <if test="returnType != null">
        `return_type` = #{returnType},
      </if>
      <if test="returnNum != null">
        `return_num` = #{returnNum},
      </if>
      <if test="returnMoneyAmount != null">
        `return_money_amount` = #{returnMoneyAmount},
      </if>
      <if test="returnIntegralAmount != null">
        `return_integral_amount` = #{returnIntegralAmount},
      </if>
      <if test="deductIntegralAmount != null">
        `deduct_integral_amount` = #{deductIntegralAmount},
      </if>
      <if test="returnExpressAmount != null">
        `return_express_amount` = #{returnExpressAmount},
      </if>
      <if test="returnVoucherCode != null">
        `return_voucher_code` = #{returnVoucherCode},
      </if>
      <if test="returnCouponCode != null">
        `return_coupon_code` = #{returnCouponCode},
      </if>
      <if test="commissionRate != null">
        `commission_rate` = #{commissionRate},
      </if>
      <if test="commissionAmount != null">
        `commission_amount` = #{commissionAmount},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="applyTime != null">
        `apply_time` = #{applyTime},
      </if>
      <if test="completeTime != null">
        `complete_time` = #{completeTime},
      </if>
      <if test="refuseReason != null">
        `refuse_reason` = #{refuseReason},
      </if>
    </trim>
    WHERE `return_id` = #{returnId}
  </update>
</mapper>