@@ -0,0 +1,226 @@
|
||||
package productctrl
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/advance_ser"
|
||||
"91porn-server/app/service/integral_config_ser"
|
||||
"91porn-server/models/v/integralconfigmod"
|
||||
"net/http"
|
||||
|
||||
"91porn-server/app/service/productser"
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/commod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type BuyProductRequest struct {
|
||||
ProductType commod.ProductType `form:"productType" json:"productType" bson:"productType"`
|
||||
ProductID primitive.ObjectID `form:"productID" json:"productID" binding:"required" bson:"productID"`
|
||||
ContentID primitive.ObjectID `form:"contentID" json:"contentID" bson:"contentID"`
|
||||
CheckoutContextID string `form:"checkoutContextId" json:"checkoutContextId"`
|
||||
ChapterID string `form:"chapterID" json:"chapterID"`
|
||||
CouponID primitive.ObjectID `form:"couponId" json:"couponId"`
|
||||
ServiceID primitive.ObjectID `form:"serviceId" json:"serviceId"`
|
||||
GoldVideoCouponNum int `form:"goldVideoCouponNum" json:"goldVideoCouponNum"`
|
||||
IsH5 bool `form:"isH5" json:"isH5"`
|
||||
Num uint64 `json:"num" form:"num"`
|
||||
UserContact string `json:"userContact" form:"userContact"`
|
||||
ExperimentID string `json:"experimentId" form:"experimentId"`
|
||||
ExperimentVariant string `json:"experimentVariant" form:"experimentVariant"`
|
||||
SessionID string `json:"sessionId" form:"sessionId"`
|
||||
}
|
||||
|
||||
// BuyProduct doc
|
||||
// @Summary 商品购买
|
||||
// @Description 商品购买
|
||||
// @Tags product
|
||||
// @Accept json,mpfd
|
||||
// @Produce json,html
|
||||
// @Param request body productctrl.BuyProductRequest true "购买参数;短剧单集解锁时productType=19且contentID、checkoutContextId必填"
|
||||
// @Param X-Request-ID header string false "短剧单集购买幂等ID"
|
||||
// @Success 200 {object} productser.BuyDramaEpisodeResponse "短剧单集购买成功时的数据结构"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/app/product/buy [post]
|
||||
func BuyProduct(ctx *gin.Context) {
|
||||
uid, err := common.GetUID(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err.Error())
|
||||
return
|
||||
}
|
||||
ua, err := common.GetUA(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
ip := common.GetIP(ctx)
|
||||
args := BuyProductRequest{}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if args.ProductType == commod.Media && !args.ContentID.IsZero() {
|
||||
data, code := productser.BuyDramaEpisode(
|
||||
uid, args.ProductID, args.ContentID, args.CheckoutContextID,
|
||||
ctx.GetHeader("X-Request-ID"), ua, ip,
|
||||
)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, data)
|
||||
return
|
||||
}
|
||||
code := productser.Buy(uid, args.ProductType, args.ProductID, args.CouponID, args.ServiceID, args.Num, args.UserContact, ua.SysType,
|
||||
args.ChapterID, args.GoldVideoCouponNum, args.IsH5, ua, ip, productser.VIPExperimentAttribution{
|
||||
ExperimentID: args.ExperimentID,
|
||||
ExperimentVariant: args.ExperimentVariant,
|
||||
SessionID: args.SessionID,
|
||||
})
|
||||
common.ServeJSON(ctx, code, nil)
|
||||
}
|
||||
|
||||
// DelBroughtProductHistory doc
|
||||
// @Summary 删除购买视频
|
||||
// @Description 删除购买视频
|
||||
// @Tags product
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param productID formData string true "产品id"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /product/delBrought [post]
|
||||
func DelBroughtProductHistory(ctx *gin.Context) {
|
||||
uid, err := common.GetUID(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err.Error())
|
||||
return
|
||||
}
|
||||
args := struct {
|
||||
ProductID primitive.ObjectID `form:"productID" json:"productID" binding:"required" bson:"productID"` //产品id
|
||||
}{}
|
||||
if err = ctx.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if err = productser.DelBroughtHistory(args.ProductID, uid); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbDeleteError, err.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, http.StatusOK, nil)
|
||||
}
|
||||
|
||||
// 获取优惠卷详情
|
||||
func GetCouponDetail(c *gin.Context) {
|
||||
uid, err := common.GetUID(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
ua, err := common.GetUA(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
var params struct {
|
||||
ProductType commod.ProductType `form:"productType"` //产品类型
|
||||
ProductID string `form:"productId" binding:"required"` //产品id
|
||||
}
|
||||
if err = c.ShouldBindQuery(¶ms); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
data, code := productser.GetCouponDetail(uid, params.ProductID, params.ProductType, ua.SysType)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
|
||||
// 金币月卡获取金币
|
||||
func GetCoinMonthCoin(c *gin.Context) {
|
||||
uid, err := common.GetUID(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
data, code := productser.GetCoin(uid)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
|
||||
// GetAwVip doc
|
||||
// @Summary 获取暗网VIP会员卡
|
||||
// @Description 获取暗网VIP会员卡
|
||||
// @Tags 产品配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /app/product/getAwVip [get]
|
||||
func GetAwVip(c *gin.Context) {
|
||||
uid, err := common.GetUID(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
data, code := productser.GetAwVipInfo(uid)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(c, code, nil)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(c, code, data)
|
||||
}
|
||||
|
||||
// ExchangeIntegral doc
|
||||
// @Summary 积分兑换
|
||||
// @Description 积分兑换
|
||||
// @Tags 产品配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param id formData string true "积分兑换配置ID"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /app/product/exchangeIntegral [post]
|
||||
func ExchangeIntegral(ctx *gin.Context) {
|
||||
uid, err := common.GetUID(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
var in integralconfigmod.ExchangeIntegralReq
|
||||
if err = ctx.ShouldBind(&in); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
code := integral_config_ser.ExchangeIntegral(uid, &in)
|
||||
if code != stderr.Success {
|
||||
common.ServeJSON(ctx, code, code.Error())
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, code, stderr.Success.Msg())
|
||||
}
|
||||
|
||||
// AdvanceStatus doc
|
||||
// @Summary 获取预售状态
|
||||
// @Description 获取预售状态
|
||||
// @Tags 产品配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 object advanceordermod.AdvanceStatus "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/app/product/advanceStatus [get]
|
||||
func AdvanceStatus(c *gin.Context) {
|
||||
uid, err := common.GetUID(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
advanceStatus := advance_ser.GainAdvanceStatus(uid)
|
||||
common.ServeJSON(c, stderr.Success, advanceStatus)
|
||||
}
|
||||
Reference in New Issue
Block a user