|
@@ -16,7 +16,7 @@ type MerchantProductType string
|
|
|
|
|
|
const (
|
|
|
detailColumns = "id,source_id,title,cover_src,cover_url,description,price,type,is_permanent,valid_days,sale_status,created_time,updated_time"
|
|
|
- detailColumnsWithRisk = "id,source_id,title,cover_src,cover_url,description,price,type,is_permanent,valid_days,sale_status,created_time,updated_time,permissions.risk_level as risk_level"
|
|
|
+ detailColumnsWithRisk = "merchant_products.id,source_id,title,cover_src,cover_url,description,price,type,is_permanent,valid_days,sale_status,created_time,updated_time,permissions.risk_level as risk_level"
|
|
|
sourceIdColumn = "id,source_id"
|
|
|
)
|
|
|
const (
|
|
@@ -62,9 +62,8 @@ func GetMerchantProductBySourceId(sourceId int, productType ...MerchantProductTy
|
|
|
db := models.Main()
|
|
|
if len(productType) > 0 {
|
|
|
if len(productType) == 1 {
|
|
|
-
|
|
|
if productType[0] == Package {
|
|
|
- err = db.Select(detailColumnsWithRisk).InnerJoins("permissions on permissions.permission_id=source_id")
|
|
|
+ err = db.Select(detailColumnsWithRisk).Joins("left join permissions on permissions.permission_id=source_id").Where("source_id =? and type = ? and deleted =?", sourceId, productType[0], 0).First(&product).Error
|
|
|
} else {
|
|
|
err = db.Select(detailColumns).Where("source_id =? and type = ? and deleted =?", sourceId, productType[0], 0).First(&product).Error
|
|
|
}
|
|
@@ -92,7 +91,11 @@ func GetProductListBySourceIds(ids []int, detail bool, productType ...MerchantPr
|
|
|
}
|
|
|
if len(productType) > 0 {
|
|
|
if len(productType) == 1 {
|
|
|
- err = db.Select(columns).Where("source_id in ? and type = ? and deleted =? order by created_time desc", ids, productType[0], false).Find(&productList).Error
|
|
|
+ if productType[0] == Package {
|
|
|
+ err = db.Select(detailColumnsWithRisk).Joins("left join permissions on permissions.permission_id=source_id").Where("source_id in ? and type = ? and deleted =? order by created_time desc", ids, productType[0], false).Find(&productList).Error
|
|
|
+ } else {
|
|
|
+ err = db.Select(columns).Where("source_id in ? and type = ? and deleted =? order by created_time desc", ids, productType[0], false).Find(&productList).Error
|
|
|
+ }
|
|
|
} else {
|
|
|
err = db.Select(columns).Where("source_id in ? and type in (?) and deleted =? by created_time desc", ids, productType, false).Find(&productList).Error
|
|
|
}
|