<?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.cku.dao.SPCartsMapper" >
  <resultMap id="BaseResultMap" type="com.cku.model.SPCarts" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="OrderID" property="orderid" jdbcType="VARCHAR" />
    <result column="cku_id" property="ckuId" jdbcType="VARCHAR" />
    <result column="pid" property="pid" jdbcType="INTEGER" />
    <result column="pcount" property="pcount" jdbcType="INTEGER" />
    <result column="sp_price" property="spPrice" jdbcType="DECIMAL" />
    <result column="total_price" property="totalPrice" jdbcType="DECIMAL" />
    <result column="sp_integral" property="spIntegral" jdbcType="INTEGER" />
    <result column="add_time" property="addTime" jdbcType="TIMESTAMP" />
    <result column="xmid" property="xmid" jdbcType="VARCHAR" />
    <result column="pz_id" property="pzId" jdbcType="VARCHAR" />
    <result column="PayConfirm" property="payconfirm" jdbcType="CHAR" />
    <result column="operate" property="operate" jdbcType="CHAR" />
    <result column="operate_time" property="operateTime" jdbcType="TIMESTAMP" />
    <result column="memberid" property="memberid" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, OrderID, cku_id, pid, pcount, sp_price, total_price, sp_integral, add_time, xmid, 
    pz_id, PayConfirm, operate, operate_time, memberid
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from SP_carts
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from SP_carts
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cku.model.SPCarts" >
    insert into SP_carts (id, OrderID, cku_id, 
      pid, pcount, sp_price, 
      total_price, sp_integral, add_time, 
      xmid, pz_id, PayConfirm, 
      operate, operate_time, memberid
      )
    values (#{id,jdbcType=INTEGER}, #{orderid,jdbcType=VARCHAR}, #{ckuId,jdbcType=VARCHAR}, 
      #{pid,jdbcType=INTEGER}, #{pcount,jdbcType=INTEGER}, #{spPrice,jdbcType=DECIMAL}, 
      #{totalPrice,jdbcType=DECIMAL}, #{spIntegral,jdbcType=INTEGER}, #{addTime,jdbcType=TIMESTAMP}, 
      #{xmid,jdbcType=VARCHAR}, #{pzId,jdbcType=VARCHAR}, #{payconfirm,jdbcType=CHAR}, 
      #{operate,jdbcType=CHAR}, #{operateTime,jdbcType=TIMESTAMP}, #{memberid,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.cku.model.SPCarts" >
    insert into SP_carts
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="orderid != null" >
        OrderID,
      </if>
      <if test="ckuId != null" >
        cku_id,
      </if>
      <if test="pid != null" >
        pid,
      </if>
      <if test="pcount != null" >
        pcount,
      </if>
      <if test="spPrice != null" >
        sp_price,
      </if>
      <if test="totalPrice != null" >
        total_price,
      </if>
      <if test="spIntegral != null" >
        sp_integral,
      </if>
      <if test="addTime != null" >
        add_time,
      </if>
      <if test="xmid != null" >
        xmid,
      </if>
      <if test="pzId != null" >
        pz_id,
      </if>
      <if test="payconfirm != null" >
        PayConfirm,
      </if>
      <if test="operate != null" >
        operate,
      </if>
      <if test="operateTime != null" >
        operate_time,
      </if>
      <if test="memberid != null" >
        memberid,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="orderid != null" >
        #{orderid,jdbcType=VARCHAR},
      </if>
      <if test="ckuId != null" >
        #{ckuId,jdbcType=VARCHAR},
      </if>
      <if test="pid != null" >
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="pcount != null" >
        #{pcount,jdbcType=INTEGER},
      </if>
      <if test="spPrice != null" >
        #{spPrice,jdbcType=DECIMAL},
      </if>
      <if test="totalPrice != null" >
        #{totalPrice,jdbcType=DECIMAL},
      </if>
      <if test="spIntegral != null" >
        #{spIntegral,jdbcType=INTEGER},
      </if>
      <if test="addTime != null" >
        #{addTime,jdbcType=TIMESTAMP},
      </if>
      <if test="xmid != null" >
        #{xmid,jdbcType=VARCHAR},
      </if>
      <if test="pzId != null" >
        #{pzId,jdbcType=VARCHAR},
      </if>
      <if test="payconfirm != null" >
        #{payconfirm,jdbcType=CHAR},
      </if>
      <if test="operate != null" >
        #{operate,jdbcType=CHAR},
      </if>
      <if test="operateTime != null" >
        #{operateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="memberid != null" >
        #{memberid,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cku.model.SPCarts" >
    update SP_carts
    <set >
      <if test="orderid != null" >
        OrderID = #{orderid,jdbcType=VARCHAR},
      </if>
      <if test="ckuId != null" >
        cku_id = #{ckuId,jdbcType=VARCHAR},
      </if>
      <if test="pid != null" >
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="pcount != null" >
        pcount = #{pcount,jdbcType=INTEGER},
      </if>
      <if test="spPrice != null" >
        sp_price = #{spPrice,jdbcType=DECIMAL},
      </if>
      <if test="totalPrice != null" >
        total_price = #{totalPrice,jdbcType=DECIMAL},
      </if>
      <if test="spIntegral != null" >
        sp_integral = #{spIntegral,jdbcType=INTEGER},
      </if>
      <if test="addTime != null" >
        add_time = #{addTime,jdbcType=TIMESTAMP},
      </if>
      <if test="xmid != null" >
        xmid = #{xmid,jdbcType=VARCHAR},
      </if>
      <if test="pzId != null" >
        pz_id = #{pzId,jdbcType=VARCHAR},
      </if>
      <if test="payconfirm != null" >
        PayConfirm = #{payconfirm,jdbcType=CHAR},
      </if>
      <if test="operate != null" >
        operate = #{operate,jdbcType=CHAR},
      </if>
      <if test="operateTime != null" >
        operate_time = #{operateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="memberid != null" >
        memberid = #{memberid,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cku.model.SPCarts" >
    update SP_carts
    set OrderID = #{orderid,jdbcType=VARCHAR},
      cku_id = #{ckuId,jdbcType=VARCHAR},
      pid = #{pid,jdbcType=INTEGER},
      pcount = #{pcount,jdbcType=INTEGER},
      sp_price = #{spPrice,jdbcType=DECIMAL},
      total_price = #{totalPrice,jdbcType=DECIMAL},
      sp_integral = #{spIntegral,jdbcType=INTEGER},
      add_time = #{addTime,jdbcType=TIMESTAMP},
      xmid = #{xmid,jdbcType=VARCHAR},
      pz_id = #{pzId,jdbcType=VARCHAR},
      PayConfirm = #{payconfirm,jdbcType=CHAR},
      operate = #{operate,jdbcType=CHAR},
      operate_time = #{operateTime,jdbcType=TIMESTAMP},
      memberid = #{memberid,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <!-- *************************************************** -->
  <!-- 根据订单号查询购物车 -->
  <select id="getPayTypeAndCount" resultMap="BaseResultMap">
   select id, OrderID, cku_id, 
      pid, pcount, sp_price, 
      total_price, sp_integral, add_time, 
      xmid, pz_id, PayConfirm, 
      operate, operate_time, memberid
      from SP_carts where OrderID=#{orderid,jdbcType=VARCHAR}
  </select>
  <update id="updateSPCartsPayConfirm" parameterType="com.cku.model.SPCarts">
  update SP_carts set PayConfirm = '1' where OrderID = #{orderID}
  </update>
  <delete id="deleteByOrderId" parameterType="java.lang.Integer" >
    delete from SP_carts
    where OrderID = #{orderId}
  </delete>
</mapper>