UpdateManualTransferOrder updates a manual transfer order @Summary Update manual transfer order @Description Update details of a manual transfer order @Tags Order @Accept json @Produce json @Security BearerAuth @Param id path int true "Order ID" @Param data body UpdateManualTransferOrderRequest true
(c *gin.Context)
| 475 | // @Success 200 {object} model.CommonResponse{data=model.Order} |
| 476 | // @Router /api/orders/{id}/manual [put] |
| 477 | func UpdateManualTransferOrder(c *gin.Context) { |
| 478 | id, err := strconv.ParseInt(c.Param("id"), 10, 64) |
| 479 | if err != nil { |
| 480 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse("Invalid ID")) |
| 481 | return |
| 482 | } |
| 483 | |
| 484 | eid := config.GetEID(c) |
| 485 | |
| 486 | var req UpdateManualTransferOrderRequest |
| 487 | if err = c.ShouldBindJSON(&req); err != nil { |
| 488 | c.JSON(http.StatusBadRequest, model.ParamError.ToResponse(err)) |
| 489 | return |
| 490 | } |
| 491 | |
| 492 | order, err := model.GetOrderByID(eid, id) |
| 493 | if err != nil { |
| 494 | c.JSON(http.StatusNotFound, model.NotFound.ToNewErrorResponse(model.OrderNotFound)) |
| 495 | return |
| 496 | } |
| 497 | |
| 498 | if order.PayType != 2 { |
| 499 | c.JSON(http.StatusBadRequest, model.ParamError.ToNewErrorResponse("Only manual payment orders can be updated")) |
| 500 | return |
| 501 | } |
| 502 | |
| 503 | // Update order fields |
| 504 | order.Amount = req.Amount |
| 505 | order.Currency = req.Currency |
| 506 | order.Duration = req.Duration |
| 507 | order.UserID = req.UserID |
| 508 | order.Nickname = req.Nickname |
| 509 | order.ServiceID = req.SubscriptionID |
| 510 | order.SubscriptionName = req.SubscriptionName |
| 511 | order.TimeUnit = req.TimeUnit |
| 512 | |
| 513 | if err := order.Update(); err != nil { |
| 514 | c.JSON(http.StatusInternalServerError, model.DBError.ToResponse(err)) |
| 515 | return |
| 516 | } |
| 517 | |
| 518 | c.JSON(http.StatusOK, model.Success.ToResponse(order)) |
| 519 | } |
| 520 | |
| 521 | func QueryTradeOrder(c *gin.Context) { |
| 522 | orderId := c.Param("order_id") |
nothing calls this directly
no test coverage detected