BuyerOrderPromotionMapper.xml 2.1 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.yohoufo.dal.order.BuyerOrderPromotionMapper">
  <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.BuyerOrderPromotion">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="uid" jdbcType="INTEGER" property="uid" />
    <result column="order_code" jdbcType="BIGINT" property="orderCode" />
    <result column="promotion_id" jdbcType="INTEGER" property="promotionId" />
    <result column="promotion_content" jdbcType="VARCHAR" property="promotionContent" />
  </resultMap>

  <sql id="Base_Column_List">
    id, uid, order_code, promotion_id, promotion_content
  </sql>

  <select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from buyer_order_promotion
    where order_code = #{orderCode,jdbcType=BIGINT}
    order by id desc limit 1
  </select>

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrderPromotion" useGeneratedKeys="true">
    insert into buyer_order_promotion (uid, order_code, promotion_id, 
      promotion_content)
    values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT},
    #{promotionId,jdbcType=INTEGER},
      #{promotionContent,jdbcType=VARCHAR})
  </insert>

  <select id="selectByUidPromotionId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from buyer_order_promotion
    where uid = #{uid,jdbcType=INTEGER}
    and promotion_id = #{promotionId,jdbcType=INTEGER}
  </select>

  <select id="selectCntByUidPromotionIdStatus" resultType="java.lang.Integer">
    select count(*) from buyer_order bo,buyer_order_promotion bop
    where bo.uid = #{uid,jdbcType=INTEGER}
    and bo.order_code = bop.order_code
    and bop.promotion_id = #{promotionId,jdbcType=INTEGER}
    and bo.status in
    <foreach collection="statusList" item="status" open="(" close=")" separator=",">
      #{status}
    </foreach>
  </select>

</mapper>