You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.7 KiB
101 lines
3.7 KiB
package goods
|
|
|
|
import (
|
|
"github.com/jinzhu/gorm"
|
|
"github.com/shopspring/decimal"
|
|
"recook/internal/dbc"
|
|
"recook/internal/libs/bean"
|
|
"recook/internal/v2/model/gys/enterprise"
|
|
goods2 "recook/internal/v2/model/gys/goods"
|
|
"recook/internal/v2/model/recook/goods"
|
|
)
|
|
|
|
// ArgsGoodsList 接收上传的参数.
|
|
type ArgsGoodsList struct {
|
|
Title string `json:"title"`
|
|
GoodsSn string `json:"goods_sn"`
|
|
FirstCategory uint `json:"first"`
|
|
SecondCategory uint `json:"second"`
|
|
Code string `json:"code" `
|
|
BrandId uint `json:"brand_id"`
|
|
StartTime string `json:"start_time"`
|
|
EndTime string `json:"end_time"`
|
|
Status int `json:"status"`
|
|
OrderInventory int `json:"order_inventory"`
|
|
OrderPrice int `json:"order_price"`
|
|
GoodsNum string `json:"goods_num"`
|
|
IsPublish uint `json:"is_publish"`
|
|
Publish bool `json:"-"`
|
|
bean.Page
|
|
}
|
|
|
|
type ListBase struct {
|
|
goods2.GysGoodsInfoModel
|
|
Inventory uint `gorm:"column:inventory"`
|
|
MainPhoto goods2.GysGoodsMainPhotoModel `gorm:"foreignKey:goods_id"`
|
|
BrandObj enterprise.GysEnterpriseBrandModel `gorm:"foreignKey:brand"`
|
|
SkuObj []goods2.GysGoodsSkuModel `gorm:"foreignKey:goods_id"`
|
|
First goods.RecookGoodsCategoryModel `gorm:"foreignKey:first_category_id"`
|
|
Second goods.RecookGoodsCategoryModel `gorm:"foreignKey:second_category_id"`
|
|
}
|
|
|
|
func NewGlBase(query *gorm.DB, page bean.Page) (result []*ListBase, total int) {
|
|
query.Count(&total)
|
|
query = query.Preload("BrandObj").Preload("MainPhoto", func(db *gorm.DB) *gorm.DB {
|
|
return db.Where("is_master = 1")
|
|
}).
|
|
Preload("First").Preload("Second")
|
|
|
|
query.Limit(page.GetLimit()).Offset(page.GetStart()).Find(&result)
|
|
return
|
|
}
|
|
|
|
type ListTempBase struct {
|
|
goods2.GysGoodsInfoTempModel
|
|
Inventory uint `gorm:"column:inventory"`
|
|
MainPhoto goods2.GysGoodsMainPhotoTempModel `gorm:"foreignKey:GoodsID"`
|
|
BrandObj enterprise.GysEnterpriseBrandModel `gorm:"foreignKey:Brand"`
|
|
First goods.RecookGoodsCategoryModel `gorm:"foreignKey:FirstCategoryId"`
|
|
Second goods.RecookGoodsCategoryModel `gorm:"foreignKey:SecondCategoryId"`
|
|
}
|
|
|
|
func NewGlTBase(query *gorm.DB, page bean.Page) (result []*ListTempBase, total int) {
|
|
query.Group("source_id").Count(&total)
|
|
query = query.Preload("BrandObj").Preload("First").Preload("Second")
|
|
query.Group("source_id").Limit(page.GetLimit()).Offset(page.GetStart()).Find(&result)
|
|
|
|
var cover goods2.GysGoodsMainPhotoTempModel
|
|
for index, v := range result {
|
|
dbc.DB.Table(cover.TableName()).First(&result[index].MainPhoto,
|
|
"goods_id = ? AND is_master = 1", v.SourceID)
|
|
}
|
|
return
|
|
}
|
|
|
|
type ListItem struct {
|
|
Inventory uint `json:"inventory"`
|
|
Lock uint `json:"lock"`
|
|
BrandName string `json:"brand_name"`
|
|
BrandID uint `json:"brand_id,omitempty"`
|
|
Title string `json:"title"`
|
|
Cover string `json:"cover"`
|
|
GoodsSn string `json:"goods_sn"`
|
|
GoodsID uint `json:"goods_id"`
|
|
Status int `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
AdminTime int64 `json:"admin_time"`
|
|
First string `json:"first"`
|
|
Second string `json:"second"`
|
|
PurchasePrice decimal.Decimal `json:"purchase_price"`
|
|
OriginalPrice decimal.Decimal `json:"original_price"`
|
|
DiscountPrice decimal.Decimal `json:"discount_price"`
|
|
}
|
|
|
|
type ReplyStep struct {
|
|
GoodsId uint `json:"goods_id"`
|
|
AuditType int `json:"audit_type"`
|
|
AuditStatus int `json:"audit_status"`
|
|
NoInfo string `json:"no_info"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|