init: 初始化 web_hgdjb_server 项目
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package rechargeapi
|
||||
|
||||
import (
|
||||
"videoweb/app/service/rechargeser"
|
||||
"videoweb/pub/common"
|
||||
"videoweb/pub/common/enum/consts"
|
||||
"videoweb/pub/common/ipaddr"
|
||||
"videoweb/pub/common/srvdef"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type submitOrderReq struct {
|
||||
PackageId int64 `json:"packageId" binding:"required"` // 购买套餐ID(会员畅享)
|
||||
PayMode string `json:"payMode" binding:"required"` // 支付方式:alipay/wechat
|
||||
SourcePageKey string `json:"sourcePageKey"` // 下单来源页面标识
|
||||
SourcePageName string `json:"sourcePageName"` // 下单来源页面名称
|
||||
}
|
||||
|
||||
// SubmitOrder 发起第三方支付下单
|
||||
// @Tags 充值
|
||||
// @Summary 创建 VIP 充值订单(第三方支付)
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param param body submitOrderReq true "下单参数"
|
||||
// @Success 200 {object} rechargeser.SubmitOrderResp "支付链接"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/app/vip/pay [POST]
|
||||
func SubmitOrder(ctx *gin.Context) {
|
||||
var req submitOrderReq
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
userId := common.GetUserId(ctx)
|
||||
sysType := ctx.GetString(consts.CtxSysType)
|
||||
devType := ctx.GetString(consts.CtxDevType)
|
||||
ip := ipaddr.ResolveClientIP(ctx)
|
||||
|
||||
user, serr := rechargeser.GetUserInfo(ctx, userId)
|
||||
if serr != nil || user == nil {
|
||||
common.ServerJSON(ctx, srvdef.ErrUserNotExsit, nil)
|
||||
return
|
||||
}
|
||||
|
||||
deviceID := rechargeser.PayDeviceID(ctx.GetString(consts.CtxDevId), user.DevID, user.DevV2)
|
||||
resp, serr := rechargeser.CreateOrder(ctx, userId, user.NickName, req.PackageId, req.PayMode, sysType, devType, deviceID, ip, user.DistrictCode, req.SourcePageKey, req.SourcePageName)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, resp)
|
||||
}
|
||||
|
||||
type orderHistoryReq struct {
|
||||
Page int64 `json:"page" form:"page"`
|
||||
PageSize int64 `json:"pageSize" form:"pageSize"`
|
||||
}
|
||||
|
||||
// GetOrderHistory 查询当前用户 VIP 订单历史
|
||||
// @Tags 充值
|
||||
// @Summary 查询 VIP 充值记录
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "页码(默认1)"
|
||||
// @Param pageSize query int false "每页数量(默认10)"
|
||||
// @Success 200 {array} vipordermod.VipOrder "订单列表"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/app/vip/orders [GET]
|
||||
func GetOrderHistory(ctx *gin.Context) {
|
||||
var req orderHistoryReq
|
||||
_ = ctx.ShouldBindQuery(&req)
|
||||
if req.Page <= 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
if req.PageSize <= 0 {
|
||||
req.PageSize = 10
|
||||
}
|
||||
|
||||
userId := common.GetUserId(ctx)
|
||||
list, total, serr := rechargeser.GetOrderHistory(ctx, userId, req.Page, req.PageSize)
|
||||
if serr != nil {
|
||||
common.ServerJSON(ctx, serr.Code, serr.Tips)
|
||||
return
|
||||
}
|
||||
common.ServerJSON(ctx, srvdef.Success, gin.H{"total": total, "list": list})
|
||||
}
|
||||
Reference in New Issue
Block a user