feat: add img_calls field for recharge products

This commit is contained in:
RockYang
2023-12-15 16:56:56 +08:00
parent d974b1ff0e
commit 45cb29d9a0
13 changed files with 83 additions and 41 deletions

View File

@@ -33,6 +33,7 @@ func (h *ProductHandler) Save(c *gin.Context) {
Enabled bool `json:"enabled"`
Days int `json:"days"`
Calls int `json:"calls"`
ImgCalls int `json:"img_calls"`
CreatedAt int64 `json:"created_at"`
}
if err := c.ShouldBindJSON(&data); err != nil {
@@ -40,7 +41,14 @@ func (h *ProductHandler) Save(c *gin.Context) {
return
}
item := model.Product{Name: data.Name, Price: data.Price, Discount: data.Discount, Days: data.Days, Calls: data.Calls, Enabled: data.Enabled}
item := model.Product{
Name: data.Name,
Price: data.Price,
Discount: data.Discount,
Days: data.Days,
Calls: data.Calls,
ImgCalls: data.ImgCalls,
Enabled: data.Enabled}
item.Id = data.Id
if item.Id > 0 {
item.CreatedAt = time.Unix(data.CreatedAt, 0)

View File

@@ -196,6 +196,7 @@ func (h *PaymentHandler) PayQrcode(c *gin.Context) {
remark := types.OrderRemark{
Days: product.Days,
Calls: product.Calls,
ImgCalls: product.ImgCalls,
Name: product.Name,
Price: product.Price,
Discount: product.Discount,
@@ -330,6 +331,12 @@ func (h *PaymentHandler) notify(orderNo string) error {
user.Calls += h.App.SysConfig.VipMonthCalls
}
if remark.ImgCalls > 0 {
user.ImgCalls += remark.ImgCalls
} else {
user.ImgCalls += h.App.SysConfig.VipMonthImgCalls
}
// 更新用户信息
res = h.db.Updates(&user)
if res.Error != nil {