SELECT a.shop_id,d.shop_name,d.shop_logo,a.product_id,a.product_name, ifnull(x.users, 0) + a.fictitious_number as users,
IF(h.image IS NULL OR h.image='',c.product_image,h.image) image,
b.price,b.sku_id,b.original_price,IF(f.number IS NULL, a.fictitious_number, f.number + a.fictitious_number) number,b.stock_number from cere_shop_product a
b.price,b.sku_id,b.original_price,IF(f.number IS NULL, a.fictitious_number, f.number + a.fictitious_number) number,b.stock_number
from cere_shop_product a
LEFT JOIN (SELECT a.product_id,a.price,a.sku_id,a.original_price,a.stock_number from cere_product_sku a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) b ON a.product_id=b.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) c ON a.product_id=c.product_id
LEFT JOIN cere_platform_shop d ON a.shop_id=d.shop_id
INNER JOIN cere_platform_shop d ON a.shop_id=d.shop_id
LEFT JOIN cere_product_classify e ON a.classify_id=e.classify_id
LEFT JOIN cere_product_classify cpcb ON a.classify_business_id=cpcb.classify_id
LEFT JOIN (SELECT SUM(number) number,sku_id,order_id from cere_order_product GROUP BY sku_id) f ON b.sku_id=f.sku_id
@ -415,6 +416,9 @@
and (a.classify_id=#{classifyId} OR e.classify_level_hierarchy like concat('%/',#{classifyId},'%')
OR a.classify_business_id=#{classifyId} OR cpcb.classify_level_hierarchy like concat('%/',#{classifyId},'%'))
IF(m.image IS NULL OR m.image='',c.product_image,m.image) image,h.if_enable,h.enable_time,
a.seckill_price price,a.sku_id,n.price original_price,IF(f.number IS NULL, b.fictitious_number, f.number + b.fictitious_number) number,n.stock_number FROM cere_shop_seckill_detail a
SELECT b.shop_id,d.shop_name,d.shop_logo,a.product_id,b.product_name, ifnull(x.users, 0) + b.fictitious_number as users, h.start_time,h.end_time,h.state,
IF(m.image IS NULL OR m.image='',c.product_image,m.image) image,h.if_enable,h.enable_time,
a.price,a.sku_id,n.price original_price,IF(f.number IS NULL, b.fictitious_number, f.number + b.fictitious_number) number,n.stock_number FROM cere_shop_discount_detail a
LEFT JOIN cere_shop_product b ON a.product_id=b.product_id
LEFT JOIN (SELECT a.product_id,a.product_image from cere_product_image a,cere_shop_product b
where a.product_id=b.product_id GROUP BY a.product_id) c ON a.product_id=c.product_id
LEFT JOIN cere_platform_shop d ON b.shop_id=d.shop_id
LEFT JOIN cere_product_classify e ON b.classify_id=e.classify_id
LEFT JOIN cere_product_classify cpcb ON b.classify_business_id=cpcb.classify_id
LEFT JOIN (SELECT SUM(number) number,sku_id,order_id from cere_order_product GROUP BY sku_id) f ON a.sku_id=f.sku_id
LEFT JOIN cere_shop_order g ON f.order_id=g.order_id and g.state in (2,3,4)
LEFT JOIN (SELECT COUNT(a.buyer_user_id) users,a.product_id FROM (SELECT b.buyer_user_id,a.product_id FROM cere_order_product a,cere_shop_order b
where a.order_id=b.order_id and b.state in (2,3,4) GROUP BY a.product_id,b.buyer_user_id) a GROUP BY a.product_id) x ON a.product_id=x.product_id
LEFT JOIN cere_shop_discount h ON a.shop_discount_id=h.shop_discount_id
LEFT JOIN (SELECT a.sku_id,a.image from cere_sku_name a,cere_product_sku b where a.sku_id=b.sku_id LIMIT 1) m ON a.sku_id=m.sku_id
LEFT JOIN cere_product_sku n ON a.sku_id=n.sku_id
where b.shelve_state=1 and h.state=1 and d.state=1
<iftest="shopId!=null">
and b.shop_id=#{shopId}
</if>
<iftest="search!=null and search!=''">
and (d.shop_name like concat('%',#{search},'%') OR
a.product_id like concat('%',#{search},'%') OR
b.product_name like concat('%',#{search},'%'))
</if>
<iftest="shelveState!=null">
and b.shelve_state=#{shelveState}
</if>
<iftest="classifyId!=null">
and (b.classify_id=#{classifyId} OR e.classify_level_hierarchy like concat('%/',#{classifyId},'%')
OR b.classify_business_id=#{classifyId} OR cpcb.classify_level_hierarchy like concat('%/',#{classifyId},'%'))