增加退单管理
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package proto
|
||||
|
||||
import (
|
||||
"stat/models/refundOrderMod"
|
||||
)
|
||||
|
||||
// ============ 退款订单管理 ============
|
||||
|
||||
// RefundOrderListReq 退款订单查询。所有过滤条件均为可选,不传表示不限制
|
||||
type RefundOrderListReq struct {
|
||||
AppId *int32 `json:"appId" form:"appId"` // appId
|
||||
UserId *uint64 `json:"userId" form:"userId"` // 用户ID
|
||||
CID *string `json:"cid" form:"cid"` // 渠道id
|
||||
ChannelName *string `json:"channelName" form:"channelName"` // 支付渠道名字
|
||||
DistrictCode *string `json:"districtCode" form:"districtCode"` // 渠道码
|
||||
PageNum int64 `json:"pageNum" form:"pageNum" binding:"required,gte=1"`
|
||||
PageSize int64 `json:"pageSize" form:"pageSize" binding:"required,gte=1,lte=500"`
|
||||
}
|
||||
|
||||
type RefundOrderListResp struct {
|
||||
Total int64 `json:"total"`
|
||||
List refundOrderMod.RefundOrderList `json:"list"`
|
||||
}
|
||||
|
||||
// AddRefundOrderReq 按 cid 回填新增。服务端据此查询 log_recharge 的成功订单并逐条落库
|
||||
type AddRefundOrderReq struct {
|
||||
CID string `json:"cid" binding:"required"` // 渠道id
|
||||
}
|
||||
|
||||
// BatchAddRefundOrderReq 批量按 cid 回填新增
|
||||
type BatchAddRefundOrderReq struct {
|
||||
CIDs []string `json:"cids" binding:"required,min=1,max=200"` // 渠道id列表
|
||||
}
|
||||
|
||||
// AddRefundOrderResp 回填结果
|
||||
type AddRefundOrderResp struct {
|
||||
Matched int64 `json:"matched"` // log_recharge 命中的成功订单数
|
||||
Inserted int64 `json:"inserted"` // 实际新增条数
|
||||
Skipped int64 `json:"skipped"` // 因已存在而跳过的条数
|
||||
Details []RefundCidStat `json:"details"` // 按 cid 分项,单条新增时只有一项
|
||||
}
|
||||
|
||||
type RefundCidStat struct {
|
||||
CID string `json:"cid"`
|
||||
Matched int64 `json:"matched"`
|
||||
Inserted int64 `json:"inserted"`
|
||||
Skipped int64 `json:"skipped"`
|
||||
}
|
||||
|
||||
// DelRefundOrderReq 按 _id 删除
|
||||
type DelRefundOrderReq struct {
|
||||
Id string `json:"id" binding:"required"` // 记录 _id (24位十六进制)
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
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, "")
|
||||
}
|
||||
Reference in New Issue
Block a user