Compare commits
	
		
			No commits in common. "ec0ad25aece1e92e6cf1422d9b3ce558365c5a56" and "829928da9be4b21d7768eb48a53b2285875b9c24" have entirely different histories.
		
	
	
		
			ec0ad25aec
			...
			829928da9b
		
	
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -17,19 +17,6 @@ var _ = proto.Marshal | ||||
| var _ = fmt.Errorf | ||||
| var _ = math.Inf | ||||
| 
 | ||||
| func (this *OrderCreateRecord) Validate() error { | ||||
| 	for _, item := range this.AddRecords { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| 				return github_com_mwitkow_go_proto_validators.FieldError("AddRecords", err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *OrderCreateAddRecord) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *OrderRecordsRequestV2) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| @ -293,13 +280,13 @@ func (this *BundleExtendRecordsListResponse) Validate() error { | ||||
| func (this *BundleExtendRecordItem) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *GetBundleBalanceListReq) Validate() error { | ||||
| func (this *GetBundleBalanceReq) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *BundleBalanceItem) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *GetBundleBalanceListResp) Validate() error { | ||||
| func (this *GetBundleBalanceResp) Validate() error { | ||||
| 	for _, item := range this.Data { | ||||
| 		if item != nil { | ||||
| 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil { | ||||
| @ -309,15 +296,3 @@ func (this *GetBundleBalanceListResp) Validate() error { | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| func (this *CreateBundleBalanceReq) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *CreateBundleBalanceResp) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *AddBundleBalanceReq) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
| func (this *AddBundleBalanceResp) Validate() error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| @ -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             v5.29.2
 | ||||
| // source: pb/bundle.proto
 | ||||
| 
 | ||||
| package bundle | ||||
| @ -37,7 +37,7 @@ type BundleClient interface { | ||||
| 	BundleDetailV2(ctx context.Context, in *BundleDetailRequest, opts ...grpc_go.CallOption) (*BundleDetailResponseV2, common.ErrorWithAttachment) | ||||
| 	BundleList(ctx context.Context, in *BundleListRequest, opts ...grpc_go.CallOption) (*BundleListResponse, common.ErrorWithAttachment) | ||||
| 	BundleDetail(ctx context.Context, in *BundleDetailRequest, opts ...grpc_go.CallOption) (*BundleDetailResponse, common.ErrorWithAttachment) | ||||
| 	CreateOrderRecord(ctx context.Context, in *OrderCreateRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	CreateOrderRecord(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	UpdateOrderRecord(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	UpdateOrderRecordByOrderNo(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) | ||||
| 	OrderRecordsList(ctx context.Context, in *OrderRecordsRequest, opts ...grpc_go.CallOption) (*OrderRecordsResponse, common.ErrorWithAttachment) | ||||
| @ -59,9 +59,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) | ||||
| 	GetBundleBalanceList(ctx context.Context, in *GetBundleBalanceListReq, opts ...grpc_go.CallOption) (*GetBundleBalanceListResp, 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) | ||||
| 	GetBundleBalance(ctx context.Context, in *GetBundleBalanceReq, opts ...grpc_go.CallOption) (*GetBundleBalanceResp, common.ErrorWithAttachment) | ||||
| } | ||||
| 
 | ||||
| type bundleClient struct { | ||||
| @ -78,7 +76,7 @@ type BundleClientImpl struct { | ||||
| 	BundleDetailV2                       func(ctx context.Context, in *BundleDetailRequest) (*BundleDetailResponseV2, error) | ||||
| 	BundleList                           func(ctx context.Context, in *BundleListRequest) (*BundleListResponse, error) | ||||
| 	BundleDetail                         func(ctx context.Context, in *BundleDetailRequest) (*BundleDetailResponse, error) | ||||
| 	CreateOrderRecord                    func(ctx context.Context, in *OrderCreateRecord) (*CommonResponse, error) | ||||
| 	CreateOrderRecord                    func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) | ||||
| 	UpdateOrderRecord                    func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) | ||||
| 	UpdateOrderRecordByOrderNo           func(ctx context.Context, in *OrderRecord) (*CommonResponse, error) | ||||
| 	OrderRecordsList                     func(ctx context.Context, in *OrderRecordsRequest) (*OrderRecordsResponse, error) | ||||
| @ -97,9 +95,7 @@ type BundleClientImpl struct { | ||||
| 	CalculatePrice                       func(ctx context.Context, in *CalculatePriceRequest) (*CalculatePriceResponse, 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) | ||||
| 	CreateBundleBalance                  func(ctx context.Context, in *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error) | ||||
| 	AddBundleBalance                     func(ctx context.Context, in *AddBundleBalanceReq) (*AddBundleBalanceResp, error) | ||||
| 	GetBundleBalance                     func(ctx context.Context, in *GetBundleBalanceReq) (*GetBundleBalanceResp, error) | ||||
| } | ||||
| 
 | ||||
| func (c *BundleClientImpl) GetDubboStub(cc *triple.TripleConn) BundleClient { | ||||
| @ -168,7 +164,7 @@ func (c *bundleClient) BundleDetail(ctx context.Context, in *BundleDetailRequest | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleDetail", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) CreateOrderRecord(ctx context.Context, in *OrderCreateRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) { | ||||
| func (c *bundleClient) CreateOrderRecord(ctx context.Context, in *OrderRecord, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) { | ||||
| 	out := new(CommonResponse) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateOrderRecord", in, out) | ||||
| @ -282,22 +278,10 @@ func (c *bundleClient) BundleExtendRecordsList(ctx context.Context, in *BundleEx | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleExtendRecordsList", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) GetBundleBalanceList(ctx context.Context, in *GetBundleBalanceListReq, opts ...grpc_go.CallOption) (*GetBundleBalanceListResp, common.ErrorWithAttachment) { | ||||
| 	out := new(GetBundleBalanceListResp) | ||||
| 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+"/GetBundleBalanceList", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) CreateBundleBalance(ctx context.Context, in *CreateBundleBalanceReq, opts ...grpc_go.CallOption) (*CreateBundleBalanceResp, common.ErrorWithAttachment) { | ||||
| 	out := new(CreateBundleBalanceResp) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateBundleBalance", in, out) | ||||
| } | ||||
| 
 | ||||
| func (c *bundleClient) AddBundleBalance(ctx context.Context, in *AddBundleBalanceReq, opts ...grpc_go.CallOption) (*AddBundleBalanceResp, common.ErrorWithAttachment) { | ||||
| 	out := new(AddBundleBalanceResp) | ||||
| 	interfaceKey := ctx.Value(constant.InterfaceKey).(string) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/AddBundleBalance", in, out) | ||||
| 	return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetBundleBalance", in, out) | ||||
| } | ||||
| 
 | ||||
| // BundleServer is the server API for Bundle service.
 | ||||
| @ -313,7 +297,7 @@ type BundleServer interface { | ||||
| 	BundleDetailV2(context.Context, *BundleDetailRequest) (*BundleDetailResponseV2, error) | ||||
| 	BundleList(context.Context, *BundleListRequest) (*BundleListResponse, error) | ||||
| 	BundleDetail(context.Context, *BundleDetailRequest) (*BundleDetailResponse, error) | ||||
| 	CreateOrderRecord(context.Context, *OrderCreateRecord) (*CommonResponse, error) | ||||
| 	CreateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) | ||||
| 	UpdateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) | ||||
| 	UpdateOrderRecordByOrderNo(context.Context, *OrderRecord) (*CommonResponse, error) | ||||
| 	OrderRecordsList(context.Context, *OrderRecordsRequest) (*OrderRecordsResponse, error) | ||||
| @ -335,9 +319,7 @@ type BundleServer interface { | ||||
| 	// 余量管理
 | ||||
| 	BundleExtend(context.Context, *BundleExtendRequest) (*BundleExtendResponse, error) | ||||
| 	BundleExtendRecordsList(context.Context, *BundleExtendRecordsListRequest) (*BundleExtendRecordsListResponse, error) | ||||
| 	GetBundleBalanceList(context.Context, *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error) | ||||
| 	CreateBundleBalance(context.Context, *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error) | ||||
| 	AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error) | ||||
| 	GetBundleBalance(context.Context, *GetBundleBalanceReq) (*GetBundleBalanceResp, error) | ||||
| 	mustEmbedUnimplementedBundleServer() | ||||
| } | ||||
| 
 | ||||
| @ -373,7 +355,7 @@ func (UnimplementedBundleServer) BundleList(context.Context, *BundleListRequest) | ||||
| func (UnimplementedBundleServer) BundleDetail(context.Context, *BundleDetailRequest) (*BundleDetailResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method BundleDetail not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) CreateOrderRecord(context.Context, *OrderCreateRecord) (*CommonResponse, error) { | ||||
| func (UnimplementedBundleServer) CreateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method CreateOrderRecord not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) UpdateOrderRecord(context.Context, *OrderRecord) (*CommonResponse, error) { | ||||
| @ -430,14 +412,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) GetBundleBalanceList(context.Context, *GetBundleBalanceListReq) (*GetBundleBalanceListResp, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method GetBundleBalanceList not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) CreateBundleBalance(context.Context, *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method CreateBundleBalance not implemented") | ||||
| } | ||||
| func (UnimplementedBundleServer) AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error) { | ||||
| 	return nil, status.Errorf(codes.Unimplemented, "method AddBundleBalance 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 | ||||
| @ -729,7 +705,7 @@ func _Bundle_BundleDetail_Handler(srv interface{}, ctx context.Context, dec func | ||||
| } | ||||
| 
 | ||||
| func _Bundle_CreateOrderRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(OrderCreateRecord) | ||||
| 	in := new(OrderRecord) | ||||
| 	if err := dec(in); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| @ -1279,8 +1255,8 @@ func _Bundle_BundleExtendRecordsList_Handler(srv interface{}, ctx context.Contex | ||||
| 	return interceptor(ctx, in, info, handler) | ||||
| } | ||||
| 
 | ||||
| func _Bundle_GetBundleBalanceList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(GetBundleBalanceListReq) | ||||
| 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 | ||||
| 	} | ||||
| @ -1292,65 +1268,7 @@ func _Bundle_GetBundleBalanceList_Handler(srv interface{}, ctx context.Context, | ||||
| 	for k, v := range md { | ||||
| 		invAttachment[k] = v | ||||
| 	} | ||||
| 	invo := invocation.NewRPCInvocation("GetBundleBalanceList", 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_CreateBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(CreateBundleBalanceReq) | ||||
| 	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("CreateBundleBalance", 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_AddBundleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) { | ||||
| 	in := new(AddBundleBalanceReq) | ||||
| 	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("AddBundleBalance", args, invAttachment) | ||||
| 	invo := invocation.NewRPCInvocation("GetBundleBalance", args, invAttachment) | ||||
| 	if interceptor == nil { | ||||
| 		result := base.XXX_GetProxyImpl().Invoke(ctx, invo) | ||||
| 		return result, result.Error() | ||||
| @ -1486,16 +1404,8 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{ | ||||
| 			Handler:    _Bundle_BundleExtendRecordsList_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "GetBundleBalanceList", | ||||
| 			Handler:    _Bundle_GetBundleBalanceList_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "CreateBundleBalance", | ||||
| 			Handler:    _Bundle_CreateBundleBalance_Handler, | ||||
| 		}, | ||||
| 		{ | ||||
| 			MethodName: "AddBundleBalance", | ||||
| 			Handler:    _Bundle_AddBundleBalance_Handler, | ||||
| 			MethodName: "GetBundleBalance", | ||||
| 			Handler:    _Bundle_GetBundleBalance_Handler, | ||||
| 		}, | ||||
| 	}, | ||||
| 	Streams:  []grpc_go.StreamDesc{}, | ||||
|  | ||||
| @ -72,7 +72,7 @@ func NewRouter() *gin.Engine { | ||||
| 		} | ||||
| 		webAcRouter := privateGroup.Group("/user") | ||||
| 		//webAcRouter.Use(middleware.CheckWebLogin(service.AccountProvider))
 | ||||
| 		webAcRouter.Use(middleware.CheckWebLogin(service.AccountProvider)) | ||||
| 		webAcRouter.Use(middleware.CheckLogin(service.AccountFieeProvider)) | ||||
| 		{ | ||||
| 			webAcRouter.POST("list", account.UserList)         //用户列表
 | ||||
| 			webAcRouter.POST("approval", account.UserApproval) //实名审核
 | ||||
|  | ||||
| @ -80,57 +80,77 @@ func CreateBundleOrderAddSignature(c *gin.Context) { | ||||
| 		Options *bundle.ValueAddPriceOptions | ||||
| 		ID      int32 | ||||
| 	} | ||||
| 
 | ||||
| 	var ( | ||||
| 		valueAddServices []ValueAddServiceInfo | ||||
| 		totalAmount      float64 | ||||
| 		mainDeadline     = orderRecordResp.OrderRecord.ExpirationTime | ||||
| 	) | ||||
| 	for _, opt := range req.AddPriceOptionsList { | ||||
| 		valueAddInfo, err := service.BundleProvider.ValueAddServiceLangByUuidAndLanguage(context.Background(), &bundle.ValueAddServiceDetailRequest{ | ||||
| 			Uuid:     opt.ValueUid, | ||||
| 			Language: req.Language, | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			service.Error(c, err) | ||||
| 			return | ||||
| 		} | ||||
| 		// 找到匹配的选项
 | ||||
| 		var selectedOption *bundle.ValueAddPriceOptions | ||||
| 		for _, option := range valueAddInfo.Options { | ||||
| 			if int32(option.Id) == opt.Id { | ||||
| 				selectedOption = option | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 		if selectedOption == nil { | ||||
| 			service.Error(c, errors.New("未找到匹配的价格选项")) | ||||
| 			return | ||||
| 		} | ||||
| 		valueAddServices = append(valueAddServices, ValueAddServiceInfo{ | ||||
| 			Service: valueAddInfo, | ||||
| 			Options: selectedOption, | ||||
| 			ID:      opt.Id, | ||||
| 		}) | ||||
| 	} | ||||
| 	// 计算总金额和确定截止日期
 | ||||
| 	var expirationDate string | ||||
| 	var addPriceList []*bundle.AddPriceOptionsInfo | ||||
| 	var totalAmount float32 | ||||
| 	for _, svc := range req.AddPriceOptionsList { | ||||
| 		valueAddInfo, err := service.BundleProvider.ValueAddServiceLangByUuidAndLanguage(context.Background(), &bundle.ValueAddServiceDetailRequest{ | ||||
| 			Uuid:     svc.ValueUid, | ||||
| 			Language: req.Language, | ||||
| 		}) | ||||
| 	for _, svc := range valueAddServices { | ||||
| 		price, err := strconv.ParseFloat(svc.Options.Price, 64) | ||||
| 		if err != nil { | ||||
| 			service.Error(c, err) | ||||
| 			service.Error(c, errors.New("价格格式错误")) | ||||
| 			return | ||||
| 		} | ||||
| 		valuePrice, err := service.BundleProvider.CalculatePrice(context.Background(), &bundle.CalculatePriceRequest{ | ||||
| 			Uuid:     svc.ValueUid, | ||||
| 			Num:      svc.Num, | ||||
| 			Language: req.Language, | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			service.Error(c, err) | ||||
| 			return | ||||
| 		var nowAmount float64 | ||||
| 		switch svc.Service.PriceMode { | ||||
| 		case 1: // 数量×单价模式
 | ||||
| 			nowAmount = float64(svc.Options.Num) * price | ||||
| 			totalAmount += float64(svc.Options.Num) * price | ||||
| 		case 2: // 固定价格模式
 | ||||
| 			nowAmount = price | ||||
| 			totalAmount += price | ||||
| 		} | ||||
| 		totalAmount += valuePrice.Price | ||||
| 
 | ||||
| 		addPriceList = append(addPriceList, &bundle.AddPriceOptionsInfo{ | ||||
| 			ValueUid:     valueAddInfo.Uuid, | ||||
| 			ServiceType:  valueAddInfo.ServiceType, | ||||
| 			CurrencyType: valueAddInfo.PriceType, | ||||
| 			Amount:       valuePrice.Price, | ||||
| 			Num:          svc.Num, | ||||
| 			Unit:         valueAddInfo.Unit, | ||||
| 			ValueUid:     svc.Service.Uuid, | ||||
| 			ServiceType:  svc.Service.ServiceType, | ||||
| 			CurrencyType: svc.Service.PriceType, | ||||
| 			Amount:       float32(nowAmount), | ||||
| 			Num:          svc.Options.Num, | ||||
| 			Unit:         svc.Service.Unit, | ||||
| 		}) | ||||
| 		// 如果是可用时长服务,计算新的截止日期
 | ||||
| 		if valueAddInfo.ServiceType == 5 { | ||||
| 			endDate := orderRecordResp.OrderRecord.ExpirationTime | ||||
| 			if endDate == "9999-12-31" { | ||||
| 				service.Error(c, errors.New(common.ErrorPermanentPackage)) | ||||
| 				return | ||||
| 		if svc.Service.ServiceType == 5 { | ||||
| 			newDeadline := calculateExpirationDate(svc.Options.Num, svc.Service.Unit) | ||||
| 			if expirationDate == "" || newDeadline > expirationDate { | ||||
| 				expirationDate = newDeadline | ||||
| 			} | ||||
| 			t, err := time.Parse("2006-01-02", endDate) | ||||
| 			if err != nil { | ||||
| 				fmt.Println("解析时间出错:", err) | ||||
| 				return | ||||
| 			} | ||||
| 			newDeadline := calculateExpirationDate(t, svc.Num, valueAddInfo.Unit) | ||||
| 			expirationDate = newDeadline | ||||
| 			//}
 | ||||
| 		} | ||||
| 	} | ||||
| 	// 如果没有可用时长服务,使用主套餐截止日期
 | ||||
| 	if expirationDate == "" { | ||||
| 		expirationDate = orderRecordResp.OrderRecord.ExpirationTime | ||||
| 		expirationDate = mainDeadline | ||||
| 	} | ||||
| 	req.CustomerNum = userInfo.SubNum | ||||
| 	req.CustomerName = userInfo.Name | ||||
| @ -140,7 +160,7 @@ func CreateBundleOrderAddSignature(c *gin.Context) { | ||||
| 	req.ExpirationDate = expirationDate | ||||
| 	req.AddPriceOptionsList = addPriceList | ||||
| 	// 当前 未将 签名 写入合同中
 | ||||
| 	signContract, signContractErr := logic.SignContractV2(req.CustomerNum, bundleDetail.Bundle.Contract, totalAmount, expirationDate) | ||||
| 	signContract, signContractErr := logic.SignContractV2(req.CustomerNum, bundleDetail.Bundle.Contract, float32(totalAmount), expirationDate) | ||||
| 	if signContractErr != nil { | ||||
| 		service.Error(c, signContractErr) | ||||
| 		return | ||||
| @ -156,21 +176,21 @@ func CreateBundleOrderAddSignature(c *gin.Context) { | ||||
| } | ||||
| 
 | ||||
| // 计算截止日期辅助函数
 | ||||
| func calculateExpirationDate(startDate time.Time, num int32, unit string) string { | ||||
| 	//now := time.Now()
 | ||||
| func calculateExpirationDate(num int32, unit string) string { | ||||
| 	now := time.Now() | ||||
| 	switch unit { | ||||
| 	case "天": | ||||
| 		return startDate.AddDate(0, 0, int(num)).Format("2006-01-02") | ||||
| 		return now.AddDate(0, 0, int(num)).Format("2006-01-02") | ||||
| 	case "月": | ||||
| 		return startDate.AddDate(0, int(num), 0).Format("2006-01-02") | ||||
| 		return now.AddDate(0, int(num), 0).Format("2006-01-02") | ||||
| 	case "年": | ||||
| 		return startDate.AddDate(int(num), 0, 0).Format("2006-01-02") | ||||
| 		return now.AddDate(int(num), 0, 0).Format("2006-01-02") | ||||
| 	default: | ||||
| 		return "" | ||||
| 	} | ||||
| } | ||||
| func CreateBundleOrderSignature(c *gin.Context) { | ||||
| 	var req bundle.OrderCreateRecord | ||||
| 	var req bundle.OrderRecord | ||||
| 
 | ||||
| 	if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil { | ||||
| 		service.Error(c, err) | ||||
| @ -235,12 +255,19 @@ func CreateBundleOrderSignature(c *gin.Context) { | ||||
| 		service.Error(c, lastOrderRecordErr) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	lastContractNo := "" | ||||
| 
 | ||||
| 	if lastOrderRecord.OrderRecords != nil { | ||||
| 		for _, lastOrder := range lastOrderRecord.OrderRecords { | ||||
| 			lastContractNo = lastOrder.ContractNo | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	req.CustomerNum = userInfo.SubNum | ||||
| 	req.CustomerName = userInfo.Name | ||||
| 	req.CustomerID = strconv.FormatUint(userInfo.ID, 10) | ||||
| 
 | ||||
| 	// 获取 套餐信息
 | ||||
| 	bundleDetailReq := &bundle.BundleDetailRequest{ | ||||
| 		Uuid: req.BundleUuid, | ||||
| @ -250,70 +277,69 @@ func CreateBundleOrderSignature(c *gin.Context) { | ||||
| 		service.Error(c, detailErr) | ||||
| 		return | ||||
| 	} | ||||
| 	//获取过期时间和增值服务金额
 | ||||
| 	var addRecords []*bundle.OrderCreateAddRecord | ||||
| 	var addTotalPrice float32 | ||||
| 	var expirationDay string | ||||
| 	for _, i := range req.AddRecords { | ||||
| 		price, err := service.BundleProvider.CalculatePrice(context.Background(), &bundle.CalculatePriceRequest{ | ||||
| 			Uuid:     i.ValueUid, | ||||
| 			Num:      i.Num, | ||||
| 			Language: req.Language, | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			service.Error(c, err) | ||||
| 			return | ||||
| 		} | ||||
| 		addTotalPrice += price.Price | ||||
| 		addService, err := service.BundleProvider.ValueAddServiceLangByUuidAndLanguage(context.Background(), &bundle.ValueAddServiceDetailRequest{ | ||||
| 			Uuid:     i.ValueUid, | ||||
| 			Language: req.Language, | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			service.Error(c, err) | ||||
| 			return | ||||
| 		} | ||||
| 		addRecords = append(addRecords, &bundle.OrderCreateAddRecord{ | ||||
| 			ServiceType:   addService.ServiceType, | ||||
| 			ValueUid:      i.ValueUid, | ||||
| 			CurrencyType:  addService.PriceType, | ||||
| 			Amount:        price.Price, | ||||
| 			Num:           i.Num, | ||||
| 			Unit:          addService.Unit, | ||||
| 			Source:        1, | ||||
| 			PaymentStatus: 1, | ||||
| 		}) | ||||
| 		//服务类型为时长 计算
 | ||||
| 		if addService.ServiceType == 5 { | ||||
| 			expirationDay = calculateExpirationDate(time.Now(), i.Num, addService.Unit) | ||||
| 		} | ||||
| 	} | ||||
| 	// 当前 未将 签名 写入合同中 todo 金额和有效时间待修改
 | ||||
| 	signContract, signContractErr := logic.SignContractV2(req.CustomerNum, bundleDetail.Bundle.Contract, addTotalPrice, expirationDay) | ||||
| 	if signContractErr != nil { | ||||
| 		service.Error(c, signContractErr) | ||||
| 		return | ||||
| 	} | ||||
| 	req.CustomerNum = userInfo.SubNum | ||||
| 	req.CustomerName = userInfo.Name | ||||
| 	req.CustomerID = strconv.FormatUint(userInfo.ID, 10) | ||||
| 
 | ||||
| 	//获取增值套餐信息
 | ||||
| 	//if req.ValueAddBundleUuid != "" {
 | ||||
| 	//	valueAddBundleDetail, err := service.BundleProvider.ValueAddBundleDetail(context.Background(), &bundle.ValueAddBundleDetailRequest{
 | ||||
| 	//		Uuid: req.ValueAddBundleUuid,
 | ||||
| 	//	})
 | ||||
| 	//	if err != nil {
 | ||||
| 	//		service.Error(c, err)
 | ||||
| 	//		return
 | ||||
| 	//	}
 | ||||
| 	//
 | ||||
| 	//	req.ValueAddBundleUuid = valueAddBundleDetail.Data.Uuid
 | ||||
| 	//	req.ValueAddOriginalPrice = valueAddBundleDetail.Data.OriginalPrice
 | ||||
| 	//	req.ValueAddDiscountPrice = valueAddBundleDetail.Data.DiscountPrice
 | ||||
| 	//	req.AddBundleCommonUid = valueAddBundleDetail.Data.AddBundleCommonUid
 | ||||
| 	//
 | ||||
| 	//	if valueAddBundleDetail.Data.Choose { // 可选条数
 | ||||
| 	//		req.ValueAddBundleAmount = valueAddBundleDetail.Data.DiscountPrice * float32(req.Num)
 | ||||
| 	//		discount, _ := new(big.Float).Sub(big.NewFloat(float64(valueAddBundleDetail.Data.OriginalPrice)), big.NewFloat(float64(valueAddBundleDetail.Data.DiscountPrice))).Float32()
 | ||||
| 	//		req.ValueAddSavedAmount = discount * float32(req.Num)
 | ||||
| 	//	} else { // 固定条数
 | ||||
| 	//		req.ValueAddBundleAmount = valueAddBundleDetail.Data.TotalPrice
 | ||||
| 	//		req.ValueAddSavedAmount = valueAddBundleDetail.Data.SavedAmount
 | ||||
| 	//	}
 | ||||
| 	//
 | ||||
| 	//	req.TotalAmount, _ = new(big.Float).Add(big.NewFloat(float64(req.ValueAddBundleAmount)), big.NewFloat(float64(bundleDetail.Bundle.Price))).Float32()
 | ||||
| 	//}
 | ||||
| 
 | ||||
| 	req.BundleName = bundleDetail.Bundle.Name | ||||
| 	req.Amount = bundleDetail.Bundle.Price | ||||
| 	req.AmountType = bundleDetail.Bundle.PriceType | ||||
| 	req.BundleCommonUid = bundleDetail.Bundle.BundleCommonUid | ||||
| 	req.TotalAmount = bundleDetail.Bundle.Price + addTotalPrice | ||||
| 	req.TotalAmount = bundleDetail.Bundle.Price | ||||
| 	req.PayType = 1 // 默认 人民币
 | ||||
| 	//获取过期时间和增值服务金额
 | ||||
| 	PriceAndTime, err := service.BundleProvider.PackagePriceAndTime(context.Background(), &req) | ||||
| 	if err != nil { | ||||
| 		service.Error(c, err) | ||||
| 		return | ||||
| 	} | ||||
| 	//套餐金额+增值服务金额
 | ||||
| 	totalAmount := PriceAndTime.Price + bundleDetail.Bundle.Price | ||||
| 	req.ContractNo = common.GenerateContractNo(lastContractNo) | ||||
| 
 | ||||
| 	// 当前 未将 签名 写入合同中 todo 金额和有效时间待修改
 | ||||
| 	signContract, signContractErr := logic.SignContractV2(req.CustomerNum, bundleDetail.Bundle.Contract, totalAmount, PriceAndTime.Time) | ||||
| 	if signContractErr != nil { | ||||
| 		service.Error(c, signContractErr) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	req.SignContract = signContract | ||||
| 
 | ||||
| 	req.SignedTime = common.GetBeijingTime() | ||||
| 
 | ||||
| 	req.Status = bundleModel.OrderSigned | ||||
| 	req.AddRecords = addRecords | ||||
| 	req.ExpirationTime = expirationDay | ||||
| 
 | ||||
| 	res, err := service.BundleProvider.CreateOrderRecord(context.Background(), &req) | ||||
| 	if err != nil { | ||||
| 		service.Error(c, err) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	service.Success(c, res) | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -21,7 +21,6 @@ const ( | ||||
| 	HadOrder                 = "您已购买过套餐,无法再次购买" | ||||
| 	InvalidValueAddBundleNum = "套餐数量无效" | ||||
| 	ThePackageHasExpired     = "当前套餐已过期" | ||||
| 	ErrorPermanentPackage    = "永久套餐无需购买" | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user