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

52 lines
1.4 KiB
Go

package front
import (
"qteam/app/models/brandmodel"
"qteam/app/models/productsmodel"
"qteam/config"
"strconv"
)
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 {
ProductId string `json:"ProductId"`
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) {
this.ProductId = in.Id
this.BrandFlag = in.Flag
this.VoucherTitle = in.Name
this.VoucherUrl = config.GetConf().YouChu.VoucherUrl + "?product_id=" + in.Id
this.VoucherIcon = in.MainImage
this.VoucherAmount = in.Price
this.VoucherOriginalPrice = in.ShowPrice
stock, _ := strconv.Atoi(in.Stock)
if stock > 0 {
this.VoucherStatus = "1"
} else {
this.VoucherStatus = "0"
}
}