发放优惠券
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
## TODO
|
||||
|
||||
异常展示全部信息,只返回 bizerr 的内容,控制台打印全部 err 内容
|
||||
|
||||
ip 提取频率限制,在 ensure 函数加逻辑,通过 redis 或者 pg 计算分钟内提取次数,只允许每分钟提取 30 次
|
||||
|
||||
proxy 的删除和更新,锁粒度应该有问题
|
||||
|
||||
交易信息持久化
|
||||
|
||||
@@ -259,6 +259,10 @@ insert into permission (parent_id, name, description, sort) values
|
||||
insert into permission (parent_id, name, description, sort) values
|
||||
((select id from permission where name = 'balance_activity:read' and deleted_at is null), 'balance_activity:read:of_user', '读取指定用户的余额变动列表', 1);
|
||||
|
||||
-- coupon:write 子权限
|
||||
insert into permission (parent_id, name, description, sort) values
|
||||
((select id from permission where name = 'coupon:write' and deleted_at is null), 'coupon:write:assign', '发放优惠券', 1);
|
||||
|
||||
-- --------------------------
|
||||
-- level 4
|
||||
-- --------------------------
|
||||
|
||||
@@ -51,6 +51,7 @@ const (
|
||||
ScopeCoupon = string("coupon") // 优惠券
|
||||
ScopeCouponRead = string("coupon:read") // 读取优惠券列表
|
||||
ScopeCouponWrite = string("coupon:write") // 写入优惠券
|
||||
ScopeCouponWriteAssign = string("coupon:write:assign") // 发放优惠券
|
||||
|
||||
ScopeBatch = string("batch") // 批次
|
||||
ScopeBatchRead = string("batch:read") // 读取批次列表
|
||||
|
||||
@@ -103,3 +103,27 @@ func DeleteCoupon(c *fiber.Ctx) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func AssignCoupon(c *fiber.Ctx) error {
|
||||
_, err := auth.GetAuthCtx(c).PermitAdmin(core.ScopeCouponWriteAssign)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var req AssignCouponReq
|
||||
if err := g.Validator.ParseBody(c, &req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = s.Coupon.Assign(req.CouponID, req.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type AssignCouponReq struct {
|
||||
CouponID int32 `json:"coupon_id" validate:"required"`
|
||||
UserID int32 `json:"user_id" validate:"required"`
|
||||
}
|
||||
|
||||
@@ -253,4 +253,5 @@ func adminRouter(api fiber.Router) {
|
||||
coupon.Post("/create", handlers.CreateCoupon)
|
||||
coupon.Post("/update", handlers.UpdateCoupon)
|
||||
coupon.Post("/remove", handlers.DeleteCoupon)
|
||||
coupon.Post("/update/assign", handlers.AssignCoupon)
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ func (s *channelBaiyinProvider) CreateChannels(source netip.Addr, resourceId int
|
||||
Sort: u.P("ip_unchanged_time_asc"),
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("获取可用节点失败: %v\n", err)
|
||||
return nil, core.NewBizErr("获取可用节点失败", err)
|
||||
}
|
||||
if edgesResp.Total != count && len(edgesResp.Edges) != count {
|
||||
|
||||
Reference in New Issue
Block a user