Update:增加查询指定用户未过期的订单列表

This commit is contained in:
jiaji.H 2026-06-08 19:17:52 +08:00
parent 307905849b
commit 46cea10a5e
7 changed files with 3827 additions and 3602 deletions

View File

@ -27,6 +27,11 @@ func (b *BundleProvider) GetBundleBalanceByUserId(_ context.Context, req *bundle
return logic.GetBundleBalanceByUserId(req)
}
// 根据用户ID查询套餐订单列表过期的套餐订单不展示
func (b *BundleProvider) GetBundleOrderListByUserId(_ context.Context, req *bundle.GetBundleOrderListByUserIdReq) (*bundle.GetBundleOrderListByUserIdResp, error) {
return logic.GetBundleOrderListByUserId(req)
}
func (b *BundleProvider) GetBundleBalanceByOrderUUID(_ context.Context, req *bundle.GetBundleBalanceByOrderUUIDReq) (*bundle.GetBundleBalanceByOrderUUIDResp, error) {
startTime, status, err := logic.GetBundleBalanceByOrderUUID(req.OrderUUID)
if err != nil {

View File

@ -178,6 +178,16 @@ func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (data mod
return
}
func GetBundleOrderListByUserId(userId int32) (orderList []string, err error) {
currentMonth := time.Now().Format("2006-01")
timeNow := time.Now().Format("2006-01-02 15:04:05")
err = app.ModuleClients.BundleDB.Table("bundle_balance").Where("user_id = ? and expired_at >= ?", userId, timeNow).Where("month = ?", currentMonth).Where("deleted_at is null").Select("order_uuid").Find(&orderList).Error
if err != nil {
return nil, err
}
return orderList, nil
}
func GetBundleBalanceByOrderUuid(orderUuid string) (data model.BundleBalance, err error) {
err = app.ModuleClients.BundleDB.Model(&model.BundleBalance{}).Where("order_uuid = ?", orderUuid).First(&data).Error
if err != nil {

View File

@ -262,6 +262,19 @@ func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (*bundle.
return result, nil
}
func GetBundleOrderListByUserId(req *bundle.GetBundleOrderListByUserIdReq) (*bundle.GetBundleOrderListByUserIdResp, error) {
orderList, err := dao.GetBundleOrderListByUserId(req.UserId)
if err != nil {
logger.Error(err)
return nil, errors.New("查询订单列表失败")
}
resp := &bundle.GetBundleOrderListByUserIdResp{}
resp.OrderUuid = lo.Map(orderList, func(m string, _ int) string {
return m
})
return resp, nil
}
// 获取最初非续费套餐订单的开始时间
// 查询失败返回2 和 默认事件
func GetBundleBalanceByOrderUUID(orderUUID string) (time.Time, int, error) {

View File

@ -57,6 +57,7 @@ service Bundle {
rpc BundleExtendRecordsList(BundleExtendRecordsListRequest) returns (BundleExtendRecordsListResponse) {} //
rpc GetBundleBalanceList(GetBundleBalanceListReq) returns (GetBundleBalanceListResp) {} //
rpc GetBundleBalanceByUserId(GetBundleBalanceByUserIdReq) returns (GetBundleBalanceByUserIdResp) {} //
rpc GetBundleOrderListByUserId(GetBundleOrderListByUserIdReq) returns (GetBundleOrderListByUserIdResp) {} // ID查询订单列表
rpc GetBundleBalanceByOrderUUID(GetBundleBalanceByOrderUUIDReq) returns (GetBundleBalanceByOrderUUIDResp) {}
rpc CreateBundleBalance(CreateBundleBalanceReq) returns (CreateBundleBalanceResp) {} //
rpc AddBundleBalance(AddBundleBalanceReq) returns (AddBundleBalanceResp) {} //
@ -1217,6 +1218,14 @@ message GetBundleBalanceByUserIdResp{
string renewalOrderUuid = 36;
}
message GetBundleOrderListByUserIdReq{
int32 userId = 1;
}
message GetBundleOrderListByUserIdResp{
repeated string orderUuid = 1;
}
message GetBundleBalanceByOrderUUIDReq{
string orderUUID = 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -493,6 +493,12 @@ func (this *GetBundleBalanceByUserIdReq) Validate() error {
func (this *GetBundleBalanceByUserIdResp) Validate() error {
return nil
}
func (this *GetBundleOrderListByUserIdReq) Validate() error {
return nil
}
func (this *GetBundleOrderListByUserIdResp) Validate() error {
return nil
}
func (this *GetBundleBalanceByOrderUUIDReq) Validate() error {
return nil
}

View File

@ -70,6 +70,7 @@ type BundleClient interface {
BundleExtendRecordsList(ctx context.Context, in *BundleExtendRecordsListRequest, opts ...grpc_go.CallOption) (*BundleExtendRecordsListResponse, common.ErrorWithAttachment)
GetBundleBalanceList(ctx context.Context, in *GetBundleBalanceListReq, opts ...grpc_go.CallOption) (*GetBundleBalanceListResp, common.ErrorWithAttachment)
GetBundleBalanceByUserId(ctx context.Context, in *GetBundleBalanceByUserIdReq, opts ...grpc_go.CallOption) (*GetBundleBalanceByUserIdResp, common.ErrorWithAttachment)
GetBundleOrderListByUserId(ctx context.Context, in *GetBundleOrderListByUserIdReq, opts ...grpc_go.CallOption) (*GetBundleOrderListByUserIdResp, common.ErrorWithAttachment)
GetBundleBalanceByOrderUUID(ctx context.Context, in *GetBundleBalanceByOrderUUIDReq, opts ...grpc_go.CallOption) (*GetBundleBalanceByOrderUUIDResp, common.ErrorWithAttachment)
CreateBundleBalance(ctx context.Context, in *CreateBundleBalanceReq, opts ...grpc_go.CallOption) (*CreateBundleBalanceResp, common.ErrorWithAttachment)
AddBundleBalance(ctx context.Context, in *AddBundleBalanceReq, opts ...grpc_go.CallOption) (*AddBundleBalanceResp, common.ErrorWithAttachment)
@ -199,6 +200,7 @@ type BundleClientImpl struct {
BundleExtendRecordsList func(ctx context.Context, in *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
GetBundleBalanceList func(ctx context.Context, in *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error)
GetBundleBalanceByUserId func(ctx context.Context, in *GetBundleBalanceByUserIdReq) (*GetBundleBalanceByUserIdResp, error)
GetBundleOrderListByUserId func(ctx context.Context, in *GetBundleOrderListByUserIdReq) (*GetBundleOrderListByUserIdResp, error)
GetBundleBalanceByOrderUUID func(ctx context.Context, in *GetBundleBalanceByOrderUUIDReq) (*GetBundleBalanceByOrderUUIDResp, error)
CreateBundleBalance func(ctx context.Context, in *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error)
AddBundleBalance func(ctx context.Context, in *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
@ -520,6 +522,12 @@ func (c *bundleClient) GetBundleBalanceByUserId(ctx context.Context, in *GetBund
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetBundleBalanceByUserId", in, out)
}
func (c *bundleClient) GetBundleOrderListByUserId(ctx context.Context, in *GetBundleOrderListByUserIdReq, opts ...grpc_go.CallOption) (*GetBundleOrderListByUserIdResp, common.ErrorWithAttachment) {
out := new(GetBundleOrderListByUserIdResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetBundleOrderListByUserId", in, out)
}
func (c *bundleClient) GetBundleBalanceByOrderUUID(ctx context.Context, in *GetBundleBalanceByOrderUUIDReq, opts ...grpc_go.CallOption) (*GetBundleBalanceByOrderUUIDResp, common.ErrorWithAttachment) {
out := new(GetBundleBalanceByOrderUUIDResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -1004,6 +1012,7 @@ type BundleServer interface {
BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
GetBundleBalanceList(context.Context, *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error)
GetBundleBalanceByUserId(context.Context, *GetBundleBalanceByUserIdReq) (*GetBundleBalanceByUserIdResp, error)
GetBundleOrderListByUserId(context.Context, *GetBundleOrderListByUserIdReq) (*GetBundleOrderListByUserIdResp, error)
GetBundleBalanceByOrderUUID(context.Context, *GetBundleBalanceByOrderUUIDReq) (*GetBundleBalanceByOrderUUIDResp, error)
CreateBundleBalance(context.Context, *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error)
AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
@ -1212,6 +1221,9 @@ func (UnimplementedBundleServer) GetBundleBalanceList(context.Context, *GetBundl
func (UnimplementedBundleServer) GetBundleBalanceByUserId(context.Context, *GetBundleBalanceByUserIdReq) (*GetBundleBalanceByUserIdResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBundleBalanceByUserId not implemented")
}
func (UnimplementedBundleServer) GetBundleOrderListByUserId(context.Context, *GetBundleOrderListByUserIdReq) (*GetBundleOrderListByUserIdResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBundleOrderListByUserId not implemented")
}
func (UnimplementedBundleServer) GetBundleBalanceByOrderUUID(context.Context, *GetBundleBalanceByOrderUUIDReq) (*GetBundleBalanceByOrderUUIDResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBundleBalanceByOrderUUID not implemented")
}
@ -2590,6 +2602,35 @@ func _Bundle_GetBundleBalanceByUserId_Handler(srv interface{}, ctx context.Conte
return interceptor(ctx, in, info, handler)
}
func _Bundle_GetBundleOrderListByUserId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBundleOrderListByUserIdReq)
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("GetBundleOrderListByUserId", 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_GetBundleBalanceByOrderUUID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetBundleBalanceByOrderUUIDReq)
if err := dec(in); err != nil {
@ -4870,6 +4911,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "GetBundleBalanceByUserId",
Handler: _Bundle_GetBundleBalanceByUserId_Handler,
},
{
MethodName: "GetBundleOrderListByUserId",
Handler: _Bundle_GetBundleOrderListByUserId_Handler,
},
{
MethodName: "GetBundleBalanceByOrderUUID",
Handler: _Bundle_GetBundleBalanceByOrderUUID_Handler,