feat: persist product claimed counts

This commit is contained in:
richjohnrambo
2026-10-19 00:02:35 +08:00
parent ac152d2f10
commit 0ce6bca10e
6 changed files with 29 additions and 1 deletions
+2
View File
@@ -35,6 +35,7 @@ type ProductColumns struct {
CoverUrl string // 封面URL
DetailHtml string // 商品详情
IsRecommended string // 是否推荐
ClaimedCount string // 已领取展示数
PublishStatus string // 发布状态
StartAt string // 展示开始时间
EndAt string // 展示结束时间
@@ -65,6 +66,7 @@ var productColumns = ProductColumns{
CoverUrl: "cover_url",
DetailHtml: "detail_html",
IsRecommended: "is_recommended",
ClaimedCount: "claimed_count",
PublishStatus: "publish_status",
StartAt: "start_at",
EndAt: "end_at",
+1 -1
View File
@@ -124,7 +124,7 @@ func (s *sSysProduct) Edit(ctx context.Context, in *sysin.ProductEditInp) (id ui
id = in.Id
} else {
in.ProductNo = "PD" + gtime.Now().Format("YmdHis") + grand.S(5)
result, e := s.Model(ctx).Fields(c.ProductNo, c.CategoryId, c.ProductType, c.PaymentType, c.Name, c.ShopName, c.PriceAmount, c.Currency, c.CoverAttachmentId, c.CoverUrl, c.DetailHtml, c.IsRecommended, c.PublishStatus, c.StartAt, c.EndAt, c.Sort, c.Remark, c.CreatedBy, c.UpdatedBy).Hook(hook.SaveTenant).Data(g.Map{c.ProductNo: in.ProductNo, c.CategoryId: in.CategoryId, c.ProductType: in.ProductType, c.PaymentType: in.PaymentType, c.Name: in.Name, c.ShopName: in.ShopName, c.PriceAmount: in.PriceAmount, c.Currency: in.Currency, c.CoverAttachmentId: in.CoverAttachmentId, c.CoverUrl: in.CoverUrl, c.DetailHtml: in.DetailHtml, c.IsRecommended: in.IsRecommended, c.PublishStatus: consts.BizPublishDraft, c.StartAt: in.StartAt, c.EndAt: in.EndAt, c.Sort: in.Sort, c.Remark: in.Remark, c.CreatedBy: uid, c.UpdatedBy: uid}).Insert()
result, e := s.Model(ctx).Fields(c.ProductNo, c.CategoryId, c.ProductType, c.PaymentType, c.Name, c.ShopName, c.PriceAmount, c.Currency, c.CoverAttachmentId, c.CoverUrl, c.DetailHtml, c.IsRecommended, c.ClaimedCount, c.PublishStatus, c.StartAt, c.EndAt, c.Sort, c.Remark, c.CreatedBy, c.UpdatedBy).Hook(hook.SaveTenant).Data(g.Map{c.ProductNo: in.ProductNo, c.CategoryId: in.CategoryId, c.ProductType: in.ProductType, c.PaymentType: in.PaymentType, c.Name: in.Name, c.ShopName: in.ShopName, c.PriceAmount: in.PriceAmount, c.Currency: in.Currency, c.CoverAttachmentId: in.CoverAttachmentId, c.CoverUrl: in.CoverUrl, c.DetailHtml: in.DetailHtml, c.IsRecommended: in.IsRecommended, c.ClaimedCount: grand.N(100, 500), c.PublishStatus: consts.BizPublishDraft, c.StartAt: in.StartAt, c.EndAt: in.EndAt, c.Sort: in.Sort, c.Remark: in.Remark, c.CreatedBy: uid, c.UpdatedBy: uid}).Insert()
if e != nil {
return 0, gerror.Wrap(e, "创建商品失败")
}
+1
View File
@@ -26,6 +26,7 @@ type Product struct {
CoverUrl any // 封面URL
DetailHtml any // 商品详情
IsRecommended any // 是否推荐
ClaimedCount any // 已领取展示数
PublishStatus any // 发布状态
StartAt *gtime.Time // 展示开始时间
EndAt *gtime.Time // 展示结束时间
+1
View File
@@ -24,6 +24,7 @@ type Product struct {
CoverUrl string `json:"coverUrl" orm:"cover_url" description:"封面URL"`
DetailHtml string `json:"detailHtml" orm:"detail_html" description:"商品详情"`
IsRecommended int `json:"isRecommended" orm:"is_recommended" description:"是否推荐"`
ClaimedCount uint `json:"claimedCount" orm:"claimed_count" description:"已领取展示数"`
PublishStatus int `json:"publishStatus" orm:"publish_status" description:"发布状态"`
StartAt *gtime.Time `json:"startAt" orm:"start_at" description:"展示开始时间"`
EndAt *gtime.Time `json:"endAt" orm:"end_at" description:"展示结束时间"`
@@ -36,6 +36,7 @@ type ProductUpdateFields struct {
type ProductInsertFields struct {
ProductUpdateFields
ProductNo string
ClaimedCount uint
PublishStatus int
CreatedBy uint64
}