init: hgmj server initial commit
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
package vipctrl
|
||||
|
||||
import (
|
||||
"91jd-server/app/service/integral_config_ser"
|
||||
"91jd-server/common/daichong"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"91jd-server/app/proto"
|
||||
"91jd-server/app/service/productser"
|
||||
"91jd-server/app/service/rechargeser"
|
||||
"91jd-server/app/service/vipcardexperimentser"
|
||||
"91jd-server/common"
|
||||
"91jd-server/common/log"
|
||||
"91jd-server/common/stderr"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Product doc
|
||||
// @Summary vip种类 新
|
||||
// @Description 可购买的vip种类
|
||||
// @Tags vip
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Success 200 {object} proto.ProductRes "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /app/vip/product [get]
|
||||
func Product(ctx *gin.Context) {
|
||||
uid, _ := common.GetUID(ctx)
|
||||
ua, _ := common.GetUA(ctx)
|
||||
var (
|
||||
data = proto.ProductRes{
|
||||
IsNewUser: false,
|
||||
}
|
||||
goldResError error
|
||||
)
|
||||
var arg struct {
|
||||
IsNewUser bool `json:"isNewUser" form:"isNewUser"` // 是否新手
|
||||
}
|
||||
if err := ctx.ShouldBind(&arg); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(3)
|
||||
common.Go(func() {
|
||||
defer wg.Done()
|
||||
countdownSec, _ := productser.CountdownTiroCard(uid)
|
||||
if countdownSec > 0 {
|
||||
data.IsNewUser = true
|
||||
}
|
||||
if arg.IsNewUser == true {
|
||||
data.IsNewUser = arg.IsNewUser
|
||||
}
|
||||
data.List, goldResError = rechargeser.New_ProductList(uid, ua.SysType, data.IsNewUser, 0)
|
||||
})
|
||||
common.Go(func() {
|
||||
defer wg.Done()
|
||||
//d, _ := daichongser.NewTakeChat(ctx, uid, 0)
|
||||
d := daichong.ChatResp{}
|
||||
data.Daichong = d.Data
|
||||
})
|
||||
common.Go(func() {
|
||||
defer wg.Done()
|
||||
data.IntegralList = integral_config_ser.GetAllConfig()
|
||||
})
|
||||
wg.Wait()
|
||||
if goldResError != nil {
|
||||
common.ServeJSON(ctx, stderr.PayBusy, goldResError.Error())
|
||||
return
|
||||
}
|
||||
if err := vipcardexperimentser.ApplyToProductResponse(uid, &data, time.Now()); err != nil {
|
||||
// 实验是增强能力,查询异常时降级到原套餐列表,不能阻断购买主链路。
|
||||
log.Warn("vip card experiment fallback to legacy product response", log.Any("uid", uid), log.E(err))
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, data)
|
||||
}
|
||||
|
||||
// 获取新手卡倒计时
|
||||
func CountdownTiroCard(ctx *gin.Context) {
|
||||
uid, err := common.GetUID(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
countdownSec, err := productser.CountdownTiroCard(uid)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrDbQueryError, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, gin.H{"countdownSec": countdownSec})
|
||||
}
|
||||
|
||||
//// VipRecommend doc
|
||||
//// @Summary vip推荐展示
|
||||
//// @Description vip推荐展示
|
||||
//// @Tags vip
|
||||
//// @Accept mpfd,json
|
||||
//// @Produce json,html
|
||||
//// @Success 200 {object} productmod.Product
|
||||
//// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
//// @Router /api/app/vip/recommend [get]
|
||||
//func VipRecommend(ctx *gin.Context) {
|
||||
// resp, err := productser.GetRecommendVip()
|
||||
// if err != nil {
|
||||
// common.ServeJSON(ctx, stderr.ErrDbQueryError, err)
|
||||
// return
|
||||
// }
|
||||
// common.ServeJSON(ctx, stderr.Success, resp)
|
||||
//}
|
||||
Reference in New Issue
Block a user