Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
增加投诉接口
Browse files Browse the repository at this point in the history
  • Loading branch information
Thxzzzzz committed May 25, 2019
1 parent 3952f71 commit 45bde75
Show file tree
Hide file tree
Showing 30 changed files with 604 additions and 66 deletions.
40 changes: 40 additions & 0 deletions controllers/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,46 @@ func (c *OrderController) Refund() {
c.ResponseSuccessJson(nil)
}

// @Title 买家根据订单 ID 发起投诉
// @Description 买家根据订单 ID 发起投诉
// @Param form body forms.ComplaintForm true "订单ID"
// @Success 200
// @Failure 400
// @router /complaint [Post]
func (c *OrderController) Complaint() {
user := c.User
if user.RoleId != enums.Role_Buyer {
c.ResponseErrJson(resultError.NewFallFundingErr("买家才能发起投诉"))
return
}
form := forms.ComplaintForm{}
err := json.Unmarshal(c.Ctx.Input.RequestBody, &form)
if err != nil {
c.ResponseErrJson(err)
return
}
// 先根据订单 ID 查询对应订单
order, err := models.FindOrderById(form.ID)
if err != nil {
c.ResponseErrJson(err)
return
}
// 只能给自己的订单发起投诉
if user.RoleId == enums.Role_Buyer && user.ID != order.BuyerId {
c.ResponseErrJson(resultError.NewFallFundingErr("这不是你的订单"))
return
}
// 添加退款原因
order.ComplaintReason = form.ComplaintReason
// 更新订单状态
err = models.UpdateOrder(order)
if err != nil {
c.ResponseErrJson(err)
return
}
c.ResponseSuccessJson(nil)
}

// @Title 根据订单 ID 取消订单
// @Description 根据订单 ID 取消订单
// @Param form body forms.RefundForm true "订单ID"
Expand Down
5 changes: 5 additions & 0 deletions forms/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ type RefundForm struct {
RefundReason string `json:"refund_reason"` // 退款原因
}

// 退款申请表单(带退款原因)
type ComplaintForm struct {
ID uint64 `json:"id"` // 订单ID
ComplaintReason string `json:"complaint_reason"` // 投诉原因
}
////////////// 卖家相关 /////////////

// 卖家获取订单的 Form
Expand Down
162 changes: 97 additions & 65 deletions funding.sql

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lastupdate.tmp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"C:\\GoPath\\src\\funding\\controllers":1558718251913543900,"C:\\GoPath\\src\\funding\\managerControllers":1558720792066964300}
{"C:\\GoPath\\src\\funding\\controllers":1558718251913543900,"C:\\GoPath\\src\\funding\\managerControllers":1558720792066964300,"F:\\GoPath\\src\\funding\\controllers":1558773121759950700,"F:\\GoPath\\src\\funding\\managerControllers":1558756358906091900}
1 change: 1 addition & 0 deletions models/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Order struct {
Status enums.OrderStatus `json:"status"` // 订单状态
CheckingNumber string `json:"checking_number"` // 物流单号
RefundReason string `json:"refund_reason"` // 申请退款原因
ComplaintReason string `json:"complaint_reason"` // 投诉原因
LastStatus enums.OrderStatus `json:"last_status"` // 上次状态(申请退款之前的订单状态),用于拒绝退款后恢复
PaidAt *time.Time `json:"paid_at"` // 支付时间
CloseAt *time.Time `json:"close_at"` // 关闭时间
Expand Down
Loading

0 comments on commit 45bde75

Please sign in to comment.