Updata:解决冲突
This commit is contained in:
commit
8b6f5da73b
@ -2,6 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"micro-bundle/internal/logic"
|
||||
"micro-bundle/pb/bundle"
|
||||
)
|
||||
@ -84,3 +85,13 @@ func (b *BundleProvider) GetBundleBalanceLayout(_ context.Context, req *bundle.G
|
||||
func (b *BundleProvider) SetBundleBalanceLayout(_ context.Context, req *bundle.SetBundleBalanceLayoutReq) (*bundle.SetBundleBalanceLayoutResp, error) {
|
||||
return logic.SetBundleBalanceLayout(req)
|
||||
}
|
||||
|
||||
// 更新余量表数据
|
||||
func (b *BundleProvider) UpdateBundleBalance(_ context.Context, req *bundle.UpdateBundleBalanceReq) (*bundle.UpdateBundleBalanceResp, error) {
|
||||
var resp bundle.UpdateBundleBalanceResp
|
||||
err := logic.UpdateBundleBalance()
|
||||
if err != nil {
|
||||
return nil, errors.New("更新余量表数据失败")
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
@ -538,8 +538,12 @@ func BundleActivate(req *bundle.BundleActivateReq) error {
|
||||
return dao.BundleActivate(req.Ids)
|
||||
}
|
||||
|
||||
func UpdateBundleBalance() {
|
||||
dao.UpdateBundleBalance()
|
||||
func UpdateBundleBalance() error {
|
||||
err := dao.UpdateBundleBalance()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func BundleBalanceExport(req *bundle.BundleBalanceExportReq) (*bundle.BundleBalanceExportResp, error) {
|
||||
|
||||
@ -51,6 +51,7 @@ service Bundle {
|
||||
|
||||
|
||||
// 余量管理
|
||||
rpc UpdateBundleBalance(UpdateBundleBalanceReq) returns (UpdateBundleBalanceResp) {} // 更新余量表数据(用于每月定时任务,谨慎调用)
|
||||
rpc BundleExtend(BundleExtendRequest) returns (BundleExtendResponse) {} // 套餐扩展
|
||||
rpc BundleExtendRecordsList(BundleExtendRecordsListRequest) returns (BundleExtendRecordsListResponse) {} // 套餐扩展记录查询
|
||||
rpc GetBundleBalanceList(GetBundleBalanceListReq) returns (GetBundleBalanceListResp) {} // 余量信息
|
||||
@ -661,6 +662,12 @@ message BatchGetValueAddServiceLangResponse{
|
||||
}
|
||||
//*********************************新增值服务-over******************************************
|
||||
|
||||
message UpdateBundleBalanceReq{
|
||||
}
|
||||
|
||||
message UpdateBundleBalanceResp{
|
||||
}
|
||||
|
||||
message BundleExtendRequest{
|
||||
int64 userId = 1;
|
||||
uint32 accountAdditional = 2;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -365,6 +365,12 @@ func (this *BatchGetValueAddServiceLangResponse) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *UpdateBundleBalanceReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *UpdateBundleBalanceResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *BundleExtendRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ type BundleClient interface {
|
||||
BatchGetValueAddServiceLang(ctx context.Context, in *BatchGetValueAddServiceLangRequest, opts ...grpc_go.CallOption) (*BatchGetValueAddServiceLangResponse, common.ErrorWithAttachment)
|
||||
DeleteValueAddService(ctx context.Context, in *DeleteValueAddServiceRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
|
||||
// 余量管理
|
||||
UpdateBundleBalance(ctx context.Context, in *UpdateBundleBalanceReq, opts ...grpc_go.CallOption) (*UpdateBundleBalanceResp, common.ErrorWithAttachment)
|
||||
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)
|
||||
GetBundleBalanceList(ctx context.Context, in *GetBundleBalanceListReq, opts ...grpc_go.CallOption) (*GetBundleBalanceListResp, common.ErrorWithAttachment)
|
||||
@ -159,6 +160,7 @@ type BundleClientImpl struct {
|
||||
CalculatePrice func(ctx context.Context, in *CalculatePriceRequest) (*CalculatePriceResponse, error)
|
||||
BatchGetValueAddServiceLang func(ctx context.Context, in *BatchGetValueAddServiceLangRequest) (*BatchGetValueAddServiceLangResponse, error)
|
||||
DeleteValueAddService func(ctx context.Context, in *DeleteValueAddServiceRequest) (*CommonResponse, error)
|
||||
UpdateBundleBalance func(ctx context.Context, in *UpdateBundleBalanceReq) (*UpdateBundleBalanceResp, error)
|
||||
BundleExtend func(ctx context.Context, in *BundleExtendRequest) (*BundleExtendResponse, error)
|
||||
BundleExtendRecordsList func(ctx context.Context, in *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
|
||||
GetBundleBalanceList func(ctx context.Context, in *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error)
|
||||
@ -421,6 +423,12 @@ func (c *bundleClient) DeleteValueAddService(ctx context.Context, in *DeleteValu
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DeleteValueAddService", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) UpdateBundleBalance(ctx context.Context, in *UpdateBundleBalanceReq, opts ...grpc_go.CallOption) (*UpdateBundleBalanceResp, common.ErrorWithAttachment) {
|
||||
out := new(UpdateBundleBalanceResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateBundleBalance", in, out)
|
||||
}
|
||||
|
||||
func (c *bundleClient) BundleExtend(ctx context.Context, in *BundleExtendRequest, opts ...grpc_go.CallOption) (*BundleExtendResponse, common.ErrorWithAttachment) {
|
||||
out := new(BundleExtendResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
@ -761,6 +769,7 @@ type BundleServer interface {
|
||||
BatchGetValueAddServiceLang(context.Context, *BatchGetValueAddServiceLangRequest) (*BatchGetValueAddServiceLangResponse, error)
|
||||
DeleteValueAddService(context.Context, *DeleteValueAddServiceRequest) (*CommonResponse, error)
|
||||
// 余量管理
|
||||
UpdateBundleBalance(context.Context, *UpdateBundleBalanceReq) (*UpdateBundleBalanceResp, error)
|
||||
BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error)
|
||||
BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error)
|
||||
GetBundleBalanceList(context.Context, *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error)
|
||||
@ -923,6 +932,9 @@ func (UnimplementedBundleServer) BatchGetValueAddServiceLang(context.Context, *B
|
||||
func (UnimplementedBundleServer) DeleteValueAddService(context.Context, *DeleteValueAddServiceRequest) (*CommonResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteValueAddService not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) UpdateBundleBalance(context.Context, *UpdateBundleBalanceReq) (*UpdateBundleBalanceResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateBundleBalance not implemented")
|
||||
}
|
||||
func (UnimplementedBundleServer) BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method BundleExtend not implemented")
|
||||
}
|
||||
@ -2058,6 +2070,35 @@ func _Bundle_DeleteValueAddService_Handler(srv interface{}, ctx context.Context,
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Bundle_UpdateBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateBundleBalanceReq)
|
||||
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("UpdateBundleBalance", 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_BundleExtend_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(BundleExtendRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@ -3647,6 +3688,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "DeleteValueAddService",
|
||||
Handler: _Bundle_DeleteValueAddService_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateBundleBalance",
|
||||
Handler: _Bundle_UpdateBundleBalance_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "BundleExtend",
|
||||
Handler: _Bundle_BundleExtend_Handler,
|
||||
|
||||
@ -11,19 +11,9 @@ import (
|
||||
func InitCronJob() {
|
||||
c := cron.New(cron.WithSeconds())
|
||||
|
||||
spec := "0 0 0 1 * *"
|
||||
|
||||
_, err := c.AddFunc(spec, func() {
|
||||
log.Printf("执行余量每月数据更新")
|
||||
logic.UpdateBundleBalance()
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 避免冲突,任务余额每月更新定时任务 - 每月1号1点执行
|
||||
taskBalanceSpec := "0 0 1 1 * *"
|
||||
_, err = c.AddFunc(taskBalanceSpec, func() {
|
||||
_, err := c.AddFunc(taskBalanceSpec, func() {
|
||||
log.Printf("执行任务余额每月数据更新")
|
||||
logic.UpdateTaskBalanceEveryMonLogic()
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user