fix: wechat pay issues
Some checks failed
build quyun abc / Build (push) Failing after 57s

This commit is contained in:
2025-08-11 10:35:58 +08:00
parent 4bddcfef9c
commit 4d0b5a8961
2 changed files with 56 additions and 35 deletions

View File

@@ -37,7 +37,12 @@ type posts struct {
// @Bind pagination query
// @Bind query query
// @Bind user local
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery, user *model.Users) (*requests.Pager, error) {
func (ctl *posts) List(
ctx fiber.Ctx,
pagination *requests.Pagination,
query *ListQuery,
user *model.Users,
) (*requests.Pager, error) {
conds := []model.Cond{
model.PostsModel().CondNotDeleted(),
model.PostsModel().CondStatus(fields.PostStatusPublished),
@@ -117,7 +122,8 @@ type PostItem struct {
func (ctl *posts) Show(ctx fiber.Ctx, id int64, user *model.Users) (*PostItem, error) {
log.Infof("Fetching post with ID: %d", id)
post, err := model.PostsModel().GetByID(ctx.Context(), id, model.PostsModel().CondNotDeleted(), model.PostsModel().CondStatus(fields.PostStatusPublished))
post, err := model.PostsModel().
GetByID(ctx.Context(), id, model.PostsModel().CondNotDeleted(), model.PostsModel().CondStatus(fields.PostStatusPublished))
if err != nil {
log.WithError(err).Errorf("GetByID err: %v", err)
return nil, err
@@ -196,7 +202,11 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
if asset.Metas.Duration == 0 {
duration = 60 * 5
}
url, err := ctl.oss.GetSignedUrl(ctx.Context(), media.Path, ali.WithExpire(time.Second*time.Duration(duration)))
url, err := ctl.oss.GetSignedUrl(
ctx.Context(),
media.Path,
ali.WithExpire(time.Second*time.Duration(duration)),
)
if err != nil {
log.WithError(err).Errorf("media GetSignedUrl err: %v", err)
return nil, err
@@ -213,7 +223,12 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *model.Users) (*PlayUrl, er
// @Bind pagination query
// @Bind query query
// @Bind user local
func (ctl *posts) Mine(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery, user *model.Users) (*requests.Pager, error) {
func (ctl *posts) Mine(
ctx fiber.Ctx,
pagination *requests.Pagination,
query *ListQuery,
user *model.Users,
) (*requests.Pager, error) {
log.Infof("Fetching posts for user with pagination: %+v and keyword: %v", pagination, query.Keyword)
conds := []model.Cond{
@@ -307,6 +322,7 @@ func (ctl *posts) Buy(ctx fiber.Ctx, id int64, user *model.Users) (*wechat.JSAPI
AppId: "balance",
}, nil
}
return nil, errors.Errorf("账户余额不足, 当前余额:%0.2f 请联系管理员购买或充值", float64(user.Balance)/100)
payPrice := post.PayPrice() - user.Balance
if err := order.SetMeta(ctx.Context(), func(om fields.OrderMeta) fields.OrderMeta {