<?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.xjs.mall.ware.dao.WareSkuDao">

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xjs.mall.ware.entity.WareSkuEntity" id="wareSkuMap">
        <result property="id" column="id"/>
        <result property="skuId" column="sku_id"/>
        <result property="wareId" column="ware_id"/>
        <result property="stock" column="stock"/>
        <result property="skuName" column="sku_name"/>
        <result property="stockLocked" column="stock_locked"/>
    </resultMap>

    <update id="addStock">
        update wms_ware_sku
        set stock = stock + #{skuNum}
        where sku_id = #{skuId}
          and ware_id = #{wareId}
    </update>

    <select id="getSkuStock" resultType="java.lang.Long">
        select sum(stock - stock_locked) from wms_ware_sku where sku_id=#{skuId}
    </select>


</mapper>
