CouponUseDetailDao.xml 6.44 KB
<?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.diligrp.etrade.coupon.dao.CouponUseDetailDao">
  <resultMap id="BaseResultMap" type="com.diligrp.etrade.coupon.model.CouponUseDetailDo">
    <id column="id"  property="id" />
    <result column="coupon_no"  property="couponNo" />
    <result column="transaction_code" property="transactionCode" />
    <result column="card_no"  property="cardNo" />
    <result column="phone"  property="phone" />
    <result column="customer_id" property="customerId" />
    <result column="seller_name" property="sellerName" />
    <result column="seller_account_id" property="sellerAccountId" />
    <result column="actual_discount_amount" property="actualDiscountAmount" />
    <result column="version" property="version" />
    <result column="market_id" property="marketId" />
  </resultMap>
  <sql id="Base_Column_List">
    id, coupon_no, transaction_code, card_no, phone, customer_id, seller_name, seller_account_id, 
    actual_discount_amount, version, market_id
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from coupon_use_detail
    where id = #{id}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from coupon_use_detail
    where id = #{id}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.diligrp.etrade.coupon.model.CouponUseDetailDo" useGeneratedKeys="true">
    insert into coupon_use_detail (coupon_no, transaction_code, card_no, 
      phone, customer_id, seller_name, 
      seller_account_id, actual_discount_amount, version, 
      market_id)
    values (#{couponNo}, #{transactionCode}, #{cardNo},
      #{phone}, #{customerId}, #{sellerName},
      #{sellerAccountId}, #{actualDiscountAmount}, #{version},
      #{marketId})
  </insert>
  <insert id="insertSelective"  parameterType="com.diligrp.etrade.coupon.model.CouponUseDetailDo">
    insert into coupon_use_detail
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="couponNo != null">
        coupon_no,
      </if>
      <if test="transactionCode != null">
        transaction_code,
      </if>
      <if test="cardNo != null">
        card_no,
      </if>
      <if test="phone != null">
        phone,
      </if>
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="sellerName != null">
        seller_name,
      </if>
      <if test="sellerAccountId != null">
        seller_account_id,
      </if>
      <if test="actualDiscountAmount != null">
        actual_discount_amount,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="marketId != null">
        market_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="couponNo != null">
        #{couponNo},
      </if>
      <if test="transactionCode != null">
        #{transactionCode},
      </if>
      <if test="cardNo != null">
        #{cardNo},
      </if>
      <if test="phone != null">
        #{phone},
      </if>
      <if test="customerId != null">
        #{customerId},
      </if>
      <if test="sellerName != null">
        #{sellerName},
      </if>
      <if test="sellerAccountId != null">
        #{sellerAccountId},
      </if>
      <if test="actualDiscountAmount != null">
        #{actualDiscountAmount},
      </if>
      <if test="version != null">
        #{version},
      </if>
      <if test="marketId != null">
        #{marketId},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.diligrp.etrade.coupon.model.CouponUseDetailDo">
    update coupon_use_detail
    <set>
      <if test="couponNo != null">
        coupon_no = #{couponNo},
      </if>
      <if test="transactionCode != null">
        transaction_code = #{transactionCode},
      </if>
      <if test="cardNo != null">
        card_no = #{cardNo},
      </if>
      <if test="phone != null">
        phone = #{phone},
      </if>
      <if test="customerId != null">
        customer_id = #{customerId},
      </if>
      <if test="sellerName != null">
        seller_name = #{sellerName},
      </if>
      <if test="sellerAccountId != null">
        seller_account_id = #{sellerAccountId},
      </if>
      <if test="actualDiscountAmount != null">
        actual_discount_amount = #{actualDiscountAmount},
      </if>
      <if test="version != null">
        version = #{version} + 1,
      </if>
      <if test="marketId != null">
        market_id = #{marketId},
      </if>
    </set>
    where id = #{id} and version = #{version}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.diligrp.etrade.coupon.model.CouponUseDetailDo">
    update coupon_use_detail
    set coupon_no = #{couponNo},
      transaction_code = #{transactionCode},
      card_no = #{cardNo},
      phone = #{phone},
      customer_id = #{customerId},
      seller_name = #{sellerName},
      seller_account_id = #{sellerAccountId},
      actual_discount_amount = #{actualDiscountAmount},
      version = #{version} + 1,
      market_id = #{marketId}
    where id = #{id} and version = #{version}
  </update>
  <update id="updateByCustomerId" parameterType="com.diligrp.etrade.coupon.model.CouponUseDetailDo">
    update coupon_use_detail
    set
        phone = #{phone},
        customer_id = #{customerId},
        seller_name = #{sellerName},
        version = #{version} + 1
    where customer_id = #{customerId} and version = #{version}
  </update>
  <insert id="batchSave" parameterType="java.util.List">
      insert into coupon_use_detail (
      `coupon_no`, `transaction_code`,
      `card_no`, `phone`,
      `customer_id`, `seller_name`,
      `seller_account_id`, `actual_discount_amount`,
      `version`, `market_id`
      )
      values
      <foreach collection="list" item="item" separator=",">
          (#{item.couponNo}, #{item.transactionCode}, #{item.cardNo},
          #{item.phone}, #{item.customerId},
          #{item.sellerName}, #{item.sellerAccountId}, #{item.actualDiscountAmount},
          1, #{item.marketId}
          )
      </foreach>
  </insert>
  <delete id="deleteBatch" parameterType="java.util.List">
    DELETE FROM coupon_use_detail WHERE coupon_no IN
    <foreach item="item" collection="list" open="(" separator="," close=")">
      #{item.couponNo}
    </foreach>
  </delete>

</mapper>