feat: update transaction handling and order service logic
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -12,10 +12,56 @@ type Transaction struct{}
|
||||
|
||||
// Create Order
|
||||
//
|
||||
// @Summary Create Order
|
||||
// @Description 创建订单
|
||||
// @Tags Transaction
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.OrderCreateForm true "订单创建参数"
|
||||
// @Success 200 {object} dto.OrderCreateResponse
|
||||
// @Router /v1/t/:tenantCode/orders [post]
|
||||
// @Bind form body
|
||||
func (t *Transaction) Create(ctx fiber.Ctx, form *dto.OrderCreateForm) (*dto.OrderCreateResponse, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
uid := getUserID(ctx)
|
||||
return services.Order.Create(ctx, tenantID, uid, form)
|
||||
}
|
||||
|
||||
// Pay Order
|
||||
//
|
||||
// @Summary Pay Order
|
||||
// @Description 支付订单
|
||||
// @Tags Transaction
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "订单ID"
|
||||
// @Param form body dto.OrderPayForm true "支付参数"
|
||||
// @Success 200 {object} dto.OrderPayResponse
|
||||
// @Router /v1/t/:tenantCode/orders/:id<int>/pay [post]
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (t *Transaction) Pay(ctx fiber.Ctx, id int64, form *dto.OrderPayForm) (*dto.OrderPayResponse, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
uid := getUserID(ctx)
|
||||
return services.Order.Pay(ctx, tenantID, uid, id, form)
|
||||
}
|
||||
|
||||
// Order Status
|
||||
//
|
||||
// @Summary Order Status
|
||||
// @Description 查询订单状态
|
||||
// @Tags Transaction
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "订单ID"
|
||||
// @Success 200 {object} dto.OrderStatusResponse
|
||||
// @Router /v1/t/:tenantCode/orders/:id<int>/status [get]
|
||||
// @Router /v1/t/:tenantCode/webhook/payment/notify [post]
|
||||
// @Bind id path
|
||||
func (t *Transaction) Status(ctx fiber.Ctx, id int64) (*dto.OrderStatusResponse, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
uid := getUserID(ctx)
|
||||
return services.Order.Status(ctx, tenantID, uid, id)
|
||||
}
|
||||
|
||||
// @Summary Payment Webhook
|
||||
// @Description Payment Webhook
|
||||
@@ -24,6 +70,7 @@ type Transaction struct{}
|
||||
// @Produce json
|
||||
// @Param form body dto.PaymentWebhookForm true "Webhook Data"
|
||||
// @Success 200 {string} string "success"
|
||||
// @Router /v1/t/:tenantCode/webhook/payment/notify [post]
|
||||
// @Bind form body
|
||||
func (t *Transaction) Webhook(ctx fiber.Ctx, form *dto.PaymentWebhookForm) (string, error) {
|
||||
tenantID := getTenantID(ctx)
|
||||
|
||||
Reference in New Issue
Block a user