Update:增加先用后付余量出

This commit is contained in:
jiaji.H 2026-06-11 10:27:32 +08:00
parent 4b7c56d1b6
commit 8efae21524
7 changed files with 1652 additions and 1467 deletions

View File

@ -93,11 +93,16 @@ func (b *BundleProvider) BundleActivate(_ context.Context, req *bundle.BundleAct
return nil, logic.BundleActivate(req)
}
// 套餐余额导出
// 普通套餐余额导出
func (b *BundleProvider) BundleBalanceExport(_ context.Context, req *bundle.BundleBalanceExportReq) (*bundle.BundleBalanceExportResp, error) {
return logic.BundleBalanceExport(req)
}
// 先用后付套餐余额导出
func (b *BundleProvider) PayLaterBundleBalanceExport(_ context.Context, req *bundle.BundleBalanceExportReq) (*bundle.PayLaterBundleBalanceExportResp, error) {
return logic.PayLaterBundleBalanceExport(req)
}
func (b *BundleProvider) GetBundleBalanceLayout(_ context.Context, req *bundle.GetBundleBalanceLayoutReq) (*bundle.GetBundleBalanceLayoutResp, error) {
return logic.GetBundleBalanceLayout(req)
}

View File

@ -226,6 +226,12 @@ func GetPayLaterBundleBalanceList(req *bundle.GetPayLaterBundleBalanceListReq) (
if req.ExpiredTimeStart != 0 {
session = session.Where("lb.expired_at >= ?", time.UnixMilli(req.ExpiredTimeStart))
}
if req.StartTimeStart != 0 {
session = session.Where("bor.created_at >= ?", time.UnixMilli(req.StartTimeStart))
}
if req.StartTimeEnd != 0 {
session = session.Where("bor.created_at <= ?", time.UnixMilli(req.StartTimeEnd))
}
err = session.Count(&total).Error
if err != nil {
return

View File

@ -764,6 +764,24 @@ func BundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.BundleBala
return &bundle.BundleBalanceExportResp{Total: int64(len(items)), Data: items}, nil
}
func PayLaterBundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.PayLaterBundleBalanceExportResp, error) {
data, err := GetPayLaterBundleBalanceList(&bundle.GetPayLaterBundleBalanceListReq{
Month: req.Month,
UserName: req.UserName,
ExpiredTimeStart: int64(req.ExpiredTimeStart),
ExpiredTimeEnd: int64(req.ExpiredTimeEnd),
Page: 1,
PageSize: 99999,
})
if err != nil {
return nil, errors.New("先用后付套餐余量导出失败")
}
return &bundle.PayLaterBundleBalanceExportResp{
Total: data.Total,
Data: data.Data,
}, nil
}
func GetBundleBalanceLayout(req *bundle.GetBundleBalanceLayoutReq) (*bundle.GetBundleBalanceLayoutResp, error) {
data, err := dao.GetBundleBalanceLayout(req)
if err != nil { // 返回默认值

View File

@ -63,7 +63,8 @@ service Bundle {
rpc CreateBundleBalance(CreateBundleBalanceReq) returns (CreateBundleBalanceResp) {} //
rpc AddBundleBalance(AddBundleBalanceReq) returns (AddBundleBalanceResp) {} //
rpc BundleActivate(BundleActivateReq) returns (BundleActivateResp) {} //
rpc BundleBalanceExport(BundleBalanceExportReq) returns (BundleBalanceExportResp) {} //
rpc BundleBalanceExport(BundleBalanceExportReq) returns (BundleBalanceExportResp) {} //
rpc PayLaterBundleBalanceExport(BundleBalanceExportReq) returns (PayLaterBundleBalanceExportResp) {} //
rpc GetBundleBalanceLayout(GetBundleBalanceLayoutReq) returns (GetBundleBalanceLayoutResp) {} //
rpc SetBundleBalanceLayout(SetBundleBalanceLayoutReq) returns (SetBundleBalanceLayoutResp) {} //
@ -1078,6 +1079,7 @@ message BundleBalanceExportReq{
uint64 expiredTimeStart = 3;
uint64 expiredTimeEnd = 4;
uint32 status = 5;
uint32 bundleType = 6;
}
message BundleBalanceExportResp{
@ -1085,6 +1087,11 @@ message BundleBalanceExportResp{
repeated BundleBalanceExportItem data =2;
}
message PayLaterBundleBalanceExportResp{
int64 total = 1;
repeated PayLaterBundleBalanceItem data =2;
}
message GetBundleBalanceListResp{
int64 total = 1;

File diff suppressed because it is too large Load Diff

View File

@ -437,6 +437,16 @@ func (this *BundleBalanceExportResp) Validate() error {
}
return nil
}
func (this *PayLaterBundleBalanceExportResp) Validate() error {
for _, item := range this.Data {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
}
}
}
return nil
}
func (this *GetBundleBalanceListResp) Validate() error {
for _, item := range this.Data {
if item != nil {

View File

@ -77,6 +77,7 @@ type BundleClient interface {
AddBundleBalance(ctx context.Context, in *AddBundleBalanceReq, opts ...grpc_go.CallOption) (*AddBundleBalanceResp, common.ErrorWithAttachment)
BundleActivate(ctx context.Context, in *BundleActivateReq, opts ...grpc_go.CallOption) (*BundleActivateResp, common.ErrorWithAttachment)
BundleBalanceExport(ctx context.Context, in *BundleBalanceExportReq, opts ...grpc_go.CallOption) (*BundleBalanceExportResp, common.ErrorWithAttachment)
PayLaterBundleBalanceExport(ctx context.Context, in *BundleBalanceExportReq, opts ...grpc_go.CallOption) (*PayLaterBundleBalanceExportResp, common.ErrorWithAttachment)
GetBundleBalanceLayout(ctx context.Context, in *GetBundleBalanceLayoutReq, opts ...grpc_go.CallOption) (*GetBundleBalanceLayoutResp, common.ErrorWithAttachment)
SetBundleBalanceLayout(ctx context.Context, in *SetBundleBalanceLayoutReq, opts ...grpc_go.CallOption) (*SetBundleBalanceLayoutResp, common.ErrorWithAttachment)
// 使用记录
@ -208,6 +209,7 @@ type BundleClientImpl struct {
AddBundleBalance func(ctx context.Context, in *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
BundleActivate func(ctx context.Context, in *BundleActivateReq) (*BundleActivateResp, error)
BundleBalanceExport func(ctx context.Context, in *BundleBalanceExportReq) (*BundleBalanceExportResp, error)
PayLaterBundleBalanceExport func(ctx context.Context, in *BundleBalanceExportReq) (*PayLaterBundleBalanceExportResp, error)
GetBundleBalanceLayout func(ctx context.Context, in *GetBundleBalanceLayoutReq) (*GetBundleBalanceLayoutResp, error)
SetBundleBalanceLayout func(ctx context.Context, in *SetBundleBalanceLayoutReq) (*SetBundleBalanceLayoutResp, error)
GetUsedRecordList func(ctx context.Context, in *GetUsedRecordListReq) (*GetUsedRecordListResp, error)
@ -566,6 +568,12 @@ func (c *bundleClient) BundleBalanceExport(ctx context.Context, in *BundleBalanc
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleBalanceExport", in, out)
}
func (c *bundleClient) PayLaterBundleBalanceExport(ctx context.Context, in *BundleBalanceExportReq, opts ...grpc_go.CallOption) (*PayLaterBundleBalanceExportResp, common.ErrorWithAttachment) {
out := new(PayLaterBundleBalanceExportResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/PayLaterBundleBalanceExport", in, out)
}
func (c *bundleClient) GetBundleBalanceLayout(ctx context.Context, in *GetBundleBalanceLayoutReq, opts ...grpc_go.CallOption) (*GetBundleBalanceLayoutResp, common.ErrorWithAttachment) {
out := new(GetBundleBalanceLayoutResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -1027,6 +1035,7 @@ type BundleServer interface {
AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
BundleActivate(context.Context, *BundleActivateReq) (*BundleActivateResp, error)
BundleBalanceExport(context.Context, *BundleBalanceExportReq) (*BundleBalanceExportResp, error)
PayLaterBundleBalanceExport(context.Context, *BundleBalanceExportReq) (*PayLaterBundleBalanceExportResp, error)
GetBundleBalanceLayout(context.Context, *GetBundleBalanceLayoutReq) (*GetBundleBalanceLayoutResp, error)
SetBundleBalanceLayout(context.Context, *SetBundleBalanceLayoutReq) (*SetBundleBalanceLayoutResp, error)
// 使用记录
@ -1251,6 +1260,9 @@ func (UnimplementedBundleServer) BundleActivate(context.Context, *BundleActivate
func (UnimplementedBundleServer) BundleBalanceExport(context.Context, *BundleBalanceExportReq) (*BundleBalanceExportResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method BundleBalanceExport not implemented")
}
func (UnimplementedBundleServer) PayLaterBundleBalanceExport(context.Context, *BundleBalanceExportReq) (*PayLaterBundleBalanceExportResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method PayLaterBundleBalanceExport not implemented")
}
func (UnimplementedBundleServer) GetBundleBalanceLayout(context.Context, *GetBundleBalanceLayoutReq) (*GetBundleBalanceLayoutResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBundleBalanceLayout not implemented")
}
@ -2817,6 +2829,35 @@ func _Bundle_BundleBalanceExport_Handler(srv interface{}, ctx context.Context, d
return interceptor(ctx, in, info, handler)
}
func _Bundle_PayLaterBundleBalanceExport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(BundleBalanceExportReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("PayLaterBundleBalanceExport", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
func _Bundle_GetBundleBalanceLayout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBundleBalanceLayoutReq)
if err := dec(in); err != nil {
@ -4980,6 +5021,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "BundleBalanceExport",
Handler: _Bundle_BundleBalanceExport_Handler,
},
{
MethodName: "PayLaterBundleBalanceExport",
Handler: _Bundle_PayLaterBundleBalanceExport_Handler,
},
{
MethodName: "GetBundleBalanceLayout",
Handler: _Bundle_GetBundleBalanceLayout_Handler,