This commit is contained in:
@@ -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