YouChuKoffee/app/http/entities/front/Voucher.go

52 lines
1.4 KiB
Go
Raw Normal View History

2024-06-19 18:32:34 +08:00
package front
2024-06-17 16:29:39 +08:00
import (
"qteam/app/models/brandmodel"
"qteam/app/models/productsmodel"
"qteam/config"
2024-06-24 11:44:38 +08:00
"strconv"
2024-06-17 16:29:39 +08:00
)
type VoucherListResponse struct {
MilkUrl string `json:"milkUrl"`
MilkList []MilkList `json:"milkList"`
MilkVoucherList []MilkVoucherList `json:"milkVoucherList"`
}
type MilkList struct {
BrandLogo string `json:"brandLogo"`
BrandFlag string `json:"brandFlag"`
}
func (this *MilkList) ResponseFromDb(in brandmodel.Brand) {
this.BrandFlag = in.Flag
this.BrandLogo = in.Logo
}
type MilkVoucherList struct {
2024-06-24 11:44:38 +08:00
ProductId string `json:"ProductId"`
2024-06-17 16:29:39 +08:00
BrandFlag string `json:"brandFlag"`
VoucherTitle string `json:"voucherTitle"`
VoucherUrl string `json:"voucherUrl"`
VoucherIcon string `json:"voucherIcon"`
VoucherAmount string `json:"voucherAmount"`
VoucherOriginalPrice string `json:"voucherOriginalPrice"`
VoucherStatus string `json:"voucherStatus"`
}
func (this *MilkVoucherList) ResponseFromDb(in productsmodel.MilkProductsList) {
2024-06-24 11:44:38 +08:00
this.ProductId = in.Id
2024-06-17 16:29:39 +08:00
this.BrandFlag = in.Flag
this.VoucherTitle = in.Name
2024-06-24 11:44:38 +08:00
this.VoucherUrl = config.GetConf().YouChu.VoucherUrl + "?product_id=" + in.Id
2024-06-17 16:29:39 +08:00
this.VoucherIcon = in.MainImage
this.VoucherAmount = in.ShowPrice
this.VoucherOriginalPrice = in.Price
2024-06-24 11:44:38 +08:00
stock, _ := strconv.Atoi(in.Stock)
if stock > 0 {
this.VoucherStatus = "1"
} else {
this.VoucherStatus = "0"
}
2024-06-17 16:29:39 +08:00
}