添加余量管理接口

This commit is contained in:
lzh 2025-06-12 17:51:24 +08:00
parent 7bd70e8968
commit 3b3efcb534
12 changed files with 1536 additions and 581 deletions

View File

@ -1,17 +1,19 @@
package main
import (
bundleConfig "micro-bundle/config"
"micro-bundle/internal/controller"
_ "micro-bundle/internal/handler"
"micro-bundle/internal/logic"
"micro-bundle/pkg/app"
"micro-bundle/pkg/tracing"
"dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/tps/strategy"
_ "dubbo.apache.org/dubbo-go/v3/imports"
"github.com/bwmarrin/snowflake"
"go.uber.org/zap"
"gorm.io/gorm"
bundleConfig "micro-bundle/config"
"micro-bundle/internal/controller"
_ "micro-bundle/internal/handler"
"micro-bundle/pkg/app"
"micro-bundle/pkg/tracing"
)
func NewApp(Lg *zap.Logger, JaegerTracer *tracing.JaegerProvider, SfNode *snowflake.Node, BundleDB *gorm.DB) *app.App {
@ -30,7 +32,8 @@ func main() {
if err != nil {
panic(err)
}
logic.GetBundleBalance(nil)
return
//l, err := net.Listen("tcp", ":8883")
//if err != nil {
// fmt.Printf("failed to listen: %v", err)

7
go.mod
View File

@ -17,6 +17,7 @@ require (
github.com/mwitkow/go-proto-validators v0.3.2
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/opentracing/opentracing-go v1.2.0
github.com/samber/lo v1.51.0
github.com/spf13/viper v1.7.1
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
github.com/uber/jaeger-client-go v2.30.0+incompatible
@ -24,6 +25,7 @@ require (
google.golang.org/protobuf v1.29.1
gorm.io/driver/mysql v1.4.7
gorm.io/gorm v1.25.12
gorm.io/plugin/soft_delete v1.2.1
)
require (
@ -142,9 +144,9 @@ require (
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/text v0.22.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.54.0 // indirect
@ -152,5 +154,4 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/plugin/soft_delete v1.2.1 // indirect
)

10
go.sum
View File

@ -612,6 +612,7 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-sqlite3 v1.14.3 h1:j7a/xn1U6TKA/PHHxqZuzh64CdtRc7rU9M+AvkOl5bA=
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
@ -782,6 +783,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM=
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
@ -1111,8 +1114,9 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -1223,8 +1227,9 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -1481,6 +1486,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.4.7 h1:rY46lkCspzGHn7+IYsNpSfEv9tA+SU4SkkB+GFX125Y=
gorm.io/driver/mysql v1.4.7/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc=
gorm.io/driver/sqlite v1.1.3 h1:BYfdVuZB5He/u9dt4qDpZqiqDJ6KhPqs5QUqsr/Eeuc=
gorm.io/driver/sqlite v1.1.3/go.mod h1:AKDgRWk8lcSQSw+9kxCJnX/yySj8G3rdwYlU57cB45c=
gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.23.0/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=

View File

@ -41,3 +41,7 @@ func (b *BundleProvider) BundleExtend(_ context.Context, req *bundle.BundleExten
func (b *BundleProvider) BundleExtendRecordsList(_ context.Context, req *bundle.BundleExtendRecordsListRequest) (*bundle.BundleExtendRecordsListResponse, error) {
return logic.BundleExtendRecordsList(req)
}
func (b *BundleProvider) GetBundleBalance(_ context.Context, req *bundle.GetBundleBalanceReq) (*bundle.GetBundleBalanceResp, error) {
return logic.GetBundleBalance(req)
}

View File

@ -396,33 +396,82 @@ func GetBundleExtendRecordList(req *bundle.BundleExtendRecordsListRequest) ([]mo
Model(&model.BundleExtensionRecords{}).
Joins("left join `fontree-account`.`user` fu on operator_id = fu.id left join `micro-account`.`user` mu on user_id = mu.id ")
if req.EndTime != 0 {
session.Where("bundle_extension_records.created_at < ?", time.Unix(int64(req.EndTime), 0))
session = session.Where("bundle_extension_records.created_at < ?", time.Unix(int64(req.EndTime), 0))
}
if req.StartTime != 0 {
session.Where("bundle_extension_records.created_at > ?", time.Unix(int64(req.StartTime), 0))
session = session.Where("bundle_extension_records.created_at > ?", time.Unix(int64(req.StartTime), 0))
}
if req.Operator != "" {
if utils.IsPhoneNumber(req.Operator) {
session.Where("fu.tel_num = ?", req.Operator)
session = session.Where("fu.tel_num = ?", req.Operator)
} else {
session.Where("fu.nickname = ?", req.Operator)
session = session.Where("fu.nickname = ?", req.Operator)
}
}
if req.User != "" {
if utils.IsPhoneNumber(req.User) {
session.Where("mu.tel_num = ?", req.User)
session = session.Where("mu.tel_num = ?", req.User)
} else {
session.Where("mu.nickname = ?", req.User)
session = session.Where("mu.nickname = ?", req.User)
}
}
if req.AssociatedOrderNumber != "" {
session.Where("associated_order_number = ?", req.AssociatedOrderNumber)
session = session.Where("associated_order_number = ?", req.AssociatedOrderNumber)
}
if req.Type != 0 {
session.Where("`type` = ?", req.Type)
session = session.Where("`type` = ?", req.Type)
}
var total int64
res := []model.BundleExtendRecordItemPo{}
session.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize)).Find(&res).Count(&total)
return res, total, session.Error
}
func GetBundleBalance(req *bundle.GetBundleBalanceReq) (data []model.BundleBalancePo, err error) {
subQuery := app.ModuleClients.BundleDB.Table("fiee_bundle.bundle_order_records").
Select("customer_id, MAX(created_at) as max_created_at").
Group("customer_id")
app.ModuleClients.BundleDB.Table("fiee_bundle.bundle_order_records AS bor").
Select(`
bor.customer_id as user_id,
u.nickname as user_name,
u.tel_num as user_phone_number,
bor.bundle_name as bundle_name,
bor.expiration_time as expiration_time,
bor.status as bundle_status,
bova.num as service_num,
bova.service_type as service_type,
cw.work_category as work_category,
cw.uuid as cw_uuid,
bova.uuid as bova_uuid,
cma.user_id as cma_uuid
`).
Joins("JOIN (?) t ON bor.customer_id = t.customer_id AND bor.created_at = t.max_created_at", subQuery).
Joins("LEFT JOIN fiee_bundle.bundle_order_value_add bova ON bova.order_uuid = bor.uuid").
Joins("LEFT JOIN fiee_bundle.cast_work cw ON cw.artist_uuid = bor.customer_id AND cw.created_at > UNIX_TIMESTAMP(bor.created_at)").
Joins("LEFT JOIN `micro-account`.`user` u ON u.id = bor.customer_id").
Joins("LEFT JOIN fiee_bundle.cast_media_account cma ON cma.artist_uuid = u.id").
Where("bor.customer_id != ?", "").
Scan(&data)
return
}
// func GetBundleCapacity(tx *gorm.DB) {
// // 子查询: 每个 customer_id 的最新 created_at
// subQuery := tx.Table("fiee_bundle.bundle_order_records").
// Select("customer_id, MAX(created_at) as max_created_at").
// Group("customer_id")
// // 主查询
// tx.Table("fiee_bundle.bundle_order_records AS bor").
// Select("bor.*, bova.*").
// Joins("JOIN (?) t ON bor.customer_id = t.customer_id AND bor.created_at = t.max_created_at", subQuery).
// Joins("LEFT JOIN fiee_bundle.bundle_order_value_add bova ON bova.order_uuid = bor.uuid").
// Where("bor.created_at < bova.created_at").
// Where("bor.expiration_time > NOW()").
// Scan(&results)
// }
// func GetBundleUsage(tx *gorm.DB, userIds []int){
// }

View File

@ -1,18 +1,22 @@
package logic
import (
"encoding/json"
"errors"
"fmt"
"micro-bundle/internal/dao"
"micro-bundle/pkg/app"
"micro-bundle/pkg/msg"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"github.com/jinzhu/copier"
"gorm.io/gorm"
"time"
"micro-bundle/internal/model"
"micro-bundle/pb/bundle"
"dubbo.apache.org/dubbo-go/v3/common/logger"
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/utils"
"github.com/jinzhu/copier"
"github.com/samber/lo"
"gorm.io/gorm"
)
func CreateBundle(req *bundle.BundleProfile) (res *bundle.CommonResponse, err error) {
@ -381,3 +385,89 @@ func BundleExtendRecordsList(req *bundle.BundleExtendRecordsListRequest) (*bundl
err = copier.Copy(result.Data, &data)
return result, err
}
func GetBundleBalance(req *bundle.GetBundleBalanceReq) (*bundle.GetBundleBalanceResp, error) {
data, err := dao.GetBundleBalance(req)
if err != nil {
return nil, err
}
fmt.Printf("len(data): %v\n", len(data))
dataByte, _ := json.Marshal(data)
fmt.Print(string(dataByte) + "\n")
type userDataDto struct {
UserID int
UserName string
UserPhoneNumber string
BundleName string
ExpirationTime time.Time
BundleStatus string
VideoCap int
ImageCap int
DataAnalysisCap int
AccountCap int
}
usersMap := map[int]*userDataDto{}
lo.ForEach(data, func(data model.BundleBalancePo, index int) {
fmt.Printf("data.UserID: %v\n", data.UserID)
_, ok := usersMap[data.UserID]
if !ok {
usersMap[data.UserID] = &userDataDto{
UserID: data.UserID,
UserName: data.UserName,
UserPhoneNumber: data.UserPhoneNumber,
BundleStatus: data.BundleStatus,
ExpirationTime: data.ExpirationTime,
}
}
})
for _, user := range usersMap {
userData := lo.Filter(data, func(data model.BundleBalancePo, _ int) bool {
return data.UserID == user.UserID
})
// 可用量计算
lo.ForEach(lo.UniqBy(lo.Filter(userData, func(data model.BundleBalancePo, _ int) bool {
return data.BovaUUID != nil
}), func(data model.BundleBalancePo) string {
return *data.BovaUUID
}), func(data model.BundleBalancePo, index int) {
logger.Infof("增加数据类型%v(%v),user_id:%v,uuid:%v", data.ServiceType, data.ServiceNum, data.UserID, *data.BovaUUID)
switch data.ServiceType {
case 1:
user.VideoCap += data.ServiceNum
case 2:
user.ImageCap += data.ServiceNum
case 3:
user.DataAnalysisCap += data.ServiceNum
case 4:
user.AccountCap += data.ServiceNum
}
})
lo.ForEach(lo.UniqBy(lo.Filter(userData, func(data model.BundleBalancePo, _ int) bool {
return data.CwUUID != nil
}), func(data model.BundleBalancePo) string {
return *data.CwUUID
}), func(data model.BundleBalancePo, index int) {
logger.Infof("减少数据类型%v,user_id:%v,uuid:%v", data.ServiceType, data.UserID, *data.CwUUID)
switch data.WorkCategory {
case 1:
user.ImageCap--
case 2:
user.VideoCap--
default:
logger.Warn("不存在的数据类型:", data.WorkCategory)
}
})
lo.ForEach(lo.UniqBy(lo.Filter(userData, func(data model.BundleBalancePo, _ int) bool {
return data.CmaUUID != nil
}), func(data model.BundleBalancePo) string {
return *data.CmaUUID
}), func(data model.BundleBalancePo, index int) {
logger.Infof("减少数据类型%v,user_id:%v,uuid:%v", "account", data.UserID, *data.CmaUUID)
user.AccountCap--
})
}
b, _ := json.Marshal(usersMap)
fmt.Print(string(b))
return nil, nil
}

View File

@ -85,8 +85,10 @@ type BundleExtensionRecords struct {
AvailableDurationAdditional uint `gorm:"column:available_duration_additional;type:int(11) unsigned;comment:可用时长增加" json:"available_duration_additional"`
Type int `gorm:"column:type;type:tinyint(4);comment:类型 0:手动操作" json:"type"`
Remark string `gorm:"column:remark;type:text;comment:备注" json:"remark"`
AssociatedOrderNumber string `gorm:"column:associated_order_number;type:varchar(1024);comment:关联增值服务订单号" json:"associated_order_number"`
AssociatedOrderNumber string `gorm:"column:associated_order_number;type:varchar(256);comment:关联增值服务订单号" json:"associated_order_number"`
OperatorId int `gorm:"column:operator_id;type:int(11);comment:操作人id" json:"operator_id"`
OperatorName string `gorm:"column:operator_name;type:varchar(256)" json:"operatorName"`
OperatorPhoneNumber string `gorm:"column:operator_phone_number;type:varchar(256)" json:"operatorPhoneNumber"`
}
// TableName 表名称
@ -95,33 +97,22 @@ func (*BundleExtensionRecords) TableName() string {
}
type BundleExtendRecordItemPo struct {
UserName string `json:"userName" gorm:"column:user_name"`
UserPhoneNumber int64 `json:"userPhoneNumber" gorm:"column:user_phone_number"`
AccountAdditional uint32 `json:"accountAdditional" gorm:"column:account_additional"`
VideoAdditional uint32 `json:"videoAdditional" gorm:"column:video_additional"`
ImagesAdditional uint32 `json:"imagesAdditional" gorm:"column:images_additional"`
DataAdditional uint32 `json:"dataAdditional" gorm:"column:data_additional"`
AvailableDurationAdditional uint32 `json:"availableDurationAdditional" gorm:"column:available_duration_additional"`
Type int32 `json:"type" gorm:"column:type"`
CreatedAt time.Time `json:"createdAt" gorm:"column:created_at"`
Remark string `json:"remark" gorm:"column:remark"`
AssociatedOrderNumber string `json:"associatedOrderNumber" gorm:"column:associated_order_number"`
OperatorName string `json:"operatorName" gorm:"column:operator_name"`
OperatorPhoneNumber string `json:"operatorPhoneNumber" gorm:"column:operator_phone_number"`
BundleExtensionRecords
UserName string `json:"userName" gorm:"column:user_name"`
UserPhoneNumber int64 `json:"userPhoneNumber" gorm:"column:user_phone_number"`
}
type BundleBalanceManagement struct {
gorm.Model
UserId int `gorm:"column:user_id;type:int(11);NOT NULL" json:"user_id"`
ExpirationTime time.Time `gorm:"column:expiration_time;type:timestamp;default:CURRENT_TIMESTAMP;NOT NULL" json:"expiration_time"`
BundleName string `gorm:"column:bundle_name;type:varchar(1024);NOT NULL" json:"bundle_name"`
AccountNumber int `gorm:"column:account_number;type:int(11);NOT NULL" json:"account_number"`
VideoNumber int `gorm:"column:video_number;type:int(11);NOT NULL" json:"video_number"`
ImageNumber int `gorm:"column:image_number;type:int(11);NOT NULL" json:"image_number"`
DataAnalysisNumber int `gorm:"column:data_analysis_number;type:int(11);NOT NULL" json:"data_analysis_number"`
ExpansionPacksNumber int `gorm:"column:expansion_packs_number;type:int(11);default:0" json:"expansion_packs_number"`
}
func (m *BundleBalanceManagement) TableName() string {
return "bundle_balance_management"
type BundleBalancePo struct {
UserID int `gorm:"column:user_id"`
UserName string `gorm:"column:user_name"`
UserPhoneNumber string `gorm:"column:user_phone_nmber"`
BundleName string `gorm:"column:bundle_name"`
ExpirationTime time.Time `gorm:"column:expired_time"`
BundleStatus string `gorm:"column:bundle_status"`
ServiceNum int `gorm:"column:service_num"`
ServiceType int `gorm:"column:service_type"`
WorkCategory int `gorm:"column:work_category"`
CwUUID *string `gorm:"column:cw_uuid"`
BovaUUID *string `gorm:"column:bova_uuid"`
CmaUUID *string `gorm:"column:cma_uuid"`
}

View File

@ -42,6 +42,7 @@ service Bundle {
//
rpc BundleExtend(BundleExtendRequest) returns (BundleExtendResponse) {} //
rpc BundleExtendRecordsList(BundleExtendRecordsListRequest) returns (BundleExtendRecordsListResponse) {} //
rpc GetBundleBalance(GetBundleBalanceReq) returns (GetBundleBalanceResp) {} //
}
@ -326,7 +327,8 @@ message BundleExtendRequest{
uint32 availableDurationAdditional = 6;
string remark = 7;
string associatedorderNumber = 8;
int64 operatorId = 9;
string operatorName = 9;
string operatorPhoneNumber = 10;
}
message BundleExtendResponse{
@ -364,17 +366,27 @@ message BundleExtendRecordItem{
string operatorPhoneNumber = 13;
}
message SetBundleBalanceRequest {
int32 userId = 1;
int64 expirationTime = 2;
message GetBundleBalanceReq{
string userName = 1;
int32 status = 2;
string bundleName = 3;
int32 accountNumber = 4;
int32 videoNumber = 5;
int32 imageNumber = 6;
int32 dataAnalysisNumber = 7;
int32 expansionPacksNumber = 8;
int64 expiredTimeStart = 4;
int64 expiredTimeEnd = 5;
}
message SetBundleBalanceResponse {
message GetBundleBalanceResp{
string userName = 1;
string userPhoneNumber = 2;
int32 status = 3;
string bundleName = 4;
int64 expiredTime = 5;
int32 accountNumber = 6;
int32 accountConsumptionNumber = 7;
int32 videoNumber = 8;
int32 videoConsumptionNumber = 9;
int32 imageNumber = 10;
int32 imageConsumptionNumber = 11;
int32 dataAnalysisNumber = 12;
int32 dataAnalysisConsumptionNumber = 13;
int32 expansionPacksNumber = 14;
}

File diff suppressed because it is too large Load Diff

View File

@ -246,9 +246,9 @@ func (this *BundleExtendRecordsListResponse) Validate() error {
func (this *BundleExtendRecordItem) Validate() error {
return nil
}
func (this *SetBundleBalanceRequest) Validate() error {
func (this *GetBundleBalanceReq) Validate() error {
return nil
}
func (this *SetBundleBalanceResponse) Validate() error {
func (this *GetBundleBalanceResp) Validate() error {
return nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v4.24.0--rc1
// - protoc v3.20.3
// source: pb/bundle.proto
package bundle
@ -54,7 +54,7 @@ type BundleClient interface {
// 余量管理
BundleExtend(ctx context.Context, in *BundleExtendRequest, opts ...grpc_go.CallOption) (*BundleExtendResponse, common.ErrorWithAttachment)
BundleExtendRecordsList(ctx context.Context, in *BundleExtendRecordsListRequest, opts ...grpc_go.CallOption) (*BundleExtendRecordsListResponse, common.ErrorWithAttachment)
SetBundleBalance(ctx context.Context, in *SetBundleBalanceRequest, opts ...grpc_go.CallOption) (*SetBundleBalanceResponse, common.ErrorWithAttachment)
GetBundleBalance(ctx context.Context, in *GetBundleBalanceReq, opts ...grpc_go.CallOption) (*GetBundleBalanceResp, common.ErrorWithAttachment)
}
type bundleClient struct {
@ -85,7 +85,7 @@ type BundleClientImpl struct {
ValueAddServiceDetail func(ctx context.Context, in *ValueAddServiceDetailRequest) (*ValueAddServiceDetailResponse, error)
BundleExtend func(ctx context.Context, in *BundleExtendRequest) (*BundleExtendResponse, error)
BundleExtendRecordsList func(ctx context.Context, in *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
SetBundleBalance func(ctx context.Context, in *SetBundleBalanceRequest) (*SetBundleBalanceResponse, error)
GetBundleBalance func(ctx context.Context, in *GetBundleBalanceReq) (*GetBundleBalanceResp, error)
}
func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient {
@ -238,10 +238,10 @@ func (c *bundleClient) BundleExtendRecordsList(ctx context.Context, in *BundleEx
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleExtendRecordsList", in, out)
}
func (c *bundleClient) SetBundleBalance(ctx context.Context, in *SetBundleBalanceRequest, opts ...grpc_go.CallOption) (*SetBundleBalanceResponse, common.ErrorWithAttachment) {
out := new(SetBundleBalanceResponse)
func (c *bundleClient) GetBundleBalance(ctx context.Context, in *GetBundleBalanceReq, opts ...grpc_go.CallOption) (*GetBundleBalanceResp, common.ErrorWithAttachment) {
out := new(GetBundleBalanceResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SetBundleBalance", in, out)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetBundleBalance", in, out)
}
// BundleServer is the server API for Bundle service.
@ -274,7 +274,7 @@ type BundleServer interface {
// 余量管理
BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error)
BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
SetBundleBalance(context.Context, *SetBundleBalanceRequest) (*SetBundleBalanceResponse, error)
GetBundleBalance(context.Context, *GetBundleBalanceReq) (*GetBundleBalanceResp, error)
mustEmbedUnimplementedBundleServer()
}
@ -352,8 +352,8 @@ func (UnimplementedBundleServer) BundleExtend(context.Context, *BundleExtendRequ
func (UnimplementedBundleServer) BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method BundleExtendRecordsList not implemented")
}
func (UnimplementedBundleServer) SetBundleBalance(context.Context, *SetBundleBalanceRequest) (*SetBundleBalanceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetBundleBalance not implemented")
func (UnimplementedBundleServer) GetBundleBalance(context.Context, *GetBundleBalanceReq) (*GetBundleBalanceResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBundleBalance not implemented")
}
func (s *UnimplementedBundleServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
@ -1050,8 +1050,8 @@ func _Bundle_BundleExtendRecordsList_Handler(srv interface{}, ctx context.Contex
return interceptor(ctx, in, info, handler)
}
func _Bundle_SetBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(SetBundleBalanceRequest)
func _Bundle_GetBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBundleBalanceReq)
if err := dec(in); err != nil {
return nil, err
}
@ -1063,7 +1063,7 @@ func _Bundle_SetBundleBalance_Handler(srv interface{}, ctx context.Context, dec
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("SetBundleBalance", args, invAttachment)
invo := invocation.NewRPCInvocation("GetBundleBalance", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
@ -1179,8 +1179,8 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
Handler: _Bundle_BundleExtendRecordsList_Handler,
},
{
MethodName: "SetBundleBalance",
Handler: _Bundle_SetBundleBalance_Handler,
MethodName: "GetBundleBalance",
Handler: _Bundle_GetBundleBalance_Handler,
},
},
Streams: []grpc_go.StreamDesc{},

View File

@ -50,6 +50,7 @@ func loadMysqlConn(conn string) *gorm.DB {
&model.ValueAddServiceLang{},
&model.BundleToValueAddService{},
&model.BundleOrderValueAdd{},
&model.BundleExtensionRecords{},
)
if err != nil {