package refundOrderApi import ( "stat/api/proto" "stat/common/stdLog" "stat/common/utils" "stat/service/opLogSer" "stat/service/refundOrderSer" "github.com/gin-gonic/gin" ) // @Tags 退款订单管理 // @Summary 退款订单列表 // @Description 支持 appId / userId / cid / channelName / districtCode 任意组合过滤 // @Router /api/stat/refundOrder/list [POST] // @Param param body proto.RefundOrderListReq true "参数" // @Success 200 {object} proto.RefundOrderListResp "成功" // @Security ApiKeyAuth func List(ctx *gin.Context) { req := &proto.RefundOrderListReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } resp, err := refundOrderSer.List(ctx, req) if err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } stdLog.ServerJSON(ctx, stdLog.Success, resp) } // @Tags 退款订单管理 // @Summary 新增退款订单 // @Description 传入 cid,查询 log_recharge 中该渠道付款成功的订单并逐条回填 // @Router /api/stat/refundOrder/add [POST] // @Param param body proto.AddRefundOrderReq true "参数" // @Success 200 {object} proto.AddRefundOrderResp "成功" // @Security ApiKeyAuth func Add(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.AddRefundOrderReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } resp, err := refundOrderSer.Add(ctx, req) if err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, resp) } // @Tags 退款订单管理 // @Summary 批量新增退款订单 // @Description 传入 cid 列表,逐个查询 log_recharge 回填 // @Router /api/stat/refundOrder/batchAdd [POST] // @Param param body proto.BatchAddRefundOrderReq true "参数" // @Success 200 {object} proto.AddRefundOrderResp "成功" // @Security ApiKeyAuth func BatchAdd(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.BatchAddRefundOrderReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } resp, err := refundOrderSer.BatchAdd(ctx, req) if err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, resp) } // @Tags 退款订单管理 // @Summary 删除退款订单 // @Description 按记录 _id 删除 // @Router /api/stat/refundOrder/del [POST] // @Param param body proto.DelRefundOrderReq true "参数" // @Success 200 {string} string "成功" // @Security ApiKeyAuth func Del(ctx *gin.Context) { account, err := utils.GetAdmin(ctx) if err != nil { stdLog.ServerJSON(ctx, stdLog.NoToken, err.Error()) return } req := &proto.DelRefundOrderReq{} if err := ctx.ShouldBindJSON(req); err != nil { stdLog.ServerJSON(ctx, stdLog.ParamError, err.Error()) return } if err := refundOrderSer.Del(ctx, req); err != nil { stdLog.ServerJSON(ctx, stdLog.Failure, err.Error()) return } opLogSer.AddOpLog(ctx, account, true, req) stdLog.ServerJSON(ctx, stdLog.Success, "") }