This commit is contained in:
eson
2023-06-26 18:19:51 +08:00
parent 0afaed5089
commit d74d27ab2d
15 changed files with 377 additions and 12 deletions

View File

@@ -27,8 +27,5 @@ func (c *FsCanteenProductModel) Create(ctx context.Context, data *FsCanteenProdu
func (c *FsCanteenProductModel) GetAllByCanteenTypeIdOrderAsc(ctx context.Context, typeId int64) (resp []FsCanteenProduct, err error) {
err = c.db.WithContext(ctx).Model(&FsCanteenProduct{}).Where("`canteen_type` = ? and `status` = ?", typeId, 1).Order("sort asc").Find(&resp).Error
if err != nil {
return nil, err
}
return
return resp, err
}

View File

@@ -49,3 +49,8 @@ func (p *FsProductModel) GetRandomProductList(ctx context.Context, limit int) (r
}
return
}
func (p *FsProductModel) FindAllOnlyByIds(ctx context.Context, ids []int64) (resp []*FsProduct, err error) {
err = p.db.WithContext(ctx).Model(&FsProduct{}).Where("`id` IN (?)", ids).Find(&resp).Error
return resp, err
}

View File

@@ -71,3 +71,20 @@ func (p *FsProductPriceModel) GetPriceListByProductIds(ctx context.Context, prod
}
return
}
// 产品价格
type ProductPrice struct {
Id int64 `json:"id"`
MinBuyNum int64 `json:"min_buy_num"`
StepNum interface{} `json:"step_num"`
StepPrice interface{} `json:"step_price"`
ProductId int64 `json:"product_id"`
SizeId int64 `json:"size_id"`
EachBoxNum int64 `json:"each_box_num"`
}
func (c *FsProductPriceModel) GetAllSelectBySizeId(ctx context.Context, sizeIds []int64) (prices []*ProductPrice, err error) {
err = c.db.WithContext(ctx).Model(&ProductPrice{}).Where("size_id IN (?) AND status = ?", sizeIds, 1).Select("id, min_buy_num, step_num, step_price, product_id, size_id, each_box_num").Find(&prices).Error
return prices, err
}

View File

@@ -45,3 +45,13 @@ func (s *FsProductSizeModel) GetAllByProductIds(ctx context.Context, productIds
}
return
}
type CapacityId struct {
Id int64 `json:"id"`
Capacity string `json:"capacity"`
}
func (c *FsProductSizeModel) GetAllSelectIdAndCapacityByIds(ctx context.Context, sizeIds []int64) (sizes []CapacityId, err error) {
err = c.db.WithContext(ctx).Where("id IN ?", sizeIds).Select("id, capacity").Find(&sizes).Error
return sizes, err
}

View File

@@ -1,2 +1,10 @@
package gmodel
// TODO: 使用model的属性做你想做的
import "context"
// TODO: 使用model的属性做你想做的
func (m *FsQuotationModel) FindOneOnlyById(ctx context.Context, quotationId int64) (resp FsQuotation, err error) {
err = m.db.WithContext(ctx).Model(&resp).Where("`quotation_id` = ?", quotationId).Take(&resp).Error
return resp, err
}

View File

@@ -1,2 +1,10 @@
package gmodel
// TODO: 使用model的属性做你想做的
import "context"
// TODO: 使用model的属性做你想做的
func (c *FsQuotationProductModel) GetAllByQuotationIdOrderAsc(ctx context.Context, quotationId int64) (resp []FsQuotationProduct, err error) {
err = c.db.WithContext(ctx).Model(&FsQuotationProduct{}).Where("`quotation_id` = ? and `status` = ?", quotationId, 1).Order("sort asc").Find(&resp).Error
return resp, err
}

View File

@@ -1,2 +1,10 @@
package gmodel
// TODO: 使用model的属性做你想做的
import "context"
// TODO: 使用model的属性做你想做的
func (c *FsQuotationRemarkTemplateModel) GetAllSelectContent(ctx context.Context) (content []string, err error) {
err = c.db.WithContext(ctx).Model(&FsQuotationRemarkTemplate{}).Where("status = ?", 1).Select("content").Find(&content).Error
return content, err
}