|
@@ -15,8 +15,9 @@ type SaleStatus string
|
|
|
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"
|
|
|
- sourceIdColumn = "id,source_id"
|
|
|
+ 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"
|
|
|
+ sourceIdColumn = "id,source_id"
|
|
|
)
|
|
|
const (
|
|
|
OnSale SaleStatus = "on_sale" //上架
|
|
@@ -36,7 +37,7 @@ type MerchantProduct struct {
|
|
|
CoverUrl string `gorm:"column:cover_url;type:varchar(255);comment:封面图片url"`
|
|
|
Description string `gorm:"column:description;type:varchar(255);comment:描述"`
|
|
|
Price string `gorm:"column:price;type:decimal(10,2);comment:价格"`
|
|
|
- RiskLevel string `gorm:"-"`
|
|
|
+ RiskLevel string `gorm:"column:risk_level;type:varchar(100);comment:风险等级"`
|
|
|
Type MerchantProductType `gorm:"column:type;type:enum('report','video','audio','package');not null;comment:类型"`
|
|
|
IsPermanent bool `gorm:"column:is_permanent;type:int(1);not null;default:0;comment:是否永久"`
|
|
|
ValidDays int `gorm:"column:valid_days;type:int(11);comment:有效期天数"`
|
|
@@ -61,7 +62,12 @@ func GetMerchantProductBySourceId(sourceId int, productType ...MerchantProductTy
|
|
|
db := models.Main()
|
|
|
if len(productType) > 0 {
|
|
|
if len(productType) == 1 {
|
|
|
- err = db.Select(detailColumns).Where("source_id =? and type = ? and deleted =?", sourceId, productType[0], 0).First(&product).Error
|
|
|
+
|
|
|
+ if productType[0] == Package {
|
|
|
+ err = db.Select(detailColumnsWithRisk).InnerJoins("permissions on permissions.permission_id=source_id")
|
|
|
+ } else {
|
|
|
+ err = db.Select(detailColumns).Where("source_id =? and type = ? and deleted =?", sourceId, productType[0], 0).First(&product).Error
|
|
|
+ }
|
|
|
} else {
|
|
|
err = db.Select(detailColumns).Where("source_id =? and type in (?) and deleted =?", sourceId, productType, 0).First(&product).Error
|
|
|
}
|