<?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.OrderProductWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.business.pojo.OrderProduct">
    <id column="order_product_id" property="orderProductId" />
    <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="goods_category_id" property="goodsCategoryId" />
    <result column="goods_id" property="goodsId" />
    <result column="goods_name" property="goodsName" />
    <result column="product_image" property="productImage" />
    <result column="spec_values" property="specValues" />
    <result column="product_id" property="productId" />
    <result column="product_show_price" property="productShowPrice" />
    <result column="product_num" property="productNum" />
    <result column="activity_discount_amount" property="activityDiscountAmount" />
    <result column="activity_discount_detail" property="activityDiscountDetail" />
    <result column="store_activity_amount" property="storeActivityAmount" />
    <result column="platform_activity_amount" property="platformActivityAmount" />
    <result column="store_voucher_amount" property="storeVoucherAmount" />
    <result column="platform_voucher_amount" property="platformVoucherAmount" />
    <result column="integral" property="integral" />
    <result column="integral_cash_amount" property="integralCashAmount" />
    <result column="money_amount" property="moneyAmount" />
    <result column="commission_rate" property="commissionRate" />
    <result column="commission_amount" property="commissionAmount" />
    <result column="attach_commission_amount" property="attachCommissionAmount" />
    <result column="spell_team_id" property="spellTeamId" />
    <result column="is_gift" property="isGift" />
    <result column="gift_id" property="giftId" />
    <result column="return_number" property="returnNumber" />
    <result column="replacement_number" property="replacementNumber" />
    <result column="is_comment" property="isComment" />
    <result column="comment_time" property="commentTime" />
    <result column="send_integral" property="sendIntegral" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <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="goodsCategoryId != null">
        `goods_category_id`,
      </if>
      <if test="goodsId != null">
        `goods_id`,
      </if>
      <if test="goodsName != null">
        `goods_name`,
      </if>
      <if test="productImage != null">
        `product_image`,
      </if>
      <if test="specValues != null">
        `spec_values`,
      </if>
      <if test="productId != null">
        `product_id`,
      </if>
      <if test="productShowPrice != null">
        `product_show_price`,
      </if>
      <if test="productNum != null">
        `product_num`,
      </if>
      <if test="activityDiscountAmount != null">
        `activity_discount_amount`,
      </if>
      <if test="activityDiscountDetail != null">
        `activity_discount_detail`,
      </if>
      <if test="storeActivityAmount != null">
        `store_activity_amount`,
      </if>
      <if test="platformActivityAmount != null">
        `platform_activity_amount`,
      </if>
      <if test="storeVoucherAmount != null">
        `store_voucher_amount`,
      </if>
      <if test="platformVoucherAmount != null">
        `platform_voucher_amount`,
      </if>
      <if test="integral != null">
        `integral`,
      </if>
      <if test="integralCashAmount != null">
        `integral_cash_amount`,
      </if>
      <if test="moneyAmount != null">
        `money_amount`,
      </if>
      <if test="commissionRate != null">
        `commission_rate`,
      </if>
      <if test="commissionAmount != null">
        `commission_amount`,
      </if>
      <if test="attachCommissionAmount != null">
        `attach_commission_amount`,
      </if>
      <if test="spellTeamId != null">
        `spell_team_id`,
      </if>
      <if test="isGift != null">
        `is_gift`,
      </if>
      <if test="giftId != null">
        `gift_id`,
      </if>
      <if test="returnNumber != null">
        `return_number`,
      </if>
      <if test="replacementNumber != null">
        `replacement_number`,
      </if>
      <if test="isComment != null">
        `is_comment`,
      </if>
      <if test="commentTime != null">
        `comment_time`,
      </if>
      <if test="sendIntegral != null">
        `send_integral`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `order_product_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.orderProductIdNotEquals != null">
          AND `order_product_id` != #{example.orderProductIdNotEquals}
        </if>
        <if test="example.orderProductIdIn != null">
          AND `order_product_id` in (${example.orderProductIdIn})
        </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.goodsCategoryId != null">
          AND `goods_category_id` = #{example.goodsCategoryId}
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </if>
        <if test="example.goodsName != null">
          AND `goods_name` = #{example.goodsName}
        </if>
        <if test="example.goodsNameLike != null">
          AND `goods_name` like concat('%',#{example.goodsNameLike},'%')
        </if>
        <if test="example.productImage != null">
          AND `product_image` = #{example.productImage}
        </if>
        <if test="example.specValues != null">
          AND `spec_values` = #{example.specValues}
        </if>
        <if test="example.productId != null">
          AND `product_id` = #{example.productId}
        </if>
        <if test="example.productShowPrice != null">
          AND `product_show_price` = #{example.productShowPrice}
        </if>
        <if test="example.productNum != null">
          AND `product_num` = #{example.productNum}
        </if>
        <if test="example.activityDiscountAmount != null">
          AND `activity_discount_amount` = #{example.activityDiscountAmount}
        </if>
        <if test="example.activityDiscountDetail != null">
          AND `activity_discount_detail` = #{example.activityDiscountDetail}
        </if>
        <if test="example.storeActivityAmount != null">
          AND `store_activity_amount` = #{example.storeActivityAmount}
        </if>
        <if test="example.platformActivityAmount != null">
          AND `platform_activity_amount` = #{example.platformActivityAmount}
        </if>
        <if test="example.storeVoucherAmount != null">
          AND `store_voucher_amount` = #{example.storeVoucherAmount}
        </if>
        <if test="example.platformVoucherAmount != null">
          AND `platform_voucher_amount` = #{example.platformVoucherAmount}
        </if>
        <if test="example.integral != null">
          AND `integral` = #{example.integral}
        </if>
        <if test="example.integralCashAmount != null">
          AND `integral_cash_amount` = #{example.integralCashAmount}
        </if>
        <if test="example.moneyAmount != null">
          AND `money_amount` = #{example.moneyAmount}
        </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.attachCommissionAmount != null">
          AND `attach_commission_amount` = #{example.attachCommissionAmount}
        </if>
        <if test="example.spellTeamId != null">
          AND `spell_team_id` = #{example.spellTeamId}
        </if>
        <if test="example.isGift != null">
          AND `is_gift` = #{example.isGift}
        </if>
        <if test="example.giftId != null">
          AND `gift_id` = #{example.giftId}
        </if>
        <if test="example.returnNumber != null">
          AND `return_number` = #{example.returnNumber}
        </if>
        <if test="example.replacementNumber != null">
          AND `replacement_number` = #{example.replacementNumber}
        </if>
        <if test="example.isComment != null">
          AND `is_comment` = #{example.isComment}
        </if>
        <if test="example.commentTimeAfter != null">
          AND `comment_time` <![CDATA[ >= ]]> #{example.commentTimeAfter}
        </if>
        <if test="example.commentTimeBefore != null">
          AND `comment_time` <![CDATA[ <= ]]> #{example.commentTimeBefore}
        </if>
        <if test="example.sendIntegral != null">
          AND `send_integral` = #{example.sendIntegral}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `order_product_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.OrderProductExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `bz_order_product`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `bz_order_product`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `bz_order_product`
    <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_product`
    <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_product`
    <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_product`
    <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_product`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `bz_order_product`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="order_product_id" keyProperty="orderProductId" parameterType="com.slodon.b2b2c.business.pojo.OrderProduct" useGeneratedKeys="true">
    INSERT INTO `bz_order_product`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <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="goodsCategoryId != null">
        #{goodsCategoryId},
      </if>
      <if test="goodsId != null">
        #{goodsId},
      </if>
      <if test="goodsName != null">
        #{goodsName},
      </if>
      <if test="productImage != null">
        #{productImage},
      </if>
      <if test="specValues != null">
        #{specValues},
      </if>
      <if test="productId != null">
        #{productId},
      </if>
      <if test="productShowPrice != null">
        #{productShowPrice},
      </if>
      <if test="productNum != null">
        #{productNum},
      </if>
      <if test="activityDiscountAmount != null">
        #{activityDiscountAmount},
      </if>
      <if test="activityDiscountDetail != null">
        #{activityDiscountDetail},
      </if>
      <if test="storeActivityAmount != null">
        #{storeActivityAmount},
      </if>
      <if test="platformActivityAmount != null">
        #{platformActivityAmount},
      </if>
      <if test="storeVoucherAmount != null">
        #{storeVoucherAmount},
      </if>
      <if test="platformVoucherAmount != null">
        #{platformVoucherAmount},
      </if>
      <if test="integral != null">
        #{integral},
      </if>
      <if test="integralCashAmount != null">
        #{integralCashAmount},
      </if>
      <if test="moneyAmount != null">
        #{moneyAmount},
      </if>
      <if test="commissionRate != null">
        #{commissionRate},
      </if>
      <if test="commissionAmount != null">
        #{commissionAmount},
      </if>
      <if test="attachCommissionAmount != null">
        #{attachCommissionAmount},
      </if>
      <if test="spellTeamId != null">
        #{spellTeamId},
      </if>
      <if test="isGift != null">
        #{isGift},
      </if>
      <if test="giftId != null">
        #{giftId},
      </if>
      <if test="returnNumber != null">
        #{returnNumber},
      </if>
      <if test="replacementNumber != null">
        #{replacementNumber},
      </if>
      <if test="isComment != null">
        #{isComment},
      </if>
      <if test="commentTime != null">
        #{commentTime},
      </if>
      <if test="sendIntegral != null">
        #{sendIntegral},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `bz_order_product`
    <trim prefix="SET" suffixOverrides=",">
      <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.goodsCategoryId != null">
        `goods_category_id` = #{record.goodsCategoryId},
      </if>
      <if test="record.goodsId != null">
        `goods_id` = #{record.goodsId},
      </if>
      <if test="record.goodsName != null">
        `goods_name` = #{record.goodsName},
      </if>
      <if test="record.productImage != null">
        `product_image` = #{record.productImage},
      </if>
      <if test="record.specValues != null">
        `spec_values` = #{record.specValues},
      </if>
      <if test="record.productId != null">
        `product_id` = #{record.productId},
      </if>
      <if test="record.productShowPrice != null">
        `product_show_price` = #{record.productShowPrice},
      </if>
      <if test="record.productNum != null">
        `product_num` = #{record.productNum},
      </if>
      <if test="record.activityDiscountAmount != null">
        `activity_discount_amount` = #{record.activityDiscountAmount},
      </if>
      <if test="record.activityDiscountDetail != null">
        `activity_discount_detail` = #{record.activityDiscountDetail},
      </if>
      <if test="record.storeActivityAmount != null">
        `store_activity_amount` = #{record.storeActivityAmount},
      </if>
      <if test="record.platformActivityAmount != null">
        `platform_activity_amount` = #{record.platformActivityAmount},
      </if>
      <if test="record.storeVoucherAmount != null">
        `store_voucher_amount` = #{record.storeVoucherAmount},
      </if>
      <if test="record.platformVoucherAmount != null">
        `platform_voucher_amount` = #{record.platformVoucherAmount},
      </if>
      <if test="record.integral != null">
        `integral` = #{record.integral},
      </if>
      <if test="record.integralCashAmount != null">
        `integral_cash_amount` = #{record.integralCashAmount},
      </if>
      <if test="record.moneyAmount != null">
        `money_amount` = #{record.moneyAmount},
      </if>
      <if test="record.commissionRate != null">
        `commission_rate` = #{record.commissionRate},
      </if>
      <if test="record.commissionAmount != null">
        `commission_amount` = #{record.commissionAmount},
      </if>
      <if test="record.attachCommissionAmount != null">
        `attach_commission_amount` = #{record.attachCommissionAmount},
      </if>
      <if test="record.spellTeamId != null">
        `spell_team_id` = #{record.spellTeamId},
      </if>
      <if test="record.isGift != null">
        `is_gift` = #{record.isGift},
      </if>
      <if test="record.giftId != null">
        `gift_id` = #{record.giftId},
      </if>
      <if test="record.returnNumber != null">
        `return_number` = #{record.returnNumber},
      </if>
      <if test="record.replacementNumber != null">
        `replacement_number` = #{record.replacementNumber},
      </if>
      <if test="record.isComment != null">
        `is_comment` = #{record.isComment},
      </if>
      <if test="record.commentTime != null">
        `comment_time` = #{record.commentTime},
      </if>
      <if test="record.sendIntegral != null">
        `send_integral` = #{record.sendIntegral},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `bz_order_product`
    <trim prefix="SET" suffixOverrides=",">
      <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="goodsCategoryId != null">
        `goods_category_id` = #{goodsCategoryId},
      </if>
      <if test="goodsId != null">
        `goods_id` = #{goodsId},
      </if>
      <if test="goodsName != null">
        `goods_name` = #{goodsName},
      </if>
      <if test="productImage != null">
        `product_image` = #{productImage},
      </if>
      <if test="specValues != null">
        `spec_values` = #{specValues},
      </if>
      <if test="productId != null">
        `product_id` = #{productId},
      </if>
      <if test="productShowPrice != null">
        `product_show_price` = #{productShowPrice},
      </if>
      <if test="productNum != null">
        `product_num` = #{productNum},
      </if>
      <if test="activityDiscountAmount != null">
        `activity_discount_amount` = #{activityDiscountAmount},
      </if>
      <if test="activityDiscountDetail != null">
        `activity_discount_detail` = #{activityDiscountDetail},
      </if>
      <if test="storeActivityAmount != null">
        `store_activity_amount` = #{storeActivityAmount},
      </if>
      <if test="platformActivityAmount != null">
        `platform_activity_amount` = #{platformActivityAmount},
      </if>
      <if test="storeVoucherAmount != null">
        `store_voucher_amount` = #{storeVoucherAmount},
      </if>
      <if test="platformVoucherAmount != null">
        `platform_voucher_amount` = #{platformVoucherAmount},
      </if>
      <if test="integral != null">
        `integral` = #{integral},
      </if>
      <if test="integralCashAmount != null">
        `integral_cash_amount` = #{integralCashAmount},
      </if>
      <if test="moneyAmount != null">
        `money_amount` = #{moneyAmount},
      </if>
      <if test="commissionRate != null">
        `commission_rate` = #{commissionRate},
      </if>
      <if test="commissionAmount != null">
        `commission_amount` = #{commissionAmount},
      </if>
      <if test="attachCommissionAmount != null">
        `attach_commission_amount` = #{attachCommissionAmount},
      </if>
      <if test="spellTeamId != null">
        `spell_team_id` = #{spellTeamId},
      </if>
      <if test="isGift != null">
        `is_gift` = #{isGift},
      </if>
      <if test="giftId != null">
        `gift_id` = #{giftId},
      </if>
      <if test="returnNumber != null">
        `return_number` = #{returnNumber},
      </if>
      <if test="replacementNumber != null">
        `replacement_number` = #{replacementNumber},
      </if>
      <if test="isComment != null">
        `is_comment` = #{isComment},
      </if>
      <if test="commentTime != null">
        `comment_time` = #{commentTime},
      </if>
      <if test="sendIntegral != null">
        `send_integral` = #{sendIntegral},
      </if>
    </trim>
    WHERE `order_product_id` = #{orderProductId}
  </update>
</mapper>