This commit is contained in:
laodaming
2023-09-25 17:20:44 +08:00
parent 29c7dc54e3
commit 4bbe9aaaa3
5 changed files with 89 additions and 179 deletions

View File

@@ -4,6 +4,18 @@ import (
"context"
)
// 阶梯价结构
type StepPriceJsonStruct struct {
PriceRange []struct {
Label string `json:"label"`
Price int64 `json:"price"`
EndQuantity int64 `json:"end_quantity"`
StartQuantity int64 `json:"start_quantity"`
} `json:"price_range"`
MinBuyUnitsNum int64 `json:"min_buy_units_num"`
StepBuyUnitsNum int64 `json:"step_buy_units_num"`
}
func (d *FsProductModel3dModel) FindOne(ctx context.Context, id int64, fields ...string) (resp *FsProductModel3d, err error) {
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).Where("`id` = ? ", id)
if len(fields) > 0 {
@@ -120,3 +132,14 @@ func (d *FsProductModel3dModel) GetOneBySizeIdTag(ctx context.Context, sizeId in
err = db.Take(&resp).Error
return resp, err
}
func (d *FsProductModel3dModel) GetAllByProductIdTag(ctx context.Context, productId int64, tag int64, fields ...string) (resp []FsProductModel3d, err error) {
db := d.db.WithContext(ctx).Model(&FsProductModel3d{}).
Where("`product_id` = ? and `tag` = ? and `status` = ?", productId, tag, 1).
Order("sort DESC")
if len(fields) != 0 {
db = db.Select(fields[0])
}
err = db.Find(&resp).Error
return resp, err
}