mitao
2024-06-06 3d2b51ea4520533de5e78f88dddf5b5c7dce4247
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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.sinata.rest.modular.mall.dao.MallGoodsSkuMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.sinata.rest.modular.mall.model.MallGoodsSku">
        <id column="id" property="id"/>
        <result column="merchant_id" property="merchantId"/>
        <result column="goods_id" property="goodsId"/>
        <result column="grep_name" property="grepName"/>
        <result column="spec_grep" property="specGrep"/>
        <result column="group_spec_name" property="groupSpecName"/>
        <result column="group_spec_grep" property="groupSpecGrep"/>
        <result column="stock" property="stock"/>
        <result column="img_url" property="imgUrl"/>
        <result column="update_time" property="updateTime"/>
        <result column="create_time" property="createTime"/>
        <result column="spec_ids" property="specIds"/>
        <result column="price" property="price"/>
        <result column="price_sale" property="priceSale"/>
        <result column="price_member" property="priceMember"/>
        <result column="price_merchant" property="priceMerchant"/>
        <result column="state" property="state"/>
        <result column="province_code" property="provinceCode"/>
        <result column="city_code" property="cityCode"/>
        <result column="county_code" property="countyCode"/>
        <result column="sku_id" property="skuId"/>
    </resultMap>
 
    <update id="updateStock">
        UPDATE mall_goods_sku
        SET stock = stock + #{goodsNum}
        WHERE id = #{skuId}
    </update>
  <select id="queryPlatMinSalePrice" resultType="com.sinata.rest.modular.mall.model.MallGoodsSku"
    parameterType="java.lang.Integer">
      SELECT g1.*
      FROM `mall_goods_sku` g1
               JOIN (
          SELECT goods_id, MIN(price_sale) AS min_price
          FROM `mall_goods_sku`
          WHERE merchant_id = 0
          GROUP BY goods_id
      ) g2
        ON g1.goods_id = g2.goods_id AND g1.price_sale = g2.min_price
      WHERE 1=1
        AND g1.merchant_id = 0
        <if test="goodsId !=null and goodsId !=''">
            AND g1.goodsId = #{goodsId}
        </if>
        GROUP BY goods_id
  </select>
 
</mapper>