|
@@ -238,39 +238,30 @@ func GetOffSaleProducts(query []MerchantProductType) (list []MerchantProduct, er
|
|
|
}
|
|
|
|
|
|
func GetReportOnSalePackageIds(ids []int) (sourceIds []int, err error) {
|
|
|
- sql := `SELECT
|
|
|
- a.id
|
|
|
-# GROUP_CONCAT( a.product_id ) product_ids
|
|
|
-FROM
|
|
|
- (
|
|
|
+ sql := `
|
|
|
SELECT
|
|
|
r.id
|
|
|
- # mp.id AS product_id
|
|
|
FROM
|
|
|
reports r
|
|
|
LEFT JOIN permission_classify_mapping pcm ON r.classify_id = pcm.classify_id
|
|
|
LEFT JOIN merchant_products mp ON mp.source_id = pcm.permission_id
|
|
|
AND mp.type = 'package'
|
|
|
AND mp.sale_status = 'on_sale'
|
|
|
+ AND mp.deleted = 0
|
|
|
WHERE
|
|
|
- mp.id IS NOT NULL and mp.id in ?
|
|
|
+ mp.id IS NOT NULL and r.id in ?
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
r.id
|
|
|
- # mp.id AS product_id
|
|
|
FROM
|
|
|
reports r
|
|
|
LEFT JOIN permissions p ON r.plate_name = p.NAME
|
|
|
LEFT JOIN merchant_products mp ON mp.source_id = p.permission_id
|
|
|
AND mp.type = 'package'
|
|
|
AND mp.sale_status = 'on_sale'
|
|
|
+ AND mp.deleted = 0
|
|
|
WHERE
|
|
|
- mp.id IS NOT NULL and mp.id in ?
|
|
|
- ) a where a.id in ?
|
|
|
-GROUP BY
|
|
|
- a.id
|
|
|
-ORDER BY
|
|
|
- a.id`
|
|
|
+ mp.id IS NOT NULL and r.id in ?`
|
|
|
db := models.Main()
|
|
|
err = db.Raw(sql, ids, ids).Scan(&sourceIds).Error
|
|
|
return
|
|
@@ -278,20 +269,18 @@ ORDER BY
|
|
|
func GetMediaOnSalePackageIds(ids []int, productType MerchantProductType) (sourceIds []int, err error) {
|
|
|
sql := `SELECT
|
|
|
a.id
|
|
|
-# GROUP_CONCAT( a.product_id ) product_ids
|
|
|
-FROM
|
|
|
+
|
|
|
(
|
|
|
SELECT
|
|
|
- r.id
|
|
|
- # mp.id AS product_id
|
|
|
+ m.id
|
|
|
FROM
|
|
|
- reports r
|
|
|
- LEFT JOIN permissions p ON r.plate_name = p.NAME
|
|
|
- LEFT JOIN merchant_products mp ON mp.source_id = p.permission_id
|
|
|
+ media_permission_mappings mpm
|
|
|
+ LEFT JOIN merchant_products mp ON mp.source_id = mpm.permission_id
|
|
|
AND mp.type = 'package'
|
|
|
AND mp.sale_status = 'on_sale'
|
|
|
+ AND mp.deleted = 0
|
|
|
WHERE
|
|
|
- mp.id IS NOT NULL and mp.id in ?
|
|
|
+ mpm.media_id IS NOT NULL and mp.media_id in ?
|
|
|
) a where a.id in ?
|
|
|
GROUP BY
|
|
|
a.id
|
|
@@ -304,18 +293,14 @@ ORDER BY
|
|
|
func GetOnSaleReportIds(ids []int) (sourceIds []int, err error) {
|
|
|
sql := `SELECT
|
|
|
r.id
|
|
|
- #GROUP_CONCAT( mp.id )AS product_ids
|
|
|
FROM
|
|
|
reports r
|
|
|
LEFT JOIN merchant_products mp ON mp.source_id = r.id
|
|
|
AND mp.type = 'report'
|
|
|
AND mp.sale_status = 'on_sale'
|
|
|
+ AND mp.deleted = 0
|
|
|
WHERE
|
|
|
- mp.id IS NOT NULL and mp.id in ?
|
|
|
-GROUP BY
|
|
|
- r.id
|
|
|
-ORDER BY
|
|
|
- r.id`
|
|
|
+ mp.id IS NOT NULL and r.id in ?`
|
|
|
db := models.Main()
|
|
|
err = db.Raw(sql, ids).Scan(&sourceIds).Error
|
|
|
return
|
|
@@ -323,12 +308,12 @@ ORDER BY
|
|
|
func GetOnSaleMediaIds(ids []int, productType MerchantProductType) (sourceIds []int, err error) {
|
|
|
sql := `SELECT
|
|
|
r.id
|
|
|
- #GROUP_CONCAT( mp.id ) AS product_ids
|
|
|
FROM
|
|
|
reports r
|
|
|
LEFT JOIN merchant_products mp ON mp.source_id = r.id
|
|
|
AND mp.type = ?
|
|
|
- AND mp.sale_status = 'on_sale'
|
|
|
+ AND mp.sale_status = 'on_sale'
|
|
|
+ AND mp.deleted = 0
|
|
|
WHERE
|
|
|
mp.id IS NOT NULL and mp.id in ?
|
|
|
GROUP BY
|