This commit is contained in:
@@ -320,7 +320,7 @@ func (ctl *posts) Buy(ctx fiber.Ctx, post *models.Post, user *models.User) (*wec
|
||||
}
|
||||
// payPrice := post.PayPrice()
|
||||
|
||||
order, err := services.Orders.CreateFromUserPostID(ctx, user.ID, post.ID)
|
||||
order, err := services.Orders.CreateFromUserPostID(ctx, user.ID, post)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "订单创建失败")
|
||||
}
|
||||
|
||||
@@ -124,18 +124,13 @@ func (m *orders) GetByOrderNO(ctx context.Context, orderNo string) (*models.Orde
|
||||
return models.OrderQuery.WithContext(ctx).Where(models.OrderQuery.OrderNo.Eq(orderNo)).First()
|
||||
}
|
||||
|
||||
func (o *orders) CreateFromUserPostID(ctx context.Context, userId, postId int64) (*models.Order, error) {
|
||||
post, err := Posts.FindByID(ctx, postId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to get post")
|
||||
}
|
||||
|
||||
func (o *orders) CreateFromUserPostID(ctx context.Context, userId int64, post *models.Post) (*models.Order, error) {
|
||||
m := &models.Order{}
|
||||
m.Status = fields.OrderStatusPending
|
||||
m.OrderNo = time.Now().Format("20060102150405")
|
||||
m.SubOrderNo = m.OrderNo
|
||||
m.UserID = userId
|
||||
m.PostID = postId
|
||||
m.PostID = post.ID
|
||||
m.Meta = types.NewJSONType(fields.OrderMeta{})
|
||||
m.Price = post.Price
|
||||
m.Discount = post.Discount
|
||||
|
||||
Reference in New Issue
Block a user