PromotionMoneyGiftMapper.xml 4.8 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.sibu.orderHelper.integral.web.dao.IMPromotionMoneyGiftDao">
	<resultMap id="rs_PromotionMoneyGiftBean" type="com.sibu.orderHelper.integral.model.PromotionMoneyGift">
		<result property="id" column="id" javaType="java.lang.Long" jdbcType="VARCHAR"/>
		<result property="buyMoney" column="buy_money" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="giftNum" column="gift_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="giftTotal" column="gift_total" javaType="java.lang.Long" jdbcType="VARCHAR"/>
		<result property="surplusNum" column="surplus_num" javaType="java.lang.Long" jdbcType="VARCHAR"/>
		<result property="isDelete" column="is_delete" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="status" column="status" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
		<result property="giftProductId" column="gift_product_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
		<result property="promotionId" column="promotion_id" javaType="java.lang.Long" jdbcType="VARCHAR"/>
	</resultMap>
	<select id="count" resultType="java.lang.Integer" >
		SELECT COUNT(id) FROM promotion_money_gift
		<trim prefix="where" prefixOverrides="and | or">
			<if test="null != id">
				AND id = #{id}
			</if>
		</trim>
	</select>
	<select id="list" resultMap="rs_PromotionMoneyGiftBean" >
		SELECT * FROM promotion_money_gift where
		 id = #{id} 
		ORDER BY create_date desc
	</select>
	<select id="listMoneyGift" resultMap="listMoneyGiftResponse" parameterType="java.lang.Integer">
		select pmg.id,pmg.buy_money,pmg.gift_num,pmg.gift_total,pmg.status,pmg.gift_product_id,pmg.create_date,ip.name gift_product_name from promotion_money_gift pmg left join im_product ip on pmg.gift_product_id = ip.im_product_id where pmg.promotion_id = ${promotionId}
	</select>
	<resultMap type="com.sibu.orderHelper.integral.reponse.PromotionMoneyGiftResponse" id="listMoneyGiftResponse">
		<result property="id" column="id" />
		<result property="buyMoney" column="buy_money" />
		<result property="giftNum" column="gift_num" />
		<result property="giftTotal" column="gift_total" />
		<result property="status" column="status" />
		<result property="giftProductId" column="gift_product_id" />
		<result property="createDate" column="create_date" />
		<result property="giftProductName" column="gift_product_name" />
	</resultMap>
	<select id="get" resultMap="rs_PromotionMoneyGiftBean" parameterType="java.lang.String">
		SELECT * FROM promotion_money_gift
		where  id = #{id}
	</select>
	<insert id="save" parameterType="com.sibu.orderHelper.integral.request.PromotionMoneyGiftRequest">
		INSERT INTO promotion_money_gift (
			buy_money,gift_num,gift_total,status,gift_product_id,promotion_id,supplier_id,supplier_name,platform_type
		) VALUES (
			#{buyMoney},#{giftNum},#{giftTotal},#{status},#{giftProductId},#{promotionId},#{supplierId},#{supplierName},#{platformType}
		)
		<!-- <selectKey resultType="java.lang.String" keyProperty="id">
			<![CDATA[SELECT last_insert_id() AS id ]]>
		</selectKey> -->
	</insert>
	<update id="update" parameterType="java.util.Map">
		UPDATE promotion_money_gift
		<trim prefix="SET" suffixOverrides=",">
			<if test="null != buyMoney">
				buy_money=#{buyMoney},
			</if>
			<if test="null != giftNum">
				gift_num=#{giftNum},
			</if>
			<if test="null != giftTotal">
				gift_total=#{giftTotal},
			</if>
			<if test="null != surplusNum">
				surplus_num=#{surplusNum},
			</if>
			<if test="null != isDelete">
				is_delete=#{isDelete},
			</if>
			<if test="null != status">
				status=#{status},
			</if>
			<if test="null != giftProductId">
				gift_product_id=#{giftProductId},
			</if>
			<if test="null != createDate">
				create_date=#{createDate},
			</if>
			<if test="null != promotionId">
				promotion_id=#{promotionId},
			</if>

		</trim>
		WHERE id = #{id}
	</update>
	<delete id="delete" parameterType="java.lang.Long">
		DELETE FROM promotion_money_gift WHERE id = #{id}
	</delete>
	<delete id="batchDelete" parameterType="java.util.List">
		DELETE FROM promotion_money_gift WHERE id in
		<foreach collection="list" item="item"  open="(" separator="," close=")">  
			#{item} 
		</foreach>
	</delete>


	<select id="listSupplierMoneyGift" resultMap="listMoneyGiftResponse" parameterType="java.util.Map">
		select pmg.id,pmg.buy_money,pmg.gift_num,pmg.gift_total,pmg.status,pmg.gift_product_id,pmg.create_date,ip.name gift_product_name from promotion_money_gift pmg left join im_product ip on pmg.gift_product_id = ip.im_product_id where pmg.promotion_id = ${promotionId}
		and pmg.supplier_id = #{supplierId}
	</select>
</mapper>