mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-08 10:13:44 +08:00
feat: add img_calls field for recharge products
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user