feat: 互动处理

This commit is contained in:
Blizzard
2026-03-05 16:54:25 +08:00
parent 74b252550b
commit 2583b5f302
30 changed files with 412 additions and 119 deletions
+7 -5
View File
@@ -7,6 +7,7 @@ import (
common "sundynix-go/model/commom/request"
"sundynix-go/model/radio"
"sundynix-go/model/radio/request"
"sundynix-go/model/system"
"sundynix-go/utils/uniqueid"
"sundynix-go/utils/wechat"
@@ -64,6 +65,11 @@ func (s *SubscriptionService) UnlockChannel(userId string, req request.UnlockCha
if err != nil {
return nil, "", err
}
var user system.User
err = global.DB.Where("id = ?", userId).First(&user).Error
if err != nil || user.OpenId == "" {
return nil, "", err
}
//2.创建一个订单 根据eventType 创建不同的订单
var price int
var orderName string
@@ -81,6 +87,7 @@ func (s *SubscriptionService) UnlockChannel(userId string, req request.UnlockCha
return nil, "", errors.New("无效的订阅类型")
}
order := radio.Order{
Type: 1, //很重要 1订阅 2开通vip
UserId: userId,
OutTradeNo: uniqueid.GenOrderNo(),
ChannelId: req.ChannelId,
@@ -93,11 +100,6 @@ func (s *SubscriptionService) UnlockChannel(userId string, req request.UnlockCha
return nil, "", err
}
//4.调用微信api 拉起支付
var user radio.RadioUser
err = global.DB.Where("user_id = ?", userId).First(&user).Error
if err != nil {
return nil, "", err
}
payClient, err := wechat.GetWxPayClient()
if err != nil {
return nil, "", err