SELECT
a.*
FROM
mall_product a
where id = #{value}
SELECT
a.id,
a.goods_id,
a.goods_specification_ids,
a.goods_specification_name_value,
a.goods_sn,
a.goods_default,
b.sell_volume,
b.market_price,
b.retail_price,
b.store_id,
b.stock_num
FROM
mall_product a
LEFT JOIN mall_product_store_rela b ON a.id = b.product_id
where b.stock_num is not null and b.stock_num > 0 and a.id = #{id} and b.store_id = #{store_id}
SELECT
a.id,
a.goods_id,
a.goods_specification_ids,
a.goods_specification_name_value,
a.goods_sn,
a.goods_default,
b.sell_volume,
b.market_price,
b.retail_price,
b.store_id,
b.stock_num
FROM
mall_product a
LEFT JOIN mall_product_store_rela b ON a.id = b.product_id
where a.id = #{id} and b.store_id = #{store_id}
SELECT
a.id,
a.goods_id,
a.goods_specification_ids,
a.goods_specification_name_value,
a.goods_sn,
a.goods_default,
b.sell_volume,
b.market_price,
b.retail_price,
b.store_id,
b.stock_num
FROM
mall_product a
LEFT JOIN mall_product_store_rela b ON a.id = b.product_id
where b.stock_num is not null and a.goods_id = #{goods_id} and b.store_id = #{store_id}
order by b.stock_num desc,a.id desc
limit 1
SELECT
a.*,
b.sell_volume,
b.market_price,
b.retail_price,
b.stock_num
FROM
mall_product a
LEFT JOIN mall_product_store_rela b ON a.id = b.product_id
left join mall_goods g on g.id=b.goods_id
1=1 and (g.goods_number > 0 or b.stock_num > 0 )
and a.goods_id = #{goods_id}
and b.store_id = #{store_id}
order by ${sidx} ${order}
order by id desc
limit #{offset}, #{limit}
select count(id) from mall_product
FROM
mall_product a
LEFT JOIN mall_product_store_rela b ON a.id = b.product_id
left join mall_goods g on g.id=b.goods_id
1=1 and (g.goods_number > 0 or b.stock_num > 0 )
and a.goods_id = #{goods_id}
and b.store_id = #{store_id}
update mall_product_store_rela a
a.`stock_num` = #{stock_num},
a.`sell_volume` = #{sell_volume},
where a.product_id = #{id} and a.store_id = #{store_id} and a.goods_id = #{goods_id}