IMProductSkuMapper.xml 2.4 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.dao.IMProductSkuDao">
    
    <!-- 查询product sku返回 -->
	<select id="selectApiSkuByProductId" parameterType="java.lang.String" resultMap="skuApiResponse">
		SELECT s.sku_id,s.erp_code,s.stock_num,s.exchange_integral,s.member_price,s.retail_price,s.market_price,
			s.is_show,ref.attr_value_id,n.attr_id,n.attr_name,v.attr_value ,n.sort_index FROM sku s 
			LEFT JOIN attr_ref ref ON s.sku_id =ref.sku_id
			LEFT JOIN attr_value v ON v.value_id =ref.attr_value_id
			LEFT JOIN attr_name n ON n.attr_id =v.attr_id
			WHERE s.im_product_id =#{productId} 
			ORDER BY n.sort_index
	</select>
	

	<update id="updateProductSku" parameterType="map">
		update sku set stock_num = stock_num-${stockNum} where sku_id = #{skuId} and im_product_id = #{productId}
	</update>
	<update id="updateProductSkuByErpCode" parameterType="map">
		update sku set stock_num = stock_num-${stockNum} where erp_code = #{erpCode}
	</update>
	<resultMap id="skuApiResponse" type="com.sibu.orderHelper.integral.reponse.SkuApiResponse">
		<result property="skuId" column="sku_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="erpCode" column="erp_code" javaType="java.lang.String" jdbcType="VARCHAR"/>
		<result property="stockNum" column="stock_num" javaType="java.lang.Integer" jdbcType="INTEGER"/>
		<result property="exchangeIntegral" column="exchange_integral" javaType="java.lang.Integer" jdbcType="INTEGER"/>
		<result property="memberPrice" column="member_price"/>
		<result property="retailPrice" column="retail_price"/>
		<result property="marketPrice" column="market_price"/>
		<collection property="values" ofType="com.sibu.orderHelper.integral.reponse.SkuValueResponse" column="sku_Id">
			<result property="attrValueId" column="attr_value_id" javaType="java.lang.Long" jdbcType="BIGINT"/>
			<result property="attrId" column="attr_id" javaType="java.lang.Long" jdbcType="BIGINT"/>
			<result property="attrName" column="attr_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
			<result property="valueName" column="attr_value" javaType="java.lang.String" jdbcType="VARCHAR"/>
			<result property="sortIndex" column="sort_index" javaType="java.lang.Integer" jdbcType="TINYINT"/>
		</collection>
	</resultMap>
</mapper>